Source Code Cross Referenced for PSStructureImpl.java in  » UML » MetaBoss » com » metaboss » sdlctools » domains » enterprisemodel » storage » xmlfileimpl » 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 » UML » MetaBoss » com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl;
016:
017:        import java.util.Iterator;
018:
019:        import javax.xml.bind.JAXBException;
020:
021:        import com.metaboss.enterprise.ps.PSDataSourceOperationInvocationException;
022:        import com.metaboss.enterprise.ps.PSException;
023:        import com.metaboss.enterprise.ps.PSUnexpectedProgramConditionException;
024:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSStructure;
025:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STConstraint;
026:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STField;
027:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STStructure;
028:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ConstraintDefListType;
029:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ConstraintDefType;
030:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.FieldDefListType;
031:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.FieldDefType;
032:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.StructureDefType;
033:
034:        public class PSStructureImpl implements  PSStructure {
035:            /** Returns  details entity corresponding to given reference or null struct if definition not found */
036:            public STStructure getStructure(String pStructureRef)
037:                    throws PSException {
038:                StructureDefType lStructureDef = Storage
039:                        .getStructure(pStructureRef);
040:                if (lStructureDef == null)
041:                    return null;
042:                STStructure lStruct = new STStructure();
043:                lStruct.StructureRef = lStructureDef.getStructureRef();
044:                lStruct.Description = lStructureDef.getDescription();
045:                // Good spot to check on validity of fields
046:                if (lStruct.StructureRef == null
047:                        || lStruct.StructureRef.length() == 0)
048:                    throw new PSUnexpectedProgramConditionException(
049:                            "StructureRef can not be empty in the definition. StructureRef: "
050:                                    + pStructureRef);
051:                if (!lStruct.StructureRef.equals(pStructureRef))
052:                    throw new PSUnexpectedProgramConditionException(
053:                            "StructureRef in definition does not match the requested StructureRef. Requested StructureRef: "
054:                                    + pStructureRef
055:                                    + ". Returned StructureRef: "
056:                                    + lStruct.StructureRef);
057:                // Check for posible clash with operation result and input structures	
058:                if (lStruct.StructureRef.toLowerCase().endsWith("result"))
059:                    throw new PSUnexpectedProgramConditionException(
060:                            "StructureRef in definition can not end with the word '"
061:                                    + lStruct.StructureRef
062:                                            .substring(lStruct.StructureRef
063:                                                    .length() - 6)
064:                                    + "' StructureRef: " + pStructureRef);
065:                if (lStruct.StructureRef.toLowerCase().endsWith("input"))
066:                    throw new PSUnexpectedProgramConditionException(
067:                            "StructureRef in definition can not end with the word '"
068:                                    + lStruct.StructureRef
069:                                            .substring(lStruct.StructureRef
070:                                                    .length() - 5)
071:                                    + "' StructureRef: " + pStructureRef);
072:                return lStruct;
073:            }
074:
075:            /** Inserts one or more new structure records into the database */
076:            public void insert(STStructure[] pNewRecords) throws PSException {
077:                try {
078:                    for (int i = 0; i < pNewRecords.length; i++) {
079:                        STStructure lStructureToInsert = pNewRecords[i];
080:                        StructureDefType lStructureDef = Util
081:                                .getObjectFactory().createStructureDef();
082:                        lStructureDef
083:                                .setStructureRef(lStructureToInsert.StructureRef);
084:                        lStructureDef
085:                                .setDescription(lStructureToInsert.Description);
086:                        FieldDefListType lFieldDefList = Util
087:                                .getObjectFactory().createFieldDefList();
088:                        lStructureDef.setFieldDefList(lFieldDefList);
089:                        Storage.insertStructure(lStructureDef);
090:                    }
091:                } catch (JAXBException e) {
092:                    throw new PSDataSourceOperationInvocationException(e);
093:                }
094:            }
095:
096:            /* Returns list of input fields for the operation with the specified name from specified service */
097:            public STField[] getFields(String pStructureRef) throws PSException {
098:                StructureDefType lStructureDef = Storage
099:                        .getStructure(pStructureRef);
100:                if (lStructureDef == null)
101:                    throw new PSException(
102:                            "Structure not found. StructureRef : "
103:                                    + pStructureRef);
104:                FieldDefListType lFieldDefList = lStructureDef
105:                        .getFieldDefList();
106:                STField[] lReturn = new STField[lFieldDefList.getFieldDef()
107:                        .size()];
108:                Iterator lIter = lFieldDefList.getFieldDef().iterator();
109:                for (int j = 0; lIter.hasNext(); j++) {
110:                    lReturn[j] = Util.getField((FieldDefType) lIter.next());
111:                }
112:                return lReturn;
113:            }
114:
115:            /* Returns list of input Constraints for the operation with the specified name from specified service */
116:            public STConstraint[] getConstraints(String pStructureRef)
117:                    throws PSException {
118:                StructureDefType lStructureDef = Storage
119:                        .getStructure(pStructureRef);
120:                if (lStructureDef == null)
121:                    throw new PSException(
122:                            "Structure not found. StructureRef : "
123:                                    + pStructureRef);
124:                ConstraintDefListType lConstraintDefList = lStructureDef
125:                        .getConstraintDefList();
126:                if (lConstraintDefList != null
127:                        && lConstraintDefList.getConstraintDef() != null) {
128:                    STConstraint[] lReturn = new STConstraint[lConstraintDefList
129:                            .getConstraintDef().size()];
130:                    Iterator lIter = lConstraintDefList.getConstraintDef()
131:                            .iterator();
132:                    for (int j = 0; lIter.hasNext(); j++) {
133:                        lReturn[j] = Util
134:                                .getConstraint((ConstraintDefType) lIter.next());
135:                    }
136:                    return lReturn;
137:                }
138:                return null;
139:            }
140:
141:            /** inserts field into the structure */
142:            public void insertField(String pStructureRef, STField pNewField)
143:                    throws PSException {
144:                StructureDefType lStructureDef = Storage
145:                        .getStructure(pStructureRef);
146:                if (lStructureDef == null)
147:                    throw new PSException(
148:                            "Structure not found. StructureRef : "
149:                                    + pStructureRef);
150:                // Make sure that field with the specified name does not exists yet
151:                FieldDefListType lFieldDefList = lStructureDef
152:                        .getFieldDefList();
153:                Iterator lIter = lFieldDefList.getFieldDef().iterator();
154:                while (lIter.hasNext()) {
155:                    FieldDefType lFieldDef = (FieldDefType) lIter.next();
156:                    if (lFieldDef.getName().equals(pNewField.Name))
157:                        throw new PSException(
158:                                "Attempt to insert duplicate field. StructureRef : "
159:                                        + pStructureRef + ". FieldName : "
160:                                        + pNewField.Name);
161:                }
162:                FieldDefType lNewFieldDef = Util.getFieldDef(pNewField);
163:                lFieldDefList.getFieldDef().add(lNewFieldDef);
164:                Storage.updateStructure(lStructureDef);
165:            }
166:        }
w___w_w___.__j__ava2__s___.__c_o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.