View Javadoc
1 /* 2 * Created on 04.03.2004 3 * 4 * To change the template for this generated file go to 5 * Window>Preferences>Java>Code Generation>Code and Comments 6 */ 7 package org.xpcards.model; 8 9 import java.util.Enumeration; 10 import java.util.Vector; 11 12 /*** 13 * @author galu02 14 * 15 * To change the template for this generated type comment go to 16 * Window>Preferences>Java>Code Generation>Code and Comments 17 */ 18 public class Project extends ModelElement { 19 20 ProjectSource source = null; 21 22 ModelElementCollection isolatedTasks = null; 23 ModelElementCollection isolatedStories = null; 24 ModelElementCollection iterations = null; 25 26 27 public String getIterationsCategory() { 28 return "Iterations"; 29 } 30 31 public String getIsolatedStoriesCategory() { 32 return "Isolated Stories"; 33 } 34 35 public String getIsolatedTasksCategory() { 36 return "Isolated Tasks"; 37 } 38 39 /*** 40 * @return 41 */ 42 public Enumeration iterations() { 43 if (iterations == null) { 44 return null; 45 } 46 return iterations.elements(); 47 } 48 /*** 49 * @param prefix 50 * @return 51 */ 52 public String createIterationsUniqueIndex(String prefix) { 53 if (iterations == null) { 54 iterations = new ModelElementCollection(this); 55 iterations.setCategory(getIterationsCategory()); 56 } 57 return iterations.createUniqueIndex(prefix); 58 } 59 60 /*** 61 * @param element 62 */ 63 public void putIteration(Iteration element) { 64 if (element == null) 65 return; 66 if (iterations == null) { 67 iterations = new ModelElementCollection(this); 68 iterations.setCategory(getIterationsCategory()); 69 } 70 if (!iterations.containsValue(element)) { 71 element.setParent(this); 72 iterations.putElement(element); 73 fireCollectionElementAdded(element, getIterationsCategory(), false); 74 } 75 } 76 77 /*** 78 * @param element 79 */ 80 public void removeIteration(Iteration element) { 81 if (element == null) 82 return; 83 if (iterations == null) { 84 return; 85 } 86 if (iterations.containsValue(element)) { 87 iterations.removeElement(element); 88 fireCollectionElementRemoved(element, getIterationsCategory()); 89 } 90 } 91 92 /*** 93 * @param prefix 94 * @return 95 */ 96 public String createIsolatedStoriesUniqueIndex(String prefix) { 97 if (isolatedStories == null) { 98 isolatedStories = new ModelElementCollection(this); 99 isolatedStories.setCategory(getIsolatedStoriesCategory()); 100 } 101 return isolatedStories.createUniqueIndex(prefix); 102 } 103 104 /*** 105 * @return 106 */ 107 public Enumeration isolatedStories() { 108 if (isolatedStories == null) { 109 return null; 110 } 111 return isolatedStories.elements(); 112 } 113 114 /*** 115 * @param element 116 */ 117 public void putIsolatedStory(Story element) { 118 if (element == null) 119 return; 120 if (isolatedStories == null) { 121 isolatedStories = new ModelElementCollection(this); 122 isolatedStories.setCategory(getIsolatedStoriesCategory()); 123 } 124 if (!isolatedStories.containsValue(element)) { 125 element.setParent(this); 126 isolatedStories.putElement(element); 127 fireCollectionElementAdded(element, getIsolatedStoriesCategory(),false); 128 } 129 } 130 131 /*** 132 * @param element 133 */ 134 public void removeIsolatedStory(Story element) { 135 if (element == null) 136 return; 137 if (isolatedStories == null) { 138 return; 139 } 140 if (isolatedStories.containsValue(element)) { 141 isolatedStories.removeElement(element); 142 fireCollectionElementRemoved(element, getIsolatedStoriesCategory()); 143 } 144 } 145 146 /*** 147 * @return 148 */ 149 public Enumeration isolatedTasks() { 150 if (isolatedTasks == null) { 151 return null; 152 } 153 return isolatedTasks.elements(); 154 } 155 156 /*** 157 * @param prefix 158 * @return 159 */ 160 public String createIsolatedTasksUniqueIndex(String prefix) { 161 if (isolatedTasks == null) { 162 isolatedTasks = new ModelElementCollection(this); 163 isolatedTasks.setCategory(getIsolatedTasksCategory()); 164 } 165 return isolatedTasks.createUniqueIndex(prefix); 166 } 167 168 /*** 169 * @param element 170 */ 171 public void putIsolatedTask(Task element) { 172 if (element == null) 173 return; 174 if (isolatedTasks == null) { 175 isolatedTasks = new ModelElementCollection(this); 176 isolatedTasks.setCategory(getIsolatedTasksCategory()); 177 } 178 if (!isolatedTasks.containsValue(element)) { 179 element.setParent(this); 180 isolatedTasks.putElement(element); 181 fireCollectionElementAdded(element, getIsolatedTasksCategory(),false); 182 } 183 } 184 185 /*** 186 * @param element 187 */ 188 public void removeIsolatedTask(Task element) { 189 if (element == null) 190 return; 191 if (isolatedTasks == null) { 192 return; 193 } 194 if (isolatedTasks.containsValue(element)) { 195 isolatedTasks.removeElement(element); 196 fireCollectionElementRemoved(element, getIsolatedTasksCategory()); 197 } 198 } 199 200 public static void main(String[] args) { 201 XPEncoder enc = new XPEncoder(System.err); 202 203 enc.writeObject(createTestProject()); 204 205 enc.close(); 206 } 207 208 public static Project createTestProject() { 209 Project p = new Project(); 210 211 p.setDescription("My test description"); 212 p.setName("My test project"); 213 214 p.setId("My project id"); 215 int iterarions = 0; 216 217 Iteration it = new Iteration(); 218 it.setId("Iteration:" + (iterarions++)); 219 it.setDescription("test description "); 220 221 p.putIteration(it); 222 223 int stories = 0; 224 Story st = new Story(); 225 st.setId("Story:" + (stories++)); 226 st.setName("My story"); 227 st.setDescription("test description"); 228 229 it.putStory(st); 230 231 st = new Story(); 232 st.setId("Story:" + (stories++)); 233 st.setName("My story"); 234 st.setDescription("test description"); 235 it.putStory(st); 236 237 st = new Story(); 238 st.setId("Story:" + (stories++)); 239 st.setName("My story"); 240 st.setDescription("test description"); 241 242 p.putIsolatedStory(st); 243 244 int tasks = 0; 245 Task ts = new Task(); 246 ts.setId("Task:" + (tasks++)); 247 ts.setName("Task 1"); 248 ts.setDescription("Test description"); 249 250 st.putTask(ts); 251 252 ts = new Task(); 253 ts.setId("Task:" + (tasks++)); 254 ts.setName(ts.getId()); 255 ts.setDescription("Test description"); 256 257 st.putTask(ts); 258 259 ts = new Task(); 260 ts.setId("Task:" + (tasks++)); 261 ts.setName(ts.getId()); 262 ts.setDescription("Test description"); 263 264 p.putIsolatedTask(ts); 265 266 ts = new Task(); 267 ts.setId("Task:" + (tasks++)); 268 ts.setName(ts.getId()); 269 ts.setDescription("Test description"); 270 271 p.putIsolatedTask(ts); 272 273 return p; 274 } 275 276 public ModelElementCollection[] getChildrenCollections() { 277 Vector v = null; 278 if (iterations != null) { 279 if (v == null) { 280 v = new Vector(); 281 } 282 v.add(iterations); 283 } 284 if (isolatedStories != null) { 285 if (v == null) { 286 v = new Vector(); 287 } 288 v.add(isolatedStories); 289 } 290 291 if (isolatedTasks != null) { 292 if (v == null) { 293 v = new Vector(); 294 } 295 v.add(isolatedTasks); 296 } 297 298 if (v != null) { 299 return (ModelElementCollection[]) v.toArray( 300 new ModelElementCollection[0]); 301 } 302 303 return null; 304 } 305 306 }

This page was automatically generated by Maven