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 ClientOrganization extends OrganizationAdapter implements
043: HasRelationships {
044:
045: public ClientOrganization() {
046: myClusterPG = null;
047: myRelationshipPG = null;
048: }
049:
050: public ClientOrganization(ClientOrganization prototype) {
051: super (prototype);
052: myClusterPG = null;
053: myRelationshipPG = null;
054: }
055:
056: /** For infrastructure only - use org.cougaar.core.domain.Factory.copyInstance instead. **/
057: public Object clone() throws CloneNotSupportedException {
058: ClientOrganization _thing = (ClientOrganization) super .clone();
059: if (myClusterPG != null)
060: _thing.setClusterPG(myClusterPG.lock());
061: return _thing;
062: }
063:
064: /** create an instance of the right class for copy operations **/
065: public Asset instanceForCopy() {
066: return new ClientOrganization();
067: }
068:
069: /** create an instance of this prototype **/
070: public Asset createInstance() {
071: return new ClientOrganization(this );
072: }
073:
074: protected void fillAllPropertyGroups(Vector v) {
075: super .fillAllPropertyGroups(v);
076: {
077: Object _tmp = getClusterPG();
078: if (_tmp != null && !(_tmp instanceof Null_PG)) {
079: v.addElement(_tmp);
080: }
081: }
082: {
083: Object _tmp = getRelationshipPG();
084: if (_tmp != null && !(_tmp instanceof Null_PG)) {
085: v.addElement(_tmp);
086: }
087: }
088: }
089:
090: private transient ClusterPG myClusterPG;
091:
092: public ClusterPG getClusterPG() {
093: ClusterPG _tmp = (myClusterPG != null) ? myClusterPG
094: : (ClusterPG) resolvePG(ClusterPG.class);
095: return (_tmp == ClusterPG.nullPG) ? null : _tmp;
096: }
097:
098: public void setClusterPG(PropertyGroup arg_ClusterPG) {
099: if (!(arg_ClusterPG instanceof ClusterPG))
100: throw new IllegalArgumentException(
101: "setClusterPG requires a ClusterPG argument.");
102: myClusterPG = (ClusterPG) arg_ClusterPG;
103: }
104:
105: private transient RelationshipPG myRelationshipPG;
106:
107: public RelationshipSchedule getRelationshipSchedule() {
108: return getRelationshipPG().getRelationshipSchedule();
109: }
110:
111: public void setRelationshipSchedule(RelationshipSchedule schedule) {
112: NewRelationshipPG _argRelationshipPG = (NewRelationshipPG) getRelationshipPG()
113: .copy();
114: _argRelationshipPG.setRelationshipSchedule(schedule);
115: setRelationshipPG(_argRelationshipPG);
116: }
117:
118: public boolean isLocal() {
119: return getRelationshipPG().getLocal();
120: }
121:
122: public void setLocal(boolean localFlag) {
123: NewRelationshipPG _argRelationshipPG = (NewRelationshipPG) getRelationshipPG()
124: .copy();
125: _argRelationshipPG.setLocal(localFlag);
126: setRelationshipPG(_argRelationshipPG);
127: }
128:
129: public boolean isSelf() {
130: return getRelationshipPG().getLocal();
131: }
132:
133: public RelationshipPG getRelationshipPG() {
134: RelationshipPG _tmp = (myRelationshipPG != null) ? myRelationshipPG
135: : (RelationshipPG) resolvePG(RelationshipPG.class);
136: return (_tmp == RelationshipPG.nullPG) ? null : _tmp;
137: }
138:
139: public void setRelationshipPG(PropertyGroup arg_RelationshipPG) {
140: if (!(arg_RelationshipPG instanceof RelationshipPG))
141: throw new IllegalArgumentException(
142: "setRelationshipPG requires a RelationshipPG argument.");
143: myRelationshipPG = (RelationshipPG) arg_RelationshipPG;
144: }
145:
146: // generic search methods
147: public PropertyGroup getLocalPG(Class c, long t) {
148: if (ClusterPG.class.equals(c)) {
149: return (myClusterPG == ClusterPG.nullPG) ? null
150: : myClusterPG;
151: }
152: if (RelationshipPG.class.equals(c)) {
153: return (myRelationshipPG == RelationshipPG.nullPG) ? null
154: : myRelationshipPG;
155: }
156: return super .getLocalPG(c, t);
157: }
158:
159: public PropertyGroupSchedule getLocalPGSchedule(Class c) {
160: return super .getLocalPGSchedule(c);
161: }
162:
163: public void setLocalPG(Class c, PropertyGroup pg) {
164: if (ClusterPG.class.equals(c)) {
165: myClusterPG = (ClusterPG) pg;
166: } else if (RelationshipPG.class.equals(c)) {
167: myRelationshipPG = (RelationshipPG) pg;
168: } else
169: super .setLocalPG(c, pg);
170: }
171:
172: public void setLocalPGSchedule(PropertyGroupSchedule pgSchedule) {
173: super .setLocalPGSchedule(pgSchedule);
174: }
175:
176: public PropertyGroup removeLocalPG(Class c) {
177: PropertyGroup removed = null;
178: if (ClusterPG.class.equals(c)) {
179: removed = myClusterPG;
180: myClusterPG = null;
181: } else if (RelationshipPG.class.equals(c)) {
182: removed = myRelationshipPG;
183: myRelationshipPG = null;
184: } else {
185: removed = super .removeLocalPG(c);
186: }
187: return removed;
188: }
189:
190: public PropertyGroup removeLocalPG(PropertyGroup pg) {
191: Class pgc = pg.getPrimaryClass();
192: if (ClusterPG.class.equals(pgc)) {
193: PropertyGroup removed = myClusterPG;
194: myClusterPG = null;
195: return removed;
196: } else if (RelationshipPG.class.equals(pgc)) {
197: PropertyGroup removed = myRelationshipPG;
198: myRelationshipPG = null;
199: return removed;
200: } else {
201: }
202: return super .removeLocalPG(pg);
203: }
204:
205: public PropertyGroupSchedule removeLocalPGSchedule(Class c) {
206: {
207: return super .removeLocalPGSchedule(c);
208: }
209: }
210:
211: public PropertyGroup generateDefaultPG(Class c) {
212: if (ClusterPG.class.equals(c)) {
213: return (myClusterPG = new ClusterPGImpl());
214: } else if (RelationshipPG.class.equals(c)) {
215: return (myRelationshipPG = new RelationshipPGImpl());
216: } else
217: return super .generateDefaultPG(c);
218: }
219:
220: // dumb serialization methods
221:
222: private void writeObject(ObjectOutputStream out) throws IOException {
223: out.defaultWriteObject();
224: if (myClusterPG instanceof Null_PG
225: || myClusterPG instanceof Future_PG) {
226: out.writeObject(null);
227: } else {
228: out.writeObject(myClusterPG);
229: }
230: if (myRelationshipPG instanceof Null_PG
231: || myRelationshipPG instanceof Future_PG) {
232: out.writeObject(null);
233: } else {
234: out.writeObject(myRelationshipPG);
235: }
236: }
237:
238: private void readObject(ObjectInputStream in)
239: throws ClassNotFoundException, IOException {
240: in.defaultReadObject();
241: myClusterPG = (ClusterPG) in.readObject();
242: myRelationshipPG = (RelationshipPG) in.readObject();
243: }
244:
245: // beaninfo support
246: private static PropertyDescriptor properties[];
247: static {
248: try {
249: properties = new PropertyDescriptor[2];
250: properties[0] = new PropertyDescriptor("ClusterPG",
251: ClientOrganization.class, "getClusterPG", null);
252: properties[1] = new PropertyDescriptor("RelationshipPG",
253: ClientOrganization.class, "getRelationshipPG", null);
254: } catch (IntrospectionException ie) {
255: }
256: }
257:
258: public PropertyDescriptor[] getPropertyDescriptors() {
259: PropertyDescriptor[] pds = super .getPropertyDescriptors();
260: PropertyDescriptor[] ps = new PropertyDescriptor[pds.length + 2];
261: System.arraycopy(pds, 0, ps, 0, pds.length);
262: System.arraycopy(properties, 0, ps, pds.length, 2);
263: return ps;
264: }
265: }
|