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 final String getDataTypeUri() { 038 return getModel().getDataTypeUri(); 039 } 040 041 @Override 042 public final DeepaMehtaType setDataTypeUri(String dataTypeUri) { 043 _getModel().updateDataTypeUri(dataTypeUri); 044 return this; 045 } 046 047 048 049 // === Index Modes === 050 051 @Override 052 public final List<IndexMode> getIndexModes() { 053 return getModel().getIndexModes(); 054 } 055 056 @Override 057 public final DeepaMehtaType addIndexMode(IndexMode indexMode) { 058 _getModel()._addIndexMode(indexMode); 059 return this; 060 } 061 062 063 064 // === Association Definitions === 065 066 @Override 067 public final Collection<AssociationDefinition> getAssocDefs() { 068 return pl.instantiate(getModel().getAssocDefs()); 069 } 070 071 @Override 072 public final AssociationDefinition getAssocDef(String assocDefUri) { 073 return getModel().getAssocDef(assocDefUri).instantiate(); 074 } 075 076 @Override 077 public final boolean hasAssocDef(String assocDefUri) { 078 return getModel().hasAssocDef(assocDefUri); 079 } 080 081 @Override 082 public final DeepaMehtaType addAssocDef(AssociationDefinitionModel assocDef) { 083 return addAssocDefBefore(assocDef, null); // beforeAssocDefUri=null 084 } 085 086 @Override 087 public final DeepaMehtaType addAssocDefBefore(AssociationDefinitionModel assocDef, String beforeAssocDefUri) { 088 _getModel()._addAssocDefBefore((AssociationDefinitionModelImpl) assocDef, beforeAssocDefUri); 089 return this; 090 } 091 092 @Override 093 public final DeepaMehtaType removeAssocDef(String assocDefUri) { 094 _getModel()._removeAssocDef(assocDefUri); 095 return this; 096 } 097 098 099 100 // === View Configuration === 101 102 @Override 103 public final ViewConfiguration getViewConfig() { 104 RoleModel configurable = pl.typeStorage.newTypeRole(getId()); // ### type ID is uninitialized 105 return new ViewConfigurationImpl(configurable, getModel().getViewConfig(), pl); 106 } 107 108 @Override 109 public final Object getViewConfigValue(String configTypeUri, String childTypeUri) { 110 return getModel().getViewConfigValue(configTypeUri, childTypeUri); 111 } 112 113 114 115 // === 116 117 @Override 118 public void update(TypeModel updateModel) { 119 _getModel().update((TypeModelImpl) updateModel); // ### FIXME: call through pl for access control 120 } 121 122 // --- 123 124 @Override 125 public TypeModelImpl getModel() { 126 return (TypeModelImpl) model; 127 } 128 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 143 // --- Label Configuration --- 144 145 final List<String> getLabelConfig() { 146 return getModel().getLabelConfig(); 147 } 148}