001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: /* @generated Thu Sep 27 15:21:46 EDT 2007 from /u01/builds/cougaar/B12_4/B12_4/070927151721/src/glm/src/org/cougaar/glm/ldm/asset/alpassets.def - DO NOT HAND EDIT */
028: package org.cougaar.glm.ldm.asset;
029:
030: import org.cougaar.planning.ldm.asset.*;
031: import java.io.ObjectOutputStream;
032: import java.io.ObjectInputStream;
033: import java.io.IOException;
034: import java.util.Vector;
035: import java.beans.PropertyDescriptor;
036: import java.beans.IndexedPropertyDescriptor;
037: import java.beans.IntrospectionException;
038: import org.cougaar.planning.ldm.plan.HasRelationships;
039: import org.cougaar.planning.ldm.plan.RelationshipSchedule;
040: import org.cougaar.planning.ldm.plan.RelationshipScheduleImpl;
041:
042: public class Organization extends OrganizationAdapter implements
043: HasRelationships {
044:
045: public Organization() {
046: myManagedAssetPG = null;
047: myAssignmentPG = null;
048: myClusterPG = null;
049: myOrganizationPG = null;
050: myCommunityPGSchedule = null;
051: myRelationshipPG = null;
052: }
053:
054: public Organization(Organization prototype) {
055: super (prototype);
056: myManagedAssetPG = null;
057: myAssignmentPG = null;
058: myClusterPG = null;
059: myOrganizationPG = null;
060: myCommunityPGSchedule = null;
061: myRelationshipPG = null;
062: }
063:
064: /** For infrastructure only - use org.cougaar.core.domain.Factory.copyInstance instead. **/
065: public Object clone() throws CloneNotSupportedException {
066: Organization _thing = (Organization) super .clone();
067: if (myManagedAssetPG != null)
068: _thing.setManagedAssetPG(myManagedAssetPG.lock());
069: if (myAssignmentPG != null)
070: _thing.setAssignmentPG(myAssignmentPG.lock());
071: if (myClusterPG != null)
072: _thing.setClusterPG(myClusterPG.lock());
073: if (myOrganizationPG != null)
074: _thing.setOrganizationPG(myOrganizationPG.lock());
075: if (myCommunityPGSchedule != null)
076: _thing
077: .setCommunityPGSchedule((PropertyGroupSchedule) myCommunityPGSchedule
078: .lock());
079: return _thing;
080: }
081:
082: /** create an instance of the right class for copy operations **/
083: public Asset instanceForCopy() {
084: return new Organization();
085: }
086:
087: /** create an instance of this prototype **/
088: public Asset createInstance() {
089: return new Organization(this );
090: }
091:
092: protected void fillAllPropertyGroups(Vector v) {
093: super .fillAllPropertyGroups(v);
094: {
095: Object _tmp = getManagedAssetPG();
096: if (_tmp != null && !(_tmp instanceof Null_PG)) {
097: v.addElement(_tmp);
098: }
099: }
100: {
101: Object _tmp = getAssignmentPG();
102: if (_tmp != null && !(_tmp instanceof Null_PG)) {
103: v.addElement(_tmp);
104: }
105: }
106: {
107: Object _tmp = getClusterPG();
108: if (_tmp != null && !(_tmp instanceof Null_PG)) {
109: v.addElement(_tmp);
110: }
111: }
112: {
113: Object _tmp = getOrganizationPG();
114: if (_tmp != null && !(_tmp instanceof Null_PG)) {
115: v.addElement(_tmp);
116: }
117: }
118: {
119: Object _tmp = getCommunityPGSchedule();
120: if (_tmp != null && !(_tmp instanceof Null_PG)) {
121: v.addElement(_tmp);
122: }
123: }
124: {
125: Object _tmp = getRelationshipPG();
126: if (_tmp != null && !(_tmp instanceof Null_PG)) {
127: v.addElement(_tmp);
128: }
129: }
130: }
131:
132: private transient ManagedAssetPG myManagedAssetPG;
133:
134: public ManagedAssetPG getManagedAssetPG() {
135: ManagedAssetPG _tmp = (myManagedAssetPG != null) ? myManagedAssetPG
136: : (ManagedAssetPG) resolvePG(ManagedAssetPG.class);
137: return (_tmp == ManagedAssetPG.nullPG) ? null : _tmp;
138: }
139:
140: public void setManagedAssetPG(PropertyGroup arg_ManagedAssetPG) {
141: if (!(arg_ManagedAssetPG instanceof ManagedAssetPG))
142: throw new IllegalArgumentException(
143: "setManagedAssetPG requires a ManagedAssetPG argument.");
144: myManagedAssetPG = (ManagedAssetPG) arg_ManagedAssetPG;
145: }
146:
147: private transient AssignmentPG myAssignmentPG;
148:
149: public AssignmentPG getAssignmentPG() {
150: AssignmentPG _tmp = (myAssignmentPG != null) ? myAssignmentPG
151: : (AssignmentPG) resolvePG(AssignmentPG.class);
152: return (_tmp == AssignmentPG.nullPG) ? null : _tmp;
153: }
154:
155: public void setAssignmentPG(PropertyGroup arg_AssignmentPG) {
156: if (!(arg_AssignmentPG instanceof AssignmentPG))
157: throw new IllegalArgumentException(
158: "setAssignmentPG requires a AssignmentPG argument.");
159: myAssignmentPG = (AssignmentPG) arg_AssignmentPG;
160: }
161:
162: private transient ClusterPG myClusterPG;
163:
164: public ClusterPG getClusterPG() {
165: ClusterPG _tmp = (myClusterPG != null) ? myClusterPG
166: : (ClusterPG) resolvePG(ClusterPG.class);
167: return (_tmp == ClusterPG.nullPG) ? null : _tmp;
168: }
169:
170: public void setClusterPG(PropertyGroup arg_ClusterPG) {
171: if (!(arg_ClusterPG instanceof ClusterPG))
172: throw new IllegalArgumentException(
173: "setClusterPG requires a ClusterPG argument.");
174: myClusterPG = (ClusterPG) arg_ClusterPG;
175: }
176:
177: private transient OrganizationPG myOrganizationPG;
178:
179: public OrganizationPG getOrganizationPG() {
180: OrganizationPG _tmp = (myOrganizationPG != null) ? myOrganizationPG
181: : (OrganizationPG) resolvePG(OrganizationPG.class);
182: return (_tmp == OrganizationPG.nullPG) ? null : _tmp;
183: }
184:
185: public void setOrganizationPG(PropertyGroup arg_OrganizationPG) {
186: if (!(arg_OrganizationPG instanceof OrganizationPG))
187: throw new IllegalArgumentException(
188: "setOrganizationPG requires a OrganizationPG argument.");
189: myOrganizationPG = (OrganizationPG) arg_OrganizationPG;
190: }
191:
192: private transient PropertyGroupSchedule myCommunityPGSchedule;
193:
194: public CommunityPG getCommunityPG(long time) {
195: CommunityPG _tmp = (myCommunityPGSchedule != null) ? (CommunityPG) myCommunityPGSchedule
196: .intersects(time)
197: : (CommunityPG) resolvePG(CommunityPG.class, time);
198: return (_tmp == CommunityPG.nullPG) ? null : _tmp;
199: }
200:
201: public PropertyGroupSchedule getCommunityPGSchedule() {
202: PropertyGroupSchedule _tmp = (myCommunityPGSchedule != null) ? myCommunityPGSchedule
203: : resolvePGSchedule(CommunityPG.class);
204: return _tmp;
205: }
206:
207: public void setCommunityPG(PropertyGroup arg_CommunityPG) {
208: if (!(arg_CommunityPG instanceof CommunityPG))
209: throw new IllegalArgumentException(
210: "setCommunityPG requires a CommunityPG argument.");
211: if (myCommunityPGSchedule == null) {
212: myCommunityPGSchedule = PropertyGroupFactory
213: .newCommunityPGSchedule();
214: }
215:
216: myCommunityPGSchedule.add(arg_CommunityPG);
217: }
218:
219: public void setCommunityPGSchedule(
220: PropertyGroupSchedule arg_OrganizationSchedule) {
221: if (!(CommunityPG.class.equals(arg_OrganizationSchedule
222: .getPGClass())))
223: throw new IllegalArgumentException(
224: "setCommunityPGSchedule requires a PropertyGroupSchedule ofCommunityPGs.");
225:
226: myCommunityPGSchedule = arg_OrganizationSchedule;
227: }
228:
229: private transient RelationshipPG myRelationshipPG;
230:
231: public RelationshipSchedule getRelationshipSchedule() {
232: return getRelationshipPG().getRelationshipSchedule();
233: }
234:
235: public void setRelationshipSchedule(RelationshipSchedule schedule) {
236: NewRelationshipPG _argRelationshipPG = (NewRelationshipPG) getRelationshipPG()
237: .copy();
238: _argRelationshipPG.setRelationshipSchedule(schedule);
239: setRelationshipPG(_argRelationshipPG);
240: }
241:
242: public boolean isLocal() {
243: return getRelationshipPG().getLocal();
244: }
245:
246: public void setLocal(boolean localFlag) {
247: NewRelationshipPG _argRelationshipPG = (NewRelationshipPG) getRelationshipPG()
248: .copy();
249: _argRelationshipPG.setLocal(localFlag);
250: setRelationshipPG(_argRelationshipPG);
251: }
252:
253: public boolean isSelf() {
254: return getRelationshipPG().getLocal();
255: }
256:
257: public RelationshipPG getRelationshipPG() {
258: RelationshipPG _tmp = (myRelationshipPG != null) ? myRelationshipPG
259: : (RelationshipPG) resolvePG(RelationshipPG.class);
260: return (_tmp == RelationshipPG.nullPG) ? null : _tmp;
261: }
262:
263: public void setRelationshipPG(PropertyGroup arg_RelationshipPG) {
264: if (!(arg_RelationshipPG instanceof RelationshipPG))
265: throw new IllegalArgumentException(
266: "setRelationshipPG requires a RelationshipPG argument.");
267: myRelationshipPG = (RelationshipPG) arg_RelationshipPG;
268: }
269:
270: // generic search methods
271: public PropertyGroup getLocalPG(Class c, long t) {
272: if (ManagedAssetPG.class.equals(c)) {
273: return (myManagedAssetPG == ManagedAssetPG.nullPG) ? null
274: : myManagedAssetPG;
275: }
276: if (AssignmentPG.class.equals(c)) {
277: return (myAssignmentPG == AssignmentPG.nullPG) ? null
278: : myAssignmentPG;
279: }
280: if (ClusterPG.class.equals(c)) {
281: return (myClusterPG == ClusterPG.nullPG) ? null
282: : myClusterPG;
283: }
284: if (OrganizationPG.class.equals(c)) {
285: return (myOrganizationPG == OrganizationPG.nullPG) ? null
286: : myOrganizationPG;
287: }
288: if (CommunityPG.class.equals(c)) {
289: if (myCommunityPGSchedule == null) {
290: return null;
291: } else {
292: if (t == UNSPECIFIED_TIME) {
293: return (CommunityPG) myCommunityPGSchedule
294: .getDefault();
295: } else {
296: return (CommunityPG) myCommunityPGSchedule
297: .intersects(t);
298: }
299: }
300: }
301: if (RelationshipPG.class.equals(c)) {
302: return (myRelationshipPG == RelationshipPG.nullPG) ? null
303: : myRelationshipPG;
304: }
305: return super .getLocalPG(c, t);
306: }
307:
308: public PropertyGroupSchedule getLocalPGSchedule(Class c) {
309: if (CommunityPG.class.equals(c)) {
310: return myCommunityPGSchedule;
311: }
312: return super .getLocalPGSchedule(c);
313: }
314:
315: public void setLocalPG(Class c, PropertyGroup pg) {
316: if (ManagedAssetPG.class.equals(c)) {
317: myManagedAssetPG = (ManagedAssetPG) pg;
318: } else if (AssignmentPG.class.equals(c)) {
319: myAssignmentPG = (AssignmentPG) pg;
320: } else if (ClusterPG.class.equals(c)) {
321: myClusterPG = (ClusterPG) pg;
322: } else if (OrganizationPG.class.equals(c)) {
323: myOrganizationPG = (OrganizationPG) pg;
324: } else if (CommunityPG.class.equals(c)) {
325: if (myCommunityPGSchedule == null) {
326: myCommunityPGSchedule = PropertyGroupFactory
327: .newCommunityPGSchedule();
328: } else {
329: myCommunityPGSchedule.removeAll(myCommunityPGSchedule
330: .intersectingSet((TimePhasedPropertyGroup) pg));
331: }
332: myCommunityPGSchedule.add(pg);
333: } else if (RelationshipPG.class.equals(c)) {
334: myRelationshipPG = (RelationshipPG) pg;
335: } else
336: super .setLocalPG(c, pg);
337: }
338:
339: public void setLocalPGSchedule(PropertyGroupSchedule pgSchedule) {
340: if (CommunityPG.class.equals(pgSchedule.getPGClass())) {
341: myCommunityPGSchedule = pgSchedule;
342: } else
343: super .setLocalPGSchedule(pgSchedule);
344: }
345:
346: public PropertyGroup removeLocalPG(Class c) {
347: PropertyGroup removed = null;
348: if (ManagedAssetPG.class.equals(c)) {
349: removed = myManagedAssetPG;
350: myManagedAssetPG = null;
351: } else if (AssignmentPG.class.equals(c)) {
352: removed = myAssignmentPG;
353: myAssignmentPG = null;
354: } else if (ClusterPG.class.equals(c)) {
355: removed = myClusterPG;
356: myClusterPG = null;
357: } else if (OrganizationPG.class.equals(c)) {
358: removed = myOrganizationPG;
359: myOrganizationPG = null;
360: } else if (CommunityPG.class.equals(c)) {
361: if (myCommunityPGSchedule != null) {
362: if (myCommunityPGSchedule.getDefault() != null) {
363: removed = myCommunityPGSchedule.getDefault();
364: } else if (myCommunityPGSchedule.size() > 0) {
365: removed = (PropertyGroup) myCommunityPGSchedule
366: .get(0);
367: }
368: myCommunityPGSchedule = null;
369: }
370: } else if (RelationshipPG.class.equals(c)) {
371: removed = myRelationshipPG;
372: myRelationshipPG = null;
373: } else {
374: removed = super .removeLocalPG(c);
375: }
376: return removed;
377: }
378:
379: public PropertyGroup removeLocalPG(PropertyGroup pg) {
380: Class pgc = pg.getPrimaryClass();
381: if (ManagedAssetPG.class.equals(pgc)) {
382: PropertyGroup removed = myManagedAssetPG;
383: myManagedAssetPG = null;
384: return removed;
385: } else if (AssignmentPG.class.equals(pgc)) {
386: PropertyGroup removed = myAssignmentPG;
387: myAssignmentPG = null;
388: return removed;
389: } else if (ClusterPG.class.equals(pgc)) {
390: PropertyGroup removed = myClusterPG;
391: myClusterPG = null;
392: return removed;
393: } else if (OrganizationPG.class.equals(pgc)) {
394: PropertyGroup removed = myOrganizationPG;
395: myOrganizationPG = null;
396: return removed;
397: } else if (CommunityPG.class.equals(pgc)) {
398: if ((myCommunityPGSchedule != null)
399: && (myCommunityPGSchedule.remove(pg))) {
400: return pg;
401: }
402: } else if (RelationshipPG.class.equals(pgc)) {
403: PropertyGroup removed = myRelationshipPG;
404: myRelationshipPG = null;
405: return removed;
406: } else {
407: }
408: return super .removeLocalPG(pg);
409: }
410:
411: public PropertyGroupSchedule removeLocalPGSchedule(Class c) {
412: if (CommunityPG.class.equals(c)) {
413: PropertyGroupSchedule removed = myCommunityPGSchedule;
414: myCommunityPGSchedule = null;
415: return removed;
416: } else {
417: return super .removeLocalPGSchedule(c);
418: }
419: }
420:
421: public PropertyGroup generateDefaultPG(Class c) {
422: if (ManagedAssetPG.class.equals(c)) {
423: return (myManagedAssetPG = new ManagedAssetPGImpl());
424: } else if (AssignmentPG.class.equals(c)) {
425: return (myAssignmentPG = new AssignmentPGImpl());
426: } else if (ClusterPG.class.equals(c)) {
427: return (myClusterPG = new ClusterPGImpl());
428: } else if (OrganizationPG.class.equals(c)) {
429: return (myOrganizationPG = new OrganizationPGImpl());
430: } else if (CommunityPG.class.equals(c)) {
431: return null;
432: } else if (RelationshipPG.class.equals(c)) {
433: return (myRelationshipPG = new RelationshipPGImpl());
434: } else
435: return super .generateDefaultPG(c);
436: }
437:
438: // dumb serialization methods
439:
440: private void writeObject(ObjectOutputStream out) throws IOException {
441: out.defaultWriteObject();
442: if (myManagedAssetPG instanceof Null_PG
443: || myManagedAssetPG instanceof Future_PG) {
444: out.writeObject(null);
445: } else {
446: out.writeObject(myManagedAssetPG);
447: }
448: if (myAssignmentPG instanceof Null_PG
449: || myAssignmentPG instanceof Future_PG) {
450: out.writeObject(null);
451: } else {
452: out.writeObject(myAssignmentPG);
453: }
454: if (myClusterPG instanceof Null_PG
455: || myClusterPG instanceof Future_PG) {
456: out.writeObject(null);
457: } else {
458: out.writeObject(myClusterPG);
459: }
460: if (myOrganizationPG instanceof Null_PG
461: || myOrganizationPG instanceof Future_PG) {
462: out.writeObject(null);
463: } else {
464: out.writeObject(myOrganizationPG);
465: }
466: if (myCommunityPGSchedule instanceof Null_PG
467: || myCommunityPGSchedule instanceof Future_PG) {
468: out.writeObject(null);
469: } else {
470: out.writeObject(myCommunityPGSchedule);
471: }
472: if (myRelationshipPG instanceof Null_PG
473: || myRelationshipPG instanceof Future_PG) {
474: out.writeObject(null);
475: } else {
476: out.writeObject(myRelationshipPG);
477: }
478: }
479:
480: private void readObject(ObjectInputStream in)
481: throws ClassNotFoundException, IOException {
482: in.defaultReadObject();
483: myManagedAssetPG = (ManagedAssetPG) in.readObject();
484: myAssignmentPG = (AssignmentPG) in.readObject();
485: myClusterPG = (ClusterPG) in.readObject();
486: myOrganizationPG = (OrganizationPG) in.readObject();
487: myCommunityPGSchedule = (PropertyGroupSchedule) in.readObject();
488: myRelationshipPG = (RelationshipPG) in.readObject();
489: }
490:
491: // beaninfo support
492: private static PropertyDescriptor properties[];
493: static {
494: try {
495: properties = new PropertyDescriptor[6];
496: properties[0] = new PropertyDescriptor("ManagedAssetPG",
497: Organization.class, "getManagedAssetPG", null);
498: properties[1] = new PropertyDescriptor("AssignmentPG",
499: Organization.class, "getAssignmentPG", null);
500: properties[2] = new PropertyDescriptor("ClusterPG",
501: Organization.class, "getClusterPG", null);
502: properties[3] = new PropertyDescriptor("OrganizationPG",
503: Organization.class, "getOrganizationPG", null);
504: properties[4] = new PropertyDescriptor(
505: "CommunityPGSchedule", Organization.class,
506: "getCommunityPGSchedule", null);
507: properties[5] = new PropertyDescriptor("RelationshipPG",
508: Organization.class, "getRelationshipPG", null);
509: } catch (IntrospectionException ie) {
510: }
511: }
512:
513: public PropertyDescriptor[] getPropertyDescriptors() {
514: PropertyDescriptor[] pds = super .getPropertyDescriptors();
515: PropertyDescriptor[] ps = new PropertyDescriptor[pds.length + 6];
516: System.arraycopy(pds, 0, ps, 0, pds.length);
517: System.arraycopy(properties, 0, ps, pds.length, 6);
518: return ps;
519: }
520: }
|