001 package de.deepamehta.core.service; 002 003 import de.deepamehta.core.Type; 004 import de.deepamehta.core.util.DeepaMehtaUtils; 005 006 import java.io.InputStream; 007 008 009 010 public abstract class Migration { 011 012 // ---------------------------------------------------------------------------------------------- Instance Variables 013 014 protected DeepaMehtaService dms; 015 016 // -------------------------------------------------------------------------------------------------- Public Methods 017 018 public void setCoreService(DeepaMehtaService dms) { 019 this.dms = dms; 020 } 021 022 public abstract void run(); 023 024 // ----------------------------------------------------------------------------------------------- Protected Methods 025 026 // Convenience method ### FIXME: belongs to Webclient module 027 protected final void addTopicTypeSetting(String topicTypeUri, String setting, Object value) { 028 addTypeSetting(dms.getTopicType(topicTypeUri), setting, value); 029 } 030 031 // Convenience method ### FIXME: belongs to Webclient module 032 protected final void addAssociationTypeSetting(String assocTypeUri, String setting, Object value) { 033 addTypeSetting(dms.getAssociationType(assocTypeUri), setting, value); 034 } 035 036 // --- 037 038 // Convenience method ### FIXME: belongs to Webclient module 039 protected final void addTypeSetting(Type type, String setting, Object value) { 040 type.getViewConfig().addSetting("dm4.webclient.view_config", "dm4.webclient." + setting, value); 041 } 042 043 // --- 044 045 protected final void readMigrationFile(String migrationFile) { 046 InputStream migrationIn = getClass().getResourceAsStream(migrationFile); 047 DeepaMehtaUtils.readMigrationFile(migrationIn, migrationFile, dms); 048 } 049 }