Source Code Cross Referenced for ModelUtils.java in  » UML » MetaBoss » com » metaboss » sdlctools » models » metabossmodel » 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.models.metabossmodel 
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.models.metabossmodel;
016:
017:        import java.util.Collection;
018:
019:        import javax.jmi.reflect.ConstraintViolationException;
020:        import javax.jmi.reflect.JmiException;
021:        import javax.jmi.reflect.RefPackage;
022:
023:        import com.metaboss.sdlctools.models.ModelRepositoryException;
024:        import com.metaboss.sdlctools.models.ModelRepositoryIllegalArgumentException;
025:        import com.metaboss.sdlctools.models.ModelValidationException;
026:        import com.metaboss.sdlctools.models.impl.ModelRepositoryImpl;
027:        import com.metaboss.sdlctools.models.impl.metabossmodel.MetaBossModelToUMLModelConvertor;
028:        import com.metaboss.sdlctools.models.impl.metabossmodel.MetaBossUMLProfileCreator;
029:        import com.metaboss.sdlctools.models.impl.metabossmodel.UMLModelToMetaBossModelConvertor;
030:        import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
031:        import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibraryModelPackage;
032:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
033:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EnterpriseModelPackage;
034:        import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.TechnologyLibrary;
035:        import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.TechnologyLibraryModelPackage;
036:
037:        /** Set of MetaBossModel utility and helper methods realising some facilities seemingly not provided by MDR. */
038:        public class ModelUtils {
039:            /** This class is a "toolbox" with static utilities and can not be instantiated */
040:            private ModelUtils() {
041:            }
042:
043:            /** Returns one and only one top level ModelElement. This element can be of 
044:             * type DesignLibrary, TechnologyLibrary or Enterprise. The type of returned element
045:             * determines what kind of model we are looking at.
046:             * @param pModelName the name of the model previously loaded in the repository
047:             * @exception ModelRepositoryException is thrown if model with the given name is not found, or it is not of the expected type */
048:            public static ModelElement getRootElement(String pModelName)
049:                    throws ModelRepositoryException {
050:                ModelRepositoryImpl lRepository = ModelRepositoryImpl
051:                        .getRepository();
052:                RefPackage lOutermostPackage = lRepository
053:                        .getModelExtent(pModelName);
054:                if (lOutermostPackage instanceof  MetaBossModelPackage)
055:                    return getRootElement((MetaBossModelPackage) lOutermostPackage);
056:                else
057:                    throw new ModelRepositoryIllegalArgumentException("Model '"
058:                            + pModelName + "' is not MetaBossModel.");
059:            }
060:
061:            /** Returns one and only one top level ModelElement. This element can be of 
062:             * type DesignLibrary, TechnologyLibrary or Enterprise. The type of returned element
063:             * determines what kind of model we are looking at.
064:             * @param pModelName the name of the model previously loaded in the repository
065:             * @exception ModelRepositoryException is thrown if model with the given name is not found, or it is not of the expected type */
066:            public static ModelElement getRootElement(
067:                    MetaBossModelPackage pMetaBossModelPackage)
068:                    throws ModelRepositoryException {
069:                // Try top elements one by one.
070:                // Start from the enteprise as this is presumably most often occuring scenario
071:                {
072:                    EnterpriseModelPackage lEnterpriseModelPackage = pMetaBossModelPackage
073:                            .getEnterpriseModel();
074:                    Collection lEnterprises = lEnterpriseModelPackage
075:                            .getEnterprise().refAllOfType();
076:                    if (lEnterprises.size() == 1)
077:                        return (Enterprise) lEnterprises.iterator().next();
078:                    else if (lEnterprises.size() != 0)
079:                        throw new ModelValidationException(
080:                                "Unable to determine root element of the model.",
081:                                new JmiException[] { new ConstraintViolationException(
082:                                        lEnterpriseModelPackage,
083:                                        lEnterpriseModelPackage.refMetaObject(),
084:                                        "There can only be at most one instance of Enterprise element in the model.") });
085:                }
086:                // Now to design library
087:                {
088:                    DesignLibraryModelPackage lDesignLibraryModelPackage = pMetaBossModelPackage
089:                            .getDesignLibraryModel();
090:                    Collection lDesignLibraries = lDesignLibraryModelPackage
091:                            .getDesignLibrary().refAllOfType();
092:                    if (lDesignLibraries.size() == 1)
093:                        return (DesignLibrary) lDesignLibraries.iterator()
094:                                .next();
095:                    else if (lDesignLibraries.size() != 0)
096:                        throw new ModelValidationException(
097:                                "Unable to determine root element of the model.",
098:                                new JmiException[] { new ConstraintViolationException(
099:                                        lDesignLibraryModelPackage,
100:                                        lDesignLibraryModelPackage
101:                                                .refMetaObject(),
102:                                        "There can only be at most one instance of DesignLibrary element in the model.") });
103:                }
104:                // Now to technology library
105:                {
106:                    TechnologyLibraryModelPackage lTechnologyLibraryModelPackage = pMetaBossModelPackage
107:                            .getTechnologyLibraryModel();
108:                    Collection lTechnologyLibraries = lTechnologyLibraryModelPackage
109:                            .getTechnologyLibrary().refAllOfType();
110:                    if (lTechnologyLibraries.size() == 1)
111:                        return (TechnologyLibrary) lTechnologyLibraries
112:                                .iterator().next();
113:                    else if (lTechnologyLibraries.size() != 0)
114:                        throw new ModelValidationException(
115:                                "Unable to determine root element of the model.",
116:                                new JmiException[] { new ConstraintViolationException(
117:                                        lTechnologyLibraryModelPackage,
118:                                        lTechnologyLibraryModelPackage
119:                                                .refMetaObject(),
120:                                        "There can only be at most one instance of TechnologyLibrary element in the model.") });
121:                }
122:                throw new ModelValidationException(
123:                        "Unable to determine root element of the model.",
124:                        new JmiException[] { new ConstraintViolationException(
125:                                pMetaBossModelPackage,
126:                                pMetaBossModelPackage.refMetaObject(),
127:                                "There must be one and only one instance of Enterprise or DesignLibrary or TechnologyLibrary element in the model.") });
128:            }
129:
130:            /** This method converts MetaBoss model to UML model with MetaBoss profile
131:             * Note that resulting UML model is a 100% UML in all aspect but it is
132:             * enriched and constrained with special stereotypes and tagged values.
133:             * In UML this is quite normal and allowed technique.
134:             * @param pSourceMetaBossModelName the name of already loaded MetaBoss model
135:             * @param pTargetUMLModelName the name of destination UML model. This model
136:             * should not exist at the time this method is called. It will be created inside this method.
137:             * @exception ModelRepositoryException is thrown in case of trouble (e.g. source model not found, target model already exists etc) */
138:            public static void convertMetaBossModelToUMLModel(
139:                    String pSourceMetaBossModelName, String pTargetUMLModelName)
140:                    throws ModelRepositoryException {
141:                // The job is too big - delegate it to the separate class in the model implementation
142:                MetaBossModelToUMLModelConvertor.doConversion(
143:                        pSourceMetaBossModelName, pTargetUMLModelName);
144:            }
145:
146:            /** This method creates UML Profile for MetaBoss model. The resulting profile
147:             * may be used as a starting point for the UML Models containing MetaBoss enterprise
148:             * definition.
149:             * @param pTargetUMLModelName the name of destination UML model. This model
150:             * should not exist at the time this method is called. It will be created inside this method.
151:             * @exception ModelRepositoryException is thrown in case of trouble (e.g. source model not found, target model already exists etc) */
152:            public static void createMetaBossUMLProfileModel(
153:                    String pTargetUMLModelName) throws ModelRepositoryException {
154:                // The job is too big - delegate it to the separate class in the model implementation
155:                MetaBossUMLProfileCreator.doCreation(pTargetUMLModelName);
156:            }
157:
158:            /** This method converts UML model to MetaBoss model.
159:             * Note that source UML model is a 100% UML in all aspect but it is
160:             * enriched and constrained with special stereotypes and tagged values.
161:             * In UML this is quite normal and allowed technique.
162:             * @param pSourceUMLModelName the name of already loaded UML model
163:             * @param pTargetMetaBossModelName the name of destination MetaBoss model. This model
164:             * should not exist at the time this method is called. It will be created inside this method.
165:             * @exception ModelRepositoryException is thrown in case of trouble (e.g. source model not found, target model already exists etc) */
166:            public static void convertUMLModelToMetaBossModel(
167:                    String pSourceUMLModelName, String pTargetMetaBossModelName)
168:                    throws ModelRepositoryException {
169:                // The job is too big - delegate it to the separate class in the model implementation
170:                UMLModelToMetaBossModelConvertor.doConversion(
171:                        pSourceUMLModelName, pTargetMetaBossModelName);
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.