1 17 package org.alfresco.repo.dictionary; 18 19 import java.io.Serializable ; 20 import java.util.Collection ; 21 import java.util.Collections ; 22 import java.util.HashMap ; 23 import java.util.List ; 24 import java.util.Map ; 25 26 import org.alfresco.service.cmr.dictionary.AspectDefinition; 27 import org.alfresco.service.cmr.dictionary.AssociationDefinition; 28 import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition; 29 import org.alfresco.service.cmr.dictionary.ModelDefinition; 30 import org.alfresco.service.cmr.dictionary.PropertyDefinition; 31 import org.alfresco.service.cmr.dictionary.TypeDefinition; 32 import org.alfresco.service.namespace.NamespaceService; 33 import org.alfresco.service.namespace.QName; 34 35 36 42 class M2AnonymousTypeDefinition implements TypeDefinition 43 { 44 private TypeDefinition type; 45 private Map <QName,PropertyDefinition> properties = new HashMap <QName,PropertyDefinition>(); 46 private Map <QName,AssociationDefinition> associations = new HashMap <QName,AssociationDefinition>(); 47 private Map <QName,ChildAssociationDefinition> childassociations = new HashMap <QName,ChildAssociationDefinition>(); 48 49 50 56 M2AnonymousTypeDefinition(TypeDefinition type, Collection <AspectDefinition> aspects) 57 { 58 this.type = type; 59 60 properties.putAll(type.getProperties()); 62 associations.putAll(type.getAssociations()); 63 childassociations.putAll(type.getChildAssociations()); 64 for (AspectDefinition aspect : aspects) 65 { 66 properties.putAll(aspect.getProperties()); 67 associations.putAll(aspect.getAssociations()); 68 childassociations.putAll(aspect.getChildAssociations()); 69 } 70 } 71 72 75 public ModelDefinition getModel() 76 { 77 return type.getModel(); 78 } 79 80 83 public List <AspectDefinition> getDefaultAspects() 84 { 85 return type.getDefaultAspects(); 86 } 87 88 89 92 public QName getName() 93 { 94 return QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "anonymous#" + type.getName().getLocalName()); 95 } 96 97 98 101 public String getTitle() 102 { 103 return type.getTitle(); 104 } 105 106 107 110 public String getDescription() 111 { 112 return type.getDescription(); 113 } 114 115 116 119 public QName getParentName() 120 { 121 return type.getParentName(); 122 } 123 124 125 128 public boolean isAspect() 129 { 130 return type.isAspect(); 131 } 132 133 134 137 public Map <QName, PropertyDefinition> getProperties() 138 { 139 return Collections.unmodifiableMap(properties); 140 } 141 142 145 public Map <QName, Serializable > getDefaultValues() 146 { 147 Map <QName, Serializable > result = new HashMap <QName, Serializable >(5); 148 149 for(Map.Entry <QName, PropertyDefinition> entry : properties.entrySet()) 150 { 151 PropertyDefinition propertyDefinition = entry.getValue(); 152 String defaultValue = propertyDefinition.getDefaultValue(); 153 if (defaultValue != null) 154 { 155 result.put(entry.getKey(), defaultValue); 156 } 157 } 158 159 return Collections.unmodifiableMap(result); 160 } 161 162 163 166 public Map <QName, AssociationDefinition> getAssociations() 167 { 168 return Collections.unmodifiableMap(associations); 169 } 170 171 172 175 public boolean isContainer() 176 { 177 return !childassociations.isEmpty(); 178 } 179 180 181 184 public Map <QName, ChildAssociationDefinition> getChildAssociations() 185 { 186 return Collections.unmodifiableMap(childassociations); 187 } 188 189 } 190 | Popular Tags |