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.pizza;
027:
028: import org.cougaar.planning.ldm.plan.Verb;
029:
030: import java.io.File;
031:
032: /**
033: * Constants for the pizza party application. Initialized by the
034: * load of the {@link PizzaDomain}, so Roles in particular are well defined.
035: *
036: * Having a Domain-specific Constants file for Roles, Verbs,
037: * and other objects that Plugins will match on off the Blackboard
038: * is fairly typical usage.
039: */
040: public class Constants {
041: // Private constructor prevents instantiation
042: private Constants() {
043: }
044:
045: // Some heavily used Strings. In particular, the invitation Relay
046: // uses these.
047: public static final String PIZZA = "Pizza";
048: public static final String INVITATION_QUERY = "Come to my party! RSVP: Meat or Veggie Pizza?";
049: public static final String MEAT_PIZZA = "Meat Pizza";
050: public static final String VEGGIE_PIZZA = "Veggie Pizza";
051:
052: /** Name of Alice's buddy list - her friends to invite. */
053: public static final String COMMUNITY = "FriendsOfMark-COMM";
054:
055: // Standard constants for Role definition. Defined here
056: // to avoid GLM dependency
057: public static final String PROVIDER_SUFFIX = "Provider";
058: public static final String CUSTOMER_SUFFIX = "Customer";
059:
060: /** used when showing how long it takes for this number of friends to reply */
061: public static final int EXPECTED_NUM_FRIENDS = 4;
062:
063: /**
064: * Verbs used by the Pizza application plugins.
065: */
066: public interface Verbs {
067: /** Verb for ordering pizzas */
068: public static final Verb ORDER = Verb.get("Order");
069: /** SDPlaceOrderPlugin uses to Initiates service discovery to find a provider */
070: public static final Verb FIND_PROVIDERS = Verb
071: .get("FindProviders");
072: }
073:
074: /**
075: * Special Prepositions used by the pizza application
076: */
077: public interface Prepositions {
078: /** Used in excluding a particular provider (see SDPlaceOrderPlugin) */
079: public static final String NOT = "Not";
080: }
081:
082: /**
083: * Relationship Types needed by the Pizza application
084: */
085: public interface RelationshipTypes {
086: /**
087: * A service providing relationship
088: */
089: org.cougaar.planning.ldm.plan.RelationshipType PROVIDER = org.cougaar.planning.ldm.plan.RelationshipType
090: .create(PROVIDER_SUFFIX, CUSTOMER_SUFFIX);
091: }
092:
093: /**
094: * Roles used on Assets in the Pizza application.
095: */
096: public static class Roles {
097: /**
098: * Ensure that Role constants are initialized. Actually does nothing, but
099: * the classloader ensures that all static initializers have been run
100: * before executing any code in this class. This ensures that Roles
101: * required for the Pizza app are created properly before a application
102: * code calls Role.get(Constants.Role.XXX)
103: *<p>
104: * All Roles have a converse - PizzaProvider/PizzaConsumer for example.
105: * The following Role.create calls specify both the Role and its converse.
106: * In the case of the Carnivore Role - the Role and its converse are the
107: * same. The call to create PizzaProvider, however, designates
108: * PizzaConsumer as the converse. (See RelationshipType.PROVIDER definition
109: * above.
110: *<p>
111: * If Role.get(XXX) is called before a proper Role.create, the Role code
112: * will create a default pairing of XXX and ConverseOfXXX Roles. The
113: * ConverseOfXXX Role is typically unusable.
114: */
115: public static void init() {
116: }
117:
118: static {
119: org.cougaar.planning.ldm.plan.Role.create(Constants.PIZZA,
120: RelationshipTypes.PROVIDER);
121: org.cougaar.planning.ldm.plan.Role.create("Carnivore",
122: "Carnivore");
123: org.cougaar.planning.ldm.plan.Role.create("Vegetarian",
124: "Vegetarian");
125: }
126:
127: // organization roles
128: /**
129: * Someone who wants a meat pizza
130: */
131: public static final org.cougaar.planning.ldm.plan.Role CARNIVORE = org.cougaar.planning.ldm.plan.Role
132: .getRole("Carnivore");
133: /**
134: * Someone who wants a Veggie pizza - no meat!
135: */
136: public static final org.cougaar.planning.ldm.plan.Role VEGETARIAN = org.cougaar.planning.ldm.plan.Role
137: .getRole("Vegetarian");
138: /**
139: * An Agent that provides the PizzaProvider service
140: */
141: public static final org.cougaar.planning.ldm.plan.Role PIZZAPROVIDER = org.cougaar.planning.ldm.plan.Role
142: .getRole(Constants.PIZZA + PROVIDER_SUFFIX);
143: /**
144: * The inverse of a PizzaProvider; orders pizza.
145: */
146: public static final org.cougaar.planning.ldm.plan.Role PIZZACUSTOMER = org.cougaar.planning.ldm.plan.Role
147: .getRole(Constants.PIZZA + CUSTOMER_SUFFIX);
148: }
149:
150: /**
151: * Returns the path to the data files required to support the pizza application e.g.
152: * $COUGAAR_INSTALL_PATH/pizza/data
153: * Used by ServiceDiscovery in particular.
154: *
155: * @return a string representing the file path
156: */
157: public static String getDataPath() {
158: return System.getProperty("org.cougaar.install.path")
159: + File.separator + "pizza" + File.separator + "data";
160: }
161:
162: /**
163: * Constants needed for ServiceDiscovery in the Pizza application.
164: */
165: public interface UDDIConstants {
166: // References pizza/data/taxonomies/CommercialServiceScheme-yp.xml which
167: // defines the set of Roles which a provider can register.
168: public final static String COMMERCIAL_SERVICE_SCHEME = "CommercialServiceScheme";
169: // References pizza/data/taxonomies/OrganizationTypes-yp.xml which
170: // defines the type of provider e.g. Military vs Commercial
171: public final static String ORGANIZATION_TYPES = "OrganizationTypes";
172: }
173: }
|