1 17 package jsftest.repository; 18 19 import java.util.ArrayList; 20 import java.util.HashMap; 21 import java.util.Iterator; 22 import java.util.List; 23 import java.util.Map; 24 25 30 public class DataDictionary 31 { 32 private Map types; 33 34 public DataDictionary() 35 { 36 this.types = new HashMap(); 37 38 Property name = new Property("name", "string", "Name", false); 40 Property desc = new Property("description", "string", "Description" , false); 41 Property created = new Property("created", "datetime", "Created Date", true); 42 Property modified = new Property("modified", "datetime", "Modified Date", false); 43 Property keywords = new Property("keywords", "string[]", "Keywords", false); 44 45 MetaData base = new MetaData("base"); 46 base.addProperty(name); 47 base.addProperty(desc); 48 base.addProperty(created); 49 base.addProperty(modified); 50 base.addProperty(keywords); 51 52 Property sopid = new Property("sopId", "string", "SOP ID", true); 53 Property effective = new Property("effective", "datetime", "Effective Date", false); 54 Property approved = new Property("approved", "boolean", "Approved", false); 55 Property latestVersion = new Property("latestversion", "string", "Latest Version", true); 56 57 MetaData sop = new MetaData("SOP"); 58 sop.setProperties(base.getProperties()); 59 sop.addProperty(sopid); 60 sop.addProperty(effective); 61 sop.addProperty(approved); 62 sop.addAspect("versionable"); 64 sop.addProperty(latestVersion); 65 66 this.types.put(base.getTypeName(), base); 67 this.types.put(sop.getTypeName(), sop); 68 } 69 70 public MetaData getMetaData(String type) 71 { 72 return (MetaData)this.types.get(type); 73 } 74 75 78 public Map getTypes() 79 { 80 return this.types; 81 } 82 83 84 88 92 public class MetaData 93 { 94 private Map propertiesMap; 95 private List properties; 96 private String typeName; 97 private List aspects; 98 99 public MetaData(String typeName) 100 { 101 this.properties = new ArrayList(); 102 this.propertiesMap = new HashMap(); 103 this.aspects = new ArrayList(); 104 this.typeName = typeName; 105 } 106 107 112 public void addProperty(Property property) 113 { 114 this.properties.add(property); 115 this.propertiesMap.put(property.getName(), property); 116 } 117 118 121 public List getProperties() 122 { 123 return this.properties; 124 } 125 126 129 public void setProperties(List properties) 130 { 131 this.properties.clear(); 132 this.propertiesMap.clear(); 133 134 Iterator iter = properties.iterator(); 135 while (iter.hasNext()) 136 { 137 Property prop = (Property)iter.next(); 138 this.properties.add(prop); 139 this.propertiesMap.put(prop.getName(), prop); 140 } 141 } 142 143 public Map getPropertiesMap() 144 { 145 return this.propertiesMap; 146 } 147 148 public List getAspects() 149 { 150 return this.aspects; 151 } 152 153 public void addAspect(String aspect) 154 { 155 this.aspects.add(aspect); 156 } 157 158 161 public String getTypeName() 162 { 163 return this.typeName; 164 } 165 } 166 167 171 public class Property 172 { 173 private String name; 174 private String type; 175 private String displayName; 176 private boolean readOnly; 177 178 183 public Property(String name, String type, String displayName, boolean readOnly) 184 { 185 this.name = name; 186 this.type = type; 187 this.displayName = displayName; 188 this.readOnly = readOnly; 189 } 190 191 194 public String getName() 195 { 196 return this.name; 197 } 198 199 202 public void setName(String name) 203 { 204 this.name = name; 205 } 206 207 210 public String getType() 211 { 212 return this.type; 213 } 214 215 218 public void setType(String type) 219 { 220 this.type = type; 221 } 222 223 226 public String getDisplayName() 227 { 228 return this.displayName; 229 } 230 231 234 public void setDisplayName(String displayName) 235 { 236 this.displayName = displayName; 237 } 238 239 242 public boolean isReadOnly() 243 { 244 return this.readOnly; 245 } 246 247 250 public void setReadOnly(boolean readOnly) 251 { 252 this.readOnly = readOnly; 253 } 254 } 255 256 } | Popular Tags |