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:
027: package org.cougaar.servicediscovery;
028:
029: import org.cougaar.planning.ldm.plan.RelationshipType;
030: import org.cougaar.planning.ldm.plan.Role;
031: import org.cougaar.planning.ldm.plan.Verb;
032: import org.cougaar.servicediscovery.description.LineageScheduleElement;
033: import org.cougaar.util.Configuration;
034: import org.cougaar.util.log.Logger;
035: import org.cougaar.util.log.Logging;
036:
037: import java.net.URL;
038:
039: public class Constants {
040: private static Logger logger = Logging.getLogger(Constants.class);
041:
042: private Constants() {
043: }
044:
045: public interface SDScheduleElementType {
046:
047: Class LINEAGE = LineageScheduleElement.class;
048: }
049:
050: public interface Verbs {
051: public static final String REPORTFORDUTY = "ReportForDuty";
052: public static final String REPORTFORSERVICE = "ReportForService";
053: public static final String FINDPROVIDERS = "FindProviders";
054: public static final String REGISTERSERVICES = "RegisterServices";
055:
056: public static final Verb ReportForDuty = Verb
057: .get(REPORTFORDUTY);
058: public static final Verb ReportForService = Verb
059: .get(REPORTFORSERVICE);
060: public static final Verb FindProviders = Verb
061: .get(FINDPROVIDERS);
062: public static final Verb RegisterServices = Verb
063: .get(REGISTERSERVICES);
064: }
065:
066: public static interface Prepositions {
067: public static final String FOR_OPLAN_STAGES = "ForOplanStages";
068: }
069:
070: public static class Roles {
071: /**
072: * Insure that Role constants are initialized. Actually does
073: * nothing, but the classloader insures that all static
074: * initializers have been run before executing any code in this
075: * class.
076: **/
077: public static void init() {
078: }
079:
080: static {
081: Role.create("Self", "Self");
082: Role.create("", RelationshipTypes.SUPERIOR);
083: Role.create("Administrative", RelationshipTypes.SUPERIOR);
084: Role.create("Operational", RelationshipTypes.SUPERIOR);
085: Role.create("Support", RelationshipTypes.SUPERIOR);
086:
087: Role.create("AircraftMaintenance",
088: RelationshipTypes.PROVIDER);
089: Role.create("FixedWingAircraftMaintenance",
090: RelationshipTypes.PROVIDER);
091: Role.create("RotaryWingAircraftMaintenance",
092: RelationshipTypes.PROVIDER);
093: Role.create("GroundVehicleMaintenance",
094: RelationshipTypes.PROVIDER);
095: Role.create("WheeledVehicleMaintenance",
096: RelationshipTypes.PROVIDER);
097: Role.create("TrackedVehicleMaintenance",
098: RelationshipTypes.PROVIDER);
099: Role
100: .create("DryCargoTransport",
101: RelationshipTypes.PROVIDER);
102: Role.create("Part", RelationshipTypes.PROVIDER);
103: }
104:
105: public static final Role SUPERIOR = Role
106: .getRole(RelationshipTypes.SUPERIOR_SUFFIX);
107: public static final Role SUBORDINATE = Role
108: .getRole(RelationshipTypes.SUBORDINATE_SUFFIX);
109: public static final Role ADMINISTRATIVESUPERIOR = Role
110: .getRole("Administrative"
111: + RelationshipTypes.SUPERIOR_SUFFIX);
112: public static final Role ADMINISTRATIVESUBORDINATE = Role
113: .getRole("Administrative"
114: + RelationshipTypes.SUBORDINATE_SUFFIX);
115: public static final Role OPERATIONALSUPERIOR = Role
116: .getRole("Operational"
117: + RelationshipTypes.SUPERIOR_SUFFIX);
118: public static final Role OPERATIONALSUBORDINATE = Role
119: .getRole("Operational"
120: + RelationshipTypes.SUBORDINATE_SUFFIX);
121: public static final Role SUPPORTSUPERIOR = Role
122: .getRole("Support" + RelationshipTypes.SUPERIOR_SUFFIX);
123: public static final Role SUPPORTSUBORDINATE = Role
124: .getRole("Support"
125: + RelationshipTypes.SUBORDINATE_SUFFIX);
126:
127: }
128:
129: public interface RelationshipTypes {
130: String SUPERIOR_SUFFIX = "Superior";
131: String SUBORDINATE_SUFFIX = "Subordinate";
132: RelationshipType SUPERIOR = RelationshipType.create(
133: SUPERIOR_SUFFIX, SUBORDINATE_SUFFIX);
134:
135: String PROVIDER_SUFFIX = "Provider";
136: String CUSTOMER_SUFFIX = "Customer";
137: RelationshipType PROVIDER = RelationshipType.create(
138: PROVIDER_SUFFIX, CUSTOMER_SUFFIX);
139: }
140:
141: public static class MilitaryEchelon {
142: public static final String UNDEFINED = "UNDEFINED";
143: public static final String BATTALION = "BATTALION";
144: public static final String BRIGADE = "BRIGADE";
145: public static final String DIVISION = "DIVISION";
146: public static final String CORPS = "CORPS";
147: public static final String THEATER = "THEATER";
148: public static final String USARMY = "US-ARMY";
149: public static final String JOINT = "JOINT";
150:
151: public static final String[] ECHELON_ORDER = { BATTALION,
152: BRIGADE, DIVISION, CORPS, THEATER, USARMY, JOINT };
153: public static final int MAX_ECHELON_INDEX = ECHELON_ORDER.length - 1;
154:
155: public static boolean validMilitaryEchelon(String echelon) {
156: return ((echelon.equals(BATTALION))
157: || (echelon.equals(BRIGADE))
158: || (echelon.equals(DIVISION))
159: || (echelon.equals(CORPS))
160: || (echelon.equals(THEATER))
161: || (echelon.equals(USARMY))
162: || (echelon.equals(JOINT)) || (echelon
163: .equals(UNDEFINED)));
164: }
165:
166: public static String mapToMilitaryEchelon(String echelonValue) {
167: // Upcase for comparison
168: String upCase = echelonValue.toUpperCase();
169:
170: if (validMilitaryEchelon(upCase)) {
171: return upCase;
172: } else {
173: return UNDEFINED;
174: }
175: }
176:
177: public static int echelonOrder(String echelonValue) {
178: // Upcase for comparison
179: String upCase = echelonValue.toUpperCase();
180:
181: for (int index = 0; index < ECHELON_ORDER.length; index++) {
182: if (upCase.equals(ECHELON_ORDER[index])) {
183: return index;
184: }
185: }
186:
187: return -1;
188: }
189: }
190:
191: public static URL getServiceProfileURL() {
192: try {
193: return new URL(Configuration.getInstallURL(),
194: "servicediscovery/data/serviceprofiles/");
195: } catch (java.net.MalformedURLException mue) {
196: logger
197: .error(
198: "Exception constructing service profile URL: ",
199: mue);
200: return null;
201: }
202: }
203:
204: }
|