001package de.deepamehta.core.impl; 002 003import de.deepamehta.core.AssociationDefinition; 004import de.deepamehta.core.DeepaMehtaType; 005import de.deepamehta.core.ViewConfiguration; 006import de.deepamehta.core.model.AssociationDefinitionModel; 007import de.deepamehta.core.model.IndexMode; 008import de.deepamehta.core.model.RoleModel; 009import de.deepamehta.core.model.TypeModel; 010 011import java.util.Collection; 012import java.util.List; 013 014 015 016abstract class DeepaMehtaTypeImpl extends TopicImpl implements DeepaMehtaType { 017 018 // ---------------------------------------------------------------------------------------------------- Constructors 019 020 DeepaMehtaTypeImpl(TypeModelImpl model, PersistenceLayer pl) { 021 super(model, pl); 022 } 023 024 // -------------------------------------------------------------------------------------------------- Public Methods 025 026 027 028 // ************************************* 029 // *** DeepaMehtaType Implementation *** 030 // ************************************* 031 032 033 034 // --- Data Type --- 035 036 @Override 037 public String getDataTypeUri() { 038 return getModel().getDataTypeUri(); 039 } 040 041 @Override 042 public void setDataTypeUri(String dataTypeUri) { 043 _getModel().updateDataTypeUri(dataTypeUri); 044 } 045 046 // --- Index Modes --- 047 048 @Override 049 public List<IndexMode> getIndexModes() { 050 return getModel().getIndexModes(); 051 } 052 053 @Override 054 public void addIndexMode(IndexMode indexMode) { 055 _getModel()._addIndexMode(indexMode); 056 } 057 058 // --- Association Definitions --- 059 060 @Override 061 public Collection<AssociationDefinition> getAssocDefs() { 062 return pl.instantiate(getModel().getAssocDefs()); 063 } 064 065 @Override 066 public AssociationDefinition getAssocDef(String assocDefUri) { 067 return getModel().getAssocDef(assocDefUri).instantiate(); 068 } 069 070 @Override 071 public boolean hasAssocDef(String assocDefUri) { 072 return getModel().hasAssocDef(assocDefUri); 073 } 074 075 @Override 076 public DeepaMehtaType addAssocDef(AssociationDefinitionModel assocDef) { 077 return addAssocDefBefore(assocDef, null); // beforeAssocDefUri=null 078 } 079 080 @Override 081 public DeepaMehtaType addAssocDefBefore(AssociationDefinitionModel assocDef, String beforeAssocDefUri) { 082 _getModel()._addAssocDefBefore((AssociationDefinitionModelImpl) assocDef, beforeAssocDefUri); 083 return this; 084 } 085 086 @Override 087 public DeepaMehtaType removeAssocDef(String assocDefUri) { 088 _getModel()._removeAssocDef(assocDefUri); 089 return this; 090 } 091 092 // --- Label Configuration --- 093 094 @Override 095 public List<String> getLabelConfig() { 096 return getModel().getLabelConfig(); 097 } 098 099 @Override 100 public void setLabelConfig(List<String> labelConfig) { 101 _getModel().updateLabelConfig(labelConfig); 102 } 103 104 // --- View Configuration --- 105 106 @Override 107 public ViewConfiguration getViewConfig() { 108 RoleModel configurable = pl.typeStorage.newTypeRole(getId()); // ### type ID is uninitialized 109 return new ViewConfigurationImpl(configurable, getModel().getViewConfigModel(), pl); 110 } 111 112 @Override 113 public Object getViewConfig(String typeUri, String settingUri) { 114 return getModel().getViewConfig(typeUri, settingUri); 115 } 116 117 // --- 118 119 @Override 120 public void update(TypeModel newModel) { 121 _getModel().update((TypeModelImpl) newModel); // ### FIXME: call through pl for access control 122 } 123 124 // --- 125 126 @Override 127 public TypeModelImpl getModel() { 128 return (TypeModelImpl) model; 129 } 130 131 // ----------------------------------------------------------------------------------------- Package Private Methods 132 133 /** 134 * Returns the <i>internal</i> (= <b>kernel</b>) model underlying this type. 135 * <p> 136 * Note: type updates must be performed on the internal type model, not the userland's type model (as returned by 137 * <code>getModel()</code>). Performing an update on the <b>userland</b>'s type model would have no effect, as it 138 * is transient. The userland's type model is always a <i>cloned</i> and filtered (= "projected") version of a 139 * kernel type model which is created on-the-fly each time a specific user requests it. 140 */ 141 abstract TypeModelImpl _getModel(); 142}