Source Code Cross Referenced for CommonUtil.java in  » UML » MetaBoss » com » metaboss » sdlctools » services » codegeneration » 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.services.codegeneration 
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.services.codegeneration;
016:
017:        import java.util.ArrayList;
018:        import java.util.HashMap;
019:        import java.util.Iterator;
020:        import java.util.List;
021:        import java.util.Map;
022:
023:        import javax.jmi.reflect.JmiException;
024:
025:        import com.metaboss.enterprise.bs.BSException;
026:        import com.metaboss.enterprise.bs.BSServiceProviderException;
027:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
028:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
029:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
030:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Namespace;
031:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
032:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.TypeTemplate;
033:        import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
034:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
035:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AggregationTypeEnum;
036:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Association;
037:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
038:
039:        /** Set of useful enterprise model utilites */
040:        public class CommonUtil {
041:            /** Builds template reference to be used in the template processing */
042:            private static Map sGetTemplateReferenceForTemplateProcessorOutput = new HashMap();
043:
044:            public static String getTemplateReferenceForTemplateProcessor(
045:                    TypeTemplate pTypeTemplate) throws BSException {
046:                String lResult = (String) sGetTemplateReferenceForTemplateProcessorOutput
047:                        .get(pTypeTemplate.getRef());
048:                if (lResult == null) {
049:                    DataDictionary lDataDictionary = pTypeTemplate
050:                            .getOwnerDataDictionary();
051:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDataDictionary
052:                            .getSystem();
053:                    DesignLibrary lDesignLibrary = lDataDictionary
054:                            .getDesignLibrary();
055:                    // Now that we have access to all elements - roll theminto string
056:                    StringBuffer lStringBuffer = new StringBuffer();
057:                    if (lSystem != null) {
058:                        lStringBuffer.append(lSystem.getEnterprise().getName());
059:                        lStringBuffer.append(".");
060:                        lStringBuffer.append(lSystem.getName());
061:                    } else {
062:                        lStringBuffer.append(lDesignLibrary.getEnterprise()
063:                                .getName());
064:                    }
065:                    lStringBuffer.append(".TypeTemplates.");
066:                    for (Iterator lNamespacesIterator = pTypeTemplate
067:                            .getNamespace().getPathWithoutDictionary()
068:                            .iterator(); lNamespacesIterator.hasNext();) {
069:                        Namespace lNamespace = (Namespace) lNamespacesIterator
070:                                .next();
071:                        lStringBuffer
072:                                .append(lNamespace.getName().toLowerCase());
073:                        lStringBuffer.append(".");
074:                    }
075:                    lStringBuffer.append(pTypeTemplate.getName());
076:                    sGetTemplateReferenceForTemplateProcessorOutput.put(
077:                            pTypeTemplate.getRef(), lResult = lStringBuffer
078:                                    .toString());
079:                }
080:                return lResult;
081:            }
082:
083:            /** Returns the list of referenced generic datatypes (they do not belong to any system) */
084:            public static DataType[] getReferencedPublicDatatypes(
085:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
086:                    throws BSException {
087:                try {
088:                    // Get all and filter out the generic ones
089:                    ArrayList lReturn = new ArrayList();
090:                    for (Iterator lCombinedTypesIterator = pSystem
091:                            .getCombinedTypes().iterator(); lCombinedTypesIterator
092:                            .hasNext();) {
093:                        ModelElement lType = (ModelElement) lCombinedTypesIterator
094:                                .next();
095:                        if (lType instanceof  DataType) {
096:                            DataType lDataType = (DataType) lType;
097:                            DataDictionary lOwnerDataDictionary = lDataType
098:                                    .getOwnerDataDictionary();
099:                            if (lOwnerDataDictionary.getSystem() == null)
100:                                lReturn.add(lDataType);
101:                        }
102:                    }
103:                    return (DataType[]) lReturn.toArray(new DataType[lReturn
104:                            .size()]);
105:                } catch (JmiException e) {
106:                    throw new BSServiceProviderException(
107:                            "Unable to execute getReferencedPublicDatatypes() method.",
108:                            e);
109:                }
110:            }
111:
112:            /** Returns the list of referenced generic structures (they do not belong to any system) */
113:            public static Structure[] getReferencedPublicStructures(
114:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
115:                    throws BSException {
116:                try {
117:                    // Get all and filter out the generic ones
118:                    ArrayList lReturn = new ArrayList();
119:                    for (Iterator lCombinedTypesIterator = pSystem
120:                            .getCombinedTypes().iterator(); lCombinedTypesIterator
121:                            .hasNext();) {
122:                        ModelElement lType = (ModelElement) lCombinedTypesIterator
123:                                .next();
124:                        if (lType instanceof  Structure) {
125:                            Structure lStructure = (Structure) lType;
126:                            // Check if mesage is in the datadictionary which does not belong to any system
127:                            DataDictionary lOwnerDataDictionary = lStructure
128:                                    .getOwnerDataDictionary();
129:                            if (lOwnerDataDictionary != null
130:                                    && lOwnerDataDictionary.getSystem() == null)
131:                                lReturn.add(lStructure);
132:                        }
133:                    }
134:                    return (Structure[]) lReturn.toArray(new Structure[lReturn
135:                            .size()]);
136:                } catch (JmiException e) {
137:                    throw new BSServiceProviderException(
138:                            "Unable to execute getReferencedPublicStructures() method.",
139:                            e);
140:                }
141:            }
142:
143:            /** Returns the list of referenced generic messages (they do not belong to any system) */
144:            public static Message[] getReferencedPublicMessages(
145:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
146:                    throws BSException {
147:                try {
148:                    // Get all and filter out the generic ones
149:                    ArrayList lReturn = new ArrayList();
150:                    for (Iterator lCombinedTypesIterator = pSystem
151:                            .getCombinedTypes().iterator(); lCombinedTypesIterator
152:                            .hasNext();) {
153:                        ModelElement lType = (ModelElement) lCombinedTypesIterator
154:                                .next();
155:                        if (lType instanceof  Message) {
156:                            Message lMessage = (Message) lType;
157:                            // Check if mesage is in the datadictionary which does not belong to any system
158:                            DataDictionary lOwnerDataDictionary = lMessage
159:                                    .getOwnerDataDictionary();
160:                            if (lOwnerDataDictionary != null
161:                                    && lOwnerDataDictionary.getSystem() == null)
162:                                lReturn.add(lMessage);
163:                        }
164:                    }
165:                    return (Message[]) lReturn.toArray(new Message[lReturn
166:                            .size()]);
167:                } catch (JmiException e) {
168:                    throw new BSServiceProviderException(
169:                            "Unable to execute getReferencedPublicMessages() method.",
170:                            e);
171:                }
172:            }
173:
174:            /** Returns true if specified role results in entity referencing this role
175:             * having referenced_instance_id attribute being included in the entity. */
176:            public static boolean doesEntityStoreReference(
177:                    AssociationRole pReference) throws BSException {
178:                try {
179:                    if (pReference.isPlural())
180:                        return false; // This role references more than one entity on the other side, therefore it can not have reference
181:                    if (pReference.equals(AggregationTypeEnum.COMPOSITION))
182:                        return true; // This is the reference to the owner - we will always have the reference
183:                    AssociationRole lEntityRole = pReference.getOppositeRole();
184:                    // In this association thie entity is an ownre - it will never have a reference
185:                    if (lEntityRole.getAggregationType().equals(
186:                            AggregationTypeEnum.COMPOSITION))
187:                        return false;
188:                    // If we are just associated (no aggregation), than entity has the reference
189:                    if (lEntityRole.getAggregationType().equals(
190:                            AggregationTypeEnum.NONE))
191:                        return true;
192:                    // We are now left with the case where this entity aggregates
193:                    // a single instance of the other entity. Since we would rather push the
194:                    // reference to the end with AggregationType NONE and it is only not possible
195:                    // if our role is plural - chec for that and give final answer
196:                    return lEntityRole.isPlural();
197:                } catch (JmiException e) {
198:                    throw new BSServiceProviderException(
199:                            "Unable to execute doesEntityHaveReference() method.",
200:                            e);
201:                }
202:            }
203:
204:            /** Returns true if in the specified association neither of entities is able to store the reference to the other. */
205:            public static boolean doEntitiesStoreReference(
206:                    Association pAssociation) throws BSException {
207:                try {
208:                    List lRoles = pAssociation.getRoles();
209:                    return doesEntityStoreReference((AssociationRole) lRoles
210:                            .get(0))
211:                            || doesEntityStoreReference((AssociationRole) lRoles
212:                                    .get(1));
213:                } catch (JmiException e) {
214:                    throw new BSServiceProviderException(
215:                            "Unable to execute doEntitiesHaveReference() method.",
216:                            e);
217:                }
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.