Source Code Cross Referenced for Level2Disposer.java in  » Science » Cougaar12_4 » org » cougaar » logistics » plugin » trans » 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.logistics.plugin.trans 
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.logistics.plugin.trans;
028:
029:        import java.util.Collection;
030:        import java.util.ArrayList;
031:        import java.util.Vector;
032:        import java.util.Iterator;
033:        import java.util.Enumeration;
034:        import java.util.HashSet;
035:
036:        import org.cougaar.planning.ldm.asset.Asset;
037:        import org.cougaar.planning.ldm.measure.CountRate;
038:        import org.cougaar.planning.ldm.plan.*;
039:        import org.cougaar.planning.plugin.util.PluginHelper;
040:        import org.cougaar.planning.plugin.util.AllocationResultHelper;
041:        import org.cougaar.logistics.ldm.Constants;
042:        import org.cougaar.glm.ldm.plan.AlpineAspectType;
043:
044:        /**
045:         * <pre>
046:         * The default RequirementsExpander for the DemandForecastPlugin.
047:         *
048:         * This class expands a determine requirements task into generateProjections tasks for each
049:         * MEI that has the passed in supply class PG on it.
050:         *
051:         *
052:         **/
053:
054:        public class Level2Disposer extends Level2TranslatorModule {
055:
056:            public Level2Disposer(Level2TranslatorPlugin translatePlugin) {
057:                super (translatePlugin);
058:            }
059:
060:            /**
061:             * Remove the expansion which is the transport version of the Level2 task
062:             * and then successfully dispose of each level 2 Task in the collection (should be 1)/
063:             **/
064:            public void disposeAndRemoveExpansion(Collection taskCollect) {
065:                Iterator it = taskCollect.iterator();
066:                while (it.hasNext()) {
067:                    disposeAndRemoveExpansion((Task) it.next());
068:                }
069:            }
070:
071:            /**
072:             * Remove the expansion which is the transport version of the Level2 task
073:             * and then successfully dispose of this one.
074:             **/
075:            public void disposeAndRemoveExpansion(Task level2Task) {
076:                boolean doDispose = true;
077:                PlanElement pe = level2Task.getPlanElement();
078:                if ((pe != null) && (pe instanceof  Expansion)) {
079:                    removeExpansion(level2Task);
080:                } else if ((pe != null) && (pe instanceof  Disposition)) {
081:                    doDispose = removeDisposition(level2Task);
082:                }
083:                if (doDispose) {
084:                    disposeOfTask(level2Task);
085:                }
086:            }
087:
088:            public void removeExpansion(Task level2Task) {
089:                Expansion expansion = (Expansion) level2Task.getPlanElement();
090:                NewWorkflow wf = (NewWorkflow) expansion.getWorkflow();
091:                Enumeration subtasks = wf.getTasks();
092:                while (subtasks.hasMoreElements()) {
093:                    Task task = (Task) subtasks.nextElement();
094:                    wf.removeTask(task);
095:                    translatorPlugin.publishRemove(task);
096:                }
097:                //Do you need to remove the workflow?
098:                //translatorPlugin.publishRemove(wf);
099:                translatorPlugin.publishRemove(expansion);
100:            }
101:
102:            public boolean removeDisposition(Task level2Task) {
103:                Disposition disposition = (Disposition) level2Task
104:                        .getPlanElement();
105:                AllocationResult ar = disposition.getEstimatedResult();
106:                if (getTaskUtils().getDailyQuantity(level2Task) == getTaskUtils()
107:                        .getQuantity(level2Task, ar)) {
108:                    if (logger.isInfoEnabled()) {
109:                        logger
110:                                .info("Quantity on task is same as on disposition - not re-disposing (Bug 13424)");
111:                    }
112:                    return false;
113:                } else {
114:                    if (logger.isInfoEnabled()) {
115:                        logger.info("Re-disposing: Quantity on task is "
116:                                + getTaskUtils().getDailyQuantity(level2Task)
117:                                + " while the estimate result says "
118:                                + getTaskUtils().getQuantity(level2Task, ar)
119:                                + " - (Bug 13424)");
120:                    }
121:                    translatorPlugin.publishRemove(disposition);
122:                    return true;
123:                }
124:            }
125:
126:            protected void disposeOfTask(Task task) {
127:                AllocationResultHelper helper = new AllocationResultHelper(
128:                        task, null);
129:                AllocationResult dispAR = helper.getAllocationResult(
130:                        Constants.Confidence.OBSERVED, true);
131:                Disposition disposition = getPlanningFactory()
132:                        .createDisposition(task.getPlan(), task, dispAR);
133:                translatorPlugin.publishAdd(disposition);
134:            }
135:
136:            /**
137:             *
138:             * TODO: MWD remove
139:             *
140:
141:             protected long getStartTimePref(Task task) {
142:             synchronized (task) {
143:             Enumeration taskPrefs = task.getPreferences();
144:             while (taskPrefs.hasMoreElements()) {
145:             Preference aPref = (Preference) taskPrefs.nextElement();
146:             if (aPref.getAspectType() == AspectType.START_TIME) {
147:             ScoringFunction sf = aPref.getScoringFunction();
148:             return (long) sf.getBest().getValue();
149:             }
150:             }
151:             }
152:             return 0L;
153:             }
154:
155:             protected Preference createStartTimePref(Task parentTask) {
156:             long startTime = getStartTimePref(parentTask);
157:             AspectValue av = AspectValue.newAspectValue(AspectType.START_TIME, startTime);
158:             ScoringFunction score = ScoringFunction.createNearOrAbove(av, 0);
159:             return getPlanningFactory().newPreference(AspectType.START_TIME, score);
160:             }
161:
162:             public PrepositionalPhrase newPrepositionalPhrase(String preposition,
163:             Object io) {
164:             NewPrepositionalPhrase pp = getPlanningFactory().newPrepositionalPhrase();
165:             pp.setPreposition(preposition);
166:             pp.setIndirectObject(io);
167:             return pp;
168:             }
169:
170:             public void updateAllocationResults(Collection planElements) {
171:             Iterator peIt = planElements.iterator();
172:             while (peIt.hasNext()) {
173:             PlanElement pe = (PlanElement) peIt.next();
174:             if (PluginHelper.updatePlanElement(pe)) {
175:             dfPlugin.publishChange(pe);
176:             }
177:             }
178:             }
179:
180:
181:
182:             public static NewTask addPrepositionalPhrase(NewTask task, PrepositionalPhrase pp) {
183:             Enumeration enum = task.getPrepositionalPhrases();
184:             Vector phrases = new Vector();
185:             while (enum.hasMoreElements()) {
186:             phrases.addElement(enum.nextElement());
187:             }
188:             phrases.addElement(pp);
189:             task.setPrepositionalPhrases(phrases.elements());
190:             return task;
191:             }
192:
193:             **/
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.