1 17 package org.alfresco.repo.dictionary; 18 19 import java.util.ArrayList ; 20 import java.util.Collections ; 21 import java.util.List ; 22 23 29 public abstract class M2Class 30 { 31 private String name = null; 32 private String title = null; 33 private String description = null; 34 private String parentName = null; 35 36 private List <M2Property> properties = new ArrayList <M2Property>(); 37 private List <M2PropertyOverride> propertyOverrides = new ArrayList <M2PropertyOverride>(); 38 private List <M2ClassAssociation> associations = new ArrayList <M2ClassAssociation>(); 39 private List <String > mandatoryAspects = new ArrayList <String >(); 40 41 M2Class() 42 { 43 } 44 45 46 public String getName() 47 { 48 return name; 49 } 50 51 52 public void setName(String name) 53 { 54 this.name = name; 55 } 56 57 58 public String getTitle() 59 { 60 return title; 61 } 62 63 64 public void setTitle(String title) 65 { 66 this.title = title; 67 } 68 69 70 public String getDescription() 71 { 72 return description; 73 } 74 75 76 public void setDescription(String description) 77 { 78 this.description = description; 79 } 80 81 82 public String getParentName() 83 { 84 return parentName; 85 } 86 87 88 public void setParentName(String parentName) 89 { 90 this.parentName = parentName; 91 } 92 93 94 public M2Property createProperty(String name) 95 { 96 M2Property property = new M2Property(); 97 property.setName(name); 98 properties.add(property); 99 return property; 100 } 101 102 103 public void removeProperty(String name) 104 { 105 M2Property property = getProperty(name); 106 if (property != null) 107 { 108 properties.remove(property); 109 } 110 } 111 112 113 public List <M2Property> getProperties() 114 { 115 return Collections.unmodifiableList(properties); 116 } 117 118 119 public M2Property getProperty(String name) 120 { 121 for (M2Property candidate : properties) 122 { 123 if (candidate.getName().equals(name)) 124 { 125 return candidate; 126 } 127 } 128 return null; 129 } 130 131 132 public M2Association createAssociation(String name) 133 { 134 M2Association association = new M2Association(); 135 association.setName(name); 136 associations.add(association); 137 return association; 138 } 139 140 141 public M2ChildAssociation createChildAssociation(String name) 142 { 143 M2ChildAssociation association = new M2ChildAssociation(); 144 association.setName(name); 145 associations.add(association); 146 return association; 147 } 148 149 150 public void removeAssociation(String name) 151 { 152 M2ClassAssociation association = getAssociation(name); 153 if (association != null) 154 { 155 associations.remove(association); 156 } 157 } 158 159 160 public List <M2ClassAssociation> getAssociations() 161 { 162 return Collections.unmodifiableList(associations); 163 } 164 165 166 public M2ClassAssociation getAssociation(String name) 167 { 168 for (M2ClassAssociation candidate : associations) 169 { 170 if (candidate.getName().equals(name)) 171 { 172 return candidate; 173 } 174 } 175 return null; 176 } 177 178 179 public M2PropertyOverride createPropertyOverride(String name) 180 { 181 M2PropertyOverride property = new M2PropertyOverride(); 182 property.setName(name); 183 propertyOverrides.add(property); 184 return property; 185 } 186 187 188 public void removePropertyOverride(String name) 189 { 190 M2PropertyOverride property = getPropertyOverride(name); 191 if (property != null) 192 { 193 propertyOverrides.remove(property); 194 } 195 } 196 197 198 public List <M2PropertyOverride> getPropertyOverrides() 199 { 200 return Collections.unmodifiableList(propertyOverrides); 201 } 202 203 204 public M2PropertyOverride getPropertyOverride(String name) 205 { 206 for (M2PropertyOverride candidate : propertyOverrides) 207 { 208 if (candidate.getName().equals(name)) 209 { 210 return candidate; 211 } 212 } 213 return null; 214 } 215 216 public void addMandatoryAspect(String name) 217 { 218 mandatoryAspects.add(name); 219 } 220 221 222 public void removeMandatoryAspect(String name) 223 { 224 mandatoryAspects.remove(name); 225 } 226 227 228 public List <String > getMandatoryAspects() 229 { 230 return Collections.unmodifiableList(mandatoryAspects); 231 } 232 233 } 234 | Popular Tags |