001    package org.deepamehta.plugins.wikidata.migrations;
002    
003    import de.deepamehta.core.AssociationType;
004    import de.deepamehta.core.Topic;
005    import de.deepamehta.core.TopicType;
006    import de.deepamehta.core.model.*;
007    import de.deepamehta.core.service.Migration;
008    import java.util.logging.Logger;
009    
010    
011    /*
012     * A very basic plugin for searching and turning wikidata-properties into association-types.
013     *
014     * @author Malte Rei├čig (<malte@mikromedia.de>)
015     * @website https://github.com/mukil/dm4-wikidata
016     */
017    
018    public class Migration4 extends Migration {
019    
020        private Logger log = Logger.getLogger(getClass().getName());
021    
022        private final static String WD_SEARCH_ENTITY_TYPE = "org.deepamehta.wikidata.search_entity_type";
023        private final static String WD_SEARCH_ENTITY = "org.deepamehta.wikidata.search_entity";
024    
025        @Override
026        public void run() {
027    
028            // 1) fetch my two topic-types
029            TopicType searchEntity = dms.getTopicType(WD_SEARCH_ENTITY);
030            TopicType searchEntityType = dms.getTopicType(WD_SEARCH_ENTITY_TYPE);
031            // 2) relate my new topic-type to the existing one
032            searchEntity.addAssocDef(new AssociationDefinitionModel("dm4.core.composition_def",
033                    searchEntity.getUri(), searchEntityType.getUri(), "dm4.core.one", "dm4.core.one"));
034            log.info("1) Assigned \"Search Entity Type\" to \"Search Entity\"");
035            // "dm4.webclient.page_renderer_uri" : "org.deepamehta.wikidata.search_entity_renderer"
036            // log.info("2) Assigned new search entity renderer to \"Search Entity\" Topic Type");
037            // ### Do so when dm4-core is fixed: remove assocDef "org.deepamehta.wikidata.language" from WD_SEARCH_ENTITY
038            // searchEntity.removeAssocDef("org.deepamehta.wikidata.language");
039    
040        }
041    
042    }