Source Code Cross Referenced for UMLStylesheet.java in  » UML » MetaBoss » com » metaboss » sdlctools » models » impl » 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.impl.metabossmodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
0002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
0003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
0005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
0006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
0008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
0011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
0012:        // POSSIBILITY OF SUCH DAMAGE.
0013:        //
0014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
0015:        package com.metaboss.sdlctools.models.impl.metabossmodel;
0016:
0017:        import java.util.Iterator;
0018:        import java.util.List;
0019:
0020:        import javax.jmi.reflect.ConstraintViolationException;
0021:
0022:        import com.metaboss.sdlctools.models.ModelRepository;
0023:        import com.metaboss.sdlctools.models.ModelRepositoryException;
0024:        import com.metaboss.sdlctools.models.ModelValidationException;
0025:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.AbstractNamespace;
0026:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
0027:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
0028:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Namespace;
0029:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
0030:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.TypeTemplate;
0031:        import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
0032:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
0033:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
0034:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
0035:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
0036:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
0037:        import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.State;
0038:        import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.StateMachine;
0039:
0040:        /** This class contains MetaBoss UML Profile textual constants and utilities to
0041:         * create MetaBoss profile in the UML model, read MetaBoss profile from the UML model 
0042:         * and navigate the UML model using constraints and hierarchy dictated by profile */
0043:        public final class UMLStylesheet {
0044:            /** The name of the standard UML stereotype used to mark packages where profiles are stored */
0045:            public static final String UMLProfilePackageStereotypeName = "profile";
0046:            /** The name of the package where MetaBoss UML Profile is stored.
0047:             * Note that this package should also have a standard UML Profile stereotype */
0048:            public static final String MetaBossUMLProfilePackageName = "MetaBoss UML Profile";
0049:            /** The name of the stereotype applicable to UML Model representing the MetaBoss Enterprise model */
0050:            public static final String EnterpriseModelStereotypeName = "metaboss.model";
0051:            /** The name of the stereotype applicable to UML Constraints representing a MetaBoss constraint */
0052:            public static final String ConstraintStereotypeName = "metaboss.constraint";
0053:            public static final String ConstraintStereotypeTagName_DefaultErrorText = "metaboss.message.default error text";
0054:            /** The name of the stereotype applicable to UML Packages representing an enterprise */
0055:            public static final String EnterprisePackageStereotypeName = "metaboss.enterprise";
0056:            /** The name of the stereotype applicable to UML Packages representing systems */
0057:            public static final String SystemPackageStereotypeName = "metaboss.system";
0058:            /** The name of the stereotype applicable to UML Packages representing servicemodules */
0059:            public static final String ServicemodulePackageStereotypeName = "metaboss.servicemodule";
0060:            /** The name of the stereotype applicable to UML Packages representing the design library */
0061:            public static final String DesignLibraryPackageStereotypeName = "metaboss.design library";
0062:            /** The name of the stereotype applicable to UML Packages representing the data dictionary */
0063:            public static final String DataDictionaryPackageStereotypeName = "metaboss.data dictionary";
0064:            /** The name of the stereotype applicable to UML Classes representing an operation return messages */
0065:            public static final String MessageClassStereotypeName = "metaboss.message";
0066:            public static final String MessageClassStereotypeTagName_DefaultText = "metaboss.message.default text";
0067:            public static final String MessageClassStereotypeTagName_Type = "metaboss.message.type";
0068:            public static final String MessageClassStereotypeTagName_Derived = "derived"; // Using UML native stereotype
0069:            /** The name of the stereotype applicable to UML Classes representing a data structure */
0070:            public static final String StructureClassStereotypeName = "metaboss.structure";
0071:            /** The name of the stereotype applicable to UML Classes representing a service */
0072:            public static final String ServiceClassStereotypeName = "metaboss.service";
0073:            /** The name of the stereotype applicable to UML Operations representing a service operation */
0074:            public static final String ServiceOperationStereotypeName = "metaboss.operation";
0075:            /** The name of the tag applicable to UML Operations representing a transaction policy kind enumerable value */
0076:            public static final String ServiceOperationStereotypeTagName_TransactionPolicy = "metaboss.operation.transaction policy";
0077:            /** The name of the stereotype applicable to UML Classes representing an event subscription */
0078:            public static final String EventSubscriptionClassStereotypeName = "metaboss.event subscription";
0079:            /** The name of the tag applicable to EventSussbcription class representing the name of the synchronisation event */
0080:            public static final String EventSubscriptionClassStereotypeTagName_SynchronisationEventName = "metaboss.event subscription.synchronisation event name";
0081:            /** The name of the stereotype applicable to UML Classes representing an event subscription operation */
0082:            public static final String EventSubscriptionOperationStereotypeName = "metaboss.event subscription operation";
0083:            /** The name of the stereotype applicable to UML Classes representing an event subscription event */
0084:            public static final String EventSubscriptionEventStereotypeName = "metaboss.event subscription event";
0085:            /** The name of the stereotype applicable to UML Parameters representing a parameter to the operation, selector, event etc...
0086:             * The main reason to have this stereotype is to add multiplicity definition. In UML parameters to operations do not seem to have the way to define multiplicity.
0087:             * As far as MetaBoss is concerned UMLParameter, which does not have this stereotype defines singular (zero or one) multiplicity */
0088:            public static final String GenericParameterStereotypeName = "metaboss.parameter";
0089:            /** The name of the tag applicable to UML Parameters representing an "IsArray" boolean flag */
0090:            public static final String GenericParameterStereotypeTagName_IsArray = "metaboss.parameter.is array";
0091:            /** The name of the tag applicable to UML Parameters representing a "IsDerived" boolean flag */
0092:            public static final String GenericParameterStereotypeTagName_Derived = "derived"; // Using UML native stereotype
0093:            /** The name of the stereotype applicable to UML Packages representing a domain */
0094:            public static final String DomainPackageStereotypeName = "metaboss.domain";
0095:            /** The name of the stereotype applicable to UML Classes representing an entity */
0096:            public static final String EntityClassStereotypeName = "metaboss.entity";
0097:            public static final String EntityClassStereotypeTagName_Type = "metaboss.entity.type";
0098:            /** The name of the tag applicable to UML Classes representing Entities. The Tag contains the pural form of the entity name */
0099:            public static final String EntityClassStereotypeTagName_PluralName = "metaboss.entity.plural name";
0100:            /** The name of the tag applicable to UML Classes representing Entities. The Tag contains the name of the single element of the primary key. Any number of these tags can be attached */
0101:            public static final String EntityClassStereotypeTagName_PrimaryKeyElement = "metaboss.entity.primary key element";
0102:            /** The name of the stereotype applicable to UML Association Ends representing the ends of association between Entities */
0103:            public static final String AssociationRoleStereotypeName = "metaboss.association role";
0104:            /** The name of the tag applicable to UML Association Ends representing the ends of association between Entities. The Tag contains the pural form of the name of the role the entity plays in this association */
0105:            public static final String AssociationRoleStereotypeTagName_PluralName = "metaboss.association role.plural name";
0106:            /** The name of the stereotype applicable to UML Attributes representing an entity attribute */
0107:            public static final String EntityAttributeStereotypeName = "metaboss.entity attribute";
0108:            /** The name of the tag applicable to UML Attributes representing an entity attribute */
0109:            public static final String EntityAttributeStereotypeTagName_Derived = "derived"; // Using UML native stereotype
0110:            /** The name of the tag applicable to UML Attributes representing an entity attribute */
0111:            public static final String EntityAttributeStereotypeTagName_Type = "metaboss.entity attribute.type";
0112:            /** The name of the tag applicable to UML Attributes representing an entity attribute */
0113:            public static final String EntityAttributeStereotypeTagName_IsUsedForOrdering = "metaboss.entity attribute.is used for ordering";
0114:            /** The name of the stereotype applicable to UML Operation which represents an entity selector */
0115:            public static final String EntitySelectorStereotypeName = "metaboss.entity selector";
0116:            /** The name of the tag applicable to UML Operation which represents an entity selector. The Tag contains the cardinality of selector return (ie. does it return collection of entity instances or a single entity instance). */
0117:            public static final String EntitySelectorStereotypeTagName_Cardinality = "metaboss.entity selector.cardinality";
0118:            /** The name of the tag applicable to UML Operation which represents an entity selector. The Tag contains the text of the SQL Query in the "default" SQL dialect. */
0119:            public static final String EntitySelectorStereotypeTagName_DefaultSQLQuery = "metaboss.entity selector.default sql query";
0120:            /** The name of the tag applicable to UML Operation which represents an entity selector. The Tag contains the boolean value if selector is implicit. */
0121:            public static final String EntitySelectorStereotypeTagName_Derived = "derived"; // Using UML native stereotype
0122:            /** The name of the stereotype applicable to UML Classes representing the Type Templates */
0123:            public static final String TypeTemplateClassStereotypeName = "metaboss.type template";
0124:            /** The name of the stereotype applicable to UML DataValues representing a concrete argument to the template etc...
0125:             * The main reason to have this stereotype is to add value tag. In UML Data Values do not seem to have the way to actualy set value. */
0126:            public static final String GenericArgumentStereotypeName = "metaboss.argument";
0127:            /** The name of the tag applicable to UML DataValues representing actual value of the argument */
0128:            public static final String GenericArgumentStereotypeTagName_Value = "metaboss.argument.value";
0129:            /** The name of the name applicable to UML Models representing the MetaBoss models */
0130:            public static final String mModelName = "MetaBoss Enterprise Model";
0131:            /** The name of the package where public interfaces of the system are located */
0132:            public static final String mSystemPublicInterfacesPackageName = "Public Interfaces";
0133:            /** The name of the package where servicemodules of the system are located */
0134:            public static final String mSystemServicemodulesPackageName = "Servicemodules";
0135:            /** The name of the package where datadictionary of the system are located */
0136:            public static final String mSystemDataDictionaryPackageName = "DataDictionary";
0137:            /** The name of the package where implementation details of the system are located */
0138:            public static final String mSystemImplementationComponentsPackageName = "Implementation Components";
0139:            /** The name of the package where servicemodule messages are located */
0140:            public static final String mServicemoduleMessagesPackageName = "Messages";
0141:            /** The name of the package where servicemodule structures are located */
0142:            public static final String mServicemoduleStructuresPackageName = "Structures";
0143:            /** The name of the package where servicemodule services are located */
0144:            public static final String mServicemoduleServicesPackageName = "Services";
0145:            /** The name of the package where servicemodule event subscriptions are located */
0146:            public static final String mServicemoduleEventSubscriptionsPackageName = "Event Subscriptions";
0147:
0148:            // This clas is used to pass down the context of the conversion
0149:            public static class UMLMetaBossProfile {
0150:                public org.omg.uml.UmlPackage mUMLModelExtent = null;
0151:                public org.omg.uml.modelmanagement.Model mEnterpriseModel = null;
0152:                public org.omg.uml.modelmanagement.UmlPackage mMetaBossModelProfilePackage = null;
0153:
0154:                /** This stereotype is used to mark the UML Model as MetaBoss Enterprise Model */
0155:                public org.omg.uml.foundation.core.Stereotype mEnterpriseModelStereotype = null;
0156:                public org.omg.uml.foundation.core.Stereotype mConstraintStereotype = null;
0157:                public org.omg.uml.foundation.core.TagDefinition mConstraintTagDefinition_DefaultErrorText = null;
0158:                public org.omg.uml.foundation.core.Stereotype mEnterprisePackageStereotype = null;
0159:                public org.omg.uml.foundation.core.Stereotype mDesignLibraryPackageStereotype = null;
0160:                public org.omg.uml.foundation.core.Stereotype mDataDictionaryPackageStereotype = null;
0161:                public org.omg.uml.foundation.core.Stereotype mTypetemplateStereotype = null;
0162:                public org.omg.uml.foundation.core.Stereotype mSystemPackageStereotype = null;
0163:                public org.omg.uml.foundation.core.Stereotype mServicemodulePackageStereotype = null;
0164:                public org.omg.uml.foundation.core.Stereotype mServicemoduleMessageStereotype = null;
0165:                public org.omg.uml.foundation.core.TagDefinition mServicemoduleMessageTagDefinition_DefaultText = null;
0166:                public org.omg.uml.foundation.core.TagDefinition mServicemoduleMessageTagDefinition_Type = null;
0167:                public org.omg.uml.foundation.core.TagDefinition mServicemoduleMessageTagDefinition_Derived = null;
0168:                public org.omg.uml.foundation.core.Stereotype mServicemoduleStructureStereotype = null;
0169:                public org.omg.uml.foundation.core.Stereotype mServicemoduleServiceStereotype = null;
0170:                public org.omg.uml.foundation.core.Stereotype mServiceOperationStereotype = null;
0171:                public org.omg.uml.foundation.core.TagDefinition mServiceOperationTagDefinition_TransactionPolicy = null;
0172:                public org.omg.uml.foundation.core.Stereotype mServicemoduleEventSubscriptionStereotype = null;
0173:                /** Defines the optional tag which contains the name of the sysnchronisation event (must be one of the child events) */
0174:                public org.omg.uml.foundation.core.TagDefinition mEventSubscriptionStereotypeTagDefinition_SynchronisationEventName = null;
0175:                public org.omg.uml.foundation.core.Stereotype mEventSubscriptionOperationStereotype = null;
0176:                public org.omg.uml.foundation.core.Stereotype mEventSubscriptionEventStereotype = null;
0177:                /** Generic Parameter stereotype. Can be attached to any UML Parameter of any UML Operation which represents service operations, selectors etc.*/
0178:                public org.omg.uml.foundation.core.Stereotype mGenericParameterStereotype = null;
0179:                /** Defines the tag which contains the boolean indicating whether the parameter has singular (zero or one) or plural (zero to many)
0180:                 * multiplicity. Can be attached to any UML Parameter with Generic Parameter stereotype. */
0181:                public org.omg.uml.foundation.core.TagDefinition mGenericParameterTagDefinition_IsArray = null;
0182:                /** Defines the tag which contains the boolean indicating whether the parameter is derived from other parts of the model. */
0183:                public org.omg.uml.foundation.core.TagDefinition mGenericParameterTagDefinition_Derived = null;
0184:                /** Generic Argument stereotype. Can be attached to any UML DataValue which represents a concrete argument value.*/
0185:                public org.omg.uml.foundation.core.Stereotype mGenericArgumentStereotype = null;
0186:                /** Defines the tag which contains actual value of the argument. Can be attached to any UML DataValue with Generic Argument stereotype. */
0187:                public org.omg.uml.foundation.core.TagDefinition mGenericArgumentTagDefinition_Value = null;
0188:                public org.omg.uml.foundation.core.Stereotype mDomainPackageStereotype = null;
0189:                public org.omg.uml.foundation.core.Stereotype mEntityClassStereotype = null;
0190:                public org.omg.uml.foundation.core.TagDefinition mEntityClassTagDefinition_Type = null;
0191:                /** Entity plural name tag. Can be attached to any UML Class which represens Entity */
0192:                public org.omg.uml.foundation.core.TagDefinition mEntityClassTagDefinition_PluralName = null;
0193:                /** Entity primary key element tag. Can be attached any number of times to any UML Class which represens Entity */
0194:                public org.omg.uml.foundation.core.TagDefinition mEntityClassTagDefinition_PrimaryKeyElement = null;
0195:                /** Entity Attribute stereotype. Can be attached to any UML Attribute owned by the UML Class which represents Entity */
0196:                public org.omg.uml.foundation.core.Stereotype mEntityAttributeStereotype = null;
0197:                /** Attribute type tag. Can be attached to any UML Attribute owned by the UML Class which represents Entity */
0198:                public org.omg.uml.foundation.core.TagDefinition mEntityAttributeTagDefinition_Derived = null;
0199:                /** Attribute type tag. Can be attached to any UML Attribute owned by the UML Class which represents Entity */
0200:                public org.omg.uml.foundation.core.TagDefinition mEntityAttributeTagDefinition_Type = null;
0201:                /** Attribute orderable flag tag. Can be attached to any UML Attribute owned by the UML Class which represents Entity */
0202:                public org.omg.uml.foundation.core.TagDefinition mEntityAttributeTagDefinition_IsUsedForOrdering = null;
0203:                /** This stereotype is applicable to UML Association Ends representing the ends of association between Entities */
0204:                public org.omg.uml.foundation.core.Stereotype mAssociationRoleStereotype = null;
0205:                /** The tag which contains the pural form of the name of the role the entity plays in this association */
0206:                public org.omg.uml.foundation.core.TagDefinition mAssociationRoleTagDefinition_PluralName = null;
0207:                /** This stereotype is applicable to UML Operations representing the entity selectors */
0208:                public org.omg.uml.foundation.core.Stereotype mSelectorStereotype = null;
0209:                /** Defines the tag which contains the value indicating cardinality of selector return (ie. does it return collection of entity instances or a single entity instance). */
0210:                public org.omg.uml.foundation.core.TagDefinition mSelectorTagDefinition_Cardinality = null;
0211:                /** Defines the tag which contains the text of the SQL Query in the "default" SQL dialect */
0212:                public org.omg.uml.foundation.core.TagDefinition mSelectorTagDefinition_DefaultSQLQuery = null;
0213:                /** Defines the tag which contains the flag whether this selector is implicit or not */
0214:                public org.omg.uml.foundation.core.TagDefinition mSelectorTagDefinition_Derived = null;
0215:            }
0216:
0217:            // Helper. Populates all MetaBoss extension definitions into the model
0218:            public static UMLStylesheet.UMLMetaBossProfile createMetaBossProfile(
0219:                    ModelRepository pModelRepository,
0220:                    org.omg.uml.modelmanagement.Model pTargetModel)
0221:                    throws ModelRepositoryException {
0222:                UMLStylesheet.UMLMetaBossProfile lProfileToReturn = new UMLStylesheet.UMLMetaBossProfile();
0223:                lProfileToReturn.mEnterpriseModel = pTargetModel;
0224:                lProfileToReturn.mUMLModelExtent = (org.omg.uml.UmlPackage) pTargetModel
0225:                        .refOutermostPackage();
0226:
0227:                // Create profile stereotype - this one is part of UML
0228:                org.omg.uml.foundation.core.Stereotype lProfilePackageStereotype = null;
0229:                lProfilePackageStereotype = lProfileToReturn.mUMLModelExtent
0230:                        .getCore().getStereotype().createStereotype();
0231:                lProfilePackageStereotype.setName("profile");
0232:                lProfilePackageStereotype
0233:                        .setNamespace(lProfileToReturn.mEnterpriseModel);
0234:                lProfilePackageStereotype
0235:                        .setVisibility(org.omg.uml.foundation.datatypes.VisibilityKindEnum.VK_PUBLIC);
0236:
0237:                // Create package to hold MetaBoss profile
0238:                lProfileToReturn.mMetaBossModelProfilePackage = lProfileToReturn.mUMLModelExtent
0239:                        .getModelManagement().getUmlPackage()
0240:                        .createUmlPackage();
0241:                lProfileToReturn.mMetaBossModelProfilePackage
0242:                        .setName(MetaBossUMLProfilePackageName);
0243:                lProfileToReturn.mMetaBossModelProfilePackage
0244:                        .setNamespace(lProfileToReturn.mEnterpriseModel);
0245:                lProfileToReturn.mMetaBossModelProfilePackage
0246:                        .setVisibility(org.omg.uml.foundation.datatypes.VisibilityKindEnum.VK_PUBLIC);
0247:                lProfileToReturn.mMetaBossModelProfilePackage.getStereotype()
0248:                        .add(lProfilePackageStereotype);
0249:
0250:                lProfileToReturn.mEnterpriseModelStereotype = createMetaBossProfileStereotype(
0251:                        lProfileToReturn.mMetaBossModelProfilePackage,
0252:                        UMLStylesheet.EnterpriseModelStereotypeName, "Model");
0253:                lProfileToReturn.mConstraintStereotype = createMetaBossProfileStereotype(
0254:                        lProfileToReturn.mMetaBossModelProfilePackage,
0255:                        UMLStylesheet.ConstraintStereotypeName, "Constraint");
0256:                lProfileToReturn.mConstraintTagDefinition_DefaultErrorText = createSingleOptionalTagDefinition(
0257:                        lProfileToReturn.mConstraintStereotype,
0258:                        UMLStylesheet.ConstraintStereotypeTagName_DefaultErrorText);
0259:                lProfileToReturn.mEnterprisePackageStereotype = createMetaBossProfileStereotype(
0260:                        lProfileToReturn.mMetaBossModelProfilePackage,
0261:                        UMLStylesheet.EnterprisePackageStereotypeName,
0262:                        "Package");
0263:                lProfileToReturn.mDesignLibraryPackageStereotype = createMetaBossProfileStereotype(
0264:                        lProfileToReturn.mMetaBossModelProfilePackage,
0265:                        UMLStylesheet.DesignLibraryPackageStereotypeName,
0266:                        "Package");
0267:                lProfileToReturn.mDataDictionaryPackageStereotype = createMetaBossProfileStereotype(
0268:                        lProfileToReturn.mMetaBossModelProfilePackage,
0269:                        UMLStylesheet.DataDictionaryPackageStereotypeName,
0270:                        "Package");
0271:                lProfileToReturn.mTypetemplateStereotype = createMetaBossProfileStereotype(
0272:                        lProfileToReturn.mMetaBossModelProfilePackage,
0273:                        UMLStylesheet.TypeTemplateClassStereotypeName,
0274:                        "Package");
0275:                lProfileToReturn.mSystemPackageStereotype = createMetaBossProfileStereotype(
0276:                        lProfileToReturn.mMetaBossModelProfilePackage,
0277:                        UMLStylesheet.SystemPackageStereotypeName, "Package");
0278:                lProfileToReturn.mServicemodulePackageStereotype = createMetaBossProfileStereotype(
0279:                        lProfileToReturn.mMetaBossModelProfilePackage,
0280:                        UMLStylesheet.ServicemodulePackageStereotypeName,
0281:                        "Package");
0282:                lProfileToReturn.mServicemoduleMessageStereotype = createMetaBossProfileStereotype(
0283:                        lProfileToReturn.mMetaBossModelProfilePackage,
0284:                        UMLStylesheet.MessageClassStereotypeName, "Class");
0285:                lProfileToReturn.mServicemoduleMessageTagDefinition_DefaultText = createSingleOptionalTagDefinition(
0286:                        lProfileToReturn.mServicemoduleMessageStereotype,
0287:                        UMLStylesheet.MessageClassStereotypeTagName_DefaultText);
0288:                lProfileToReturn.mServicemoduleMessageTagDefinition_Type = createSingleOptionalTagDefinition(
0289:                        lProfileToReturn.mServicemoduleMessageStereotype,
0290:                        UMLStylesheet.MessageClassStereotypeTagName_Type);
0291:                lProfileToReturn.mServicemoduleMessageTagDefinition_Derived = createSingleOptionalTagDefinition(
0292:                        lProfileToReturn.mServicemoduleMessageStereotype,
0293:                        UMLStylesheet.MessageClassStereotypeTagName_Derived);
0294:                lProfileToReturn.mServicemoduleStructureStereotype = createMetaBossProfileStereotype(
0295:                        lProfileToReturn.mMetaBossModelProfilePackage,
0296:                        UMLStylesheet.StructureClassStereotypeName, "Class");
0297:                lProfileToReturn.mServicemoduleServiceStereotype = createMetaBossProfileStereotype(
0298:                        lProfileToReturn.mMetaBossModelProfilePackage,
0299:                        UMLStylesheet.ServiceClassStereotypeName, "Class");
0300:                lProfileToReturn.mServiceOperationStereotype = createMetaBossProfileStereotype(
0301:                        lProfileToReturn.mMetaBossModelProfilePackage,
0302:                        UMLStylesheet.ServiceOperationStereotypeName,
0303:                        "Operation");
0304:                lProfileToReturn.mServiceOperationTagDefinition_TransactionPolicy = createSingleOptionalTagDefinition(
0305:                        lProfileToReturn.mServiceOperationStereotype,
0306:                        UMLStylesheet.ServiceOperationStereotypeTagName_TransactionPolicy);
0307:                lProfileToReturn.mServicemoduleEventSubscriptionStereotype = createMetaBossProfileStereotype(
0308:                        lProfileToReturn.mMetaBossModelProfilePackage,
0309:                        UMLStylesheet.EventSubscriptionClassStereotypeName,
0310:                        "Class");
0311:                lProfileToReturn.mEventSubscriptionStereotypeTagDefinition_SynchronisationEventName = createSingleOptionalTagDefinition(
0312:                        lProfileToReturn.mServicemoduleEventSubscriptionStereotype,
0313:                        UMLStylesheet.EventSubscriptionClassStereotypeTagName_SynchronisationEventName);
0314:                lProfileToReturn.mEventSubscriptionOperationStereotype = createMetaBossProfileStereotype(
0315:                        lProfileToReturn.mMetaBossModelProfilePackage,
0316:                        UMLStylesheet.EventSubscriptionOperationStereotypeName,
0317:                        "Operation");
0318:                lProfileToReturn.mEventSubscriptionEventStereotype = createMetaBossProfileStereotype(
0319:                        lProfileToReturn.mMetaBossModelProfilePackage,
0320:                        UMLStylesheet.EventSubscriptionEventStereotypeName,
0321:                        "Operation");
0322:                lProfileToReturn.mGenericParameterStereotype = createMetaBossProfileStereotype(
0323:                        lProfileToReturn.mMetaBossModelProfilePackage,
0324:                        UMLStylesheet.GenericParameterStereotypeName,
0325:                        "Parameter");
0326:                lProfileToReturn.mGenericParameterTagDefinition_IsArray = createSingleOptionalTagDefinition(
0327:                        lProfileToReturn.mGenericParameterStereotype,
0328:                        UMLStylesheet.GenericParameterStereotypeTagName_IsArray);
0329:                lProfileToReturn.mGenericParameterTagDefinition_Derived = createSingleOptionalTagDefinition(
0330:                        lProfileToReturn.mGenericParameterStereotype,
0331:                        UMLStylesheet.GenericParameterStereotypeTagName_Derived);
0332:                lProfileToReturn.mGenericArgumentStereotype = createMetaBossProfileStereotype(
0333:                        lProfileToReturn.mMetaBossModelProfilePackage,
0334:                        UMLStylesheet.GenericArgumentStereotypeName,
0335:                        "DataValue");
0336:                lProfileToReturn.mGenericArgumentTagDefinition_Value = createSingleOptionalTagDefinition(
0337:                        lProfileToReturn.mGenericArgumentStereotype,
0338:                        UMLStylesheet.GenericArgumentStereotypeTagName_Value);
0339:                lProfileToReturn.mDomainPackageStereotype = createMetaBossProfileStereotype(
0340:                        lProfileToReturn.mMetaBossModelProfilePackage,
0341:                        UMLStylesheet.DomainPackageStereotypeName, "Package");
0342:                lProfileToReturn.mEntityClassStereotype = createMetaBossProfileStereotype(
0343:                        lProfileToReturn.mMetaBossModelProfilePackage,
0344:                        UMLStylesheet.EntityClassStereotypeName, "Class");
0345:                lProfileToReturn.mEntityClassTagDefinition_Type = createSingleOptionalTagDefinition(
0346:                        lProfileToReturn.mEntityClassStereotype,
0347:                        UMLStylesheet.EntityClassStereotypeTagName_Type);
0348:                lProfileToReturn.mEntityClassTagDefinition_PluralName = createSingleOptionalTagDefinition(
0349:                        lProfileToReturn.mEntityClassStereotype,
0350:                        UMLStylesheet.EntityClassStereotypeTagName_PluralName);
0351:                lProfileToReturn.mEntityClassTagDefinition_PrimaryKeyElement = createSingleOptionalTagDefinition(
0352:                        lProfileToReturn.mEntityClassStereotype,
0353:                        UMLStylesheet.EntityClassStereotypeTagName_PrimaryKeyElement);
0354:                lProfileToReturn.mEntityAttributeStereotype = createMetaBossProfileStereotype(
0355:                        lProfileToReturn.mMetaBossModelProfilePackage,
0356:                        UMLStylesheet.EntityAttributeStereotypeName,
0357:                        "Attribute");
0358:                lProfileToReturn.mEntityAttributeTagDefinition_Derived = createSingleOptionalTagDefinition(
0359:                        lProfileToReturn.mEntityAttributeStereotype,
0360:                        UMLStylesheet.EntityAttributeStereotypeTagName_Derived);
0361:                lProfileToReturn.mEntityAttributeTagDefinition_Type = createSingleOptionalTagDefinition(
0362:                        lProfileToReturn.mEntityAttributeStereotype,
0363:                        UMLStylesheet.EntityAttributeStereotypeTagName_Type);
0364:                lProfileToReturn.mEntityAttributeTagDefinition_IsUsedForOrdering = createSingleOptionalTagDefinition(
0365:                        lProfileToReturn.mEntityAttributeStereotype,
0366:                        UMLStylesheet.EntityAttributeStereotypeTagName_IsUsedForOrdering);
0367:                lProfileToReturn.mAssociationRoleStereotype = createMetaBossProfileStereotype(
0368:                        lProfileToReturn.mMetaBossModelProfilePackage,
0369:                        UMLStylesheet.AssociationRoleStereotypeName,
0370:                        "AssociationEnd");
0371:                lProfileToReturn.mAssociationRoleTagDefinition_PluralName = createSingleOptionalTagDefinition(
0372:                        lProfileToReturn.mAssociationRoleStereotype,
0373:                        UMLStylesheet.AssociationRoleStereotypeTagName_PluralName);
0374:                lProfileToReturn.mSelectorStereotype = createMetaBossProfileStereotype(
0375:                        lProfileToReturn.mMetaBossModelProfilePackage,
0376:                        UMLStylesheet.EntitySelectorStereotypeName, "Operation");
0377:                lProfileToReturn.mSelectorTagDefinition_Cardinality = createSingleOptionalTagDefinition(
0378:                        lProfileToReturn.mSelectorStereotype,
0379:                        UMLStylesheet.EntitySelectorStereotypeTagName_Cardinality);
0380:                lProfileToReturn.mSelectorTagDefinition_DefaultSQLQuery = createSingleOptionalTagDefinition(
0381:                        lProfileToReturn.mSelectorStereotype,
0382:                        UMLStylesheet.EntitySelectorStereotypeTagName_DefaultSQLQuery);
0383:                lProfileToReturn.mSelectorTagDefinition_Derived = createSingleOptionalTagDefinition(
0384:                        lProfileToReturn.mSelectorStereotype,
0385:                        UMLStylesheet.EntitySelectorStereotypeTagName_Derived);
0386:
0387:                // Set the stereotype for the whole model
0388:                lProfileToReturn.mEnterpriseModel.getStereotype().add(
0389:                        lProfileToReturn.mEnterpriseModelStereotype);
0390:                // Return created profile
0391:                return lProfileToReturn;
0392:            }
0393:
0394:            // Helper. Populates all MetaBoss extension definitions into the model
0395:            public static UMLStylesheet.UMLMetaBossProfile loadMetaBossProfile(
0396:                    ModelRepository pModelRepository,
0397:                    org.omg.uml.UmlPackage pUmlModelExtent)
0398:                    throws ModelRepositoryException {
0399:                UMLStylesheet.UMLMetaBossProfile lProfileToReturn = new UMLStylesheet.UMLMetaBossProfile();
0400:                lProfileToReturn.mUMLModelExtent = pUmlModelExtent;
0401:
0402:                // Work on enterprise model
0403:                {
0404:                    List lSearchResults = pModelRepository.searchByXPath(
0405:                            pUmlModelExtent, getAllEnterpriseModelsXPath());
0406:                    if (lSearchResults.isEmpty() || lSearchResults.size() != 1)
0407:                        throw new ConstraintViolationException(
0408:                                null,
0409:                                null,
0410:                                "The instance of the MetaBoss Enterprise Model must have one and only one Enterprise Model instance.");
0411:                    lProfileToReturn.mEnterpriseModel = (org.omg.uml.modelmanagement.Model) lSearchResults
0412:                            .get(0);
0413:                }
0414:                // Work on profile package
0415:                {
0416:                    List lSearchResults = pModelRepository.searchByXPath(
0417:                            pUmlModelExtent, getMetaBossProfilePackageXPath());
0418:                    if (lSearchResults.isEmpty() || lSearchResults.size() != 1)
0419:                        throw new ConstraintViolationException(
0420:                                null,
0421:                                null,
0422:                                "The instance of the MetaBoss Enterprise Model must have one and only one Package containing MetaBoss UML Profile.");
0423:                    lProfileToReturn.mMetaBossModelProfilePackage = (org.omg.uml.modelmanagement.UmlPackage) lSearchResults
0424:                            .get(0);
0425:                }
0426:
0427:                // Load all definitions of MetaBoss stereotypes and tag definitions. All of them ar mandatory and
0428:                // failure to find any of them will result in exception	
0429:                lProfileToReturn.mEnterpriseModelStereotype = getMetaBossProfileStereotype(
0430:                        pModelRepository, pUmlModelExtent,
0431:                        UMLStylesheet.EnterpriseModelStereotypeName);
0432:                lProfileToReturn.mConstraintStereotype = getMetaBossProfileStereotype(
0433:                        pModelRepository, pUmlModelExtent,
0434:                        UMLStylesheet.ConstraintStereotypeName);
0435:                lProfileToReturn.mConstraintTagDefinition_DefaultErrorText = getMetaBossProfileTagDefinition(
0436:                        pModelRepository,
0437:                        lProfileToReturn.mConstraintStereotype,
0438:                        UMLStylesheet.ConstraintStereotypeTagName_DefaultErrorText);
0439:                lProfileToReturn.mEnterprisePackageStereotype = getMetaBossProfileStereotype(
0440:                        pModelRepository, pUmlModelExtent,
0441:                        UMLStylesheet.EnterprisePackageStereotypeName);
0442:                lProfileToReturn.mDesignLibraryPackageStereotype = getMetaBossProfileStereotype(
0443:                        pModelRepository, pUmlModelExtent,
0444:                        UMLStylesheet.DesignLibraryPackageStereotypeName);
0445:                lProfileToReturn.mDataDictionaryPackageStereotype = getMetaBossProfileStereotype(
0446:                        pModelRepository, pUmlModelExtent,
0447:                        UMLStylesheet.DataDictionaryPackageStereotypeName);
0448:                lProfileToReturn.mTypetemplateStereotype = getMetaBossProfileStereotype(
0449:                        pModelRepository, pUmlModelExtent,
0450:                        UMLStylesheet.TypeTemplateClassStereotypeName);
0451:                lProfileToReturn.mSystemPackageStereotype = getMetaBossProfileStereotype(
0452:                        pModelRepository, pUmlModelExtent,
0453:                        UMLStylesheet.SystemPackageStereotypeName);
0454:                lProfileToReturn.mServicemodulePackageStereotype = getMetaBossProfileStereotype(
0455:                        pModelRepository, pUmlModelExtent,
0456:                        UMLStylesheet.ServicemodulePackageStereotypeName);
0457:                lProfileToReturn.mServicemoduleMessageStereotype = getMetaBossProfileStereotype(
0458:                        pModelRepository, pUmlModelExtent,
0459:                        UMLStylesheet.MessageClassStereotypeName);
0460:                lProfileToReturn.mServicemoduleMessageTagDefinition_DefaultText = getMetaBossProfileTagDefinition(
0461:                        pModelRepository,
0462:                        lProfileToReturn.mServicemoduleMessageStereotype,
0463:                        UMLStylesheet.MessageClassStereotypeTagName_DefaultText);
0464:                lProfileToReturn.mServicemoduleMessageTagDefinition_Type = getMetaBossProfileTagDefinition(
0465:                        pModelRepository,
0466:                        lProfileToReturn.mServicemoduleMessageStereotype,
0467:                        UMLStylesheet.MessageClassStereotypeTagName_Type);
0468:                lProfileToReturn.mServicemoduleMessageTagDefinition_Derived = getMetaBossProfileTagDefinition(
0469:                        pModelRepository,
0470:                        lProfileToReturn.mServicemoduleMessageStereotype,
0471:                        UMLStylesheet.MessageClassStereotypeTagName_Derived);
0472:                lProfileToReturn.mServicemoduleStructureStereotype = getMetaBossProfileStereotype(
0473:                        pModelRepository, pUmlModelExtent,
0474:                        UMLStylesheet.StructureClassStereotypeName);
0475:                lProfileToReturn.mServicemoduleServiceStereotype = getMetaBossProfileStereotype(
0476:                        pModelRepository, pUmlModelExtent,
0477:                        UMLStylesheet.ServiceClassStereotypeName);
0478:                lProfileToReturn.mServiceOperationStereotype = getMetaBossProfileStereotype(
0479:                        pModelRepository, pUmlModelExtent,
0480:                        UMLStylesheet.ServiceOperationStereotypeName);
0481:                lProfileToReturn.mServiceOperationTagDefinition_TransactionPolicy = getMetaBossProfileTagDefinition(
0482:                        pModelRepository,
0483:                        lProfileToReturn.mServiceOperationStereotype,
0484:                        UMLStylesheet.ServiceOperationStereotypeTagName_TransactionPolicy);
0485:                lProfileToReturn.mServicemoduleEventSubscriptionStereotype = getMetaBossProfileStereotype(
0486:                        pModelRepository, pUmlModelExtent,
0487:                        UMLStylesheet.EventSubscriptionClassStereotypeName);
0488:                lProfileToReturn.mEventSubscriptionStereotypeTagDefinition_SynchronisationEventName = getMetaBossProfileTagDefinition(
0489:                        pModelRepository,
0490:                        lProfileToReturn.mServicemoduleEventSubscriptionStereotype,
0491:                        UMLStylesheet.EventSubscriptionClassStereotypeTagName_SynchronisationEventName);
0492:                lProfileToReturn.mEventSubscriptionOperationStereotype = getMetaBossProfileStereotype(
0493:                        pModelRepository, pUmlModelExtent,
0494:                        UMLStylesheet.EventSubscriptionOperationStereotypeName);
0495:                lProfileToReturn.mEventSubscriptionEventStereotype = getMetaBossProfileStereotype(
0496:                        pModelRepository, pUmlModelExtent,
0497:                        UMLStylesheet.EventSubscriptionEventStereotypeName);
0498:                lProfileToReturn.mGenericParameterStereotype = getMetaBossProfileStereotype(
0499:                        pModelRepository, pUmlModelExtent,
0500:                        UMLStylesheet.GenericParameterStereotypeName);
0501:                lProfileToReturn.mGenericParameterTagDefinition_IsArray = getMetaBossProfileTagDefinition(
0502:                        pModelRepository,
0503:                        lProfileToReturn.mGenericParameterStereotype,
0504:                        UMLStylesheet.GenericParameterStereotypeTagName_IsArray);
0505:                lProfileToReturn.mGenericParameterTagDefinition_Derived = getMetaBossProfileTagDefinition(
0506:                        pModelRepository,
0507:                        lProfileToReturn.mGenericParameterStereotype,
0508:                        UMLStylesheet.GenericParameterStereotypeTagName_Derived);
0509:                lProfileToReturn.mGenericArgumentStereotype = getMetaBossProfileStereotype(
0510:                        pModelRepository, pUmlModelExtent,
0511:                        UMLStylesheet.GenericArgumentStereotypeName);
0512:                lProfileToReturn.mGenericArgumentTagDefinition_Value = getMetaBossProfileTagDefinition(
0513:                        pModelRepository,
0514:                        lProfileToReturn.mGenericArgumentStereotype,
0515:                        UMLStylesheet.GenericArgumentStereotypeTagName_Value);
0516:                lProfileToReturn.mDomainPackageStereotype = getMetaBossProfileStereotype(
0517:                        pModelRepository, pUmlModelExtent,
0518:                        UMLStylesheet.DomainPackageStereotypeName);
0519:                lProfileToReturn.mEntityClassStereotype = getMetaBossProfileStereotype(
0520:                        pModelRepository, pUmlModelExtent,
0521:                        UMLStylesheet.EntityClassStereotypeName);
0522:                lProfileToReturn.mEntityClassTagDefinition_Type = getMetaBossProfileTagDefinition(
0523:                        pModelRepository,
0524:                        lProfileToReturn.mEntityClassStereotype,
0525:                        UMLStylesheet.EntityClassStereotypeTagName_Type);
0526:                lProfileToReturn.mEntityClassTagDefinition_PluralName = getMetaBossProfileTagDefinition(
0527:                        pModelRepository,
0528:                        lProfileToReturn.mEntityClassStereotype,
0529:                        UMLStylesheet.EntityClassStereotypeTagName_PluralName);
0530:                lProfileToReturn.mEntityClassTagDefinition_PrimaryKeyElement = getMetaBossProfileTagDefinition(
0531:                        pModelRepository,
0532:                        lProfileToReturn.mEntityClassStereotype,
0533:                        UMLStylesheet.EntityClassStereotypeTagName_PrimaryKeyElement);
0534:                lProfileToReturn.mEntityAttributeStereotype = getMetaBossProfileStereotype(
0535:                        pModelRepository, pUmlModelExtent,
0536:                        UMLStylesheet.EntityAttributeStereotypeName);
0537:                lProfileToReturn.mEntityAttributeTagDefinition_Derived = getMetaBossProfileTagDefinition(
0538:                        pModelRepository,
0539:                        lProfileToReturn.mEntityAttributeStereotype,
0540:                        UMLStylesheet.EntityAttributeStereotypeTagName_Derived);
0541:                lProfileToReturn.mEntityAttributeTagDefinition_Type = getMetaBossProfileTagDefinition(
0542:                        pModelRepository,
0543:                        lProfileToReturn.mEntityAttributeStereotype,
0544:                        UMLStylesheet.EntityAttributeStereotypeTagName_Type);
0545:                lProfileToReturn.mEntityAttributeTagDefinition_IsUsedForOrdering = getMetaBossProfileTagDefinition(
0546:                        pModelRepository,
0547:                        lProfileToReturn.mEntityAttributeStereotype,
0548:                        UMLStylesheet.EntityAttributeStereotypeTagName_IsUsedForOrdering);
0549:                lProfileToReturn.mAssociationRoleStereotype = getMetaBossProfileStereotype(
0550:                        pModelRepository, pUmlModelExtent,
0551:                        UMLStylesheet.AssociationRoleStereotypeName);
0552:                lProfileToReturn.mAssociationRoleTagDefinition_PluralName = getMetaBossProfileTagDefinition(
0553:                        pModelRepository,
0554:                        lProfileToReturn.mAssociationRoleStereotype,
0555:                        UMLStylesheet.AssociationRoleStereotypeTagName_PluralName);
0556:                lProfileToReturn.mSelectorStereotype = getMetaBossProfileStereotype(
0557:                        pModelRepository, pUmlModelExtent,
0558:                        UMLStylesheet.EntitySelectorStereotypeName);
0559:                lProfileToReturn.mSelectorTagDefinition_Cardinality = getMetaBossProfileTagDefinition(
0560:                        pModelRepository,
0561:                        lProfileToReturn.mSelectorStereotype,
0562:                        UMLStylesheet.EntitySelectorStereotypeTagName_Cardinality);
0563:                lProfileToReturn.mSelectorTagDefinition_DefaultSQLQuery = getMetaBossProfileTagDefinition(
0564:                        pModelRepository,
0565:                        lProfileToReturn.mSelectorStereotype,
0566:                        UMLStylesheet.EntitySelectorStereotypeTagName_DefaultSQLQuery);
0567:                lProfileToReturn.mSelectorTagDefinition_Derived = getMetaBossProfileTagDefinition(
0568:                        pModelRepository, lProfileToReturn.mSelectorStereotype,
0569:                        UMLStylesheet.EntitySelectorStereotypeTagName_Derived);
0570:                return lProfileToReturn;
0571:            }
0572:
0573:            /** Helper. Returns XPath expression able to locate given Namespace package */
0574:            public static String getNamespaceXPath(AbstractNamespace pNamespace)
0575:                    throws ModelRepositoryException {
0576:                // Build xpath to the package and find it
0577:                DataDictionary lDataDictionary = null;
0578:                if (pNamespace instanceof  DataDictionary) {
0579:                    lDataDictionary = (DataDictionary) pNamespace;
0580:                } else {
0581:                    lDataDictionary = ((Namespace) pNamespace)
0582:                            .getOwnerDataDictionary();
0583:                }
0584:                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDataDictionary
0585:                        .getSystem();
0586:                DesignLibrary lDesignLibrary = lDataDictionary
0587:                        .getDesignLibrary();
0588:                Enterprise lEnterpise = (lSystem != null) ? lSystem
0589:                        .getEnterprise() : lDesignLibrary.getEnterprise();
0590:                StringBuffer lStringBuffer = new StringBuffer("/Model[@name='");
0591:                lStringBuffer.append(mModelName);
0592:                lStringBuffer.append("']");
0593:                if (lEnterpise != null) {
0594:                    // This is an enterprise
0595:                    lStringBuffer.append("/Package[@name='");
0596:                    lStringBuffer.append(lEnterpise.getName());
0597:                    lStringBuffer.append("']");
0598:                    if (lSystem != null) {
0599:                        // Namespace is inside system dictionary
0600:                        lStringBuffer.append("/Package[@name='");
0601:                        lStringBuffer.append(lSystem.getName());
0602:                        lStringBuffer.append("']");
0603:                        // Namespace is inside system dictionary
0604:                        lStringBuffer.append("/Package[@name='");
0605:                        lStringBuffer
0606:                                .append(mSystemPublicInterfacesPackageName);
0607:                        lStringBuffer.append("']");
0608:
0609:                        // Add system datadictionary package 			
0610:                        lStringBuffer.append("/Package[@name='");
0611:                        lStringBuffer.append(mSystemDataDictionaryPackageName);
0612:                        lStringBuffer.append("']");
0613:
0614:                    } else {
0615:                        // Namespace is inside design library
0616:                        lStringBuffer.append("/Package[@name='DesignLibrary']");
0617:
0618:                        // Add datadictionary package 			
0619:                        lStringBuffer.append("/Package[@name='");
0620:                        lStringBuffer.append(lDataDictionary.getName());
0621:                        lStringBuffer.append("']");
0622:                    }
0623:                } else {
0624:                    // This is standalone design library
0625:                    lStringBuffer.append("/Package[@name='");
0626:                    lStringBuffer.append(lDesignLibrary.getName());
0627:                    lStringBuffer.append("']");
0628:                    // Add datadictionary package 			
0629:                    lStringBuffer.append("/Package[@name='");
0630:                    lStringBuffer.append(lDataDictionary.getName());
0631:                    lStringBuffer.append("']");
0632:                }
0633:                for (Iterator lNamespaceIter = pNamespace
0634:                        .getPathWithoutDictionary().iterator(); lNamespaceIter
0635:                        .hasNext();) {
0636:                    Namespace lNamespace = (Namespace) lNamespaceIter.next();
0637:                    lStringBuffer.append("/Package[@name='");
0638:                    lStringBuffer.append(lNamespace.getName());
0639:                    lStringBuffer.append("']");
0640:                }
0641:                return lStringBuffer.toString();
0642:            }
0643:
0644:            /** Helper. Returns XPath expression able to locate given DataType in the UML model */
0645:            public static String getDataTypeXPath(DataType pDataType)
0646:                    throws ModelRepositoryException {
0647:                StringBuffer lStringBuffer = new StringBuffer(
0648:                        getNamespaceXPath(pDataType.getNamespace()));
0649:                // This is an enterprise
0650:                lStringBuffer.append("/DataType[@name='");
0651:                lStringBuffer.append(pDataType.getName());
0652:                lStringBuffer.append("']");
0653:                return lStringBuffer.toString();
0654:            }
0655:
0656:            /** Helper. Returns XPath expression able to locate given TypeTemplate in the UML model */
0657:            public static String getTypeTemplateXPath(TypeTemplate pTypeTemplate)
0658:                    throws ModelRepositoryException {
0659:                StringBuffer lStringBuffer = new StringBuffer(
0660:                        getNamespaceXPath(pTypeTemplate.getNamespace()));
0661:                // This is an enterprise
0662:                lStringBuffer.append("/Class[reference('stereotype')[@name='");
0663:                lStringBuffer.append(TypeTemplateClassStereotypeName);
0664:                lStringBuffer.append("']][@name='");
0665:                lStringBuffer.append(pTypeTemplate.getName());
0666:                lStringBuffer.append("']");
0667:                return lStringBuffer.toString();
0668:            }
0669:
0670:            /** Helper. Returns XPath expression able to locate given Enterprise package */
0671:            public static String getEnterpriseXPath(Enterprise pEnterprise)
0672:                    throws ModelRepositoryException {
0673:                StringBuffer lStringBuffer = new StringBuffer("/Model[@name='");
0674:                lStringBuffer.append(mModelName);
0675:                lStringBuffer.append("']");
0676:                // This is an enterprise
0677:                lStringBuffer.append("/Package[@name='");
0678:                lStringBuffer.append(pEnterprise.getName());
0679:                lStringBuffer.append("']");
0680:                return lStringBuffer.toString();
0681:            }
0682:
0683:            /** Helper. Returns XPath expression able to locate all Enterprise packages */
0684:            public static String getAllEnterprisesXPath()
0685:                    throws ModelRepositoryException {
0686:                StringBuffer lStringBuffer = new StringBuffer(
0687:                        getAllEnterpriseModelsXPath());
0688:                lStringBuffer
0689:                        .append("//Package[reference('stereotype')[@name='");
0690:                lStringBuffer.append(EnterprisePackageStereotypeName);
0691:                lStringBuffer.append("']]");
0692:                return lStringBuffer.toString();
0693:            }
0694:
0695:            /** Helper. Returns XPath expression able to locate all Enterprise packages */
0696:            public static String getAllEnterpriseModelsXPath()
0697:                    throws ModelRepositoryException {
0698:                StringBuffer lStringBuffer = new StringBuffer(
0699:                        "/Model[reference('stereotype')[@name='");
0700:                lStringBuffer.append(EnterpriseModelStereotypeName);
0701:                lStringBuffer.append("']]");
0702:                return lStringBuffer.toString();
0703:            }
0704:
0705:            /** Helper. Returns XPath expression able to locate required MetaBoss stereotype */
0706:            public static String getMetaBossProfilePackageXPath()
0707:                    throws ModelRepositoryException {
0708:                StringBuffer lStringBuffer = new StringBuffer(
0709:                        getAllEnterpriseModelsXPath());
0710:                lStringBuffer.append("/Package[@name='");
0711:                lStringBuffer.append(MetaBossUMLProfilePackageName);
0712:                lStringBuffer.append("'][reference('stereotype')[@name='");
0713:                lStringBuffer.append(UMLProfilePackageStereotypeName);
0714:                lStringBuffer.append("']]");
0715:                return lStringBuffer.toString();
0716:            }
0717:
0718:            /** Helper. Returns XPath expression able to locate required MetaBoss stereotype */
0719:            public static String getMetaBossProfileStereotypeXPath(
0720:                    String pStereotypeName) throws ModelRepositoryException {
0721:                StringBuffer lStringBuffer = new StringBuffer(
0722:                        getMetaBossProfilePackageXPath());
0723:                lStringBuffer.append("/Stereotype[@name='");
0724:                lStringBuffer.append(pStereotypeName);
0725:                lStringBuffer.append("']");
0726:                return lStringBuffer.toString();
0727:            }
0728:
0729:            /** Helper. Returns XPath expression able to locate required MetaBoss stereotype */
0730:            public static String getMetaBossProfileTagDefinitionXPath(
0731:                    String pTagName) throws ModelRepositoryException {
0732:                StringBuffer lStringBuffer = new StringBuffer(
0733:                        "child::TagDefinition[@name='");
0734:                lStringBuffer.append(pTagName);
0735:                lStringBuffer.append("']");
0736:                return lStringBuffer.toString();
0737:            }
0738:
0739:            /** Helper. Returns XPath expression able to locate all Systems under the given Enterprise packages */
0740:            public static String getAllSystemsXPath(Enterprise pEnterprise)
0741:                    throws ModelRepositoryException {
0742:                StringBuffer lStringBuffer = new StringBuffer(
0743:                        getAllEnterprisesXPath());
0744:                lStringBuffer.append("[@name='");
0745:                lStringBuffer.append(pEnterprise.getName());
0746:                lStringBuffer
0747:                        .append("']//Package[reference('stereotype')[@name='");
0748:                lStringBuffer.append(SystemPackageStereotypeName);
0749:                lStringBuffer.append("']]");
0750:                return lStringBuffer.toString();
0751:            }
0752:
0753:            /** Helper. Returns XPath expression able to locate all Servicemodules under the given Enterprise package */
0754:            public static String getAllServicemodulesXPath(
0755:                    Enterprise pEnterprise) throws ModelRepositoryException {
0756:                StringBuffer lStringBuffer = new StringBuffer(
0757:                        getAllEnterprisesXPath());
0758:                lStringBuffer.append("[@name='");
0759:                lStringBuffer.append(pEnterprise.getName());
0760:                lStringBuffer
0761:                        .append("']//Package[reference('stereotype')[@name='");
0762:                lStringBuffer.append(ServicemodulePackageStereotypeName);
0763:                lStringBuffer.append("']]");
0764:                return lStringBuffer.toString();
0765:            }
0766:
0767:            /** Helper. Returns XPath expression able to locate all Domains under the given Enterprise package */
0768:            public static String getAllDomainsXPath(Enterprise pEnterprise)
0769:                    throws ModelRepositoryException {
0770:                StringBuffer lStringBuffer = new StringBuffer(
0771:                        getAllEnterprisesXPath());
0772:                lStringBuffer.append("[@name='");
0773:                lStringBuffer.append(pEnterprise.getName());
0774:                lStringBuffer
0775:                        .append("']//Package[reference('stereotype')[@name='");
0776:                lStringBuffer.append(DomainPackageStereotypeName);
0777:                lStringBuffer.append("']]");
0778:                return lStringBuffer.toString();
0779:            }
0780:
0781:            /** Helper. Returns XPath expression able to locate all Messages under the given Enterprise package */
0782:            public static String getAllMessagesXPath(Enterprise pEnterprise)
0783:                    throws ModelRepositoryException {
0784:                StringBuffer lStringBuffer = new StringBuffer(
0785:                        getAllEnterprisesXPath());
0786:                lStringBuffer.append("[@name='");
0787:                lStringBuffer.append(pEnterprise.getName());
0788:                lStringBuffer
0789:                        .append("']//Class[reference('stereotype')[@name='");
0790:                lStringBuffer.append(MessageClassStereotypeName);
0791:                lStringBuffer.append("']]");
0792:                return lStringBuffer.toString();
0793:            }
0794:
0795:            /** Helper. Returns XPath expression able to locate all Services under the given Enterprise package */
0796:            public static String getAllServicesXPath(Enterprise pEnterprise)
0797:                    throws ModelRepositoryException {
0798:                StringBuffer lStringBuffer = new StringBuffer(
0799:                        getAllEnterprisesXPath());
0800:                lStringBuffer.append("[@name='");
0801:                lStringBuffer.append(pEnterprise.getName());
0802:                lStringBuffer
0803:                        .append("']//Class[reference('stereotype')[@name='");
0804:                lStringBuffer.append(ServiceClassStereotypeName);
0805:                lStringBuffer.append("']]");
0806:                return lStringBuffer.toString();
0807:            }
0808:
0809:            /** Helper. Returns XPath expression able to locate all Event Subscriptions under the given Enterprise package */
0810:            public static String getAllEventSubscriptionsXPath(
0811:                    Enterprise pEnterprise) throws ModelRepositoryException {
0812:                StringBuffer lStringBuffer = new StringBuffer(
0813:                        getAllEnterprisesXPath());
0814:                lStringBuffer.append("[@name='");
0815:                lStringBuffer.append(pEnterprise.getName());
0816:                lStringBuffer
0817:                        .append("']//Class[reference('stereotype')[@name='");
0818:                lStringBuffer.append(EventSubscriptionClassStereotypeName);
0819:                lStringBuffer.append("']]");
0820:                return lStringBuffer.toString();
0821:            }
0822:
0823:            /** Helper. Returns XPath expression able to locate all Entities under the given Enterprise package */
0824:            public static String getAllEntitiesXPath(Enterprise pEnterprise)
0825:                    throws ModelRepositoryException {
0826:                StringBuffer lStringBuffer = new StringBuffer(
0827:                        getAllDomainsXPath(pEnterprise));
0828:                lStringBuffer.append("/Class[reference('stereotype')[@name='");
0829:                lStringBuffer.append(EntityClassStereotypeName);
0830:                lStringBuffer.append("']]");
0831:                return lStringBuffer.toString();
0832:            }
0833:
0834:            /** Helper. Returns XPath expression able to locate all Generalizations which describe entity inheritance tree under the given Enterprise package */
0835:            public static String getAllEntityGeneralizationsXPath(
0836:                    Enterprise pEnterprise) throws ModelRepositoryException {
0837:                StringBuffer lStringBuffer = new StringBuffer(
0838:                        getAllDomainsXPath(pEnterprise));
0839:                lStringBuffer
0840:                        .append("/Generalization[reference('child')[reference('stereotype')[@name='");
0841:                lStringBuffer.append(EntityClassStereotypeName);
0842:                lStringBuffer
0843:                        .append("']]][reference('parent')[reference('stereotype')[@name='");
0844:                lStringBuffer.append(EntityClassStereotypeName);
0845:                lStringBuffer.append("']]]");
0846:                return lStringBuffer.toString();
0847:            }
0848:
0849:            /** Helper. Returns XPath expression able to locate all Associations which describe inter-entity associations under the given Enterprise package */
0850:            public static String getAllEntityAssociationsXPath(
0851:                    Enterprise pEnterprise) throws ModelRepositoryException {
0852:                StringBuffer lStringBuffer = new StringBuffer(
0853:                        getAllDomainsXPath(pEnterprise));
0854:                lStringBuffer
0855:                        .append("/Association[AssociationEnd[1][reference('stereotype')[@name='");
0856:                lStringBuffer.append(AssociationRoleStereotypeName);
0857:                lStringBuffer
0858:                        .append("']]][AssociationEnd[2][reference('stereotype')[@name='");
0859:                lStringBuffer.append(AssociationRoleStereotypeName);
0860:                lStringBuffer.append("']]]");
0861:                return lStringBuffer.toString();
0862:            }
0863:
0864:            /** Helper. Returns XPath expression able to locate all UML Operations which describe entity selctors under the given Enterprise package */
0865:            public static String getAllEntitySelectorsXPath(
0866:                    Enterprise pEnterprise) throws ModelRepositoryException {
0867:                StringBuffer lStringBuffer = new StringBuffer(
0868:                        getAllEntitiesXPath(pEnterprise));
0869:                lStringBuffer
0870:                        .append("/Operation[reference('stereotype')[@name='");
0871:                lStringBuffer.append(EntitySelectorStereotypeName);
0872:                lStringBuffer.append("']]");
0873:                return lStringBuffer.toString();
0874:            }
0875:
0876:            /** Helper. Returns XPath expression able to locate all UML StateMachines which describe entity state machines under the given Enterprise package */
0877:            public static String getAllEntityStateMachinesXPath(
0878:                    Enterprise pEnterprise) throws ModelRepositoryException {
0879:                // Allow state macines to be present anywhere in the model.
0880:                // When we convert MetaBoss model to UML we prefer that the entity owns its own state machine
0881:                // In UML specification this ownership is optional, so it is possible to have a StateMachine directly
0882:                // owned by the model but in reality describing the behaviour of the particular entity
0883:                StringBuffer lStringBuffer = new StringBuffer(
0884:                        "//StateMachine[reference('context')[count(intersection(evaluate(\"");
0885:                lStringBuffer.append(getAllEntitiesXPath(pEnterprise));
0886:                lStringBuffer.append("\"))) = 1]]");
0887:                return lStringBuffer.toString();
0888:            }
0889:
0890:            /** Helper. Returns XPath expression able to locate all Entitity attributes under the given Enterprise package */
0891:            public static String getAllAttributesXPath(Enterprise pEnterprise)
0892:                    throws ModelRepositoryException {
0893:                StringBuffer lStringBuffer = new StringBuffer(
0894:                        getAllEntitiesXPath(pEnterprise));
0895:                lStringBuffer
0896:                        .append("/Attribute[reference('stereotype')[@name='");
0897:                lStringBuffer.append(EntityAttributeStereotypeName);
0898:                lStringBuffer.append("']]");
0899:                return lStringBuffer.toString();
0900:            }
0901:
0902:            /** Helper. Returns XPath expression able to locate all Message fields under the given Enterprise package */
0903:            public static String getAllMessageFieldsXPath(Enterprise pEnterprise)
0904:                    throws ModelRepositoryException {
0905:                StringBuffer lStringBuffer = new StringBuffer(
0906:                        getAllMessagesXPath(pEnterprise));
0907:                lStringBuffer.append("/Attribute");
0908:                return lStringBuffer.toString();
0909:            }
0910:
0911:            /** Helper. Returns XPath expression able to locate all Structure fields under the given Enterprise package */
0912:            public static String getAllStructureFieldsXPath(
0913:                    Enterprise pEnterprise) throws ModelRepositoryException {
0914:                StringBuffer lStringBuffer = new StringBuffer(
0915:                        getAllEnterprisesXPath());
0916:                lStringBuffer.append("[@name='");
0917:                lStringBuffer.append(pEnterprise.getName());
0918:                lStringBuffer
0919:                        .append("']//Class[reference('stereotype')[@name='");
0920:                lStringBuffer.append(StructureClassStereotypeName);
0921:                lStringBuffer.append("']]/Attribute");
0922:                return lStringBuffer.toString();
0923:            }
0924:
0925:            /** Helper. Returns XPath expression able to locate all Operations fields under the given Enterprise package */
0926:            public static String getAllOperationsXPath(Enterprise pEnterprise)
0927:                    throws ModelRepositoryException {
0928:                StringBuffer lStringBuffer = new StringBuffer(
0929:                        getAllEnterprisesXPath());
0930:                lStringBuffer.append("[@name='");
0931:                lStringBuffer.append(pEnterprise.getName());
0932:                lStringBuffer
0933:                        .append("']//Class[reference('stereotype')[@name='");
0934:                lStringBuffer.append(ServiceClassStereotypeName);
0935:                lStringBuffer.append("']]/Operation");
0936:                return lStringBuffer.toString();
0937:            }
0938:
0939:            /** Helper. Returns XPath expression able to locate all Operations fields under the given Enterprise package */
0940:            public static String getAllEventSubscriptionOperationsXPath(
0941:                    Enterprise pEnterprise) throws ModelRepositoryException {
0942:                StringBuffer lStringBuffer = new StringBuffer(
0943:                        getAllEnterprisesXPath());
0944:                lStringBuffer.append("[@name='");
0945:                lStringBuffer.append(pEnterprise.getName());
0946:                lStringBuffer
0947:                        .append("']//Class[reference('stereotype')[@name='");
0948:                lStringBuffer.append(EventSubscriptionClassStereotypeName);
0949:                lStringBuffer
0950:                        .append("']]/Operation[reference('stereotype')[@name='");
0951:                lStringBuffer.append(EventSubscriptionOperationStereotypeName);
0952:                lStringBuffer.append("']]");
0953:                return lStringBuffer.toString();
0954:            }
0955:
0956:            /** Helper. Returns XPath expression able to locate all Events fields under the given Enterprise package */
0957:            public static String getAllEventsXPath(Enterprise pEnterprise)
0958:                    throws ModelRepositoryException {
0959:                StringBuffer lStringBuffer = new StringBuffer(
0960:                        getAllEnterprisesXPath());
0961:                lStringBuffer.append("[@name='");
0962:                lStringBuffer.append(pEnterprise.getName());
0963:                lStringBuffer
0964:                        .append("']//Class[reference('stereotype')[@name='");
0965:                lStringBuffer.append(EventSubscriptionClassStereotypeName);
0966:                lStringBuffer
0967:                        .append("']]/Operation[reference('stereotype')[@name='");
0968:                lStringBuffer.append(EventSubscriptionEventStereotypeName);
0969:                lStringBuffer.append("']]");
0970:                return lStringBuffer.toString();
0971:            }
0972:
0973:            /** Helper. Returns XPath expression able to locate all Operations fields under the given Enterprise package */
0974:            public static String getAllEventSubscriptionEventsXPath(
0975:                    Enterprise pEnterprise) throws ModelRepositoryException {
0976:                StringBuffer lStringBuffer = new StringBuffer(
0977:                        getAllEnterprisesXPath());
0978:                lStringBuffer.append("[@name='");
0979:                lStringBuffer.append(pEnterprise.getName());
0980:                lStringBuffer
0981:                        .append("']//Class[reference('stereotype')[@name='");
0982:                lStringBuffer.append(EventSubscriptionClassStereotypeName);
0983:                lStringBuffer
0984:                        .append("']]/Operation[reference('stereotype')[@name='");
0985:                lStringBuffer.append(EventSubscriptionEventStereotypeName);
0986:                lStringBuffer.append("']]");
0987:                return lStringBuffer.toString();
0988:            }
0989:
0990:            /** Helper. Returns XPath expression able to locate all Structures under the given Enterprise package */
0991:            public static String getAllStructuresXPath(Enterprise pEnterprise)
0992:                    throws ModelRepositoryException {
0993:                StringBuffer lStringBuffer = new StringBuffer(
0994:                        getAllEnterprisesXPath());
0995:                lStringBuffer.append("[@name='");
0996:                lStringBuffer.append(pEnterprise.getName());
0997:                lStringBuffer
0998:                        .append("']//Class[reference('stereotype')[@name='");
0999:                lStringBuffer.append(StructureClassStereotypeName);
1000:                lStringBuffer.append("']]");
1001:                return lStringBuffer.toString();
1002:            }
1003:
1004:            /** Helper. Returns XPath expression able to locate all Design Libraries under the given Enterprise packages */
1005:            public static String getAllDesignLibrariesXPath(
1006:                    Enterprise pEnterprise) throws ModelRepositoryException {
1007:                StringBuffer lStringBuffer = new StringBuffer(
1008:                        getAllEnterprisesXPath());
1009:                lStringBuffer.append("[@name='");
1010:                lStringBuffer.append(pEnterprise.getName());
1011:                lStringBuffer
1012:                        .append("']//Package[reference('stereotype')[@name='");
1013:                lStringBuffer.append(DesignLibraryPackageStereotypeName);
1014:                lStringBuffer.append("']]");
1015:                return lStringBuffer.toString();
1016:            }
1017:
1018:            /** Helper. Returns XPath expression able to locate all Data Dictionaries under the Design Library package */
1019:            public static String getAllDataDictionariesXPath(
1020:                    DesignLibrary pDesignLibrary)
1021:                    throws ModelRepositoryException {
1022:                StringBuffer lStringBuffer = new StringBuffer(
1023:                        getAllDesignLibrariesXPath(pDesignLibrary
1024:                                .getEnterprise()));
1025:                lStringBuffer
1026:                        .append("//Package[reference('stereotype')[@name='");
1027:                lStringBuffer.append(DataDictionaryPackageStereotypeName);
1028:                lStringBuffer.append("']]");
1029:                return lStringBuffer.toString();
1030:            }
1031:
1032:            /** Helper. Returns XPath expression able to locate all System Data Dictionaries in the Enterprise */
1033:            public static String getAllSystemDataDictionariesXPath(
1034:                    Enterprise pEnterprise) throws ModelRepositoryException {
1035:                StringBuffer lStringBuffer = new StringBuffer(
1036:                        getAllSystemsXPath(pEnterprise));
1037:                lStringBuffer
1038:                        .append("//Package[reference('stereotype')[@name='");
1039:                lStringBuffer.append(DataDictionaryPackageStereotypeName);
1040:                lStringBuffer.append("']]");
1041:                return lStringBuffer.toString();
1042:            }
1043:
1044:            /** Helper. Returns XPath expression able to locate all Data Dictionaries under the System  package */
1045:            public static String getAllDataDictionariesXPath(
1046:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
1047:                    throws ModelRepositoryException {
1048:                StringBuffer lStringBuffer = new StringBuffer(
1049:                        getAllSystemsXPath(pSystem.getEnterprise()));
1050:                lStringBuffer.append("[@name='");
1051:                lStringBuffer.append(pSystem.getName());
1052:                lStringBuffer
1053:                        .append("']//Package[reference('stereotype')[@name='");
1054:                lStringBuffer.append(DataDictionaryPackageStereotypeName);
1055:                lStringBuffer.append("']]");
1056:                return lStringBuffer.toString();
1057:            }
1058:
1059:            /** Helper. Returns XPath expression able to locate all TypeTemplates under the Data Dictionary package */
1060:            public static String getAllTypetemplatesXPath(
1061:                    DataDictionary pDataDictionary)
1062:                    throws ModelRepositoryException {
1063:                StringBuffer lStringBuffer = new StringBuffer(
1064:                        pDataDictionary.getSystem() != null ? getAllDataDictionariesXPath(pDataDictionary
1065:                                .getSystem())
1066:                                : getAllDataDictionariesXPath(pDataDictionary
1067:                                        .getDesignLibrary()));
1068:                lStringBuffer.append("//Class[reference('stereotype')[@name='");
1069:                lStringBuffer.append(TypeTemplateClassStereotypeName);
1070:                lStringBuffer.append("']]");
1071:                return lStringBuffer.toString();
1072:            }
1073:
1074:            /** Helper. Returns XPath expression able to locate all DataTypes under the Data Dictionary package */
1075:            public static String getAllDataTypesXPath(
1076:                    DataDictionary pDataDictionary)
1077:                    throws ModelRepositoryException {
1078:                StringBuffer lStringBuffer = new StringBuffer(
1079:                        pDataDictionary.getSystem() != null ? getAllDataDictionariesXPath(pDataDictionary
1080:                                .getSystem())
1081:                                : getAllDataDictionariesXPath(pDataDictionary
1082:                                        .getDesignLibrary()));
1083:                lStringBuffer.append("//DataType");
1084:                return lStringBuffer.toString();
1085:            }
1086:
1087:            /** Helper. Returns XPath expression able to locate all DataTypes under the Data Dictionary package */
1088:            public static String getAllDataTypeTemplateBindingsXPath(
1089:                    DataType pDataType) throws ModelRepositoryException {
1090:                StringBuffer lStringBuffer = new StringBuffer(
1091:                        getDataTypeXPath(pDataType));
1092:                lStringBuffer
1093:                        .append("/Binding[reference('argument')[reference('modelElement')[reference('stereotype')[@name='");
1094:                lStringBuffer.append(GenericArgumentStereotypeName);
1095:                lStringBuffer.append("']]]]");
1096:                return lStringBuffer.toString();
1097:            }
1098:
1099:            /** Helper. Returns XPath expression able to locate given System package */
1100:            public static String getSystemXPath(
1101:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
1102:                    throws ModelRepositoryException {
1103:                StringBuffer lStringBuffer = new StringBuffer(
1104:                        getEnterpriseXPath(pSystem.getEnterprise()));
1105:                // Add system
1106:                lStringBuffer.append("/Package[@name='");
1107:                lStringBuffer.append(pSystem.getName());
1108:                lStringBuffer.append("']");
1109:                return lStringBuffer.toString();
1110:            }
1111:
1112:            /** Helper. Returns XPath expression able to locate owner Enterprise package */
1113:            public static String getOwnerEnterpriseXPath()
1114:                    throws ModelRepositoryException {
1115:                StringBuffer lStringBuffer = new StringBuffer();
1116:                // Add system
1117:                lStringBuffer
1118:                        .append("ancestor-or-self::Package[reference('stereotype')[@name='");
1119:                lStringBuffer.append(EnterprisePackageStereotypeName);
1120:                lStringBuffer.append("']]");
1121:                return lStringBuffer.toString();
1122:            }
1123:
1124:            /** Helper. Returns XPath expression able to locate owner System package */
1125:            public static String getOwnerSystemXPath()
1126:                    throws ModelRepositoryException {
1127:                StringBuffer lStringBuffer = new StringBuffer();
1128:                // Add system
1129:                lStringBuffer
1130:                        .append("ancestor-or-self::Package[reference('stereotype')[@name='");
1131:                lStringBuffer.append(SystemPackageStereotypeName);
1132:                lStringBuffer.append("']]");
1133:                return lStringBuffer.toString();
1134:            }
1135:
1136:            /** Helper. Returns XPath expression able to locate owner DesignLibrary package */
1137:            public static String getOwnerDesignLibraryXPath()
1138:                    throws ModelRepositoryException {
1139:                StringBuffer lStringBuffer = new StringBuffer();
1140:                // Add system
1141:                lStringBuffer
1142:                        .append("ancestor-or-self::Package[reference('stereotype')[@name='");
1143:                lStringBuffer.append(DesignLibraryPackageStereotypeName);
1144:                lStringBuffer.append("']]");
1145:                return lStringBuffer.toString();
1146:            }
1147:
1148:            /** Helper. Returns XPath expression able to locate owner DataDictionary package */
1149:            public static String getOwnerDataDictionaryXPath()
1150:                    throws ModelRepositoryException {
1151:                StringBuffer lStringBuffer = new StringBuffer();
1152:                // Add system
1153:                lStringBuffer
1154:                        .append("ancestor-or-self::Package[reference('stereotype')[@name='");
1155:                lStringBuffer.append(DataDictionaryPackageStereotypeName);
1156:                lStringBuffer.append("']]");
1157:                return lStringBuffer.toString();
1158:            }
1159:
1160:            /** Helper. Returns XPath expression able to locate owner Domain package */
1161:            public static String getOwnerDomainXPath()
1162:                    throws ModelRepositoryException {
1163:                StringBuffer lStringBuffer = new StringBuffer();
1164:                // Add system
1165:                lStringBuffer
1166:                        .append("ancestor-or-self::Package[reference('stereotype')[@name='");
1167:                lStringBuffer.append(DomainPackageStereotypeName);
1168:                lStringBuffer.append("']]");
1169:                return lStringBuffer.toString();
1170:            }
1171:
1172:            /** Helper. Returns XPath expression able to locate owned Binding association */
1173:            public static String getClientBindingXPath()
1174:                    throws ModelRepositoryException {
1175:                StringBuffer lStringBuffer = new StringBuffer();
1176:                lStringBuffer
1177:                        .append("self::node()[reference('clientDependency')]/Binding");
1178:                return lStringBuffer.toString();
1179:            }
1180:
1181:            /** Helper. Returns XPath expression able to locate owner Servicemodule package */
1182:            public static String getOwnerServicemoduleXPath()
1183:                    throws ModelRepositoryException {
1184:                StringBuffer lStringBuffer = new StringBuffer();
1185:                // Add system
1186:                lStringBuffer
1187:                        .append("ancestor-or-self::Package[reference('stereotype')[@name='");
1188:                lStringBuffer.append(ServicemodulePackageStereotypeName);
1189:                lStringBuffer.append("']]");
1190:                return lStringBuffer.toString();
1191:            }
1192:
1193:            /** Helper. Returns XPath expression able to locate given System Public Interfaces package */
1194:            public static String getSystemPublicInterfacesXPath(
1195:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
1196:                    throws ModelRepositoryException {
1197:                StringBuffer lStringBuffer = new StringBuffer(
1198:                        getSystemXPath(pSystem));
1199:                // Add public interfaces
1200:                lStringBuffer.append("/Package[@name='");
1201:                lStringBuffer.append(mSystemPublicInterfacesPackageName);
1202:                lStringBuffer.append("']");
1203:                return lStringBuffer.toString();
1204:            }
1205:
1206:            /** Helper. Returns XPath expression able to locate given System Implementation Components package */
1207:            public static String getSystemImplementationComponentsXPath(
1208:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
1209:                    throws ModelRepositoryException {
1210:                StringBuffer lStringBuffer = new StringBuffer(
1211:                        getSystemXPath(pSystem));
1212:                // Add public interfaces
1213:                lStringBuffer.append("/Package[@name='");
1214:                lStringBuffer
1215:                        .append(mSystemImplementationComponentsPackageName);
1216:                lStringBuffer.append("']");
1217:                return lStringBuffer.toString();
1218:            }
1219:
1220:            /** Helper. Returns XPath expression able to locate given System Servicemodules package */
1221:            public static String getSystemServicemodulesXPath(
1222:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
1223:                    throws ModelRepositoryException {
1224:                StringBuffer lStringBuffer = new StringBuffer(
1225:                        getSystemPublicInterfacesXPath(pSystem));
1226:                // Add servciemodules
1227:                lStringBuffer.append("/Package[@name='");
1228:                lStringBuffer.append(mSystemServicemodulesPackageName);
1229:                lStringBuffer.append("']");
1230:                return lStringBuffer.toString();
1231:            }
1232:
1233:            /** Helper. Returns XPath expression able to locate given Servicemodule package */
1234:            public static String getServicemoduleXPath(
1235:                    Servicemodule pServicemodule)
1236:                    throws ModelRepositoryException {
1237:                StringBuffer lStringBuffer = new StringBuffer(
1238:                        getSystemServicemodulesXPath(pServicemodule.getSystem()));
1239:                // Add servciemodules
1240:                lStringBuffer.append("/Package[@name='");
1241:                lStringBuffer.append(pServicemodule.getName());
1242:                lStringBuffer.append("']");
1243:                return lStringBuffer.toString();
1244:            }
1245:
1246:            /** Helper. Returns XPath expression able to locate given Servicemodule Messages package */
1247:            public static String getServicemoduleMessagesXPath(
1248:                    Servicemodule pServicemodule)
1249:                    throws ModelRepositoryException {
1250:                StringBuffer lStringBuffer = new StringBuffer(
1251:                        getServicemoduleXPath(pServicemodule));
1252:                // Add servciemodules
1253:                lStringBuffer.append("/Package[@name='");
1254:                lStringBuffer.append(mServicemoduleMessagesPackageName);
1255:                lStringBuffer.append("']");
1256:                return lStringBuffer.toString();
1257:            }
1258:
1259:            /** Helper. Returns XPath expression able to locate given Servicemodule Structures package */
1260:            public static String getServicemoduleStructuresXPath(
1261:                    Servicemodule pServicemodule)
1262:                    throws ModelRepositoryException {
1263:                StringBuffer lStringBuffer = new StringBuffer(
1264:                        getServicemoduleXPath(pServicemodule));
1265:                // Add servciemodules
1266:                lStringBuffer.append("/Package[@name='");
1267:                lStringBuffer.append(mServicemoduleStructuresPackageName);
1268:                lStringBuffer.append("']");
1269:                return lStringBuffer.toString();
1270:            }
1271:
1272:            /** Helper. Returns XPath expression able to locate given Servicemodule Services package */
1273:            public static String getServicemoduleServicesXPath(
1274:                    Servicemodule pServicemodule)
1275:                    throws ModelRepositoryException {
1276:                StringBuffer lStringBuffer = new StringBuffer(
1277:                        getServicemoduleXPath(pServicemodule));
1278:                // Add servciemodules
1279:                lStringBuffer.append("/Package[@name='");
1280:                lStringBuffer.append(mServicemoduleServicesPackageName);
1281:                lStringBuffer.append("']");
1282:                return lStringBuffer.toString();
1283:            }
1284:
1285:            /** Helper. Returns XPath expression able to locate given Servicemodule Event Subscriptions package */
1286:            public static String getServicemoduleEventSubscriptionsXPath(
1287:                    Servicemodule pServicemodule)
1288:                    throws ModelRepositoryException {
1289:                StringBuffer lStringBuffer = new StringBuffer(
1290:                        getServicemoduleXPath(pServicemodule));
1291:                // Add servciemodules
1292:                lStringBuffer.append("/Package[@name='");
1293:                lStringBuffer
1294:                        .append(mServicemoduleEventSubscriptionsPackageName);
1295:                lStringBuffer.append("']");
1296:                return lStringBuffer.toString();
1297:            }
1298:
1299:            /** Helper. Returns XPath expression able to locate given Structure class */
1300:            public static String getStructureXPath(Structure pStructure)
1301:                    throws ModelRepositoryException {
1302:                StringBuffer lStringBuffer = new StringBuffer();
1303:                Servicemodule lStructureServicemodule = pStructure
1304:                        .getServicemodule();
1305:                AbstractNamespace lStructureNamespace = pStructure
1306:                        .getNamespace();
1307:                if (lStructureServicemodule != null)
1308:                    lStringBuffer
1309:                            .append(getServicemoduleStructuresXPath(lStructureServicemodule));
1310:                else if (lStructureNamespace != null)
1311:                    lStringBuffer
1312:                            .append(getNamespaceXPath(lStructureNamespace));
1313:                else
1314:                    throw new ModelRepositoryException(
1315:                            "Structure must be contained inside Servicemodule or Namespace. StructureRef: "
1316:                                    + pStructure.getRef());
1317:                // Add servciemodules
1318:                lStringBuffer.append("/Class[@name='");
1319:                lStringBuffer.append(pStructure.getName());
1320:                lStringBuffer.append("']");
1321:                return lStringBuffer.toString();
1322:            }
1323:
1324:            /** Helper. Returns XPath expression able to locate given Entity class */
1325:            public static String getEntityXPath(Entity pEntity)
1326:                    throws ModelRepositoryException {
1327:                StringBuffer lStringBuffer = new StringBuffer(
1328:                        getDomainXPath(pEntity.getDomain()));
1329:                // Add servciemodules
1330:                lStringBuffer.append("/Class[@name='");
1331:                lStringBuffer.append(pEntity.getName());
1332:                lStringBuffer.append("']");
1333:                return lStringBuffer.toString();
1334:            }
1335:
1336:            /** Helper. Returns XPath expression able to locate given StateMachine class */
1337:            public static String getStateMachineXPath(StateMachine pStateMachine)
1338:                    throws ModelRepositoryException {
1339:                // Allow state macines to be present anywhere in the model.
1340:                // When we convert MetaBoss model to UML we prefer that the entity owns its own state machine
1341:                // In UML specification this ownership is optional, so it is possible to have a StateMachine directly
1342:                // owned by the model but in reality describing the behaviour of the particular entity
1343:                StringBuffer lStringBuffer = new StringBuffer(
1344:                        "//StateMachine[reference('context')[count(intersection(evaluate(\"");
1345:                lStringBuffer.append(getEntityXPath(pStateMachine.getEntity()));
1346:                lStringBuffer.append("\"))) = 1]]");
1347:                return lStringBuffer.toString();
1348:            }
1349:
1350:            /** Helper. Returns XPath expression able to locate given State class */
1351:            public static String getStateXPath(State pState)
1352:                    throws ModelRepositoryException {
1353:                StringBuffer lStringBuffer = new StringBuffer(
1354:                        getStateMachineXPath(pState.getStateMachine()));
1355:                // Add statemachine
1356:                lStringBuffer
1357:                        .append("[reference('top')]/CompositeState[reference('subvertex')]/*[@name='");
1358:                lStringBuffer.append(pState.getName());
1359:                lStringBuffer.append("']");
1360:                return lStringBuffer.toString();
1361:            }
1362:
1363:            /** Helper. Returns XPath expression able to locate given Domain class */
1364:            public static String getDomainXPath(Domain pDomain)
1365:                    throws ModelRepositoryException {
1366:                StringBuffer lStringBuffer = new StringBuffer(
1367:                        getSystemImplementationComponentsXPath(pDomain
1368:                                .getSystem()));
1369:                // Add servciemodules
1370:                lStringBuffer.append("/Package[@name='");
1371:                lStringBuffer.append(pDomain.getName());
1372:                lStringBuffer.append("']");
1373:                return lStringBuffer.toString();
1374:            }
1375:
1376:            /** Helper. Returns XPath expression able to locate given Message class */
1377:            public static String getMessageXPath(Message pMessage)
1378:                    throws ModelRepositoryException {
1379:                StringBuffer lStringBuffer = new StringBuffer();
1380:                Servicemodule lMessageServicemodule = pMessage
1381:                        .getServicemodule();
1382:                AbstractNamespace lMessageNamespace = pMessage.getNamespace();
1383:                if (lMessageServicemodule != null)
1384:                    lStringBuffer
1385:                            .append(getServicemoduleMessagesXPath(lMessageServicemodule));
1386:                else if (lMessageNamespace != null)
1387:                    lStringBuffer.append(getNamespaceXPath(lMessageNamespace));
1388:                else
1389:                    throw new ModelRepositoryException(
1390:                            "Message must be contained inside Servicemodule or Namespace. MessageRef: "
1391:                                    + pMessage.getRef());
1392:                // Add servciemodules
1393:                lStringBuffer.append("/Class[@name='");
1394:                lStringBuffer.append(pMessage.getName());
1395:                lStringBuffer.append("']");
1396:                return lStringBuffer.toString();
1397:            }
1398:
1399:            /** Helper. Returns XPath expression able to locate the xpath for the value of the given Tag */
1400:            public static String getModelElementTagValueXPath(String pTagName)
1401:                    throws ModelRepositoryException {
1402:                StringBuffer lStringBuffer = new StringBuffer(
1403:                        "child::TaggedValue[reference('type')[@name='");
1404:                lStringBuffer.append(pTagName);
1405:                lStringBuffer.append("']]/@dataValue");
1406:                return lStringBuffer.toString();
1407:            }
1408:
1409:            /** Helper. Returns XPath expression able to locate given Stereotype class */
1410:            public static String getStereotypeXPath(String pStereotypeName)
1411:                    throws ModelRepositoryException {
1412:                StringBuffer lStringBuffer = new StringBuffer("/Model[@name='");
1413:                lStringBuffer.append(mModelName);
1414:                lStringBuffer.append("']");
1415:                lStringBuffer.append("/Package[@name='");
1416:                lStringBuffer.append(MetaBossUMLProfilePackageName);
1417:                lStringBuffer.append("']");
1418:                lStringBuffer.append("/Stereotype[@name='");
1419:                lStringBuffer.append(pStereotypeName);
1420:                lStringBuffer.append("']");
1421:                return lStringBuffer.toString();
1422:            }
1423:
1424:            // Helper. Returns UML Class corresponding to the given Model Element or null if none found
1425:            private static org.omg.uml.foundation.core.Stereotype getMetaBossProfileStereotype(
1426:                    ModelRepository pModelRepository,
1427:                    org.omg.uml.UmlPackage pUmlModelExtent,
1428:                    String pStereotypeName) throws ModelRepositoryException {
1429:                try {
1430:                    List lSearchResults = pModelRepository.searchByXPath(
1431:                            pUmlModelExtent,
1432:                            getMetaBossProfileStereotypeXPath(pStereotypeName));
1433:                    if (lSearchResults.isEmpty() || lSearchResults.size() != 1)
1434:                        throw new ConstraintViolationException(
1435:                                null,
1436:                                null,
1437:                                "Missing required stereotype definition in profile. The MetaBoss UML Profile must have definition for the '"
1438:                                        + pStereotypeName + "' stereotype.");
1439:                    return (org.omg.uml.foundation.core.Stereotype) lSearchResults
1440:                            .get(0);
1441:                } catch (ConstraintViolationException e) {
1442:                    throw new ModelValidationException(
1443:                            "Error encountered while loading the '"
1444:                                    + pStereotypeName
1445:                                    + "' stereotype definition", e);
1446:                }
1447:            }
1448:
1449:            // Helper. Creates required stereotype in the given package
1450:            private static org.omg.uml.foundation.core.Stereotype createMetaBossProfileStereotype(
1451:                    org.omg.uml.modelmanagement.UmlPackage pProfilePackage,
1452:                    String pStereotypeName, String pBaseClassName)
1453:                    throws ModelRepositoryException {
1454:                org.omg.uml.foundation.core.Stereotype lStereotype = ((org.omg.uml.UmlPackage) pProfilePackage
1455:                        .refOutermostPackage()).getCore().getStereotype()
1456:                        .createStereotype();
1457:                lStereotype.setName(pStereotypeName);
1458:                lStereotype.setNamespace(pProfilePackage);
1459:                lStereotype
1460:                        .setVisibility(org.omg.uml.foundation.datatypes.VisibilityKindEnum.VK_PUBLIC);
1461:                lStereotype.getBaseClass().add(pBaseClassName);
1462:                return lStereotype;
1463:            }
1464:
1465:            // Helper. Returns UML Class corresponding to the given Model Element or null if none found
1466:            private static org.omg.uml.foundation.core.TagDefinition getMetaBossProfileTagDefinition(
1467:                    ModelRepository pModelRepository,
1468:                    org.omg.uml.foundation.core.Stereotype pTagOwner,
1469:                    String pTagName) throws ModelRepositoryException {
1470:                try {
1471:                    List lSearchResults = pModelRepository.searchByXPath(
1472:                            pTagOwner,
1473:                            getMetaBossProfileTagDefinitionXPath(pTagName));
1474:                    if (lSearchResults.isEmpty() || lSearchResults.size() != 1)
1475:                        throw new ConstraintViolationException(
1476:                                null,
1477:                                null,
1478:                                "Missing required tag definition in profile. The MetaBoss UML Profile must have definition for the '"
1479:                                        + pTagName
1480:                                        + "' tag owned by '"
1481:                                        + pTagOwner.getName() + "' stereotype.");
1482:                    return (org.omg.uml.foundation.core.TagDefinition) lSearchResults
1483:                            .get(0);
1484:                } catch (ConstraintViolationException e) {
1485:                    throw new ModelValidationException(
1486:                            "Error encountered while loading the '" + pTagName
1487:                                    + "' tag definition for the '"
1488:                                    + pTagOwner.getName() + "' stereotype.", e);
1489:                }
1490:            }
1491:
1492:            // Helper. Creates required singilar tag definition (can only be attached once) owned by the given stereotype
1493:            private static org.omg.uml.foundation.core.TagDefinition createSingleOptionalTagDefinition(
1494:                    org.omg.uml.foundation.core.Stereotype pOwnerStereotype,
1495:                    String pTagName) throws ModelRepositoryException {
1496:                org.omg.uml.foundation.core.TagDefinition lTagDefinition = ((org.omg.uml.foundation.core.CorePackage) pOwnerStereotype
1497:                        .refImmediatePackage()).getTagDefinition()
1498:                        .createTagDefinition();
1499:                lTagDefinition.setName(pTagName);
1500:                lTagDefinition.setOwner(pOwnerStereotype);
1501:                lTagDefinition.setMultiplicity(UMLUtils
1502:                        .createMultiplicityInstance(
1503:                                (org.omg.uml.UmlPackage) pOwnerStereotype
1504:                                        .refOutermostPackage(), 0, 1));
1505:                return lTagDefinition;
1506:            }
1507:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.