Changes between Version 14 and Version 15 of PluginDevelopmentGuide


Ignore:
Timestamp:
13.04.2013 16:54:48 (7 years ago)
Author:
jri
Comment:

Writing an imperative migration

Legend:

Unmodified
Added
Removed
Modified
  • PluginDevelopmentGuide

    v14 v15  
    539539}}} 
    540540 
    541 As you see, this migration defines 3 topic types (and no other things): the 2 simple types //Title// and //Text//, and the composite type //Note//. A Note is composed of a Title and a Text. 
     541As you see, this migration defines 3 topic types (and no other things): //Title// and //Text// are 2 simple types, and //Note// is a composite type. A Note is composed of one Title and one Text. 
    542542 
    543543=== Writing an imperative migration === 
     544 
     545An imperative migration is a Java class that is derived from `de.deepamehta.core.service.Migration` and that overrides the `run()` method. The `run()` method is called by DeepaMehta to run the migration. 
     546 
     547Within the migration you have access to the //DeepaMehta Core Service// through the `dms` object. By the means of the DeepaMehta Core Service you can perform arbitrary database operations. Typically this involves importing further objects from the `de.deepamehta.core` API. 
     548 
     549As an example see a migration that comes with the //DeepaMehta 4 Topicmaps// plugin: 
     550 
     551{{{ 
     552#!java 
     553package de.deepamehta.plugins.topicmaps.migrations; 
     554 
     555import de.deepamehta.core.TopicType; 
     556import de.deepamehta.core.model.AssociationDefinitionModel; 
     557import de.deepamehta.core.service.Migration; 
     558 
     559public class Migration3 extends Migration { 
     560 
     561    @Override 
     562    public void run() { 
     563        TopicType type = dms.getTopicType("dm4.topicmaps.topicmap", null); 
     564        type.addAssocDef(new AssociationDefinitionModel("dm4.core.composition_def", 
     565            "dm4.topicmaps.topicmap", "dm4.topicmaps.state", "dm4.core.one", "dm4.core.one")); 
     566    } 
     567} 
     568}}} 
     569 
     570Here an association definition is added to the //Topicmap// type subsequently.