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:20:42 EDT 2007 from /u01/builds/cougaar/B12_4/B12_4/070927151721/src/planning/src/org/cougaar/planning/ldm/asset/assets.def - DO NOT HAND EDIT */
028: package org.cougaar.planning.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 Entity extends EntityAdapter implements HasRelationships {
043:
044: public Entity() {
045: myClusterPG = null;
046: myEntityPG = null;
047: myCommunityPGSchedule = null;
048: myRelationshipPG = null;
049: myLocationSchedulePG = null;
050: }
051:
052: public Entity(Entity prototype) {
053: super (prototype);
054: myClusterPG = null;
055: myEntityPG = null;
056: myCommunityPGSchedule = null;
057: myRelationshipPG = null;
058: myLocationSchedulePG = null;
059: }
060:
061: /** For infrastructure only - use org.cougaar.core.domain.Factory.copyInstance instead. **/
062: public Object clone() throws CloneNotSupportedException {
063: Entity _thing = (Entity) super .clone();
064: if (myClusterPG != null)
065: _thing.setClusterPG(myClusterPG.lock());
066: if (myEntityPG != null)
067: _thing.setEntityPG(myEntityPG.lock());
068: if (myCommunityPGSchedule != null)
069: _thing
070: .setCommunityPGSchedule((PropertyGroupSchedule) myCommunityPGSchedule
071: .lock());
072: if (myLocationSchedulePG != null)
073: _thing.setLocationSchedulePG(myLocationSchedulePG.lock());
074: return _thing;
075: }
076:
077: /** create an instance of the right class for copy operations **/
078: public Asset instanceForCopy() {
079: return new Entity();
080: }
081:
082: /** create an instance of this prototype **/
083: public Asset createInstance() {
084: return new Entity(this );
085: }
086:
087: protected void fillAllPropertyGroups(Vector v) {
088: super .fillAllPropertyGroups(v);
089: {
090: Object _tmp = getClusterPG();
091: if (_tmp != null && !(_tmp instanceof Null_PG)) {
092: v.addElement(_tmp);
093: }
094: }
095: {
096: Object _tmp = getEntityPG();
097: if (_tmp != null && !(_tmp instanceof Null_PG)) {
098: v.addElement(_tmp);
099: }
100: }
101: {
102: Object _tmp = getCommunityPGSchedule();
103: if (_tmp != null && !(_tmp instanceof Null_PG)) {
104: v.addElement(_tmp);
105: }
106: }
107: {
108: Object _tmp = getRelationshipPG();
109: if (_tmp != null && !(_tmp instanceof Null_PG)) {
110: v.addElement(_tmp);
111: }
112: }
113: {
114: Object _tmp = getLocationSchedulePG();
115: if (_tmp != null && !(_tmp instanceof Null_PG)) {
116: v.addElement(_tmp);
117: }
118: }
119: }
120:
121: private transient ClusterPG myClusterPG;
122:
123: public ClusterPG getClusterPG() {
124: ClusterPG _tmp = (myClusterPG != null) ? myClusterPG
125: : (ClusterPG) resolvePG(ClusterPG.class);
126: return (_tmp == ClusterPG.nullPG) ? null : _tmp;
127: }
128:
129: public void setClusterPG(PropertyGroup arg_ClusterPG) {
130: if (!(arg_ClusterPG instanceof ClusterPG))
131: throw new IllegalArgumentException(
132: "setClusterPG requires a ClusterPG argument.");
133: myClusterPG = (ClusterPG) arg_ClusterPG;
134: }
135:
136: private transient EntityPG myEntityPG;
137:
138: public EntityPG getEntityPG() {
139: EntityPG _tmp = (myEntityPG != null) ? myEntityPG
140: : (EntityPG) resolvePG(EntityPG.class);
141: return (_tmp == EntityPG.nullPG) ? null : _tmp;
142: }
143:
144: public void setEntityPG(PropertyGroup arg_EntityPG) {
145: if (!(arg_EntityPG instanceof EntityPG))
146: throw new IllegalArgumentException(
147: "setEntityPG requires a EntityPG argument.");
148: myEntityPG = (EntityPG) arg_EntityPG;
149: }
150:
151: private transient PropertyGroupSchedule myCommunityPGSchedule;
152:
153: public CommunityPG getCommunityPG(long time) {
154: CommunityPG _tmp = (myCommunityPGSchedule != null) ? (CommunityPG) myCommunityPGSchedule
155: .intersects(time)
156: : (CommunityPG) resolvePG(CommunityPG.class, time);
157: return (_tmp == CommunityPG.nullPG) ? null : _tmp;
158: }
159:
160: public PropertyGroupSchedule getCommunityPGSchedule() {
161: PropertyGroupSchedule _tmp = (myCommunityPGSchedule != null) ? myCommunityPGSchedule
162: : resolvePGSchedule(CommunityPG.class);
163: return _tmp;
164: }
165:
166: public void setCommunityPG(PropertyGroup arg_CommunityPG) {
167: if (!(arg_CommunityPG instanceof CommunityPG))
168: throw new IllegalArgumentException(
169: "setCommunityPG requires a CommunityPG argument.");
170: if (myCommunityPGSchedule == null) {
171: myCommunityPGSchedule = PropertyGroupFactory
172: .newCommunityPGSchedule();
173: }
174:
175: myCommunityPGSchedule.add(arg_CommunityPG);
176: }
177:
178: public void setCommunityPGSchedule(
179: PropertyGroupSchedule arg_EntitySchedule) {
180: if (!(CommunityPG.class.equals(arg_EntitySchedule.getPGClass())))
181: throw new IllegalArgumentException(
182: "setCommunityPGSchedule requires a PropertyGroupSchedule ofCommunityPGs.");
183:
184: myCommunityPGSchedule = arg_EntitySchedule;
185: }
186:
187: private transient RelationshipPG myRelationshipPG;
188:
189: public RelationshipSchedule getRelationshipSchedule() {
190: return getRelationshipPG().getRelationshipSchedule();
191: }
192:
193: public void setRelationshipSchedule(RelationshipSchedule schedule) {
194: NewRelationshipPG _argRelationshipPG = (NewRelationshipPG) getRelationshipPG()
195: .copy();
196: _argRelationshipPG.setRelationshipSchedule(schedule);
197: setRelationshipPG(_argRelationshipPG);
198: }
199:
200: public boolean isLocal() {
201: return getRelationshipPG().getLocal();
202: }
203:
204: public void setLocal(boolean localFlag) {
205: NewRelationshipPG _argRelationshipPG = (NewRelationshipPG) getRelationshipPG()
206: .copy();
207: _argRelationshipPG.setLocal(localFlag);
208: setRelationshipPG(_argRelationshipPG);
209: }
210:
211: public boolean isSelf() {
212: return getRelationshipPG().getLocal();
213: }
214:
215: public RelationshipPG getRelationshipPG() {
216: RelationshipPG _tmp = (myRelationshipPG != null) ? myRelationshipPG
217: : (RelationshipPG) resolvePG(RelationshipPG.class);
218: return (_tmp == RelationshipPG.nullPG) ? null : _tmp;
219: }
220:
221: public void setRelationshipPG(PropertyGroup arg_RelationshipPG) {
222: if (!(arg_RelationshipPG instanceof RelationshipPG))
223: throw new IllegalArgumentException(
224: "setRelationshipPG requires a RelationshipPG argument.");
225: myRelationshipPG = (RelationshipPG) arg_RelationshipPG;
226: }
227:
228: private transient LocationSchedulePG myLocationSchedulePG;
229:
230: public LocationSchedulePG getLocationSchedulePG() {
231: LocationSchedulePG _tmp = (myLocationSchedulePG != null) ? myLocationSchedulePG
232: : (LocationSchedulePG) resolvePG(LocationSchedulePG.class);
233: return (_tmp == LocationSchedulePG.nullPG) ? null : _tmp;
234: }
235:
236: public void setLocationSchedulePG(
237: PropertyGroup arg_LocationSchedulePG) {
238: if (!(arg_LocationSchedulePG instanceof LocationSchedulePG))
239: throw new IllegalArgumentException(
240: "setLocationSchedulePG requires a LocationSchedulePG argument.");
241: myLocationSchedulePG = (LocationSchedulePG) arg_LocationSchedulePG;
242: }
243:
244: // generic search methods
245: public PropertyGroup getLocalPG(Class c, long t) {
246: if (ClusterPG.class.equals(c)) {
247: return (myClusterPG == ClusterPG.nullPG) ? null
248: : myClusterPG;
249: }
250: if (EntityPG.class.equals(c)) {
251: return (myEntityPG == EntityPG.nullPG) ? null : myEntityPG;
252: }
253: if (CommunityPG.class.equals(c)) {
254: if (myCommunityPGSchedule == null) {
255: return null;
256: } else {
257: if (t == UNSPECIFIED_TIME) {
258: return (CommunityPG) myCommunityPGSchedule
259: .getDefault();
260: } else {
261: return (CommunityPG) myCommunityPGSchedule
262: .intersects(t);
263: }
264: }
265: }
266: if (RelationshipPG.class.equals(c)) {
267: return (myRelationshipPG == RelationshipPG.nullPG) ? null
268: : myRelationshipPG;
269: }
270: if (LocationSchedulePG.class.equals(c)) {
271: return (myLocationSchedulePG == LocationSchedulePG.nullPG) ? null
272: : myLocationSchedulePG;
273: }
274: return super .getLocalPG(c, t);
275: }
276:
277: public PropertyGroupSchedule getLocalPGSchedule(Class c) {
278: if (CommunityPG.class.equals(c)) {
279: return myCommunityPGSchedule;
280: }
281: return super .getLocalPGSchedule(c);
282: }
283:
284: public void setLocalPG(Class c, PropertyGroup pg) {
285: if (ClusterPG.class.equals(c)) {
286: myClusterPG = (ClusterPG) pg;
287: } else if (EntityPG.class.equals(c)) {
288: myEntityPG = (EntityPG) pg;
289: } else if (CommunityPG.class.equals(c)) {
290: if (myCommunityPGSchedule == null) {
291: myCommunityPGSchedule = PropertyGroupFactory
292: .newCommunityPGSchedule();
293: } else {
294: myCommunityPGSchedule.removeAll(myCommunityPGSchedule
295: .intersectingSet((TimePhasedPropertyGroup) pg));
296: }
297: myCommunityPGSchedule.add(pg);
298: } else if (RelationshipPG.class.equals(c)) {
299: myRelationshipPG = (RelationshipPG) pg;
300: } else if (LocationSchedulePG.class.equals(c)) {
301: myLocationSchedulePG = (LocationSchedulePG) pg;
302: } else
303: super .setLocalPG(c, pg);
304: }
305:
306: public void setLocalPGSchedule(PropertyGroupSchedule pgSchedule) {
307: if (CommunityPG.class.equals(pgSchedule.getPGClass())) {
308: myCommunityPGSchedule = pgSchedule;
309: } else
310: super .setLocalPGSchedule(pgSchedule);
311: }
312:
313: public PropertyGroup removeLocalPG(Class c) {
314: PropertyGroup removed = null;
315: if (ClusterPG.class.equals(c)) {
316: removed = myClusterPG;
317: myClusterPG = null;
318: } else if (EntityPG.class.equals(c)) {
319: removed = myEntityPG;
320: myEntityPG = null;
321: } else if (CommunityPG.class.equals(c)) {
322: if (myCommunityPGSchedule != null) {
323: if (myCommunityPGSchedule.getDefault() != null) {
324: removed = myCommunityPGSchedule.getDefault();
325: } else if (myCommunityPGSchedule.size() > 0) {
326: removed = (PropertyGroup) myCommunityPGSchedule
327: .get(0);
328: }
329: myCommunityPGSchedule = null;
330: }
331: } else if (RelationshipPG.class.equals(c)) {
332: removed = myRelationshipPG;
333: myRelationshipPG = null;
334: } else if (LocationSchedulePG.class.equals(c)) {
335: removed = myLocationSchedulePG;
336: myLocationSchedulePG = null;
337: } else {
338: removed = super .removeLocalPG(c);
339: }
340: return removed;
341: }
342:
343: public PropertyGroup removeLocalPG(PropertyGroup pg) {
344: Class pgc = pg.getPrimaryClass();
345: if (ClusterPG.class.equals(pgc)) {
346: PropertyGroup removed = myClusterPG;
347: myClusterPG = null;
348: return removed;
349: } else if (EntityPG.class.equals(pgc)) {
350: PropertyGroup removed = myEntityPG;
351: myEntityPG = null;
352: return removed;
353: } else if (CommunityPG.class.equals(pgc)) {
354: if ((myCommunityPGSchedule != null)
355: && (myCommunityPGSchedule.remove(pg))) {
356: return pg;
357: }
358: } else if (RelationshipPG.class.equals(pgc)) {
359: PropertyGroup removed = myRelationshipPG;
360: myRelationshipPG = null;
361: return removed;
362: } else if (LocationSchedulePG.class.equals(pgc)) {
363: PropertyGroup removed = myLocationSchedulePG;
364: myLocationSchedulePG = null;
365: return removed;
366: } else {
367: }
368: return super .removeLocalPG(pg);
369: }
370:
371: public PropertyGroupSchedule removeLocalPGSchedule(Class c) {
372: if (CommunityPG.class.equals(c)) {
373: PropertyGroupSchedule removed = myCommunityPGSchedule;
374: myCommunityPGSchedule = null;
375: return removed;
376: } else {
377: return super .removeLocalPGSchedule(c);
378: }
379: }
380:
381: public PropertyGroup generateDefaultPG(Class c) {
382: if (ClusterPG.class.equals(c)) {
383: return (myClusterPG = new ClusterPGImpl());
384: } else if (EntityPG.class.equals(c)) {
385: return (myEntityPG = new EntityPGImpl());
386: } else if (CommunityPG.class.equals(c)) {
387: return null;
388: } else if (RelationshipPG.class.equals(c)) {
389: return (myRelationshipPG = new RelationshipPGImpl());
390: } else if (LocationSchedulePG.class.equals(c)) {
391: return (myLocationSchedulePG = new LocationSchedulePGImpl());
392: } else
393: return super .generateDefaultPG(c);
394: }
395:
396: // dumb serialization methods
397:
398: private void writeObject(ObjectOutputStream out) throws IOException {
399: out.defaultWriteObject();
400: if (myClusterPG instanceof Null_PG
401: || myClusterPG instanceof Future_PG) {
402: out.writeObject(null);
403: } else {
404: out.writeObject(myClusterPG);
405: }
406: if (myEntityPG instanceof Null_PG
407: || myEntityPG instanceof Future_PG) {
408: out.writeObject(null);
409: } else {
410: out.writeObject(myEntityPG);
411: }
412: if (myCommunityPGSchedule instanceof Null_PG
413: || myCommunityPGSchedule instanceof Future_PG) {
414: out.writeObject(null);
415: } else {
416: out.writeObject(myCommunityPGSchedule);
417: }
418: if (myRelationshipPG instanceof Null_PG
419: || myRelationshipPG instanceof Future_PG) {
420: out.writeObject(null);
421: } else {
422: out.writeObject(myRelationshipPG);
423: }
424: if (myLocationSchedulePG instanceof Null_PG
425: || myLocationSchedulePG instanceof Future_PG) {
426: out.writeObject(null);
427: } else {
428: out.writeObject(myLocationSchedulePG);
429: }
430: }
431:
432: private void readObject(ObjectInputStream in)
433: throws ClassNotFoundException, IOException {
434: in.defaultReadObject();
435: myClusterPG = (ClusterPG) in.readObject();
436: myEntityPG = (EntityPG) in.readObject();
437: myCommunityPGSchedule = (PropertyGroupSchedule) in.readObject();
438: myRelationshipPG = (RelationshipPG) in.readObject();
439: myLocationSchedulePG = (LocationSchedulePG) in.readObject();
440: }
441:
442: // beaninfo support
443: private static PropertyDescriptor properties[];
444: static {
445: try {
446: properties = new PropertyDescriptor[5];
447: properties[0] = new PropertyDescriptor("ClusterPG",
448: Entity.class, "getClusterPG", null);
449: properties[1] = new PropertyDescriptor("EntityPG",
450: Entity.class, "getEntityPG", null);
451: properties[2] = new PropertyDescriptor(
452: "CommunityPGSchedule", Entity.class,
453: "getCommunityPGSchedule", null);
454: properties[3] = new PropertyDescriptor("RelationshipPG",
455: Entity.class, "getRelationshipPG", null);
456: properties[4] = new PropertyDescriptor(
457: "LocationSchedulePG", Entity.class,
458: "getLocationSchedulePG", null);
459: } catch (IntrospectionException ie) {
460: }
461: }
462:
463: public PropertyDescriptor[] getPropertyDescriptors() {
464: PropertyDescriptor[] pds = super .getPropertyDescriptors();
465: PropertyDescriptor[] ps = new PropertyDescriptor[pds.length + 5];
466: System.arraycopy(pds, 0, ps, 0, pds.length);
467: System.arraycopy(properties, 0, ps, pds.length, 5);
468: return ps;
469: }
470: }
|