Source Code Cross Referenced for OrgActivityImpl.java in  » Science » Cougaar12_4 » org » cougaar » glm » ldm » oplan » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » org.cougaar.glm.ldm.oplan 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        package org.cougaar.glm.ldm.oplan;
027:
028:        import java.beans.PropertyChangeListener;
029:        import java.beans.PropertyChangeSupport;
030:        import java.util.HashMap;
031:
032:        import org.cougaar.core.util.OwnedUniqueObject;
033:        import org.cougaar.core.util.UID;
034:        import org.cougaar.glm.ldm.plan.GeolocLocation;
035:        import org.cougaar.planning.ldm.plan.LocationScheduleElement;
036:        import org.cougaar.planning.ldm.plan.Transferable;
037:        import org.cougaar.util.log.Logger;
038:        import org.cougaar.util.log.Logging;
039:
040:        /**
041:         * OrgActivity
042:         * The OrgActivity method is a LDM Object that contains organizational activity information.
043:         * TheOrgActivity object includes information such as activityName, activityType, 
044:         * opTempo, timespan, Location information, and a hashmap containing other 
045:         * detailed information.  The OrgActivities are initially created in the J3 cluster 
046:         * and then is transferred to other clusters by the Propagation Plugin. Subordinate clusters can subscribe 
047:         * to changes in the OrgActivity information in order to react to changes accordingly.
048:         * Subordinate clusters should not modify (set) OrgActivity information.
049:         **/
050:        public class OrgActivityImpl extends OwnedUniqueObject implements 
051:                OrgActivity {
052:            private static final Logger logger = Logging
053:                    .getLogger(OrgActivity.class);
054:
055:            private String activityName;
056:            private String activityType;
057:            private String opTempo;
058:            private TimeSpan theTimeSpan;
059:            private GeolocLocation geoLoc;
060:            private HashMap oaHashMap = new HashMap(5);
061:            private String orgID;
062:            private UID oplanUID;
063:            private String adCon;
064:            private String opCon;
065:
066:            OrgActivityImpl(String orgID, UID oplanUID) {
067:                this .orgID = unique(orgID);
068:                this .oplanUID = oplanUID;
069:            }
070:
071:            OrgActivityImpl(String activityType, String activityName,
072:                    String orgID, UID oplanUID) {
073:                this .activityType = unique(activityType);
074:                this .activityName = unique(activityName);
075:                this .orgID = unique(orgID);
076:                this .oplanUID = oplanUID;
077:            }
078:
079:            public void setActivityType(String activityType) {
080:                this .activityType = unique(activityType);
081:            }
082:
083:            public void setActivityName(String activityName) {
084:                this .activityName = unique(activityName);
085:            }
086:
087:            public void setOrgID(String orgID) {
088:                this .orgID = unique(orgID);
089:            }
090:
091:            public void setOrgActivityId(UID uid) {
092:
093:            }
094:
095:            public UID getOrgActivityId() {
096:                return getUID();
097:            }
098:
099:            public String getOpCon() {
100:                return opCon;
101:            }
102:
103:            public void setOpCon(String opCon) {
104:                this .opCon = opCon;
105:            }
106:
107:            public String getAdCon() {
108:                return adCon;
109:            }
110:
111:            public void setAdCon(String adCon) {
112:                this .adCon = adCon;
113:            }
114:
115:            public void setOplanUID(UID oplanUID) {
116:                this .oplanUID = oplanUID;
117:            }
118:
119:            /** @deprecated Use setOplanUID */
120:            public void setOplanID(UID oplanUID) {
121:                this .oplanUID = oplanUID;
122:            }
123:
124:            /** @deprecated Use getOplanUID */
125:            public UID getOplanID() {
126:                return oplanUID;
127:            }
128:
129:            public UID getOplanUID() {
130:                return oplanUID;
131:            }
132:
133:            public String getOrgID() {
134:                return orgID;
135:            }
136:
137:            public void setOpTempo(String opTempo) {
138:                // BOZO - check against valid range
139:                this .opTempo = unique(opTempo);
140:            }
141:
142:            public void setTimeSpan(TimeSpan ts) {
143:                theTimeSpan = ts;
144:            }
145:
146:            public void setGeoLoc(GeolocLocation geoLoc) {
147:                this .geoLoc = geoLoc;
148:            }
149:
150:            public GeolocLocation getGeoLoc() {
151:                return geoLoc;
152:            }
153:
154:            public String getActivityType() {
155:                return activityType;
156:            }
157:
158:            public String getActivityName() {
159:                return activityName;
160:            }
161:
162:            public void addActivityItem(String key, String value) {
163:                // Does the key already exist
164:                if (oaHashMap.containsKey(key)) {
165:                    logger.warn("OrgActivity:Key already in use: " + key,
166:                            new Throwable());
167:                } else {
168:                    oaHashMap.put(unique(key), unique(value));
169:                }
170:            }
171:
172:            public void modifyActivityItem(String key, String value) {
173:                oaHashMap.put(unique(key), unique(value));
174:            }
175:
176:            public String getActivityItem(String key) {
177:                return (String) oaHashMap.get(key);
178:            }
179:
180:            public HashMap getItems() {
181:                return oaHashMap;
182:            }
183:
184:            public String getOpTempo() {
185:                return opTempo;
186:            }
187:
188:            public TimeSpan getTimeSpan() {
189:                return theTimeSpan;
190:            }
191:
192:            public long getStartTime() {
193:                return theTimeSpan.getStartTime();
194:            }
195:
196:            public long getEndTime() {
197:                return theTimeSpan.getEndTime();
198:            }
199:
200:            public void setAll(Transferable other) {
201:
202:                if (!(other instanceof  OrgActivity)) {
203:                    throw new IllegalArgumentException(
204:                            "Parameter is not OrgActivity.");
205:                } else {
206:                    OrgActivity oa = (OrgActivity) other;
207:                    activityName = oa.getActivityName();
208:                    activityType = oa.getActivityType();
209:                    opTempo = oa.getOpTempo();
210:                    theTimeSpan = oa.getTimeSpan();
211:                    orgID = oa.getOrgID();
212:                    oplanUID = oa.getOplanUID();
213:                    adCon = oa.getAdCon();
214:                    opCon = oa.getOpCon();
215:                    setUID(oa.getOrgActivityId());
216:                    if (oa instanceof  OwnedUniqueObject) {
217:                        setOwner(((OwnedUniqueObject) oa).getOwner());
218:                    }
219:                    geoLoc = oa.getGeoLoc();
220:                }
221:            }
222:
223:            public boolean same(Transferable other) {
224:                if (other instanceof  OrgActivity) {
225:                    OrgActivity oa = (OrgActivity) other;
226:                    return getUID().equals(oa.getUID());
227:                }
228:                return false;
229:            }
230:
231:            public boolean equals(Object o) {
232:                if (o instanceof  OrgActivity) {
233:                    OrgActivity oa = (OrgActivity) o;
234:                    boolean status = matches(getActivityName(), oa
235:                            .getActivityName())
236:                            && matches(getActivityType(), oa.getActivityType())
237:                            && matches(getOpTempo(), oa.getOpTempo())
238:                            && matches(getTimeSpan(), oa.getTimeSpan())
239:                            && matches(getGeoLoc(), oa.getGeoLoc())
240:                            && matches(getOrgID(), oa.getOrgID())
241:                            && matches(getOplanUID(), oa.getOplanUID())
242:                            && matches(getAdCon(), oa.getAdCon())
243:                            && matches(getOpCon(), oa.getOpCon())
244:                            && matches(getOrgActivityId(), oa
245:                                    .getOrgActivityId());
246:
247:                    return status;
248:                } else {
249:                    return false;
250:                }
251:            }
252:
253:            public Object clone() {
254:                OrgActivityImpl oa = new OrgActivityImpl(orgID, oplanUID);
255:
256:                oa.setOpTempo(opTempo);
257:                oa.setActivityType(activityType);
258:                oa.setActivityName(activityName);
259:                oa.setUID(getUID());
260:                oa.setOwner(getOwner());
261:                oa.setAdCon(getAdCon());
262:                oa.setOpCon(getOpCon());
263:
264:                if (oaHashMap != null)
265:                    oa.oaHashMap = new HashMap((HashMap) oaHashMap.clone());
266:
267:                if (theTimeSpan != null)
268:                    oa.setTimeSpan((TimeSpan) theTimeSpan.clone());
269:
270:                if (geoLoc != null)
271:                    oa.setGeoLoc((GeolocLocation) geoLoc.clone());
272:
273:                return oa;
274:            }
275:
276:            //dummy PropertyChangeSupport for the Jess Interpreter.
277:            protected transient PropertyChangeSupport pcs = new PropertyChangeSupport(
278:                    this );
279:
280:            public void addPropertyChangeListener(PropertyChangeListener pcl) {
281:                pcs.addPropertyChangeListener(pcl);
282:            }
283:
284:            public void removePropertyChangeListener(PropertyChangeListener pcl) {
285:                pcs.removePropertyChangeListener(pcl);
286:            }
287:
288:            /** convert OPlan-centric location and timespan to 
289:             * standard ALPish (logplan) schedule element 
290:             * @return a LocationScheduleElement or null, if a locationscheduleelement 
291:             * cannot be constructed (e.g. no schedule, no location).
292:             **/
293:            public LocationScheduleElement getNormalizedScheduleElement() {
294:                // don't NPE on bogus OAs
295:                if (theTimeSpan == null || geoLoc == null)
296:                    return null;
297:
298:                return new OAScheduleElement(theTimeSpan.getStartTime(),
299:                        theTimeSpan.getEndTime(), geoLoc, getUID());
300:            }
301:
302:            private static boolean matches(Object a, Object b) {
303:                return (a == null) ? (b == null) : (a.equals(b));
304:            }
305:
306:            public static final String unique(String s) {
307:                return (s == null) ? null : (s.intern());
308:            }
309:
310:            public String toString() {
311:                // FIXME: What else would be useful in here?
312:                return "<OrgActivity name:" + getActivityName() + ", type:"
313:                        + getActivityType() + ", TimeSpan:" + getTimeSpan()
314:                        + ", Tempo:" + getOpTempo() + ", GeoLoc: "
315:                        + getGeoLoc() + ", Org:" + getOrgID() + ">";
316:            }
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.