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.plan;
028:
029: import java.util.Date;
030: import java.util.Enumeration;
031:
032: import org.cougaar.core.blackboard.ChangeReport;
033: import org.cougaar.core.blackboard.Publishable;
034: import org.cougaar.core.util.UID;
035: import org.cougaar.core.util.UniqueObject;
036: import org.cougaar.planning.ldm.asset.Asset;
037:
038: /** Task Interface
039: * Task is the essential "execute" directive,
040: * instructing a subordinate or service provider
041: * to plan and eventually accomplish a task.
042: * A the general form of a task is:
043: * Verb <DirectObject> {PrepositionalPhrase} per <Schedule> per <Constraints>
044: **/
045: public interface Task extends PlanningDirective, UniqueObject,
046: Priority, Annotatable, Publishable {
047:
048: /**
049: * Returns the UID of the base or parent task of
050: * a given task, where the given task is
051: * an expansion of the base task. The
052: * parent task could be "move vehicles
053: * from point a to point b ...". An
054: * expanded task could be "fuel vehicles ...".
055: * </PRE> UID basetask = fueltask.getParentTaskUID(); </PRE>
056: * @return UID of the Task that is the "parenttask"
057: **/
058: UID getParentTaskUID();
059:
060: /**
061: * All Tasks are members of
062: * a Workflow. The tasks that are expansions
063: * of a basetask are placed in one workflow.
064: * For example, the fueltask will be a member
065: * of a workflow that contains all of the tasks
066: * and constraints needed to complete the basetask.
067: * <PRE> Workflow myworkflow = fueltask.getWorkflow(); </PRE>
068: * @return Workflow Returns the Workflow that the task is a member of.
069: **/
070: Workflow getWorkflow();
071:
072: /**
073: * Returns the prepositional phrase(s) of the Task.
074: * A PrepositionalPhrase object contains a String
075: * representation of the preposition (from, to, with, etc.)
076: * and an object representing the indirect object. The indirect
077: * object will be an Asset which can represent an Asset, AssetGroup or Location.
078: * For example, in the task
079: * "UnitA requisitions commodityB from UnitC"...
080: * the PrepositionalPhrase is "from UnitC".
081: * @return An enumeration of PrepositionalPhrases
082: * @see Preposition
083: **/
084: Enumeration getPrepositionalPhrases();
085:
086: /**
087: * Return the first PrepositionalPhrase found with the
088: * specified Preposition. Returns null if not found.
089: * @param preposition One of the strings named in
090: * org.cougaar.planning.ldm.plan.Preposition.
091: **/
092: PrepositionalPhrase getPrepositionalPhrase(String preposition);
093:
094: /**
095: * The getVerb method returns the verb of the Task.
096: * For example, in the Task "fuel vehicles...", the
097: * Verb is the object represented by "fuel".
098: * <PRE> Verb mytaskverb = fueltask.getVerb(); </PRE>
099: * @return the Verb of the Task.
100: **/
101: Verb getVerb();
102:
103: /**
104: * Returns the Asset (or AssetGroup) that is being acted upon
105: * by the Task. For example, in the task "fuel
106: * vehicle 14 ..." the direct object is "vehicle 14".
107: * @return the Direct Object of the task.
108: **/
109: Asset getDirectObject();
110:
111: /**
112: * @return Plan.RealityPlan -- this slot is unused / deprecated
113: **/
114: Plan getPlan();
115:
116: /**
117: * Returns PlanElement that this Task is associated with.
118: * Can be used to discern between expandable and non-expandable
119: * Tasks. If Task has no PlanElement associated with it, will
120: * return null.
121: */
122: PlanElement getPlanElement();
123:
124: /** get the preferences on this task.
125: * @return Enumeration{Preference}
126: */
127: Enumeration getPreferences();
128:
129: /** return the preference for the given aspect type
130: * will return null if there is not a preference defined for this aspect type
131: * @param aspect_type The Aspect referenced by the preference
132: */
133: Preference getPreference(int aspect_type);
134:
135: /** return the preferred value for a given aspect type
136: * from the defined preference (and scoring function)
137: * will return Double.NaN if there is not a preference defined for this aspect type
138: * @param aspect_type The Aspect referenced by the preference
139: * @note Reminder that you must use Double.isNaN to test for NaN, since NaN == NaN is always false.
140: */
141: double getPreferredValue(int aspect_type);
142:
143: /** Get the priority of this task.
144: * Note that this should only be used when there are competing tasks
145: * from the SAME customer.
146: * @return The priority of this task
147: * @see org.cougaar.planning.ldm.plan.Priority
148: */
149: byte getPriority();
150:
151: /** WARNING: This method may return null if the commitment date is undefined.
152: * The task commitment date of a task represents the date past which the planning
153: * module will warn if the task is changed or removed. Commitment dates in the planning
154: * domain are used to note the last possible date that a task could be changed before
155: * the supplier has committed resources to fill or commit the task. E.g. If a supplier
156: * has an order and ship lead time of 3 days, then the task's commitment date should be
157: * atleast 3 days before the desired delivery date (usually represented with an end
158: * date preference).
159: * @return Date The Commitment date of this task.
160: */
161: Date getCommitmentDate();
162:
163: /**
164: * Get the deleted status of this task.
165: **/
166: boolean isDeleted();
167:
168: Enumeration getObservableAspects();
169:
170: /**
171: * Check to see if the current time is before the Commitment date.
172: * Will return true if we have not reached the commitment date.
173: * Will return true if the commitment date is undefined.
174: * Will return false if we have passed the commitment date.
175: * @param currentdate The current date.
176: */
177: boolean beforeCommitment(Date currentdate);
178:
179: /** Get a collection of the requested AuxiliaryQueryTypes (int).
180: * Note: if there are no types set, this will return an
181: * array with one element = -1
182: * @see org.cougaar.planning.ldm.plan.AuxiliaryQueryType
183: */
184: int[] getAuxiliaryQueryTypes();
185:
186: /**
187: * Get the problem Context (if any) for this task.
188: * @see Context
189: **/
190: Context getContext();
191:
192: interface TaskChangeReport extends ChangeReport {
193: }
194:
195: class PreferenceChangeReport implements TaskChangeReport {
196: private int type;
197: public final static int UNDEFINED_TYPE = AspectType.UNDEFINED;
198: private Preference old = null;
199:
200: public PreferenceChangeReport() {
201: type = UNDEFINED_TYPE;
202: }
203:
204: public PreferenceChangeReport(int t) {
205: type = t;
206: }
207:
208: public PreferenceChangeReport(int t, Preference o) {
209: type = t;
210: old = o;
211: }
212:
213: public PreferenceChangeReport(Preference o) {
214: type = o.getAspectType();
215: old = o;
216: }
217:
218: /** May return AspectType.UNDEFINED if the aspect type id is unknown **/
219: public int getAspectType() {
220: return type;
221: }
222:
223: public int hashCode() {
224: return getClass().hashCode() + type;
225: }
226:
227: public boolean equals(Object o) {
228: if (o == null)
229: return false;
230:
231: return (this == o)
232: || (o.getClass() == getClass() && ((PreferenceChangeReport) o).type == type);
233: }
234:
235: public String toString() {
236: if (type == UNDEFINED_TYPE) {
237: return "PreferenceChangeReport (?)";
238: } else {
239: return "PreferenceChangeReport (" + type + ")";
240: }
241: }
242: }
243:
244: class PrepositionChangeReport implements TaskChangeReport {
245: private String prep;
246:
247: public PrepositionChangeReport() {
248: prep = null;
249: }
250:
251: public PrepositionChangeReport(String p) {
252: prep = p;
253: }
254:
255: /** May return null if unknown **/
256: public String getPreposition() {
257: return prep;
258: }
259:
260: public int hashCode() {
261: int hc = getClass().hashCode();
262: if (prep != null)
263: hc += prep.hashCode();
264: return hc;
265: }
266:
267: public boolean equals(Object o) {
268: if (o == null)
269: return false;
270:
271: return (this == o)
272: || (o.getClass() == getClass() && prep != null && prep
273: .equals(((PrepositionChangeReport) o).prep));
274: }
275:
276: public String toString() {
277: if (prep == null) {
278: return "PrepositionChangeReport (?)";
279: } else {
280: return "PrepositionChangeReport (" + prep + ")";
281: }
282: }
283: }
284:
285: }
|