Source Code Cross Referenced for AllocationImpl.java in  » Science » Cougaar12_4 » org » cougaar » planning » ldm » plan » 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.planning.ldm.plan 
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:
027:        package org.cougaar.planning.ldm.plan;
028:
029:        import java.beans.IntrospectionException;
030:        import java.beans.PropertyDescriptor;
031:        import java.io.IOException;
032:        import java.io.ObjectInputStream;
033:        import java.io.ObjectOutputStream;
034:        import java.util.Collection;
035:
036:        import org.cougaar.core.blackboard.Subscriber;
037:        import org.cougaar.core.blackboard.Blackboard;
038:        import org.cougaar.core.util.UID;
039:        import org.cougaar.planning.ldm.asset.Asset;
040:        import org.cougaar.util.log.Logger;
041:
042:        /** AllocationImpl.java
043:         * Implementation for allocation
044:         */
045:
046:        public class AllocationImpl extends PlanElementImpl implements 
047:                Allocation, RoleScheduleConflicts, AllocationforCollections {
048:
049:            private transient Asset asset; // changed to transient : Persistence
050:
051:            private transient UID allocTaskUID = null; // changed to transient : Persistence
052:            private transient boolean allocTaskDeleted = false;
053:            private transient boolean potentialconflict = false;
054:            private transient boolean stale = false;
055:            private transient boolean assetavailconflict = false;
056:            private transient boolean checkconflict = false;
057:            private Role theRole;
058:
059:            public AllocationImpl() {
060:            }
061:
062:            /* Constructor that takes the Asset, and assumes that there is not a good
063:             * estimate of the result for now.
064:             * @param p
065:             * @param t
066:             * @param a
067:             */
068:            public AllocationImpl(Plan p, Task t, Asset a) {
069:                super (p, t);
070:                setAsset(a);
071:                // add myself to the asset's roleschedule
072:                //doRoleSchedule(this.getAsset());
073:                // done during publishAdd now.
074:            }
075:
076:            /* Constructor that takes the Asset, and an initial estimated result
077:             * @param p
078:             * @param t
079:             * @param a
080:             * @param estimatedresult
081:             */
082:            public AllocationImpl(Plan p, Task t, Asset a,
083:                    AllocationResult estimatedresult, Role aRole) {
084:                super (p, t);
085:                setAsset(a);
086:                estAR = estimatedresult;
087:                this .theRole = aRole;
088:                // add myself to the asset's roleschedule
089:                //doRoleSchedule(this.getAsset());
090:                // done during publishAdd
091:            }
092:
093:            /** Set the estimated allocation result so that a notification will
094:             * propagate up another level.
095:             * @param estimatedresult
096:             */
097:            public void setEstimatedResult(AllocationResult estimatedresult) {
098:                super .setEstimatedResult(estimatedresult);
099:                setCheckConflicts(true);
100:            }
101:
102:            /**
103:             * @return Asset - Asset associated with this allocation/subtask
104:             */
105:            public Asset getAsset() {
106:                return asset;
107:            }
108:
109:            /**
110:             * @return boolean - true if there is a potential conflict with another 
111:             * allocation to the same asset.
112:             * @deprecated
113:             */
114:            public boolean isPotentialConflict() {
115:                //throw new RuntimeException("isPotentialConflict is temporarily deprecated.");
116:                System.err
117:                        .println("AllocationImpl::isPotentialConflict() - a temporarily deprecated method - has been called");
118:                return potentialconflict;
119:            }
120:
121:            /** Checks to see if there is a potential conflict with the asset's
122:             * available schedule.  ( Asset.getRoleSchedule().getAvailableSchedule() )
123:             * Will return true if there is a potential conflict.
124:             * @return boolean
125:             * @deprecated
126:             */
127:            public boolean isAssetAvailabilityConflict() {
128:                //   throw new RuntimeException("isAssetAvailabilityConflict is temporarily deprecated.");
129:                System.err
130:                        .println("AllocationImpl::isAssetAvailabilityConflict() - a temporarily deprecated method - has been called");
131:                return assetavailconflict;
132:            }
133:
134:            /** Check to see if this allocation is Stale and needs to be revisited.
135:             * Will return true if it is stale (needs to be revisted)
136:             * @return boolean
137:             */
138:            public boolean isStale() {
139:                return stale;
140:            }
141:
142:            /** Return the Role that the Asset is performing while executing this PlanElement (Task).
143:             * @return Role
144:             **/
145:            public Role getRole() {
146:                return theRole;
147:            }
148:
149:            /** Set the stale flag.  Usualy used by Trigger actions.
150:             * @param stalestate
151:             */
152:            public void setStale(boolean stalestate) {
153:                stale = stalestate;
154:            }
155:
156:            /**
157:             * @param anAsset - set Asset associated with this allocation/subtask
158:             */
159:            private void setAsset(Asset anAsset) {
160:                asset = anAsset;
161:            }
162:
163:            /* INFRASTRUCTURE ONLY */
164:            public void setPotentialConflict(boolean conflict) {
165:                potentialconflict = conflict;
166:            }
167:
168:            /* INFRASTRUCTURE ONLY */
169:            public void setAssetAvailabilityConflict(boolean availconflict) {
170:                assetavailconflict = availconflict;
171:            }
172:
173:            /* INFRASTRUCTURE ONLY */
174:            public void setCheckConflicts(boolean check) {
175:                checkconflict = check;
176:            }
177:
178:            /* INFRASTRUCTURE ONLY */
179:            public boolean checkConflicts() {
180:                return checkconflict;
181:            }
182:
183:            // ActiveSubscriptionObject
184:            public void addingToBlackboard(Subscriber s, boolean commit) {
185:                super .addingToBlackboard(s, commit);
186:                Blackboard.getTracker().checkpoint(commit, asset,
187:                        "getRoleSchedule");
188:                if (!commit)
189:                    return;
190:
191:                // check for conflicts
192:
193:                addToRoleSchedule(asset);
194:            }
195:
196:            public void changingInBlackboard(Subscriber s, boolean commit) {
197:                super .changingInBlackboard(s, commit);
198:                // check for conflicts
199:            }
200:
201:            public void removingFromBlackboard(Subscriber s, boolean commit) {
202:                super .removingFromBlackboard(s, commit);
203:                Blackboard.getTracker().checkpoint(commit, asset,
204:                        "getRoleSchedule");
205:                if (!commit)
206:                    return;
207:
208:                // check for conflicts
209:
210:                removeFromRoleSchedule(asset);
211:            }
212:
213:            public UID getAllocationTaskUID() {
214:                return allocTaskUID;
215:            }
216:
217:            public void setAllocationTask(Task t) {
218:                setAllocationTaskUID(t.getUID());
219:            }
220:
221:            public void setAllocationTaskUID(UID uid) {
222:                allocTaskUID = uid;
223:                allocTaskDeleted = false;
224:            }
225:
226:            public boolean isAllocationTaskDeleted() {
227:                return allocTaskDeleted;
228:            }
229:
230:            public void setAllocationTaskDeleted(boolean newDeleted) {
231:                allocTaskDeleted = newDeleted;
232:            }
233:
234:            private void writeObject(ObjectOutputStream stream)
235:                    throws IOException {
236:                stream.defaultWriteObject();
237:                stream.writeObject(asset);
238:                stream.writeObject(allocTaskUID);
239:                stream.writeBoolean(allocTaskDeleted);
240:            }
241:
242:            private void readObject(ObjectInputStream stream)
243:                    throws ClassNotFoundException, IOException {
244:                /** ----------
245:                 *    READ handlers common to Persistence and
246:                 *    Network serialization.  NOte that these
247:                 *    cannot be references to Persistable objects.
248:                 *    defaultReadObject() is likely to belong here...
249:                 * ---------- **/
250:                stream.defaultReadObject();
251:                asset = (Asset) stream.readObject();
252:                allocTaskUID = (UID) stream.readObject();
253:                allocTaskDeleted = stream.readBoolean();
254:            }
255:
256:            public void postRehydration(Logger logger) {
257:                super .postRehydration(logger);
258:                fixAsset(getAsset());
259:            }
260:
261:            public String toString() {
262:                return "[Allocation of " + getTask().getUID() + " to " + asset
263:                        + "]";
264:            }
265:
266:            // beaninfo
267:            protected void addPropertyDescriptors(Collection c)
268:                    throws IntrospectionException {
269:                super .addPropertyDescriptors(c);
270:                c.add(new PropertyDescriptor("asset", AllocationImpl.class,
271:                        "getAsset", null));
272:                c.add(new PropertyDescriptor("role", AllocationImpl.class,
273:                        "getRole", null));
274:                c.add(new PropertyDescriptor("allocationTaskUID",
275:                        AllocationImpl.class, "getAllocationTaskUID", null));
276:                c.add(new PropertyDescriptor("stale", AllocationImpl.class,
277:                        "isStale", null));
278:            }
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.