001: /*
002: * <copyright>
003: *
004: * Copyright 2002-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: package org.cougaar.servicediscovery.description;
027:
028: import org.cougaar.planning.ldm.plan.Role;
029: import org.cougaar.planning.ldm.plan.Schedule;
030: import org.cougaar.servicediscovery.Constants;
031: import org.cougaar.util.log.Logger;
032: import org.cougaar.util.log.Logging;
033:
034: /**
035: * Maintains a Role and echelon
036: */
037:
038: public class ProviderCapabilityImpl implements ProviderCapability {
039: private static Logger logger = Logging
040: .getLogger(ProviderCapability.class);
041:
042: private Role myRole = null;
043: private String myEchelon = null;
044: private Schedule myAvailableSchedule = null;
045:
046: public ProviderCapabilityImpl() {
047: }
048:
049: public ProviderCapabilityImpl(Role role, String echelon,
050: Schedule availableSchedule) {
051: setRole(role);
052: setEchelon(echelon);
053: setAvailableSchedule(availableSchedule);
054: }
055:
056: /**
057: * @return the echelon of support
058: **/
059: public String getEchelon() {
060: return myEchelon;
061: }
062:
063: /**
064: * @param echelon
065: **/
066: public void setEchelon(String echelon) {
067: String mappedEchelon = Constants.MilitaryEchelon
068: .mapToMilitaryEchelon(echelon);
069:
070: if (mappedEchelon.equals(Constants.MilitaryEchelon.UNDEFINED)) {
071: logger.warn("setEchelon: changing echelon from "
072: + getEchelon() + " to " + mappedEchelon + " for "
073: + this );
074: }
075: myEchelon = mappedEchelon;
076: }
077:
078: /**
079: * @return the provided role
080: **/
081: public Role getRole() {
082: return myRole;
083: }
084:
085: public void setRole(Role role) {
086: if (myRole != null) {
087: logger.error("setRole: attempt to change role from "
088: + myRole + " to " + role + " ignored.");
089: } else {
090: myRole = role;
091: }
092: }
093:
094: /**
095: * @return the availability schedule
096: **/
097: public Schedule getAvailableSchedule() {
098: return myAvailableSchedule;
099: }
100:
101: /**
102: * @param availableSchedule
103: **/
104: public void setAvailableSchedule(Schedule availableSchedule) {
105: myAvailableSchedule = availableSchedule;
106: }
107:
108: public String toString() {
109: return "(ProviderCapability role=" + myRole + " echelon="
110: + myEchelon + " schedule=" + myAvailableSchedule + ")";
111: }
112: }
|