001package systems.dmx.core.service; 002 003import systems.dmx.core.DMXType; 004import systems.dmx.core.service.ModelFactory; 005 006 007 008public abstract class Migration { 009 010 // ---------------------------------------------------------------------------------------------- Instance Variables 011 012 protected CoreService dmx; 013 protected ModelFactory mf; 014 015 // -------------------------------------------------------------------------------------------------- Public Methods 016 017 // ### TODO: make this internal. Define a public Migration interface? 018 public void setCoreService(CoreService dmx) { 019 this.dmx = dmx; 020 this.mf = dmx.getModelFactory(); 021 } 022 023 public abstract void run(); 024 025 // ----------------------------------------------------------------------------------------------- Protected Methods 026 027 // Note: exceptionally here the Core has some knowledge about the Webclient. 028 // ### TODO: move these methods to the Webclient service. 029 030 /** 031 * Convenience method for plugin authors to set a Webclient view config value for a certain topic type. 032 * 033 * @param topicTypeUri The URI of the topic type whose view configuration value to set. 034 * @param setting Last component of the child type URI whose value to set, e.g. "icon". 035 * @param value The config value (String, Integer, Long, Double, or Boolean). 036 */ 037 protected final void setTopicTypeViewConfigValue(String topicTypeUri, String setting, Object value) { 038 setViewConfigValue(dmx.getTopicType(topicTypeUri), setting, value); 039 } 040 041 /** 042 * Convenience method for plugin authors to set a Webclient view config value for a certain assoc type. 043 * 044 * @param assocTypeUri The URI of the assoc type whose view configuration value to set. 045 * @param setting Last component of the child type URI whose value to set, e.g. "color". 046 * @param value The config value (String, Integer, Long, Double, or Boolean). 047 */ 048 protected final void setAssocTypeViewConfigValue(String assocTypeUri, String setting, Object value) { 049 setViewConfigValue(dmx.getAssociationType(assocTypeUri), setting, value); 050 } 051 052 // ------------------------------------------------------------------------------------------------- Private Methods 053 054 private void setViewConfigValue(DMXType type, String setting, Object value) { 055 type.getViewConfig().setConfigValue("dmx.webclient.view_config", "dmx.webclient." + setting, value); 056 } 057}