Source Code Cross Referenced for ConstructionInventoryPlugin.java in  » Science » Cougaar12_4 » org » cougaar » mlm » construction » 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.mlm.construction 
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.mlm.construction;
027:
028:        import org.cougaar.glm.ldm.asset.Inventory;
029:        import org.cougaar.glm.ldm.asset.InventoryBG;
030:        import org.cougaar.glm.ldm.asset.NewInventoryPG;
031:        import org.cougaar.glm.ldm.asset.NewReportSchedulePG;
032:        import org.cougaar.glm.ldm.asset.NewScheduledContentPG;
033:        import org.cougaar.glm.ldm.asset.ProjectionWeight;
034:        import org.cougaar.glm.ldm.asset.PropertyGroupFactory;
035:        import org.cougaar.glm.ldm.plan.Agency;
036:        import org.cougaar.glm.plugins.inventory.InventoryPlugin;
037:        import org.cougaar.planning.ldm.asset.Asset;
038:        import org.cougaar.planning.ldm.asset.NewItemIdentificationPG;
039:        import org.cougaar.planning.ldm.asset.NewTypeIdentificationPG;
040:
041:        import java.util.GregorianCalendar;
042:
043:        /** Plugin for Construction Inventory.  Contains methods to setup and create construction
044:         *  inventory.
045:         */
046:
047:        public class ConstructionInventoryPlugin extends InventoryPlugin {
048:
049:            //Hardcoded required inventory levels
050:            protected double capacity = 1000000;
051:            protected double init_level = 0.0;
052:            protected double erq = 0.0;
053:            protected double min_reorder = 0.0;
054:
055:            /** Constructor */
056:            public ConstructionInventoryPlugin() {
057:                super ();
058:            }
059:
060:            /** Establishes and sets up Construction Inventory Decorator */
061:            protected void decoratePlugin() {
062:                ConstructionInventoryDecorator decorator = new ConstructionInventoryDecorator(
063:                        this , myOrganization_);
064:                decorator.decoratePlugin(myOrganization_);
065:            }
066:
067:            /** Sets up fields needed for construction inventory.
068:             *  Initializes inventory.
069:             */
070:            public Inventory createInventory(String supplytype, Asset resource) {
071:                String id = resource.getTypeIdentificationPG()
072:                        .getTypeIdentification();
073:                if (logger.isDebugEnabled()) {
074:                    logger
075:                            .debug("*****ConstructionInventoryPlugin:  createInventory()"
076:                                    + "<"
077:                                    + supplytype
078:                                    + "> createInventory for " + id);
079:                }
080:                GregorianCalendar reportBaseDate = null;
081:                int reportStepKind = 0;
082:                boolean success = false;
083:                InventoryBG bg = null;
084:                NewInventoryPG invpg = (NewInventoryPG) PropertyGroupFactory
085:                        .newInventoryPG();
086:                InventoryItemInfo info = null;
087:                double[] levels = null;
088:
089:                info = (InventoryItemInfo) inventoryInitHash_.get(id);
090:
091:                invpg.setResource(resource);
092:                Agency agency = myOrganization_.getOrganizationPG().getAgency();
093:
094:                if (inventoryInitHash_.isEmpty()) {
095:                    double[] temp_levels = { capacity, init_level, erq,
096:                            min_reorder };
097:                    levels = (double[]) temp_levels;
098:                }
099:                if ((info != null) && (levels == null)) {
100:                    //GLMDebug.DEBUG(className_, clusterId_,"*****ConstructionInventoryPlugin: info not null and levels null");
101:                    levels = (double[]) info.levels;
102:                }
103:
104:                // Try to initialize the inventory behavior group, if it fails this cluster
105:                // does not handle the item.
106:                if (levels != null) {
107:                    bg = new ConstructionInventoryBG(invpg);
108:                    success = ((ConstructionInventoryBG) bg).initialize(levels);
109:                    if (info != null) {
110:                        if (info.reportBase != null) {
111:                            reportBaseDate = info.reportBase;
112:                            reportStepKind = info.reportStepKind;
113:                        }
114:                    }
115:                }
116:
117:                if (!success) {
118:                    if (logger.isDebugEnabled()) {
119:                        logger
120:                                .debug("createInventory(), cannot create inventory for "
121:                                        + id);
122:                    }
123:                    return null;
124:                }
125:
126:                Inventory inventory = null;
127:                inventory = (Inventory) theLDMF.createAsset("Inventory");
128:                if (inventory == null) {
129:                    if (logger.isDebugEnabled()) {
130:                        logger
131:                                .debug("*****ConstructionInventoryPlugin"
132:                                        + "<"
133:                                        + supplytype
134:                                        + "> createInventory - fail to create inventory for "
135:                                        + id);
136:                    }
137:                    return null;
138:                }
139:                invpg.setInvBG(bg);
140:                bg.setProjectionWeight(getProjectionWeight(supplytype));
141:                inventory.addOtherPropertyGroup(invpg);
142:                long time = getMyDelegate().currentTimeMillis();
143:                invpg.resetInventory(inventory, time);
144:                invpg.clearContentSchedule(inventory);
145:
146:                NewTypeIdentificationPG ti = (NewTypeIdentificationPG) inventory
147:                        .getTypeIdentificationPG();
148:                ti.setTypeIdentification("InventoryAsset");
149:                ti.setNomenclature("Inventory Asset");
150:
151:                ((NewItemIdentificationPG) inventory.getItemIdentificationPG())
152:                        .setItemIdentification("Inventory:" + id);
153:
154:                NewScheduledContentPG scp;
155:                scp = (NewScheduledContentPG) inventory.getScheduledContentPG();
156:                scp.setAsset(resource);
157:
158:                if (reportBaseDate != null) {
159:                    NewReportSchedulePG nrsp = PropertyGroupFactory
160:                            .newReportSchedulePG();
161:                    nrsp.setBase(info.reportBase);
162:                    nrsp.setStep(info.reportStepKind);
163:                    inventory.setReportSchedulePG(nrsp);
164:                    //System.out.println("setReportSchedulePG " + info.reportBase);
165:                }
166:                return inventory;
167:            }
168:
169:            /**
170:               Don't call this directly. Use the base class
171:               getProjectionWeight which will invoke this if necessary.
172:             **/
173:            protected ProjectionWeight createProjectionWeight(String supplyType) {
174:                return new ConstructionProjectionWeight(2);
175:            }
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.