01: /*
02: * <copyright>
03: *
04: * Copyright 1997-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26: package org.cougaar.mlm.plugin.organization;
27:
28: import java.util.Calendar;
29: import java.util.Collection;
30: import java.util.Iterator;
31:
32: import org.cougaar.glm.ldm.Constants;
33: import org.cougaar.planning.ldm.plan.Role;
34: import org.cougaar.planning.ldm.plan.Verb;
35: import org.cougaar.planning.plugin.asset.AssetDataPlugin;
36:
37: /**
38: * Extension of AssetDataPlugin which recognizes the GLM report verbs -
39: * ReportForService and ReportForDuty. Assumes all report relationships
40: * are static and created at startup. Does not respond to oplan or org activity
41: * changes.
42: *
43: * Used with minitestconfig.
44: **/
45: public class SimpleOrgDataPlugin extends AssetDataPlugin {
46:
47: private static Calendar myCalendar = Calendar.getInstance();
48:
49: private static long DEFAULT_START_TIME = -1;
50: private static long DEFAULT_END_TIME = -1;
51:
52: static {
53: myCalendar.set(1990, 0, 1, 0, 0, 0);
54: DEFAULT_START_TIME = myCalendar.getTime().getTime();
55:
56: myCalendar.set(2010, 0, 1, 0, 0, 0);
57: DEFAULT_END_TIME = myCalendar.getTime().getTime();
58:
59: packages.add("org.cougaar.glm.ldm.asset");
60: packages.add("org.cougaar.glm.ldm.plan");
61: packages.add("org.cougaar.glm.ldm.oplan");
62: packages.add("org.cougaar.glm.ldm.policy");
63: }
64:
65: public long getDefaultStartTime() {
66: return DEFAULT_START_TIME;
67: }
68:
69: public long getDefaultEndTime() {
70: return DEFAULT_END_TIME;
71: }
72:
73: protected Verb getReportVerb(Collection roles) {
74: // Assuming that collection of roles never mixes subordinate with
75: // provider roles.
76: for (Iterator iterator = roles.iterator(); iterator.hasNext();) {
77: Role role = (Role) iterator.next();
78:
79: // Does this Role match SUPERIOR/SUBORDINATE RelationshipType
80: if ((role.getName()
81: .endsWith(Constants.RelationshipType.SUBORDINATE_SUFFIX))
82: && (role.getConverse().getName()
83: .endsWith(Constants.RelationshipType.SUPERIOR_SUFFIX))) {
84: return Constants.Verb.ReportForDuty;
85: }
86: }
87:
88: // Didn't get a superior/subordinate match
89: return Constants.Verb.ReportForService;
90: }
91: }
|