Source Code Cross Referenced for Util.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.ArrayList;
018:        import java.util.Iterator;
019:        import java.util.List;
020:
021:        import javax.xml.bind.JAXBException;
022:
023:        import com.metaboss.enterprise.ps.PSDataSourceOperationInvocationException;
024:        import com.metaboss.enterprise.ps.PSException;
025:        import com.metaboss.enterprise.ps.PSUnexpectedProgramConditionException;
026:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STConstraint;
027:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STField;
028:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STOperation;
029:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STOutputMessage;
030:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STProperty;
031:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STPropertyDescriptor;
032:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STReportEntity;
033:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STServiceimplementation;
034:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STVersion;
035:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ConstraintDefType;
036:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.FieldDefType;
037:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.InputFieldDefListType;
038:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ObjectFactory;
039:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OperationDefType;
040:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OutputFieldDefListType;
041:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OutputMessageDefListType;
042:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OutputMessageDefType;
043:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.PropertyDescriptorListType;
044:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.PropertyDescriptorType;
045:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.PropertyType;
046:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ReportEntityDefType;
047:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ServiceimplementationDefType;
048:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.VersionNumberType;
049:        import com.metaboss.sdlctools.types.enterprisemodel.TransactionPolicyTextHelper;
050:
051:        /** This class is an interface between ps layer and dom storage */
052:        public class Util {
053:            private static ObjectFactory cObjectFactory = null;
054:
055:            /** Returns object factory used to create dom objects */
056:            public static ObjectFactory getObjectFactory() {
057:                if (cObjectFactory == null) {
058:                    // create a JAXBContext capable of handling classes generated into the primer.po package
059:                    cObjectFactory = new ObjectFactory();
060:                }
061:                return cObjectFactory;
062:            }
063:
064:            public static STPropertyDescriptor[] getPropertyDescriptors(
065:                    List pDescriptorsList) throws PSException {
066:                if (pDescriptorsList == null)
067:                    return new STPropertyDescriptor[0];
068:
069:                STPropertyDescriptor[] lRet = new STPropertyDescriptor[pDescriptorsList
070:                        .size()];
071:                Iterator lIter = pDescriptorsList.iterator();
072:                for (int i = 0; lIter.hasNext(); i++) {
073:                    PropertyDescriptorType lDescriptor = (PropertyDescriptorType) lIter
074:                            .next();
075:                    STPropertyDescriptor lElement = new STPropertyDescriptor();
076:                    lElement.Name = lDescriptor.getName();
077:                    lElement.Description = lDescriptor.getDescription();
078:                    lElement.IsArray = lDescriptor.isIsArray();
079:                    lElement.IsAvailableAsResource = lDescriptor
080:                            .isIsAvailableAsResource();
081:                    // Look after possible subproperties
082:                    PropertyDescriptorListType lSubPropertyDescriptors = lDescriptor
083:                            .getPropertyDescriptorList();
084:                    if (lSubPropertyDescriptors != null) {
085:                        List lPropertyDescriptorList = lSubPropertyDescriptors
086:                                .getPropertyDescriptor();
087:                        if (lPropertyDescriptorList != null
088:                                && lPropertyDescriptorList.size() > 0)
089:                            lElement.PropertyDescriptors = getPropertyDescriptors(lSubPropertyDescriptors
090:                                    .getPropertyDescriptor());
091:                        else
092:                            lElement.PropertyDescriptors = new STPropertyDescriptor[0];
093:                    } else
094:                        lElement.PropertyDescriptors = new STPropertyDescriptor[0];
095:                    lRet[i] = lElement;
096:                }
097:                return lRet;
098:            }
099:
100:            public static STProperty[] getPropertyStructures(
101:                    List pPropertiesList) {
102:                if (pPropertiesList == null)
103:                    return new STProperty[0];
104:
105:                STProperty[] lRet = new STProperty[pPropertiesList.size()];
106:                Iterator lIter = pPropertiesList.iterator();
107:                for (int i = 0; lIter.hasNext(); i++) {
108:                    PropertyType lProp = (PropertyType) lIter.next();
109:                    STProperty lElement = new STProperty();
110:                    lElement.Name = lProp.getName();
111:                    lElement.Value = lProp.getValue();
112:                    lRet[i] = lElement;
113:                }
114:                return lRet;
115:            }
116:
117:            public static List getPropertiesList(
118:                    STProperty[] pPropertyStructures) throws PSException {
119:                try {
120:                    ArrayList lPropertiesList = new ArrayList();
121:                    if (pPropertyStructures != null
122:                            && pPropertyStructures.length > 0) {
123:                        for (int i = 0; i < pPropertyStructures.length; i++) {
124:                            PropertyType lProp = getObjectFactory()
125:                                    .createProperty();
126:                            lProp.setName(pPropertyStructures[i].Name);
127:                            lProp.setValue(pPropertyStructures[i].Value);
128:                            lPropertiesList.add(lProp);
129:                        }
130:                    }
131:                    return lPropertiesList;
132:                } catch (JAXBException e) {
133:                    throw new PSDataSourceOperationInvocationException(e);
134:                }
135:            }
136:
137:            // Helper. Converts xml struct to the PS struct
138:            public static STReportEntity getReportEntity(
139:                    ReportEntityDefType pReportEntityDef) throws PSException {
140:                if (pReportEntityDef == null)
141:                    return null;
142:                STReportEntity lStruct = new STReportEntity();
143:                lStruct.EntityRef = pReportEntityDef.getEntityRef();
144:                lStruct.Name = pReportEntityDef.getName();
145:                lStruct.Description = pReportEntityDef.getDescription();
146:                lStruct.Cardinality = com.metaboss.sdlctools.types.enterprisemodel.ReportEntityCardinalityTextHelper
147:                        .fromTextObject(pReportEntityDef
148:                                .getReportEntityCardinality());
149:                if (pReportEntityDef.getPluralName() != null)
150:                    lStruct.PluralName = pReportEntityDef.getPluralName();
151:                // Good place for now to put some validation tests
152:                if (lStruct.Cardinality.isEmpty())
153:                    throw new PSUnexpectedProgramConditionException(
154:                            "Report entity cardinality can not be empty in the report definition. ReportRef : "
155:                                    + pReportEntityDef.getEntityRef());
156:                return lStruct;
157:            }
158:
159:            // Helper. Converts xml struct to the PS struct
160:            public static STField getField(FieldDefType pFieldDef) {
161:                if (pFieldDef == null)
162:                    return null;
163:                STField lStruct = new STField();
164:                lStruct.Name = pFieldDef.getName();
165:                lStruct.Description = pFieldDef.getDescription();
166:                lStruct.IsArray = pFieldDef.isIsArray();
167:                lStruct.DataTypeRef = pFieldDef.getDataTypeRef();
168:                lStruct.StructRef = pFieldDef.getStructureRef();
169:                return lStruct;
170:            }
171:
172:            // Helper. Converts PS struct to xml struct
173:            public static FieldDefType getFieldDef(STField pField)
174:                    throws PSException {
175:                try {
176:                    FieldDefType lFieldDef = getObjectFactory()
177:                            .createFieldDef();
178:                    lFieldDef.setName(pField.Name);
179:                    lFieldDef.setDescription(pField.Description);
180:                    lFieldDef.setIsArray(pField.IsArray);
181:                    lFieldDef
182:                            .setDataTypeRef(pField.DataTypeRef != null ? pField.DataTypeRef
183:                                    : "");
184:                    lFieldDef
185:                            .setStructureRef(pField.StructRef != null ? pField.StructRef
186:                                    : "");
187:                    return lFieldDef;
188:                } catch (JAXBException e) {
189:                    throw new PSDataSourceOperationInvocationException(e);
190:                }
191:            }
192:
193:            // Helper. Converts xml struct to the PS struct
194:            public static STOutputMessage getOutputMessage(
195:                    OutputMessageDefType pOutputMessageDef) {
196:                if (pOutputMessageDef == null)
197:                    return null;
198:                STOutputMessage lStruct = new STOutputMessage();
199:                lStruct.Name = pOutputMessageDef.getName();
200:                lStruct.Description = pOutputMessageDef.getDescription();
201:                lStruct.IsArray = pOutputMessageDef.isIsArray();
202:                lStruct.MessageRef = pOutputMessageDef.getMessageRef();
203:                return lStruct;
204:            }
205:
206:            // Helper. Converts xml struct to the PS struct
207:            public static STConstraint getConstraint(
208:                    ConstraintDefType pConstraintDef) {
209:                if (pConstraintDef == null)
210:                    return null;
211:                STConstraint lStruct = new STConstraint();
212:                lStruct.Name = pConstraintDef.getName();
213:                lStruct.Description = pConstraintDef.getDescription();
214:                lStruct.OCLExpression = pConstraintDef.getOCLExpression();
215:                lStruct.DefaultErrorText = pConstraintDef.getDefaultErrorText();
216:                return lStruct;
217:            }
218:
219:            // Helper. Converts PS struct to xml struct
220:            public static OutputMessageDefType getMessageFieldDef(
221:                    STOutputMessage pOutputMessage) throws PSException {
222:                try {
223:                    OutputMessageDefType lOutputMessageDef = getObjectFactory()
224:                            .createOutputMessageDef();
225:                    lOutputMessageDef.setName(pOutputMessage.Name);
226:                    lOutputMessageDef
227:                            .setDescription(pOutputMessage.Description);
228:                    lOutputMessageDef.setIsArray(pOutputMessage.IsArray);
229:                    lOutputMessageDef.setMessageRef(pOutputMessage.MessageRef);
230:                    return lOutputMessageDef;
231:                } catch (JAXBException e) {
232:                    throw new PSDataSourceOperationInvocationException(e);
233:                }
234:            }
235:
236:            // Helper. Converts PS struct to xml struct
237:            public static OperationDefType getOperationDef(
238:                    STOperation pOperation) throws PSException {
239:                try {
240:                    OperationDefType lOperationDef = getObjectFactory()
241:                            .createOperationDef();
242:                    lOperationDef.setName(pOperation.Name);
243:                    lOperationDef.setDescription(pOperation.Description);
244:                    lOperationDef
245:                            .setOperationTransactionPolicy(TransactionPolicyTextHelper
246:                                    .toTextObject(pOperation.TransactionPolicy));
247:                    InputFieldDefListType lInputFieldDefList = getObjectFactory()
248:                            .createInputFieldDefList();
249:                    lOperationDef.setInputFieldDefList(lInputFieldDefList);
250:                    OutputFieldDefListType lOutputFieldDefList = getObjectFactory()
251:                            .createOutputFieldDefList();
252:                    lOperationDef.setOutputFieldDefList(lOutputFieldDefList);
253:                    OutputMessageDefListType lOutputMessageDefList = getObjectFactory()
254:                            .createOutputMessageDefList();
255:                    lOperationDef
256:                            .setOutputMessageDefList(lOutputMessageDefList);
257:                    return lOperationDef;
258:                } catch (JAXBException e) {
259:                    throw new PSDataSourceOperationInvocationException(e);
260:                }
261:            }
262:
263:            // Helper. Converts PS struct to xml struct
264:            public static ServiceimplementationDefType getServiceimplementationDef(
265:                    STServiceimplementation pServiceimplementation)
266:                    throws PSException {
267:                try {
268:                    ServiceimplementationDefType lServiceimplementationDef = getObjectFactory()
269:                            .createServiceimplementationDef();
270:                    lServiceimplementationDef
271:                            .setName(pServiceimplementation.ServiceimplementationRef
272:                                    .substring(pServiceimplementation.ServiceimplementationRef
273:                                            .lastIndexOf(".") + 1));
274:                    lServiceimplementationDef
275:                            .setDescription(pServiceimplementation.Description);
276:                    return lServiceimplementationDef;
277:                } catch (JAXBException e) {
278:                    throw new PSDataSourceOperationInvocationException(e);
279:                }
280:            }
281:
282:            // Helper. Converts xml struct to the PS struct
283:            public static STVersion getVersion(VersionNumberType pVersionNumber) {
284:                if (pVersionNumber == null)
285:                    return null;
286:                STVersion lStruct = new STVersion();
287:                lStruct.MajorNumber = pVersionNumber.getMajorVersionNumber();
288:                lStruct.MinorNumber = pVersionNumber.getMinorVersionNumber();
289:                return lStruct;
290:            }
291:        }
www__.j__a___v__a__2___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.