Source Code Cross Referenced for SQLAssetPrototypeProvider.java in  » Science » Cougaar12_4 » org » cougaar » mlm » plugin » ldm » 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.plugin.ldm 
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.mlm.plugin.ldm;
028:
029:        import org.cougaar.planning.ldm.PlanningFactory;
030:        import org.cougaar.planning.ldm.asset.Asset;
031:        import org.cougaar.planning.ldm.asset.AssetFactory;
032:        import org.cougaar.planning.ldm.asset.NewTypeIdentificationPG;
033:
034:        /** A QueryHandler which can convert a TypeIdentification code
035:         * into an Asset Prototype.
036:         **/
037:
038:        public class SQLAssetPrototypeProvider
039:        //extends QueryHandler
040:                extends org.cougaar.mlm.plugin.ldm.PrototypeProvider {
041:
042:            private AssetFactory theAssetFactory = null;
043:
044:            public SQLAssetPrototypeProvider() {
045:                theAssetFactory = new AssetFactory();
046:            }
047:
048:            /** Called to decide if this QueryHandler can provide
049:             * type resolution for this type id code.
050:             **/
051:            public boolean canHandle(String typeid) {
052:                if (!(NSNtoAssetClass(typeid).equals("ClassVIIMajorEndItem")))
053:                    return true;
054:                return false;
055:            }
056:
057:            /** Turn a typeid into an Asset Prototype, presumably
058:             * by looking it up in a database.
059:             **/
060:            public Asset getAssetPrototype(String typeid) {
061:                //public Asset getPrototype( String typeid ) {
062:                PlanningFactory ldmfactory = getLDM().getFactory();
063:
064:                String protoname = typeid;
065:
066:                try {
067:                    //try {
068:                    //if (!ldmfactory.isRegistered(protoname)) {
069:                    //if (!getLDM().isPrototypeCached(protoname)) {
070:                    String assetClass = NSNtoAssetClass(typeid);
071:                    //System.err.println( "Trying to register prototype " + assetClass );
072:                    Asset tmp_asset = (Asset) theAssetFactory.create(Class
073:                            .forName("org.cougaar.planning.ldm.asset."
074:                                    + assetClass), typeid);
075:                    //System.err.println( "\ncachePrototype( " + protoname + "," + tmp_asset + ")" );
076:                    getLDM().cachePrototype(protoname, tmp_asset);
077:                    //System.err.println("Registered proto for "+assetClass);
078:                    //}
079:                    //} catch (org.cougaar.data.RegistryException ex) {
080:                    //System.out.println("warning: prototype name already in registry \n");
081:                    //}
082:
083:                    //System.err.println( "\nGetting prototype " + protoname );
084:                    Asset pr = (Asset) getLDM().getPrototype(protoname);
085:                    NewTypeIdentificationPG p1 = (NewTypeIdentificationPG) pr
086:                            .getTypeIdentificationPG();
087:                    String tmptypeid = p1.getTypeIdentification();
088:                    //System.out.println("\n *****AssetPrototypeProvider typeid is: " + tmptypeid);
089:                    p1.setTypeIdentification(typeid);
090:                    p1.setNomenclature(typeid);
091:                    //System.err.println( "\nNOW, typeid = " + pr.getTypeIdentificationPG().getTypeIdentification() );
092:                    p1.setAlternateTypeIdentification(typeid);
093:
094:                    System.err.println("Created PrototypeAsset for " + typeid
095:                            + " = " + pr);
096:
097:                    myLDMPlugin.fillProperties(pr);
098:
099:                    return pr;
100:                } catch (Exception ee) {
101:                    System.out.println(ee.toString());
102:                    ee.printStackTrace();
103:                }
104:                return null;
105:            }
106:
107:            private String NSNtoAssetClass(String nsn) {
108:                // hel
109:                if (nsn.equals("NSN/1520011069519") || // Helicopter: AH-64A
110:                        nsn.equals("NSN/1520010820686") || // Helicopter: EH-60A
111:                        nsn.equals("NSN/1520011255476")) // Helicopter: OH-58D
112:                    return "RotaryWingAircraftWeapon";
113:
114:                if (nsn.equals("NSN/1520010350266")) // Helicopter: UH-60A
115:                    return "CargoRotaryWingAircraft";
116:
117:                if (nsn.equals("NSN/2350010871095") || // Tank: M1A1
118:                        nsn.equals("NSN/2350001226826") || // Recovery Vehicle: M88A1
119:                        nsn.equals("NSN/2350013050028") || // Howitzer: M109A6
120:                        nsn.equals("NSN/2350014059886") || // Fighting Veh: M2A2 W/ODS
121:                        nsn.equals("NSN/2350012487620") || // Fighting Veh: M3A2
122:                        nsn.equals("NSN/2350010684089") || // CommandPostCarrier: M57782
123:                        nsn.equals("NSN/2350012197577") || // PersonnelCarrier: M113A3
124:                        nsn.equals("NSN/2350010853792")) // TrackedPersonnelCarrier: M981
125:                    return "SelfPropelledGroundWeapon";
126:
127:                if (nsn.equals("NSN/2320011077155") || // HMMWV M998
128:                        nsn.equals("NSN/2320011007673") || // HMMWV M985
129:                        nsn.equals("NSN/2320011007672") || // HEMMT M978 WOWN (Tank)
130:                        nsn.equals("NSN/2320013042278") || // PLS Truck: M1075
131:                        nsn.equals("NSN/2320013189902")) // HET Tractor: M1070
132:                    return "Truck";
133:
134:                if (nsn.equals("NSN/2330013035197") || // PLS Trailer: M1076
135:                        nsn.equals("NSN/2330013038832")) // HET Trailer: M1000
136:                    return "Trailer";
137:
138:                if (nsn.equals("NSN/8115001519953")) // 20 Ft Container
139:                    return "Container";
140:
141:                if (nsn.equals("NSN/3990013077676")) // PLS Flatrack: M1077
142:                    return "Container";
143:
144:                if (nsn.equals("C005A") || nsn.equals("C005B")
145:                        || nsn.equals("C017A") || nsn.equals("C141B")
146:                        || nsn.equals("DC10"))
147:                    return "CargoFixedWingAircraft";
148:
149:                return "ClassVIIMajorEndItem";
150:            }
151:
152:            public String getQuery() {
153:                return null;
154:            }
155:
156:            public void processRow(Object[] row) {
157:                return;
158:            }
159:
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.