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 org.cougaar.core.blackboard.ChangeReport;
030: import org.cougaar.core.blackboard.ClaimableHolder;
031: import org.cougaar.core.blackboard.Publishable;
032: import org.cougaar.core.util.UniqueObject;
033:
034: /**
035: * PlanElements are the primitive building blocks from which
036: * planning models are constructed. A single PlanElement represents a
037: * cycle of work completed against a Task. A PlanElement is of
038: * type Expansion (represented by a Workflow and the implied tasks
039: * embodied in it), Allocation (represented by an Asset),
040: * Aggregation (represented by an MPWorkflow) or AssetTransfer.
041: **/
042:
043: public interface PlanElement extends ScheduleElement, UniqueObject,
044: Annotatable, ClaimableHolder, Publishable {
045:
046: /** @return Plan the Plan of this plan element.
047: **/
048: Plan getPlan();
049:
050: /** This returns the Task of the PlanElement.
051: * @return Task
052: **/
053:
054: Task getTask();
055:
056: /** Returns the estimated allocation result that is related to performing
057: * the Task.
058: * @return AllocationResult
059: **/
060:
061: AllocationResult getEstimatedResult();
062:
063: /**
064: * Returns the reported allocation result. The reported result is
065: * computed from the received and observed results
066: * @return AllocationResult
067: **/
068: AllocationResult getReportedResult();
069:
070: /** Returns the received allocation result.
071: * @return AllocationResult
072: **/
073: AllocationResult getReceivedResult();
074:
075: /**
076: * Returns the observed allocation result.
077: * @return AllocationResult
078: **/
079: AllocationResult getObservedResult();
080:
081: /** Set the estimated allocation result so that a notification will
082: * propagate up another level.
083: * @param estimatedresult
084: **/
085: void setEstimatedResult(AllocationResult estimatedresult);
086:
087: /**
088: * Set the observed allocation result that be incorporated into the
089: * reported result
090: * @param observedResult
091: **/
092: void setObservedResult(AllocationResult observedResult);
093:
094: interface PlanElementChangeReport extends ChangeReport {
095: }
096:
097: abstract class ResultChangeReport implements
098: PlanElementChangeReport {
099: private int type;
100: public final static int UNDEFINED_TYPE = AspectType.UNDEFINED;
101: private double oldValue;
102: public final static double UNDEFINED_VALUE = Double.MIN_VALUE;
103:
104: public ResultChangeReport() {
105: type = UNDEFINED_TYPE;
106: oldValue = UNDEFINED_VALUE;
107: }
108:
109: public ResultChangeReport(int t) {
110: type = t;
111: oldValue = UNDEFINED_VALUE;
112: }
113:
114: public ResultChangeReport(int t, double o) {
115: type = t;
116: oldValue = o;
117: }
118:
119: /** May return AspectType.UNDEFINED if the aspect type id is unknown **/
120: public int getAspectType() {
121: return type;
122: }
123:
124: /** old value if known. If unknown (e.g. no previous value)
125: * will return Double.MIN_VALUE.
126: **/
127: public double getOldValue() {
128: return oldValue;
129: }
130:
131: public int hashCode() {
132: return getClass().hashCode() + type;
133: }
134:
135: public boolean equals(Object o) {
136: if (o == null)
137: return false;
138:
139: return (this == o)
140: || (o.getClass() == getClass() && ((ResultChangeReport) o).type == type);
141: }
142:
143: public String toString() {
144: if (type == UNDEFINED_TYPE) {
145: return " (?)";
146: } else {
147: return " (" + type + ")";
148: }
149: }
150: }
151:
152: // change reports
153:
154: /** Something in the Estimated result changed. **/
155: class EstimatedResultChangeReport extends ResultChangeReport {
156: public EstimatedResultChangeReport() {
157: super ();
158: }
159:
160: public EstimatedResultChangeReport(int t) {
161: super (t);
162: }
163:
164: public EstimatedResultChangeReport(int t, double ov) {
165: super (t, ov);
166: }
167:
168: public String toString() {
169: return "EstimatedResultChangeReport" + super .toString();
170: }
171: }
172:
173: /** Something in the reported result changed. **/
174: class ReportedResultChangeReport extends ResultChangeReport {
175: public ReportedResultChangeReport() {
176: super ();
177: }
178:
179: public ReportedResultChangeReport(int t) {
180: super (t);
181: }
182:
183: public ReportedResultChangeReport(int t, double ov) {
184: super (t, ov);
185: }
186:
187: public String toString() {
188: return "ReportedResultChangeReport" + super .toString();
189: }
190: }
191:
192: /** Something in the observed result changed. **/
193: class ObservedResultChangeReport extends ResultChangeReport {
194: public ObservedResultChangeReport() {
195: super ();
196: }
197:
198: public ObservedResultChangeReport(int t) {
199: super (t);
200: }
201:
202: public ObservedResultChangeReport(int t, double ov) {
203: super (t, ov);
204: }
205:
206: public String toString() {
207: return "ObservedResultChangeReport" + super.toString();
208: }
209: }
210: }
|