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.servicediscovery.description;
028:
029: import org.cougaar.core.util.UID;
030: import org.cougaar.planning.ldm.plan.HasRelationships;
031: import org.cougaar.planning.ldm.plan.RelationshipImpl;
032: import org.cougaar.planning.ldm.plan.Role;
033: import org.cougaar.servicediscovery.transaction.ServiceContractRelay;
034:
035: /**
036: * A ServiceContractRelationshipImpl is the encapsulation of a time phased relationship based on
037: * a service contract
038: *
039: **/
040:
041: public class ServiceContractRelationshipImpl extends RelationshipImpl
042: implements ServiceContractRelationship {
043:
044: private UID myServiceContractUID;
045:
046: /** no-arg constructor */
047: public ServiceContractRelationshipImpl() {
048: super ();
049: }
050:
051: /** constructor for factory use that takes the start, end, role,
052: * direct and indirect objects
053: **/
054: public ServiceContractRelationshipImpl(long startTime,
055: long endTime, Role providerRole, HasRelationships provider,
056: HasRelationships client, ServiceContractRelay relay) {
057: super (startTime, endTime, providerRole, provider, client);
058: setServiceContractUID(relay);
059: }
060:
061: /** UID for the associated ServiceContractRelay
062: * @return UID UID for the associated service contract
063: */
064: public UID getServiceContractUID() {
065: return myServiceContractUID;
066: }
067:
068: /**
069: *
070: * @param relay ServiceContractRelay associated with the relationship
071: */
072: public void setServiceContractUID(ServiceContractRelay relay) {
073: myServiceContractUID = relay.getUID();
074: }
075:
076: /**
077: * equals - performs field by field comparison
078: *
079: * @param object Object to compare
080: * @return boolean if 'same'
081: */
082: public boolean equals(Object object) {
083: if (!(object instanceof ServiceContractRelationship)) {
084: return false;
085: }
086:
087: if (super .equals(object)) {
088: return getServiceContractUID().equals(
089: ((ServiceContractRelationship) object)
090: .getServiceContractUID());
091: } else {
092: return false;
093: }
094: }
095:
096: public String toString() {
097: return super .toString() + "<ServiceContractRelay UID:"
098: + getServiceContractUID();
099: }
100: }
|