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.glm.ldm.oplan;
028:
029: import java.io.Serializable;
030:
031: import org.cougaar.core.mts.MessageAddress;
032: import org.cougaar.core.util.OwnedUniqueObject;
033: import org.cougaar.core.util.UID;
034: import org.cougaar.core.util.UniqueObject;
035: import org.cougaar.planning.ldm.plan.Transferable;
036:
037: /**
038: * Redeem for one Oplan and accompanying OplanContributors
039: */
040: public class OplanCoupon extends OwnedUniqueObject implements
041: Transferable, UniqueObject, Serializable, Cloneable {
042:
043: private UID _oplanUID;
044: private String _oplanQueryFile;
045: private String _oplanID;
046:
047: public OplanCoupon(MessageAddress homeClusterID) {
048: setOwner(homeClusterID);
049: }
050:
051: public OplanCoupon(UID oplanUID, MessageAddress homeClusterID) {
052: _oplanUID = oplanUID;
053: setOwner(homeClusterID);
054: }
055:
056: public OplanCoupon(UID this UID, UID oplanUID,
057: MessageAddress homeClusterID) {
058: setUID(this UID);
059: _oplanUID = oplanUID;
060: setOwner(homeClusterID);
061: }
062:
063: public OplanCoupon(UID this UID, UID oplanUID,
064: MessageAddress homeClusterID, String queryFile,
065: String oplanID) {
066: setUID(this UID);
067: _oplanUID = oplanUID;
068: setOwner(homeClusterID);
069: setOplanQueryFile(queryFile);
070: setOplanID(oplanID);
071: }
072:
073: public void setOplanID(String oplanID) {
074: _oplanID = oplanID;
075: }
076:
077: public String getOplanID() {
078: return _oplanID;
079: }
080:
081: public void setOplanUID(UID oplanUID) {
082: _oplanUID = oplanUID;
083: }
084:
085: public UID getOplanUID() {
086: return _oplanUID;
087: }
088:
089: public void setOplanQueryFile(String oplanQueryFile) {
090: _oplanQueryFile = oplanQueryFile;
091: }
092:
093: public String getOplanQueryFile() {
094: return _oplanQueryFile;
095: }
096:
097: public void setHomeClusterID(MessageAddress homeClusterID) {
098: setOwner(homeClusterID);
099: }
100:
101: public MessageAddress getHomeClusterID() {
102: return getOwner();
103: }
104:
105: // Tranferable
106: public Object clone() {
107: OplanCoupon newOplanCoupon = new OplanCoupon(getUID(),
108: _oplanUID, getOwner(), getOplanQueryFile(),
109: getOplanID());
110: return newOplanCoupon;
111: }
112:
113: // Tranferable
114: public boolean same(Transferable trans) {
115: if (trans instanceof OplanCoupon) {
116: OplanCoupon other = (OplanCoupon) trans;
117: if (other.getUID().equals(getUID())
118: && other.getOplanUID().equals(_oplanUID)
119: && other.getHomeClusterID().equals(getOwner())
120: && other.getOplanQueryFile().equals(
121: getOplanQueryFile())
122: && other.getOplanID().equals(getOplanID())) {
123: return true;
124: }
125: }
126: return false;
127: }
128:
129: // Tranferable
130: public void setAll(Transferable otherTransferable) {
131:
132: if (!(otherTransferable instanceof OplanCoupon)) {
133: throw new IllegalArgumentException(
134: "Parameter is not OplanCoupon.");
135: }
136:
137: OplanCoupon other = (OplanCoupon) otherTransferable;
138:
139: setUID(other.getUID());
140: _oplanUID = other.getOplanUID();
141: setOwner(other.getHomeClusterID());
142: setOplanQueryFile(other.getOplanQueryFile());
143: setOplanID(other.getOplanID());
144: }
145:
146: }
|