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: package org.cougaar.planning.ldm;
028:
029: import org.cougaar.core.domain.Factory;
030: import org.cougaar.planning.ldm.asset.Asset;
031: import org.cougaar.planning.ldm.asset.EssentialAssetFactory;
032: import org.cougaar.planning.ldm.asset.PropertyGroup;
033: import org.cougaar.planning.ldm.plan.ClusterObjectFactory;
034:
035: /**
036: * Factory methods for all LDM objects.
037: **/
038:
039: public interface PlanningFactory extends Factory, ClusterObjectFactory {
040: /** register a propertyfactory with us so that short (no package!)
041: * property group names may be used in createPropertyGroup(String).
042: * Either a PropertyGroupFactory class or an instance of such may be passed in.
043: **/
044: void addPropertyGroupFactory(Object pf);
045:
046: /** @return true iff the factory parameter is already registered as a
047: * propertygroup factory.
048: **/
049: boolean containsPropertyGroupFactory(Object pf);
050:
051: /** register an assetfactory with us so that we can
052: * (1) find an asset class from an asset name and (2)
053: * can figure out which factory to use for a given
054: * asset class.
055: **/
056: void addAssetFactory(EssentialAssetFactory af);
057:
058: boolean containsAssetFactory(Object f);
059:
060: /** Find a prototype Asset based on it's typeid description,
061: * (e.g. "NSN/1234567890123") either by looking up an existing
062: * object or by creating one of the appropriate type.
063: *
064: * Shorthand for LDMServesPlugin.getPrototype(aTypeName);
065: **/
066: Asset getPrototype(String aTypeName);
067:
068: /** Create a raw Asset instance for use by LDM Plugins
069: * which are PrototypeProviders.
070: * The asset created will have *no* propertygroups.
071: * This *always* creates a prototype of the specific class.
072: * most plugins want to call getPrototype(String typeid);
073: *
074: * @param classname One of the defined LDM class names. This must
075: * be the actual class name without the package path. For example,
076: * "Container" is correct, "org.cougaar.planning.ldm.asset.Container" is not.
077: **/
078: Asset createAsset(String classname);
079:
080: /** Create a raw Asset instance for use by LDM Plugins
081: * which are PrototypeProviders.
082: * The asset created will have *no* propertygroups.
083: * This *always* creates a prototype of the specific class.
084: * most plugins want to call getPrototype(String typeid);
085: *
086: * @param assetClass an LDM Asset class.
087: **/
088: Asset createAsset(Class assetClass);
089:
090: /** convenience routine for creating prototype assets.
091: * does a createAsset followed by setting the TypeIdentification
092: * to the specified string.
093: **/
094: Asset createPrototype(String classname, String typeid);
095:
096: /** convenience routine for creating prototype assets.
097: * does a createAsset followed by setting the TypeIdentification
098: * to the specified string.
099: **/
100: Asset createPrototype(Class assetclass, String typeid);
101:
102: /** convenience routine for creating prototype assets.
103: * does a createAsset followed by setting the TypeIdentification
104: * and the nomenclature to the specified string.
105: **/
106: Asset createPrototype(String classname, String typeid, String nomen);
107:
108: /** Create an instance of a prototypical asset.
109: * This variation does <em>not</em> add an ItemIdentificationCode
110: * to the constructed asset instance. Without itemIDs,
111: * multiple instances of a prototype will test as .equals(), and
112: * can be confusing if they're added to the logplan.
113: * Most users will find #createInstance(Asset, String) more convenient.
114: **/
115: Asset createInstance(Asset prototypeAsset);
116:
117: /** Create an instance of a prototypical asset.
118: * This variation does <em>not</em> add an ItemIdentificationCode
119: * to the constructed asset instance. Without itemIDs,
120: * multiple instances of a prototype will test as .equals(), and
121: * can be confusing if they're added to the logplan.
122: * Most users will find #createInstance(String, String) more convenient.
123: **/
124: Asset createInstance(String prototypeAssetTypeId);
125:
126: /** Create an instance of a prototypical asset, specifying an initial
127: * UniqueID for its itemIdentificationPG .
128: **/
129: Asset createInstance(Asset prototypeAsset, String uniqueId);
130:
131: /** Create an instance of a prototypical asset, specifying an initial UniqueID
132: * for its itemIdentificationPG.
133: **/
134: Asset createInstance(String prototypeAssetTypeId, String uniqueId);
135:
136: /** Make a copy of an instance. The result will be a shallow copy
137: * of the original - that is, it will share most PropertyGroups with the
138: * original instance. The differences will be that the copy's PGs will
139: * be locked and the copy will have a different UID.
140: * The copy will truly be a different asset which happens to (initially) have
141: * identical propertygroups.
142: * This method should be used to create new assets which are very much
143: * like another instance. The use of this method is a less-desirable alternative
144: * to creating a new instance of your original's prototype and then adding back
145: * any extra properties. This is less desirable because it doesn't allow the
146: * LDM to participate in the construction of the copy.
147: **/
148: Asset copyInstance(Asset asset);
149:
150: /** make an evil twin of an instance. The result will be a shallow copy of the
151: * original (as in copyInstance), with locked PropertyGroups. The copy
152: * <em> will </em> have the same UID as the original, so will, in a systems sense
153: * actually be the same asset. It could be very bad for multiple clones of an
154: * asset to show up in someone's Blackboard.
155: * This method should be used when subsetting the capabilities of an asset
156: * for some other consumer. Eg. when you want to allow a client to use just one
157: * capability of your organization.
158: * Note: This method name may change.
159: **/
160: Asset cloneInstance(Asset asset);
161:
162: /** Create an aggregate asset instance of a prototypical asset.
163: **/
164: Asset createAggregate(Asset prototypeAsset, int quantity);
165:
166: /** Create an aggregate asset instance of a prototypical asset.
167: **/
168: Asset createAggregate(String prototypeAssetTypeId, int quantity);
169:
170: /** Create an aggregate asset instance of a prototypical asset.
171: **/
172: Asset createInstance(String prototypeAssetTypeId, int quantity);
173:
174: /** create a new property group, given a PropertyGroup name.
175: * The name should not have any package prefix and should
176: * be the cannonical name (not the implementation class name).
177: **/
178: PropertyGroup createPropertyGroup(String propertyName);
179:
180: /** create a new property group, given a PropertyGroupGroup name.
181: * The name should not have any package prefix and should
182: * be the cannonical name (not the implementation class name).
183: **/
184: PropertyGroup createPropertyGroup(Class propertyClass);
185:
186: /** @return a copy of another property group **/
187: PropertyGroup createPropertyGroup(PropertyGroup originalProperty);
188:
189: /** dummy for create(String) **/
190: Object create(String objectname);
191:
192: /** dummy for create(Class) **/
193: Object create(Class objectclass);
194: }
|