Source Code Cross Referenced for AssetTransferImpl.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.mts.MessageAddress;
039:        import org.cougaar.planning.ldm.asset.Asset;
040:        import org.cougaar.util.log.Logger;
041:
042:        /**
043:         * Implementation for AssetTransfer
044:         */
045:        public class AssetTransferImpl extends PlanElementImpl implements 
046:                AssetTransfer, RoleScheduleConflicts {
047:
048:            private transient Asset asset; // changed to transient : Persistence
049:            private transient Asset assigneeAsset;
050:            private MessageAddress assignerAgent;
051:            private Schedule assetSchedule;
052:            private Role theRole;
053:            private transient boolean potentialconflict = false;
054:            private transient boolean assetavailconflict = false;
055:            private transient boolean checkconflict = false;
056:
057:            private transient boolean isAssetChanged = false;
058:
059:            //private String role = "RemoteAssignment";
060:
061:            public AssetTransferImpl() {
062:            }
063:
064:            /** Constructor that assumes there is not a good estimated result at this time.
065:             * @param p
066:             * @param t
067:             * @param a  The asset being transferred
068:             * @param s  The schedule representing the time frame that the asset is being transferred for.
069:             * @param to  The Agent that will receive this asset for use
070:             * @param from  The Agent that is provided this asset for use
071:             */
072:            public AssetTransferImpl(Plan p, Task t, Asset a, Schedule s,
073:                    Asset to, MessageAddress from) {
074:                super (p, t);
075:                setAsset(a);
076:                setSchedule(s);
077:                setAssignee(to);
078:                setAssignor(from);
079:                // add myself to the asset's roleschedule
080:                //doRoleSchedule(this.getAsset());
081:                // done in publishAdd
082:            }
083:
084:            /** Constructor 
085:             * @param p
086:             * @param t
087:             * @param a  The asset being transferred
088:             * @param s  The schedule representing the time frame that the asset is being transferred for.
089:             * @param to  The Agent that will receive this asset for use
090:             * @param from  The Agent that is provided this asset for use
091:             * @param estimatedresult
092:             * @param aRole
093:             */
094:            public AssetTransferImpl(Plan p, Task t, Asset a, Schedule s,
095:                    Asset to, MessageAddress from,
096:                    AllocationResult estimatedresult, Role aRole) {
097:                super (p, t);
098:                setAsset(a);
099:                setSchedule(s);
100:                setAssignee(to);
101:                setAssignor(from);
102:                setEstimatedResult(estimatedresult);
103:                this .theRole = aRole;
104:                // add myself to the asset's roleschedule
105:                //doRoleSchedule(this.getAsset());
106:                // done during publishAdd
107:            }
108:
109:            //AssetTransfer interface implementations
110:
111:            /**
112:             * @return Asset - Asset being assigned
113:             */
114:            public Asset getAsset() {
115:                return asset;
116:            }
117:
118:            /**
119:             * @return Asset - The Asset to which the Asset is being assigned
120:             */
121:            public Asset getAssignee() {
122:                return assigneeAsset;
123:            }
124:
125:            /** Returns the Agent that the asset is assigned from.
126:             * @return MessageAddress representing the source of the asset
127:             */
128:
129:            public MessageAddress getAssignor() {
130:                return assignerAgent;
131:            }
132:
133:            /** Returns the Schedule for the "ownership" of the asset being transfered.
134:             *  @return Schedule
135:             */
136:            public Schedule getSchedule() {
137:                return assetSchedule;
138:            }
139:
140:            public long getStartTime() {
141:                return (assetSchedule == null) ? MIN_VALUE : assetSchedule
142:                        .getStartTime();
143:            }
144:
145:            public long getEndTime() {
146:                return (assetSchedule == null) ? MAX_VALUE : assetSchedule
147:                        .getEndTime();
148:            }
149:
150:            /** Checks to see if there is a protential conflict with another allocation
151:             * to the same asset.
152:             * Will return true if there is a potential conflict.
153:             * Will return false if there is NOT a potential conflict.
154:             * @return boolean
155:             */
156:            public boolean isPotentialConflict() {
157:                throw new RuntimeException(
158:                        "isPotentialConflict is temporarily deprecated.");
159:                //return potentialconflict;
160:            }
161:
162:            /** Checks to see if there is a potential conflict with the asset's
163:             * available schedule.  ( Asset.getRoleSchedule().getAvailableSchedule() )
164:             * Will return true if there is a potential conflict.
165:             * @return boolean
166:             */
167:            public boolean isAssetAvailabilityConflict() {
168:                throw new RuntimeException(
169:                        "isAssetAvailabilityConflict is temporarily deprecated.");
170:                //return assetavailconflict;
171:            }
172:
173:            /** Return the Role this Asset is performing while transferred.
174:             *  @return Role
175:             **/
176:            public Role getRole() {
177:                return theRole;
178:            }
179:
180:            //NewAssetTransfer inteface implementations
181:
182:            /**
183:             * @param anAsset - set the Asset being assigned
184:             */
185:            private void setAsset(Asset anAsset) {
186:                asset = anAsset;
187:            }
188:
189:            /**
190:             * @param toAsset - Set the Asset being assigned the Asset
191:             */
192:            private void setAssignee(Asset toAsset) {
193:                assigneeAsset = toAsset;
194:            }
195:
196:            /** Sets the Agent that the asset is assigned from.
197:             * @param aAgent
198:             */
199:
200:            private void setAssignor(MessageAddress aAgent) {
201:                assignerAgent = aAgent;
202:            }
203:
204:            /** Sets the Schedule for the "ownership" of the asset being transfered.
205:             *  @param aSchedule
206:             */
207:            private void setSchedule(Schedule aSchedule) {
208:                assetSchedule = aSchedule;
209:            }
210:
211:            /** Set the estimated allocation result so that a notification will
212:             * propagate up another level.
213:             * @param estimatedresult
214:             */
215:            public void setEstimatedResult(AllocationResult estimatedresult) {
216:                super .setEstimatedResult(estimatedresult);
217:                setCheckConflicts(true);
218:            }
219:
220:            /* INFRASTRUCTURE ONLY */
221:            public void setPotentialConflict(boolean conflict) {
222:                potentialconflict = conflict;
223:            }
224:
225:            /* INFRASTRUCTURE ONLY */
226:            public void setAssetAvailabilityConflict(boolean availconflict) {
227:                assetavailconflict = availconflict;
228:            }
229:
230:            /* INFRASTRUCTURE ONLY */
231:            public void setCheckConflicts(boolean check) {
232:                checkconflict = check;
233:            }
234:
235:            /* INFRASTRUCTURE ONLY */
236:            public boolean checkConflicts() {
237:                return checkconflict;
238:            }
239:
240:            synchronized public void indicateAssetChange() {
241:                isAssetChanged = true;
242:            }
243:
244:            /** Infrastructure only: this actually should be locked
245:             * before calling this method so that we can tell if it
246:             * has changed again.
247:             **/
248:            synchronized public void resetAssetChangeIndicated() {
249:                isAssetChanged = false;
250:            }
251:
252:            synchronized public boolean isAssetChangeIndicated() {
253:                return isAssetChanged;
254:            }
255:
256:            // ActiveSubscriptionObject
257:            public void addingToBlackboard(Subscriber s, boolean commit) {
258:                super .addingToBlackboard(s, commit);
259:                Blackboard.getTracker().checkpoint(commit, asset,
260:                        "getRoleSchedule");
261:                if (!commit)
262:                    return;
263:                // check for conflicts.
264:
265:                addToRoleSchedule(asset);
266:            }
267:
268:            public void changingInBlackboard(Subscriber s, boolean commit) {
269:                super .changingInBlackboard(s, commit);
270:                // check for conflicts
271:            }
272:
273:            public void removingFromBlackboard(Subscriber s, boolean commit) {
274:                super .removingFromBlackboard(s, commit);
275:                Blackboard.getTracker().checkpoint(commit, asset,
276:                        "getRoleSchedule");
277:                if (!commit)
278:                    return;
279:
280:                removeFromRoleSchedule(asset);
281:            }
282:
283:            private void writeObject(ObjectOutputStream stream)
284:                    throws IOException {
285:                stream.defaultWriteObject();
286:
287:                stream.writeObject(asset);
288:                stream.writeObject(assigneeAsset);
289:            }
290:
291:            private void readObject(ObjectInputStream stream)
292:                    throws ClassNotFoundException, IOException {
293:                stream.defaultReadObject();
294:
295:                asset = (Asset) stream.readObject();
296:                assigneeAsset = (Asset) stream.readObject();
297:            }
298:
299:            public void postRehydration(Logger logger) {
300:                super .postRehydration(logger);
301:                fixAsset(getAsset());
302:                fixAsset(getAssignee());
303:            }
304:
305:            public String toString() {
306:                return "[Transfer of " + asset + " from " + assignerAgent
307:                        + " to " + assigneeAsset + "]";
308:            }
309:
310:            // beaninfo
311:            protected void addPropertyDescriptors(Collection c)
312:                    throws IntrospectionException {
313:                super .addPropertyDescriptors(c);
314:                c.add(new PropertyDescriptor("asset", AssetTransferImpl.class,
315:                        "getAsset", null));
316:                c.add(new PropertyDescriptor("role", AssetTransferImpl.class,
317:                        "getRole", null));
318:                c.add(new PropertyDescriptor("assignee",
319:                        AssetTransferImpl.class, "getAssignee", null));
320:                c.add(new PropertyDescriptor("assignor",
321:                        AssetTransferImpl.class, "getAssignor", null));
322:                c.add(new PropertyDescriptor("schedule",
323:                        AssetTransferImpl.class, "getSchedule", null));
324:            }
325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.