Source Code Cross Referenced for BSCodeGenerationStylesheetImpl.java in  » UML » MetaBoss » com » metaboss » sdlctools » services » codegenerationstylesheet » defaultstyleimpl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » MetaBoss » com.metaboss.sdlctools.services.codegenerationstylesheet.defaultstyleimpl 
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.services.codegenerationstylesheet.defaultstyleimpl;
0016:
0017:        import java.io.File;
0018:        import java.io.IOException;
0019:        import java.io.PrintWriter;
0020:        import java.io.StringWriter;
0021:        import java.util.HashMap;
0022:
0023:        import javax.naming.Context;
0024:        import javax.naming.InitialContext;
0025:
0026:        import com.metaboss.enterprise.bo.BOException;
0027:        import com.metaboss.enterprise.bs.BSException;
0028:        import com.metaboss.enterprise.bs.BSIllegalArgumentException;
0029:        import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
0030:        import com.metaboss.enterprise.bs.BSUnexpectedProgramConditionException;
0031:        import com.metaboss.enterprise.datatypes.DataTypeTranslationMetadata;
0032:        import com.metaboss.sdlctools.models.ModelRepository;
0033:        import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
0034:        import com.metaboss.sdlctools.models.metabossmodel.ModelElementClass;
0035:        import com.metaboss.sdlctools.models.metabossmodel.ModelVersion;
0036:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.AbstractNamespace;
0037:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
0038:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
0039:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataTypeUtils;
0040:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Namespace;
0041:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
0042:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.StructureField;
0043:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.TypeTemplate;
0044:        import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
0045:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
0046:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Event;
0047:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventDataField;
0048:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventMessageField;
0049:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventSubscription;
0050:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventSubscriptionOperation;
0051:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
0052:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.MessageField;
0053:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Operation;
0054:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationInputField;
0055:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationOutputField;
0056:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationOutputMessage;
0057:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
0058:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
0059:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Association;
0060:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
0061:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
0062:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
0063:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
0064:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Report;
0065:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ReportOutputElement;
0066:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorInputField;
0067:        import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.TechnologyLibrary;
0068:        import com.metaboss.sdlctools.services.codegeneration.CopyrightUtils;
0069:        import com.metaboss.sdlctools.services.codegenerationstylesheet.BSCodeGenerationStylesheet;
0070:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STAssociationRoleStylesheet;
0071:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STAssociationStylesheet;
0072:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STAttributeStylesheet;
0073:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDataDictionaryStylesheet;
0074:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDatatypeStylesheet;
0075:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDatatypeTranslationStylesheet;
0076:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDesignLibraryStylesheet;
0077:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDocumentationStylesheet;
0078:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDomainStylesheet;
0079:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEnterpriseStylesheet;
0080:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEntityStylesheet;
0081:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEventDataFieldStylesheet;
0082:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEventMessageFieldStylesheet;
0083:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEventStylesheet;
0084:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEventSubscriptionOperationStylesheet;
0085:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEventSubscriptionStylesheet;
0086:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STMessageFieldStylesheet;
0087:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STMessageStylesheet;
0088:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STNamespaceStylesheet;
0089:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STOperationInputFieldStylesheet;
0090:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STOperationOutputFieldStylesheet;
0091:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STOperationOutputMessageStylesheet;
0092:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STOperationStylesheet;
0093:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STReportOutputElementStylesheet;
0094:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STReportStylesheet;
0095:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STSelectorInputFieldStylesheet;
0096:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STServiceStylesheet;
0097:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STServicemoduleStylesheet;
0098:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STStructureFieldStylesheet;
0099:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STStructureStylesheet;
0100:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STSystemStylesheet;
0101:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STTypeTemplateStylesheet;
0102:        import com.metaboss.util.StringUtils;
0103:
0104:        // The default implementation of the coding stylesheet
0105:        public class BSCodeGenerationStylesheetImpl implements 
0106:                BSCodeGenerationStylesheet {
0107:            // This is the model repository we will use
0108:            private ModelRepository mModelRepository = null;
0109:            private Object mModelRepositoryCreationSemaphore = new Object();
0110:            // This is the stylesheet service we use ourselves. It can not be initialised in
0111:            // constructor because of possible circular creation and stack overflow
0112:            private BSCodeGenerationStylesheet mStylesheetService = null; // The styleshet service we use ourselves
0113:            private Object mStylesheetServiceCreationSemaphore = new Object();
0114:
0115:            /* Returns the stylesheet which describes names pertained to the system */
0116:            public BSCodeGenerationStylesheet.STGetEnterpriseStylesheetResult getEnterpriseStylesheet(
0117:                    BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput pInput)
0118:                    throws BSException {
0119:                try {
0120:                    // Get access to required model elements
0121:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0122:                            .getDefaultModelExtent();
0123:                    Enterprise lEnterprise = (Enterprise) lMetaBossModelPackage
0124:                            .getModelElement().getByRef("Enterprise");
0125:                    if (!lEnterprise.getName().equals(
0126:                            pInput.getEnterpriseName()))
0127:                        throw new BSIllegalArgumentException(
0128:                                "Name of enterprise in the default model is not matching requested name. Requested name '"
0129:                                        + pInput.getEnterpriseName()
0130:                                        + "'. Name in the default model '"
0131:                                        + lEnterprise.getName() + "'.");
0132:
0133:                    String lNormalisedEnterpriseName = StringUtils.suggestName(
0134:                            lEnterprise.getName(), true, false);
0135:                    String lNormalisedEnterpriseNameLowerCase = lNormalisedEnterpriseName
0136:                            .toLowerCase();
0137:
0138:                    // Generate stylesheet
0139:                    STEnterpriseStylesheet lStylesheet = new STEnterpriseStylesheet();
0140:                    lStylesheet.setName(pInput.getEnterpriseName());
0141:                    lStylesheet.setNormalisedName(lNormalisedEnterpriseName);
0142:                    lStylesheet.setNormalisedTypedName("Enterprise"
0143:                            + lNormalisedEnterpriseName);
0144:                    lStylesheet.setBusinessServicesInterfaceModuleName("BS"
0145:                            + lNormalisedEnterpriseName);
0146:                    lStylesheet
0147:                            .setBusinessServicesImplementationModuleName("BS"
0148:                                    + lNormalisedEnterpriseName + "Impl");
0149:                    lStylesheet.setBusinessServicesDistributionModuleName("BS"
0150:                            + lNormalisedEnterpriseName + "Dist");
0151:                    lStylesheet.setBusinessDomainImplementationModuleName("BO"
0152:                            + lNormalisedEnterpriseName + "Impl");
0153:                    lStylesheet.setWebServicesServerModuleName("BWS"
0154:                            + lNormalisedEnterpriseName + "Server");
0155:                    lStylesheet
0156:                            .setDataDictionaryModuleName(lNormalisedEnterpriseName
0157:                                    + "DataDictionary");
0158:                    lStylesheet.setRootPackageName("com."
0159:                            + lNormalisedEnterpriseNameLowerCase);
0160:                    lStylesheet.setNamespaceURI(lNormalisedEnterpriseName);
0161:                    // Enterprise is always at the top of the catalogue
0162:                    lStylesheet.setCataloguePathToTop("");
0163:                    lStylesheet.setCataloguePathFromTop("");
0164:                    // Prepare result and return			
0165:                    BSCodeGenerationStylesheet.STGetEnterpriseStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetEnterpriseStylesheetResult();
0166:                    lResult.setStylesheet(lStylesheet);
0167:                    return lResult;
0168:                } catch (com.metaboss.enterprise.bo.BOException e) {
0169:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0170:                            "Caught error while generating Enteprise stylesheet. Enteprise Name: "
0171:                                    + pInput.getEnterpriseName(), e);
0172:                }
0173:            }
0174:
0175:            /* Returns the stylesheet which describes names pertained to the DesignLibrary */
0176:            public BSCodeGenerationStylesheet.STGetDesignLibraryStylesheetResult getDesignLibraryStylesheet(
0177:                    BSCodeGenerationStylesheet.STGetDesignLibraryStylesheetInput pInput)
0178:                    throws BSException {
0179:                try {
0180:                    STDesignLibraryStylesheet lStylesheet = new STDesignLibraryStylesheet();
0181:                    // Get access to required model elements
0182:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0183:                            .getDefaultModelExtent();
0184:                    Enterprise lEnterprise = null;
0185:                    DesignLibrary lDesignLibrary = (DesignLibrary) lMetaBossModelPackage
0186:                            .getModelElement().findByRef("DesignLibrary");
0187:                    if (lDesignLibrary == null) {
0188:                        lEnterprise = (Enterprise) lMetaBossModelPackage
0189:                                .getModelElement().findByRef("Enterprise");
0190:                        if (lEnterprise == null)
0191:                            throw new BSUnexpectedProgramConditionException(
0192:                                    "DesignLibrary must be stand alone or belong to an Enterprise. Design Library Name: "
0193:                                            + pInput.getDesignLibraryName());
0194:                        lDesignLibrary = lEnterprise.getDesignLibrary();
0195:                    }
0196:                    // If design library name is given - we have to compare it to the actual one
0197:                    if (pInput.getDesignLibraryName() != null) {
0198:                        if (!lDesignLibrary.getName().equals(
0199:                                pInput.getDesignLibraryName()))
0200:                            throw new BSIllegalArgumentException(
0201:                                    "Name of design library in the default model is not matching requested name. Requested name '"
0202:                                            + pInput.getDesignLibraryName()
0203:                                            + "'. Name in the default model '"
0204:                                            + lDesignLibrary.getName() + "'.");
0205:                    }
0206:
0207:                    String lNormalisedName = StringUtils.suggestName(
0208:                            lDesignLibrary.getName(), true, false);
0209:                    String lNormalisedNameLowerCase = lNormalisedName
0210:                            .toLowerCase();
0211:                    // Generate stylesheet
0212:                    lStylesheet.setName(lDesignLibrary.getName());
0213:                    lStylesheet.setNormalisedName(lNormalisedName);
0214:                    lStylesheet.setNormalisedTypedName("DesignLibrary"
0215:                            + lNormalisedName);
0216:                    // Root package name is different for the standalone design library or the enterprise one
0217:                    if (lEnterprise != null) {
0218:                        BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput lEnterpriseStylesheetInput = new BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput();
0219:                        lEnterpriseStylesheetInput
0220:                                .setEnterpriseName(lEnterprise.getName());
0221:                        STEnterpriseStylesheet lEnterpriseStylesheet = getStylesheetService()
0222:                                .getEnterpriseStylesheet(
0223:                                        lEnterpriseStylesheetInput)
0224:                                .getStylesheet();
0225:                        lStylesheet.setRootPackageName(lEnterpriseStylesheet
0226:                                .getRootPackageName());
0227:                        // DesignLibrary is under enterprise
0228:                        lStylesheet.setCataloguePathToTop(lEnterpriseStylesheet
0229:                                .getCataloguePathToTop()
0230:                                + "../");
0231:                        lStylesheet
0232:                                .setCataloguePathFromTop(lEnterpriseStylesheet
0233:                                        .getCataloguePathFromTop()
0234:                                        + lEnterpriseStylesheet
0235:                                                .getNormalisedTypedName() + "/");
0236:                        lStylesheet.setNamespaceURI(lEnterpriseStylesheet
0237:                                .getNamespaceURI());
0238:                        lStylesheet
0239:                                .setDataDictionaryModuleName(lEnterpriseStylesheet
0240:                                        .getNormalisedName()
0241:                                        + "CommonDataDictionary");
0242:                    } else {
0243:                        lStylesheet.setRootPackageName("com.libs."
0244:                                + lNormalisedNameLowerCase);
0245:                        // DesignLibrary is at the top of the catalogue
0246:                        lStylesheet.setCataloguePathToTop("");
0247:                        lStylesheet.setCataloguePathFromTop("");
0248:                        lStylesheet.setNamespaceURI(lNormalisedName);
0249:                        lStylesheet.setDataDictionaryModuleName(lNormalisedName
0250:                                + "DataDictionary");
0251:                    }
0252:                    lStylesheet.setTypesRootPackageName(lStylesheet
0253:                            .getRootPackageName()
0254:                            + ".types");
0255:                    lStylesheet.setAdaptersRootPackageName(lStylesheet
0256:                            .getRootPackageName()
0257:                            + ".adapters");
0258:
0259:                    // Paackage and return result
0260:                    BSCodeGenerationStylesheet.STGetDesignLibraryStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetDesignLibraryStylesheetResult();
0261:                    lResult.setStylesheet(lStylesheet);
0262:                    return lResult;
0263:                } catch (com.metaboss.enterprise.bo.BOException e) {
0264:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0265:                            "Caught error while generating Design Library stylesheet. Design Library Name: "
0266:                                    + pInput.getDesignLibraryName(), e);
0267:                }
0268:            }
0269:
0270:            /* Returns the stylesheet which describes names pertained to the System */
0271:            public BSCodeGenerationStylesheet.STGetSystemStylesheetResult getSystemStylesheet(
0272:                    BSCodeGenerationStylesheet.STGetSystemStylesheetInput pInput)
0273:                    throws BSException {
0274:                try {
0275:                    // Get access to required model elements
0276:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0277:                            .getDefaultModelExtent();
0278:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) lMetaBossModelPackage
0279:                            .getModelElement().getByRef(pInput.getSystemRef());
0280:                    Enterprise lEnterprise = (Enterprise) lSystem
0281:                            .getEnterprise();
0282:                    // Obtain enterprise stylesheet
0283:                    BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput lEnterpriseStylesheetInput = new BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput();
0284:                    lEnterpriseStylesheetInput.setEnterpriseName(lEnterprise
0285:                            .getName());
0286:                    STEnterpriseStylesheet lEnterpriseStylesheet = getStylesheetService()
0287:                            .getEnterpriseStylesheet(lEnterpriseStylesheetInput)
0288:                            .getStylesheet();
0289:
0290:                    String lNormalisedSystemName = StringUtils.suggestName(
0291:                            lSystem.getName(), true, false);
0292:                    String lNormalisedSystemNameLowerCase = lNormalisedSystemName
0293:                            .toLowerCase();
0294:
0295:                    // Generate stylesheet
0296:                    STSystemStylesheet lStylesheet = new STSystemStylesheet();
0297:                    lStylesheet.setSystemRef(pInput.getSystemRef());
0298:                    lStylesheet.setNormalisedName(lNormalisedSystemName);
0299:                    lStylesheet.setNormalisedTypedName("System"
0300:                            + lNormalisedSystemName);
0301:                    lStylesheet.setRootPackageName(lEnterpriseStylesheet
0302:                            .getRootPackageName()
0303:                            + "." + lNormalisedSystemNameLowerCase);
0304:                    lStylesheet.setTypesRootPackageName(lStylesheet
0305:                            .getRootPackageName()
0306:                            + ".types");
0307:                    lStylesheet.setAdaptersRootPackageName(lStylesheet
0308:                            .getRootPackageName()
0309:                            + ".adapters");
0310:                    lStylesheet.setNamespaceURI(lEnterpriseStylesheet
0311:                            .getNamespaceURI()
0312:                            + "/Systems/" + lNormalisedSystemName);
0313:                    lStylesheet.setBusinessServicesInterfaceModuleName("BS"
0314:                            + lEnterpriseStylesheet.getNormalisedName()
0315:                            + lNormalisedSystemName);
0316:                    lStylesheet
0317:                            .setBusinessServicesImplementationModuleName("BS"
0318:                                    + lEnterpriseStylesheet.getNormalisedName()
0319:                                    + lNormalisedSystemName + "Impl");
0320:                    lStylesheet.setBusinessServicesDistributionModuleName("BS"
0321:                            + lEnterpriseStylesheet.getNormalisedName()
0322:                            + lNormalisedSystemName + "Dist");
0323:                    lStylesheet.setBusinessDomainImplementationModuleName("BO"
0324:                            + lEnterpriseStylesheet.getNormalisedName()
0325:                            + lNormalisedSystemName + "Impl");
0326:                    lStylesheet
0327:                            .setDataDictionaryModuleName(lEnterpriseStylesheet
0328:                                    .getNormalisedName()
0329:                                    + lNormalisedSystemName + "DataDictionary");
0330:                    lStylesheet.setWebServicesServerModuleName("BWS"
0331:                            + lEnterpriseStylesheet.getNormalisedName()
0332:                            + lNormalisedSystemName + "Server");
0333:                    // System is always owned by the enteprise
0334:                    lStylesheet.setCataloguePathToTop(lEnterpriseStylesheet
0335:                            .getCataloguePathToTop()
0336:                            + "../");
0337:                    lStylesheet.setCataloguePathFromTop(lEnterpriseStylesheet
0338:                            .getCataloguePathFromTop()
0339:                            + lEnterpriseStylesheet.getNormalisedTypedName()
0340:                            + "/");
0341:                    // Prepare result and return
0342:                    BSCodeGenerationStylesheet.STGetSystemStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetSystemStylesheetResult();
0343:                    lResult.setStylesheet(lStylesheet);
0344:                    return lResult;
0345:                } catch (com.metaboss.enterprise.bo.BOException e) {
0346:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0347:                            "Caught error while generating System stylesheet. SystemRef: "
0348:                                    + pInput.getSystemRef(), e);
0349:                }
0350:            }
0351:
0352:            /* Returns the stylesheet which describes names pertained to the DataDictionary */
0353:            public BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetResult getDataDictionaryStylesheet(
0354:                    BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput pInput)
0355:                    throws BSException {
0356:                try {
0357:                    // Get access to required model elements
0358:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0359:                            .getDefaultModelExtent();
0360:                    DataDictionary lDataDictionary = (DataDictionary) lMetaBossModelPackage
0361:                            .getModelElement().getByRef(
0362:                                    pInput.getDataDictionaryRef());
0363:
0364:                    String lNormalisedDataDictionaryName = StringUtils
0365:                            .suggestName(lDataDictionary.getName(), true, false);
0366:                    String lNormalisedDataDictionaryNameLowerCase = lNormalisedDataDictionaryName
0367:                            .toLowerCase();
0368:
0369:                    STDataDictionaryStylesheet lStylesheet = new STDataDictionaryStylesheet();
0370:                    lStylesheet.setDataDictionaryRef(pInput
0371:                            .getDataDictionaryRef());
0372:                    lStylesheet
0373:                            .setNormalisedName(lNormalisedDataDictionaryName);
0374:                    lStylesheet.setNormalisedTypedName("DataDictionary"
0375:                            + lNormalisedDataDictionaryName);
0376:                    lStylesheet.setAdapterClassName("ADDataDictionary");
0377:
0378:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDataDictionary
0379:                            .getSystem();
0380:                    DesignLibrary lDesignLibrary = lDataDictionary
0381:                            .getDesignLibrary();
0382:                    if (lSystem != null) {
0383:                        // This datadictionary belongs to the system therefore it should appear in the system catalogue
0384:
0385:                        // Obtain system stylesheet
0386:                        BSCodeGenerationStylesheet.STGetSystemStylesheetInput lSystemStylesheetInput = new BSCodeGenerationStylesheet.STGetSystemStylesheetInput();
0387:                        lSystemStylesheetInput.setSystemRef(lSystem.getRef());
0388:                        STSystemStylesheet lSystemStylesheet = getStylesheetService()
0389:                                .getSystemStylesheet(lSystemStylesheetInput)
0390:                                .getStylesheet();
0391:
0392:                        // Obtain enterprise stylesheet
0393:                        BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput lEnterpriseStylesheetInput = new BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput();
0394:                        lEnterpriseStylesheetInput.setEnterpriseName(lSystem
0395:                                .getEnterprise().getName());
0396:                        STEnterpriseStylesheet lEnterpriseStylesheet = getStylesheetService()
0397:                                .getEnterpriseStylesheet(
0398:                                        lEnterpriseStylesheetInput)
0399:                                .getStylesheet();
0400:
0401:                        lStylesheet.setCataloguePathToTop(lSystemStylesheet
0402:                                .getCataloguePathToTop()
0403:                                + "../");
0404:                        lStylesheet.setCataloguePathFromTop(lSystemStylesheet
0405:                                .getCataloguePathFromTop()
0406:                                + lSystemStylesheet.getNormalisedTypedName()
0407:                                + "/");
0408:
0409:                        // If DataDictionary is the system data dictionary - its own name is ignored ( as there is only one data dictionary)
0410:                        lStylesheet.setPackageName(lSystemStylesheet
0411:                                .getTypesRootPackageName());
0412:                        lStylesheet
0413:                                .setAdaptersRootPackageName(lSystemStylesheet
0414:                                        .getAdaptersRootPackageName());
0415:                        lStylesheet
0416:                                .setGenericStringStructuresAdapterPackageName(lStylesheet
0417:                                        .getAdaptersRootPackageName()
0418:                                        + ".generic.stringstructures.types");
0419:                        lStylesheet
0420:                                .setGenericSimplifiedStringStructuresAdapterPackageName(lStylesheet
0421:                                        .getAdaptersRootPackageName()
0422:                                        + ".generic.simplifiedstringstructures.types");
0423:                        lStylesheet
0424:                                .setGenericDomElementsAdapterPackageName(lStylesheet
0425:                                        .getAdaptersRootPackageName()
0426:                                        + ".generic.domelements.types");
0427:                        lStylesheet
0428:                                .setGenericXmlStringsAdapterPackageName(lStylesheet
0429:                                        .getAdaptersRootPackageName()
0430:                                        + ".generic.xmlstrings.types");
0431:                        lStylesheet.setNamespaceURI(lSystemStylesheet
0432:                                .getNamespaceURI()
0433:                                + "/Types");
0434:                        lStylesheet
0435:                                .setDataDictionaryModuleName(lEnterpriseStylesheet
0436:                                        .getNormalisedName()
0437:                                        + lSystemStylesheet.getNormalisedName()
0438:                                        + "DataDictionary");
0439:                    } else if (lDesignLibrary != null) {
0440:                        // This datadictionary belongs to the design library therefore it should appear in the design library catalogue
0441:
0442:                        // Obtain DesignLibrary stylesheet
0443:                        BSCodeGenerationStylesheet.STGetDesignLibraryStylesheetInput lDesignLibraryStylesheetInput = new BSCodeGenerationStylesheet.STGetDesignLibraryStylesheetInput();
0444:                        lDesignLibraryStylesheetInput
0445:                                .setDesignLibraryName(lDesignLibrary.getName());
0446:                        STDesignLibraryStylesheet lDesignLibraryStylesheet = getStylesheetService()
0447:                                .getDesignLibraryStylesheet(
0448:                                        lDesignLibraryStylesheetInput)
0449:                                .getStylesheet();
0450:
0451:                        lStylesheet
0452:                                .setCataloguePathToTop(lDesignLibraryStylesheet
0453:                                        .getCataloguePathToTop()
0454:                                        + "../");
0455:                        lStylesheet
0456:                                .setCataloguePathFromTop(lDesignLibraryStylesheet
0457:                                        .getCataloguePathFromTop()
0458:                                        + lDesignLibraryStylesheet
0459:                                                .getNormalisedTypedName() + "/");
0460:
0461:                        // If DataDictionary is in the design library - its name forms part of the package and namespace
0462:                        lStylesheet.setPackageName(lDesignLibraryStylesheet
0463:                                .getTypesRootPackageName()
0464:                                + "." + lNormalisedDataDictionaryNameLowerCase);
0465:                        lStylesheet
0466:                                .setAdaptersRootPackageName(lDesignLibraryStylesheet
0467:                                        .getAdaptersRootPackageName());
0468:                        lStylesheet
0469:                                .setGenericStringStructuresAdapterPackageName(lStylesheet
0470:                                        .getAdaptersRootPackageName()
0471:                                        + ".generic.stringstructures.types."
0472:                                        + lNormalisedDataDictionaryNameLowerCase);
0473:                        lStylesheet
0474:                                .setGenericSimplifiedStringStructuresAdapterPackageName(lStylesheet
0475:                                        .getAdaptersRootPackageName()
0476:                                        + ".generic.simplifiedstringstructures.types."
0477:                                        + lNormalisedDataDictionaryNameLowerCase);
0478:                        lStylesheet
0479:                                .setGenericDomElementsAdapterPackageName(lStylesheet
0480:                                        .getAdaptersRootPackageName()
0481:                                        + ".generic.domelements.types."
0482:                                        + lNormalisedDataDictionaryNameLowerCase);
0483:                        lStylesheet
0484:                                .setGenericXmlStringsAdapterPackageName(lStylesheet
0485:                                        .getAdaptersRootPackageName()
0486:                                        + ".generic.xmlstrings.types."
0487:                                        + lNormalisedDataDictionaryNameLowerCase);
0488:                        lStylesheet.setNamespaceURI(lDesignLibraryStylesheet
0489:                                .getNamespaceURI()
0490:                                + "/Types/" + lStylesheet.getNormalisedName());
0491:                        if (lDesignLibrary.getEnterprise() != null) {
0492:                            // Enterprise design library - obtain enterprise stylesheet
0493:                            BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput lEnterpriseStylesheetInput = new BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput();
0494:                            lEnterpriseStylesheetInput
0495:                                    .setEnterpriseName(lDesignLibrary
0496:                                            .getEnterprise().getName());
0497:                            STEnterpriseStylesheet lEnterpriseStylesheet = getStylesheetService()
0498:                                    .getEnterpriseStylesheet(
0499:                                            lEnterpriseStylesheetInput)
0500:                                    .getStylesheet();
0501:                            lStylesheet
0502:                                    .setDataDictionaryModuleName(lEnterpriseStylesheet
0503:                                            .getNormalisedName()
0504:                                            + lNormalisedDataDictionaryName
0505:                                            + "DataDictionary");
0506:                        } else {
0507:                            // Standalone desing library
0508:                            lStylesheet
0509:                                    .setDataDictionaryModuleName(lNormalisedDataDictionaryName
0510:                                            + "DataDictionary");
0511:                        }
0512:                    } else
0513:                        throw new BSUnexpectedProgramConditionException(
0514:                                "DataDictionary must belong to System or DesignLibrary. DataDictionaryRef: "
0515:                                        + pInput.getDataDictionaryRef());
0516:                    lStylesheet.setAdapterRootPackageDir(StringUtils.replace(
0517:                            lStylesheet.getAdaptersRootPackageName(), ".",
0518:                            File.separator));
0519:
0520:                    // Prepare result and return
0521:                    BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetResult();
0522:                    lResult.setStylesheet(lStylesheet);
0523:                    return lResult;
0524:                } catch (com.metaboss.enterprise.bo.BOException e) {
0525:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0526:                            "Caught error while generating DataDictionary stylesheet. DataDictionaryRef: "
0527:                                    + pInput.getDataDictionaryRef(), e);
0528:                }
0529:            }
0530:
0531:            /* Returns the stylesheet which describes names pertained to the Namespace */
0532:            public BSCodeGenerationStylesheet.STGetNamespaceStylesheetResult getNamespaceStylesheet(
0533:                    BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput pInput)
0534:                    throws BSException {
0535:                try {
0536:                    // Get access to required model elements
0537:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0538:                            .getDefaultModelExtent();
0539:                    Namespace lNamespace = (Namespace) lMetaBossModelPackage
0540:                            .getModelElement().getByRef(
0541:                                    pInput.getNamespaceRef());
0542:
0543:                    String lNormalisedNamespaceName = StringUtils.suggestName(
0544:                            lNamespace.getName(), true, false);
0545:                    String lLowerCaseNormalisedNamespaceName = lNormalisedNamespaceName
0546:                            .toLowerCase();
0547:
0548:                    STNamespaceStylesheet lStylesheet = new STNamespaceStylesheet();
0549:                    lStylesheet.setNamespaceRef(pInput.getNamespaceRef());
0550:                    lStylesheet.setNormalisedName(lNormalisedNamespaceName);
0551:                    lStylesheet.setNormalisedTypedName("Namespace"
0552:                            + lNormalisedNamespaceName);
0553:                    lStylesheet.setAdapterClassName("ADNamespace");
0554:
0555:                    AbstractNamespace lParentNamespace = lNamespace
0556:                            .getNamespace();
0557:                    StringBuffer lPackageNameBuffer = new StringBuffer();
0558:                    if (lParentNamespace instanceof  Namespace) {
0559:                        // This namespace belongs to another namespace therefore it should appear in the namespace's catalogue
0560:
0561:                        // Obtain namespace stylesheet
0562:                        BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput lParentNamespaceStylesheetInput = new BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput();
0563:                        lParentNamespaceStylesheetInput
0564:                                .setNamespaceRef(lParentNamespace.getRef());
0565:                        STNamespaceStylesheet lParentNamespaceStylesheet = getStylesheetService()
0566:                                .getNamespaceStylesheet(
0567:                                        lParentNamespaceStylesheetInput)
0568:                                .getStylesheet();
0569:
0570:                        lStylesheet
0571:                                .setCataloguePathToTop(lParentNamespaceStylesheet
0572:                                        .getCataloguePathToTop()
0573:                                        + "../");
0574:                        lStylesheet
0575:                                .setCataloguePathFromTop(lParentNamespaceStylesheet
0576:                                        .getCataloguePathFromTop()
0577:                                        + lParentNamespaceStylesheet
0578:                                                .getNormalisedTypedName() + "/");
0579:                        lStylesheet
0580:                                .setDictionarySubPackageName(lParentNamespaceStylesheet
0581:                                        .getDictionarySubPackageName()
0582:                                        + "."
0583:                                        + lLowerCaseNormalisedNamespaceName);
0584:                        lStylesheet.setNamespaceURI(lParentNamespaceStylesheet
0585:                                .getNamespaceURI()
0586:                                + "/" + lNormalisedNamespaceName);
0587:
0588:                        lPackageNameBuffer.append(lParentNamespaceStylesheet
0589:                                .getPackageName());
0590:                    } else if (lParentNamespace instanceof  DataDictionary) {
0591:                        // This namespace belongs to the datadictionary therefore it should appear in the datadictionary catalogue
0592:
0593:                        // Obtain DataDictionary stylesheet
0594:                        BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput lParentDataDictionaryStylesheetInput = new BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput();
0595:                        lParentDataDictionaryStylesheetInput
0596:                                .setDataDictionaryRef(lParentNamespace.getRef());
0597:                        STDataDictionaryStylesheet lParentDataDictionaryStylesheet = getStylesheetService()
0598:                                .getDataDictionaryStylesheet(
0599:                                        lParentDataDictionaryStylesheetInput)
0600:                                .getStylesheet();
0601:
0602:                        lStylesheet
0603:                                .setCataloguePathToTop(lParentDataDictionaryStylesheet
0604:                                        .getCataloguePathToTop()
0605:                                        + "../");
0606:                        lStylesheet
0607:                                .setCataloguePathFromTop(lParentDataDictionaryStylesheet
0608:                                        .getCataloguePathFromTop()
0609:                                        + lParentDataDictionaryStylesheet
0610:                                                .getNormalisedTypedName() + "/");
0611:                        lStylesheet
0612:                                .setDictionarySubPackageName(lLowerCaseNormalisedNamespaceName);
0613:                        lStylesheet
0614:                                .setNamespaceURI(lParentDataDictionaryStylesheet
0615:                                        .getNamespaceURI()
0616:                                        + "/" + lNormalisedNamespaceName);
0617:
0618:                        lPackageNameBuffer
0619:                                .append(lParentDataDictionaryStylesheet
0620:                                        .getPackageName());
0621:                    } else
0622:                        throw new BSUnexpectedProgramConditionException(
0623:                                "Namespace must belong to another Namespace or DataDictionary. NamespaceRef: "
0624:                                        + pInput.getNamespaceRef());
0625:
0626:                    // Finish forming the package name
0627:                    lPackageNameBuffer.append(".");
0628:                    lPackageNameBuffer
0629:                            .append(lLowerCaseNormalisedNamespaceName);
0630:                    lStylesheet.setPackageName(lPackageNameBuffer.toString());
0631:
0632:                    // Prepare result and return
0633:                    BSCodeGenerationStylesheet.STGetNamespaceStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetNamespaceStylesheetResult();
0634:                    lResult.setStylesheet(lStylesheet);
0635:                    return lResult;
0636:                } catch (com.metaboss.enterprise.bo.BOException e) {
0637:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0638:                            "Caught error while generating Namespace stylesheet. NamespaceRef: "
0639:                                    + pInput.getNamespaceRef(), e);
0640:                }
0641:            }
0642:
0643:            /* Returns the stylesheet which describes names pertained to the servicemodule */
0644:            public BSCodeGenerationStylesheet.STGetServicemoduleStylesheetResult getServicemoduleStylesheet(
0645:                    BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput pInput)
0646:                    throws BSException {
0647:                try {
0648:                    // Get access to required model elements
0649:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0650:                            .getDefaultModelExtent();
0651:                    Servicemodule lServicemodule = (Servicemodule) lMetaBossModelPackage
0652:                            .getModelElement().getByRef(
0653:                                    pInput.getServicemoduleRef());
0654:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lServicemodule
0655:                            .getSystem();
0656:                    Enterprise lEnterprise = (Enterprise) lSystem
0657:                            .getEnterprise();
0658:
0659:                    // Obtain enterprise stylesheet
0660:                    BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput lEnterpriseStylesheetInput = new BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput();
0661:                    lEnterpriseStylesheetInput.setEnterpriseName(lEnterprise
0662:                            .getName());
0663:                    STEnterpriseStylesheet lEnterpriseStylesheet = getStylesheetService()
0664:                            .getEnterpriseStylesheet(lEnterpriseStylesheetInput)
0665:                            .getStylesheet();
0666:
0667:                    // Obtain system stylesheet
0668:                    BSCodeGenerationStylesheet.STGetSystemStylesheetInput lSystemStylesheetInput = new BSCodeGenerationStylesheet.STGetSystemStylesheetInput();
0669:                    lSystemStylesheetInput.setSystemRef(lSystem.getRef());
0670:                    STSystemStylesheet lSystemStylesheet = getStylesheetService()
0671:                            .getSystemStylesheet(lSystemStylesheetInput)
0672:                            .getStylesheet();
0673:
0674:                    String lNormalisedServicemoduleName = StringUtils
0675:                            .suggestName(lServicemodule.getName(), true, false);
0676:
0677:                    // Generate stylesheet
0678:                    STServicemoduleStylesheet lStylesheet = new STServicemoduleStylesheet();
0679:                    lStylesheet.setServicemoduleRef(pInput
0680:                            .getServicemoduleRef());
0681:                    lStylesheet.setNormalisedName(lNormalisedServicemoduleName);
0682:                    lStylesheet.setNormalisedTypedName("Servicemodule"
0683:                            + lNormalisedServicemoduleName);
0684:                    lStylesheet
0685:                            .setSystemSubPackageName(lNormalisedServicemoduleName
0686:                                    .toLowerCase());
0687:                    lStylesheet.setPackageName(lSystemStylesheet
0688:                            .getRootPackageName()
0689:                            + ".services."
0690:                            + lStylesheet.getSystemSubPackageName());
0691:                    lStylesheet.setEventPublisherPackageName(lSystemStylesheet
0692:                            .getRootPackageName()
0693:                            + ".eventpublishers."
0694:                            + lStylesheet.getSystemSubPackageName());
0695:                    lStylesheet.setPackageDir(StringUtils.replace(lStylesheet
0696:                            .getPackageName(), ".", File.separator));
0697:                    lStylesheet.setAdaptersRootPackageName(lSystemStylesheet
0698:                            .getAdaptersRootPackageName());
0699:                    lStylesheet.setAdapterRootPackageDir(StringUtils.replace(
0700:                            lStylesheet.getAdaptersRootPackageName(), ".",
0701:                            File.separator));
0702:                    lStylesheet.setAdapterClassName("ADServicemodule");
0703:                    lStylesheet.setNamespaceURI(lSystemStylesheet
0704:                            .getNamespaceURI()
0705:                            + "/Services/" + lNormalisedServicemoduleName);
0706:                    lStylesheet.setEventPublisherNamespaceURI(lSystemStylesheet
0707:                            .getNamespaceURI()
0708:                            + "/EventPublishers/"
0709:                            + lNormalisedServicemoduleName);
0710:                    lStylesheet
0711:                            .setServicesGenericStringStructuresAdapterPackageName(lStylesheet
0712:                                    .getAdaptersRootPackageName()
0713:                                    + ".generic.stringstructures.services."
0714:                                    + lStylesheet.getSystemSubPackageName());
0715:                    lStylesheet
0716:                            .setServicesGenericSimplifiedStringStructuresAdapterPackageName(lStylesheet
0717:                                    .getAdaptersRootPackageName()
0718:                                    + ".generic.simplifiedstringstructures.services."
0719:                                    + lStylesheet.getSystemSubPackageName());
0720:                    lStylesheet
0721:                            .setServicesGenericDomElementsAdapterPackageName(lStylesheet
0722:                                    .getAdaptersRootPackageName()
0723:                                    + ".generic.domelements.services."
0724:                                    + lStylesheet.getSystemSubPackageName());
0725:                    lStylesheet
0726:                            .setServicesGenericXmlStringsAdapterPackageName(lStylesheet
0727:                                    .getAdaptersRootPackageName()
0728:                                    + ".generic.xmlstrings.services."
0729:                                    + lStylesheet.getSystemSubPackageName());
0730:                    lStylesheet
0731:                            .setEventPublishersGenericStringStructuresAdapterPackageName(lStylesheet
0732:                                    .getAdaptersRootPackageName()
0733:                                    + ".generic.stringstructures.eventpublishers."
0734:                                    + lStylesheet.getSystemSubPackageName());
0735:                    lStylesheet
0736:                            .setEventPublishersGenericSimplifiedStringStructuresAdapterPackageName(lStylesheet
0737:                                    .getAdaptersRootPackageName()
0738:                                    + ".generic.simplifiedstringstructures.eventpublishers."
0739:                                    + lStylesheet.getSystemSubPackageName());
0740:                    lStylesheet
0741:                            .setEventPublishersGenericDomElementsAdapterPackageName(lStylesheet
0742:                                    .getAdaptersRootPackageName()
0743:                                    + ".generic.domelements.eventpublishers."
0744:                                    + lStylesheet.getSystemSubPackageName());
0745:                    lStylesheet
0746:                            .setEventPublishersGenericXmlStringsAdapterPackageName(lStylesheet
0747:                                    .getAdaptersRootPackageName()
0748:                                    + ".generic.xmlstrings.eventpublishers."
0749:                                    + lStylesheet.getSystemSubPackageName());
0750:                    lStylesheet.setBusinessServicesInterfaceModuleName("BS"
0751:                            + lEnterpriseStylesheet.getNormalisedName()
0752:                            + lSystemStylesheet.getNormalisedName()
0753:                            + lNormalisedServicemoduleName);
0754:                    lStylesheet
0755:                            .setBusinessServicesImplementationModuleName("BS"
0756:                                    + lEnterpriseStylesheet.getNormalisedName()
0757:                                    + lSystemStylesheet.getNormalisedName()
0758:                                    + lNormalisedServicemoduleName + "Impl");
0759:                    lStylesheet.setBusinessServicesDistributionModuleName("BS"
0760:                            + lEnterpriseStylesheet.getNormalisedName()
0761:                            + lSystemStylesheet.getNormalisedName()
0762:                            + lNormalisedServicemoduleName + "Dist");
0763:                    lStylesheet.setWebServicesServerModuleName("BWS"
0764:                            + lEnterpriseStylesheet.getNormalisedName()
0765:                            + lSystemStylesheet.getNormalisedName()
0766:                            + lNormalisedServicemoduleName + "Server");
0767:                    lStylesheet.setGeneratedProxyRootPackageName(lStylesheet
0768:                            .getPackageName()
0769:                            + ".generatedproxy");
0770:                    lStylesheet.setGeneratedProxyRootPackageDir(StringUtils
0771:                            .replace(lStylesheet
0772:                                    .getGeneratedProxyRootPackageName(), ".",
0773:                                    File.separator));
0774:
0775:                    // Servicemodule is always inside the system catalogue
0776:                    lStylesheet.setCataloguePathToTop(lSystemStylesheet
0777:                            .getCataloguePathToTop()
0778:                            + "../");
0779:                    lStylesheet.setCataloguePathFromTop(lSystemStylesheet
0780:                            .getCataloguePathFromTop()
0781:                            + lSystemStylesheet.getNormalisedTypedName() + "/");
0782:
0783:                    // Prepare result and return
0784:                    BSCodeGenerationStylesheet.STGetServicemoduleStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetServicemoduleStylesheetResult();
0785:                    lResult.setStylesheet(lStylesheet);
0786:                    return lResult;
0787:                } catch (com.metaboss.enterprise.bo.BOException e) {
0788:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0789:                            "Caught error while generating Servicemodule stylesheet. ServicemoduleRef: "
0790:                                    + pInput.getServicemoduleRef(), e);
0791:                }
0792:            }
0793:
0794:            /* Returns the stylesheet which describes names pertained to the attribute */
0795:            public BSCodeGenerationStylesheet.STGetAttributeStylesheetResult getAttributeStylesheet(
0796:                    BSCodeGenerationStylesheet.STGetAttributeStylesheetInput pInput)
0797:                    throws BSException {
0798:                try {
0799:                    // Get access to required model elements
0800:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0801:                            .getDefaultModelExtent();
0802:                    Attribute lAttribute = (Attribute) lMetaBossModelPackage
0803:                            .getModelElement().getByRef(
0804:                                    pInput.getAttributeRef());
0805:
0806:                    String lNormalisedAttributeName = StringUtils.suggestName(
0807:                            lAttribute.getName(), true, false);
0808:
0809:                    // Generate stylesheet
0810:                    BSCodeGenerationStylesheet.STGetAttributeStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetAttributeStylesheetResult();
0811:                    STAttributeStylesheet lSTAttributeStylesheet = new STAttributeStylesheet();
0812:                    lSTAttributeStylesheet.setAttributeRef(pInput
0813:                            .getAttributeRef());
0814:                    lSTAttributeStylesheet
0815:                            .setNormalisedName(lNormalisedAttributeName);
0816:                    lResult.setStylesheet(lSTAttributeStylesheet);
0817:                    return lResult;
0818:                } catch (com.metaboss.enterprise.bo.BOException e) {
0819:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0820:                            "Caught error while generating Attribute stylesheet. AttributeRef: "
0821:                                    + pInput.getAttributeRef(), e);
0822:                }
0823:            }
0824:
0825:            /* Returns the stylesheet which describes names pertained to the StructureField */
0826:            public BSCodeGenerationStylesheet.STGetStructureFieldStylesheetResult getStructureFieldStylesheet(
0827:                    BSCodeGenerationStylesheet.STGetStructureFieldStylesheetInput pInput)
0828:                    throws BSException {
0829:                try {
0830:                    // Get access to required model elements
0831:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0832:                            .getDefaultModelExtent();
0833:                    StructureField lStructureField = (StructureField) lMetaBossModelPackage
0834:                            .getModelElement().getByRef(
0835:                                    pInput.getStructureFieldRef());
0836:
0837:                    String lNormalisedStructureFieldName = StringUtils
0838:                            .suggestName(lStructureField.getName(), true, false);
0839:
0840:                    // Generate stylesheet
0841:                    BSCodeGenerationStylesheet.STGetStructureFieldStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetStructureFieldStylesheetResult();
0842:                    STStructureFieldStylesheet lSTStructureFieldStylesheet = new STStructureFieldStylesheet();
0843:                    lSTStructureFieldStylesheet.setStructureFieldRef(pInput
0844:                            .getStructureFieldRef());
0845:                    lSTStructureFieldStylesheet
0846:                            .setNormalisedName(lNormalisedStructureFieldName);
0847:                    lResult.setStylesheet(lSTStructureFieldStylesheet);
0848:                    return lResult;
0849:                } catch (com.metaboss.enterprise.bo.BOException e) {
0850:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0851:                            "Caught error while generating StructureField stylesheet. StructureFieldRef: "
0852:                                    + pInput.getStructureFieldRef(), e);
0853:                }
0854:            }
0855:
0856:            /* Returns the stylesheet which describes names pertained to the MessageField */
0857:            public BSCodeGenerationStylesheet.STGetMessageFieldStylesheetResult getMessageFieldStylesheet(
0858:                    BSCodeGenerationStylesheet.STGetMessageFieldStylesheetInput pInput)
0859:                    throws BSException {
0860:                try {
0861:                    // Get access to required model elements
0862:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0863:                            .getDefaultModelExtent();
0864:                    MessageField lMessageField = (MessageField) lMetaBossModelPackage
0865:                            .getModelElement().getByRef(
0866:                                    pInput.getMessageFieldRef());
0867:
0868:                    String lNormalisedMessageFieldName = StringUtils
0869:                            .suggestName(lMessageField.getName(), true, false);
0870:
0871:                    // Generate stylesheet
0872:                    BSCodeGenerationStylesheet.STGetMessageFieldStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetMessageFieldStylesheetResult();
0873:                    STMessageFieldStylesheet lSTMessageFieldStylesheet = new STMessageFieldStylesheet();
0874:                    lSTMessageFieldStylesheet.setMessageFieldRef(pInput
0875:                            .getMessageFieldRef());
0876:                    lSTMessageFieldStylesheet
0877:                            .setNormalisedName(lNormalisedMessageFieldName);
0878:                    lResult.setStylesheet(lSTMessageFieldStylesheet);
0879:                    return lResult;
0880:                } catch (com.metaboss.enterprise.bo.BOException e) {
0881:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0882:                            "Caught error while generating MessageField stylesheet. MessageFieldRef: "
0883:                                    + pInput.getMessageFieldRef(), e);
0884:                }
0885:            }
0886:
0887:            /* Returns the stylesheet which describes names pertained to the OperationInputField */
0888:            public BSCodeGenerationStylesheet.STGetOperationInputFieldStylesheetResult getOperationInputFieldStylesheet(
0889:                    BSCodeGenerationStylesheet.STGetOperationInputFieldStylesheetInput pInput)
0890:                    throws BSException {
0891:                try {
0892:                    // Get access to required model elements
0893:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0894:                            .getDefaultModelExtent();
0895:                    OperationInputField lOperationInputField = (OperationInputField) lMetaBossModelPackage
0896:                            .getModelElement().getByRef(
0897:                                    pInput.getOperationInputFieldRef());
0898:
0899:                    String lNormalisedOperationInputFieldName = StringUtils
0900:                            .suggestName(lOperationInputField.getName(), true,
0901:                                    false);
0902:
0903:                    // Generate stylesheet
0904:                    BSCodeGenerationStylesheet.STGetOperationInputFieldStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetOperationInputFieldStylesheetResult();
0905:                    STOperationInputFieldStylesheet lSTOperationInputFieldStylesheet = new STOperationInputFieldStylesheet();
0906:                    lSTOperationInputFieldStylesheet
0907:                            .setOperationInputFieldRef(pInput
0908:                                    .getOperationInputFieldRef());
0909:                    lSTOperationInputFieldStylesheet
0910:                            .setNormalisedName(lNormalisedOperationInputFieldName);
0911:                    lResult.setStylesheet(lSTOperationInputFieldStylesheet);
0912:                    return lResult;
0913:                } catch (com.metaboss.enterprise.bo.BOException e) {
0914:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0915:                            "Caught error while generating OperationInputField stylesheet. OperationInputFieldRef: "
0916:                                    + pInput.getOperationInputFieldRef(), e);
0917:                }
0918:            }
0919:
0920:            /* Returns the stylesheet which describes names pertained to the EventDataField */
0921:            public BSCodeGenerationStylesheet.STGetEventDataFieldStylesheetResult getEventDataFieldStylesheet(
0922:                    BSCodeGenerationStylesheet.STGetEventDataFieldStylesheetInput pInput)
0923:                    throws BSException {
0924:                try {
0925:                    // Get access to required model elements
0926:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0927:                            .getDefaultModelExtent();
0928:                    EventDataField lEventDataField = (EventDataField) lMetaBossModelPackage
0929:                            .getModelElement().getByRef(
0930:                                    pInput.getEventDataFieldRef());
0931:
0932:                    String lNormalisedEventDataFieldName = StringUtils
0933:                            .suggestName(lEventDataField.getName(), true, false);
0934:
0935:                    // Generate stylesheet
0936:                    BSCodeGenerationStylesheet.STGetEventDataFieldStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetEventDataFieldStylesheetResult();
0937:                    STEventDataFieldStylesheet lSTEventDataFieldStylesheet = new STEventDataFieldStylesheet();
0938:                    lSTEventDataFieldStylesheet.setEventDataFieldRef(pInput
0939:                            .getEventDataFieldRef());
0940:                    lSTEventDataFieldStylesheet
0941:                            .setNormalisedName(lNormalisedEventDataFieldName);
0942:                    lResult.setStylesheet(lSTEventDataFieldStylesheet);
0943:                    return lResult;
0944:                } catch (com.metaboss.enterprise.bo.BOException e) {
0945:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0946:                            "Caught error while generating EventDataField stylesheet. EventDataFieldRef: "
0947:                                    + pInput.getEventDataFieldRef(), e);
0948:                }
0949:            }
0950:
0951:            /* Returns the stylesheet which describes names pertained to the EventMessageField */
0952:            public BSCodeGenerationStylesheet.STGetEventMessageFieldStylesheetResult getEventMessageFieldStylesheet(
0953:                    BSCodeGenerationStylesheet.STGetEventMessageFieldStylesheetInput pInput)
0954:                    throws BSException {
0955:                try {
0956:                    // Get access to required model elements
0957:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0958:                            .getDefaultModelExtent();
0959:                    EventMessageField lEventMessageField = (EventMessageField) lMetaBossModelPackage
0960:                            .getModelElement().getByRef(
0961:                                    pInput.getEventMessageFieldRef());
0962:
0963:                    String lNormalisedEventMessageFieldName = StringUtils
0964:                            .suggestName(lEventMessageField.getName(), true,
0965:                                    false);
0966:
0967:                    // Generate stylesheet
0968:                    BSCodeGenerationStylesheet.STGetEventMessageFieldStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetEventMessageFieldStylesheetResult();
0969:                    STEventMessageFieldStylesheet lSTEventMessageFieldStylesheet = new STEventMessageFieldStylesheet();
0970:                    lSTEventMessageFieldStylesheet
0971:                            .setEventMessageFieldRef(pInput
0972:                                    .getEventMessageFieldRef());
0973:                    lSTEventMessageFieldStylesheet
0974:                            .setNormalisedName(lNormalisedEventMessageFieldName);
0975:                    lResult.setStylesheet(lSTEventMessageFieldStylesheet);
0976:                    return lResult;
0977:                } catch (com.metaboss.enterprise.bo.BOException e) {
0978:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
0979:                            "Caught error while generating EventMessageField stylesheet. EventMessageFieldRef: "
0980:                                    + pInput.getEventMessageFieldRef(), e);
0981:                }
0982:            }
0983:
0984:            /* Returns the stylesheet which describes names pertained to the SelectorInputField */
0985:            public BSCodeGenerationStylesheet.STGetSelectorInputFieldStylesheetResult getSelectorInputFieldStylesheet(
0986:                    BSCodeGenerationStylesheet.STGetSelectorInputFieldStylesheetInput pInput)
0987:                    throws BSException {
0988:                try {
0989:                    // Get access to required model elements
0990:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
0991:                            .getDefaultModelExtent();
0992:                    SelectorInputField lSelectorInputField = (SelectorInputField) lMetaBossModelPackage
0993:                            .getModelElement().getByRef(
0994:                                    pInput.getSelectorInputFieldRef());
0995:
0996:                    String lNormalisedSelectorInputFieldName = StringUtils
0997:                            .suggestName(lSelectorInputField.getName(), true,
0998:                                    false);
0999:
1000:                    // Generate stylesheet
1001:                    BSCodeGenerationStylesheet.STGetSelectorInputFieldStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetSelectorInputFieldStylesheetResult();
1002:                    STSelectorInputFieldStylesheet lSTSelectorInputFieldStylesheet = new STSelectorInputFieldStylesheet();
1003:                    lSTSelectorInputFieldStylesheet
1004:                            .setSelectorInputFieldRef(pInput
1005:                                    .getSelectorInputFieldRef());
1006:                    lSTSelectorInputFieldStylesheet
1007:                            .setNormalisedName(lNormalisedSelectorInputFieldName);
1008:                    lResult.setStylesheet(lSTSelectorInputFieldStylesheet);
1009:                    return lResult;
1010:                } catch (com.metaboss.enterprise.bo.BOException e) {
1011:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1012:                            "Caught error while generating SelectorInputField stylesheet. SelectorInputFieldRef: "
1013:                                    + pInput.getSelectorInputFieldRef(), e);
1014:                }
1015:            }
1016:
1017:            /* Returns the stylesheet which describes names pertained to the OperationOutputField */
1018:            public BSCodeGenerationStylesheet.STGetOperationOutputFieldStylesheetResult getOperationOutputFieldStylesheet(
1019:                    BSCodeGenerationStylesheet.STGetOperationOutputFieldStylesheetInput pInput)
1020:                    throws BSException {
1021:                try {
1022:                    // Get access to required model elements
1023:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1024:                            .getDefaultModelExtent();
1025:                    OperationOutputField lOperationOutputField = (OperationOutputField) lMetaBossModelPackage
1026:                            .getModelElement().getByRef(
1027:                                    pInput.getOperationOutputFieldRef());
1028:
1029:                    String lNormalisedOperationOutputFieldName = StringUtils
1030:                            .suggestName(lOperationOutputField.getName(), true,
1031:                                    false);
1032:
1033:                    // Generate stylesheet
1034:                    BSCodeGenerationStylesheet.STGetOperationOutputFieldStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetOperationOutputFieldStylesheetResult();
1035:                    STOperationOutputFieldStylesheet lSTOperationOutputFieldStylesheet = new STOperationOutputFieldStylesheet();
1036:                    lSTOperationOutputFieldStylesheet
1037:                            .setOperationOutputFieldRef(pInput
1038:                                    .getOperationOutputFieldRef());
1039:                    lSTOperationOutputFieldStylesheet
1040:                            .setNormalisedName(lNormalisedOperationOutputFieldName);
1041:                    lResult.setStylesheet(lSTOperationOutputFieldStylesheet);
1042:                    return lResult;
1043:                } catch (com.metaboss.enterprise.bo.BOException e) {
1044:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1045:                            "Caught error while generating OperationOutputField stylesheet. OperationOutputFieldRef: "
1046:                                    + pInput.getOperationOutputFieldRef(), e);
1047:                }
1048:            }
1049:
1050:            /* Returns the stylesheet which describes names pertained to the OperationOutputMessage */
1051:            public BSCodeGenerationStylesheet.STGetOperationOutputMessageStylesheetResult getOperationOutputMessageStylesheet(
1052:                    BSCodeGenerationStylesheet.STGetOperationOutputMessageStylesheetInput pInput)
1053:                    throws BSException {
1054:                try {
1055:                    // Get access to required model elements
1056:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1057:                            .getDefaultModelExtent();
1058:                    OperationOutputMessage lOperationOutputMessage = (OperationOutputMessage) lMetaBossModelPackage
1059:                            .getModelElement().getByRef(
1060:                                    pInput.getOperationOutputMessageRef());
1061:
1062:                    String lNormalisedOperationOutputMessageName = StringUtils
1063:                            .suggestName(lOperationOutputMessage.getName(),
1064:                                    true, false);
1065:
1066:                    // Generate stylesheet
1067:                    BSCodeGenerationStylesheet.STGetOperationOutputMessageStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetOperationOutputMessageStylesheetResult();
1068:                    STOperationOutputMessageStylesheet lSTOperationOutputMessageStylesheet = new STOperationOutputMessageStylesheet();
1069:                    lSTOperationOutputMessageStylesheet
1070:                            .setOperationOutputMessageRef(pInput
1071:                                    .getOperationOutputMessageRef());
1072:                    lSTOperationOutputMessageStylesheet
1073:                            .setNormalisedName(lNormalisedOperationOutputMessageName);
1074:                    lResult.setStylesheet(lSTOperationOutputMessageStylesheet);
1075:                    return lResult;
1076:                } catch (com.metaboss.enterprise.bo.BOException e) {
1077:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1078:                            "Caught error while generating OperationOutputMessage stylesheet. OperationOutputMessageRef: "
1079:                                    + pInput.getOperationOutputMessageRef(), e);
1080:                }
1081:            }
1082:
1083:            /* Returns the stylesheet which describes names pertained to the domain */
1084:            public BSCodeGenerationStylesheet.STGetDomainStylesheetResult getDomainStylesheet(
1085:                    BSCodeGenerationStylesheet.STGetDomainStylesheetInput pInput)
1086:                    throws BSException {
1087:                try {
1088:                    // Get access to required model elements
1089:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1090:                            .getDefaultModelExtent();
1091:                    Domain lDomain = (Domain) lMetaBossModelPackage
1092:                            .getModelElement().getByRef(pInput.getDomainRef());
1093:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
1094:                            .getSystem();
1095:                    Enterprise lEnterprise = (Enterprise) lSystem
1096:                            .getEnterprise();
1097:                    // Obtain enterprise stylesheet
1098:                    BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput lEnterpriseStylesheetInput = new BSCodeGenerationStylesheet.STGetEnterpriseStylesheetInput();
1099:                    lEnterpriseStylesheetInput.setEnterpriseName(lEnterprise
1100:                            .getName());
1101:                    STEnterpriseStylesheet lEnterpriseStylesheet = getStylesheetService()
1102:                            .getEnterpriseStylesheet(lEnterpriseStylesheetInput)
1103:                            .getStylesheet();
1104:
1105:                    // Obtain system stylesheet
1106:                    BSCodeGenerationStylesheet.STGetSystemStylesheetInput lSystemStylesheetInput = new BSCodeGenerationStylesheet.STGetSystemStylesheetInput();
1107:                    lSystemStylesheetInput.setSystemRef(lSystem.getRef());
1108:                    STSystemStylesheet lSystemStylesheet = getStylesheetService()
1109:                            .getSystemStylesheet(lSystemStylesheetInput)
1110:                            .getStylesheet();
1111:
1112:                    String lNormalisedDomainName = StringUtils.suggestName(
1113:                            lDomain.getName(), true, false);
1114:                    String lNormalisedDomainNameLowerCase = lNormalisedDomainName
1115:                            .toLowerCase();
1116:
1117:                    // Generate stylesheet
1118:                    STDomainStylesheet lStylesheet = new STDomainStylesheet();
1119:                    lStylesheet.setDomainRef(pInput.getDomainRef());
1120:                    lStylesheet.setNormalisedName(lNormalisedDomainName);
1121:                    lStylesheet.setNormalisedTypedName("Domain"
1122:                            + lNormalisedDomainName);
1123:                    lStylesheet.setDomainPackageName(lSystemStylesheet
1124:                            .getRootPackageName()
1125:                            + ".domains." + lNormalisedDomainNameLowerCase);
1126:                    lStylesheet.setDomainInterfaceName("BODomain");
1127:                    lStylesheet.setDomainInterfaceFullName(lStylesheet
1128:                            .getDomainPackageName()
1129:                            + "." + lStylesheet.getDomainInterfaceName());
1130:                    lStylesheet.setDomainImplementationName(lStylesheet
1131:                            .getDomainInterfaceName()
1132:                            + "Impl");
1133:                    lStylesheet.setImplementationFactoryClassName(lStylesheet
1134:                            .getDomainInterfaceName()
1135:                            + "Factory");
1136:                    lStylesheet
1137:                            .setSupportServicemoduleName(lNormalisedDomainName
1138:                                    + "DomainSupport");
1139:                    lStylesheet.setDataManagementServiceName("DataManagement");
1140:                    lStylesheet.setImplementationPackageName(lStylesheet
1141:                            .getDomainPackageName()
1142:                            + ".impl");
1143:                    lStylesheet.setImplementationPackageDir(StringUtils
1144:                            .replace(
1145:                                    lStylesheet.getImplementationPackageName(),
1146:                                    ".", File.separator));
1147:                    lStylesheet.setStoragePackageName(lStylesheet
1148:                            .getDomainPackageName()
1149:                            + ".storage");
1150:                    lStylesheet.setStorageInterfaceName("PSDomain");
1151:                    lStylesheet.setStorageInterfaceFullName(lStylesheet
1152:                            .getStoragePackageName()
1153:                            + "." + lStylesheet.getStorageInterfaceName());
1154:                    lStylesheet.setStorageImplementationName(lStylesheet
1155:                            .getStorageInterfaceName()
1156:                            + "Impl");
1157:                    lStylesheet.setStorageFactoryName(lStylesheet
1158:                            .getStorageInterfaceName()
1159:                            + "Factory");
1160:                    lStylesheet.setBusinessDomainImplementationModuleName("BO"
1161:                            + lEnterpriseStylesheet.getNormalisedName()
1162:                            + lSystemStylesheet.getNormalisedName()
1163:                            + lNormalisedDomainName + "Impl");
1164:                    lStylesheet.setCataloguePathToTop(lSystemStylesheet
1165:                            .getCataloguePathToTop()
1166:                            + "../");
1167:                    lStylesheet.setCataloguePathFromTop(lSystemStylesheet
1168:                            .getCataloguePathFromTop()
1169:                            + lSystemStylesheet.getNormalisedTypedName() + "/");
1170:                    // Prepare result and return
1171:                    BSCodeGenerationStylesheet.STGetDomainStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetDomainStylesheetResult();
1172:                    lResult.setStylesheet(lStylesheet);
1173:                    return lResult;
1174:                } catch (com.metaboss.enterprise.bo.BOException e) {
1175:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1176:                            "Caught error while generating Domain stylesheet. DomainRef: "
1177:                                    + pInput.getDomainRef(), e);
1178:                }
1179:            }
1180:
1181:            /* Returns the stylesheet which describes names pertained to the service */
1182:            public BSCodeGenerationStylesheet.STGetServiceStylesheetResult getServiceStylesheet(
1183:                    BSCodeGenerationStylesheet.STGetServiceStylesheetInput pInput)
1184:                    throws BSException {
1185:                try {
1186:                    // Get access to required model elements
1187:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1188:                            .getDefaultModelExtent();
1189:                    Service lService = (Service) lMetaBossModelPackage
1190:                            .getModelElement().getByRef(pInput.getServiceRef());
1191:                    Servicemodule lServicemodule = lService.getServicemodule();
1192:
1193:                    String lNormalisedServiceName = StringUtils.suggestName(
1194:                            lService.getName(), true, false);
1195:                    String lNormalisedServiceNameLowerCase = lNormalisedServiceName
1196:                            .toLowerCase();
1197:
1198:                    // Obtain servicemodule stylesheet
1199:                    BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput lServicemoduleStylesheetInput = new BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput();
1200:                    lServicemoduleStylesheetInput
1201:                            .setServicemoduleRef(lServicemodule.getRef());
1202:                    STServicemoduleStylesheet lServicemoduleStylesheet = getStylesheetService()
1203:                            .getServicemoduleStylesheet(
1204:                                    lServicemoduleStylesheetInput)
1205:                            .getStylesheet();
1206:
1207:                    // Generate stylesheet
1208:                    STServiceStylesheet lStylesheet = new STServiceStylesheet();
1209:                    lStylesheet.setServiceRef(pInput.getServiceRef());
1210:                    lStylesheet.setNormalisedName(lNormalisedServiceName);
1211:                    lStylesheet.setNormalisedTypedName("Service"
1212:                            + lNormalisedServiceName);
1213:                    lStylesheet.setInterfaceName("BS" + lNormalisedServiceName);
1214:                    lStylesheet.setPackageName(lServicemoduleStylesheet
1215:                            .getPackageName());
1216:                    lStylesheet
1217:                            .setAdaptersRootPackageName(lServicemoduleStylesheet
1218:                                    .getAdaptersRootPackageName());
1219:                    lStylesheet
1220:                            .setAdapterRootPackageDir(lServicemoduleStylesheet
1221:                                    .getAdapterRootPackageDir());
1222:                    lStylesheet.setInterfaceFullName(lStylesheet
1223:                            .getPackageName()
1224:                            + "." + lStylesheet.getInterfaceName());
1225:                    lStylesheet.setNamespaceURI(lServicemoduleStylesheet
1226:                            .getNamespaceURI()
1227:                            + "/" + lNormalisedServiceName);
1228:                    lStylesheet.setAdapterClassName("AD"
1229:                            + lStylesheet.getInterfaceName());
1230:                    lStylesheet.setImplementationClassName(lStylesheet
1231:                            .getInterfaceName()
1232:                            + "Impl");
1233:                    lStylesheet.setImplementationFactoryClassName(lStylesheet
1234:                            .getInterfaceName()
1235:                            + "Factory");
1236:                    lStylesheet.setGeneratedImplementationNamePrefix("");
1237:                    lStylesheet
1238:                            .setGeneratedImplementationNameSuffix("Autogenerated");
1239:                    lStylesheet
1240:                            .setGeneratedImplementationBasePackageName(lStylesheet
1241:                                    .getPackageName()
1242:                                    + ".generatedimpl");
1243:                    lStylesheet.setGeneratedProxyRefSuffix("Autogenerated");
1244:                    lStylesheet
1245:                            .setGeneratedProxyBasePackageName(lServicemoduleStylesheet
1246:                                    .getGeneratedProxyRootPackageName());
1247:                    // This structure is inside servicemodule catalogue
1248:                    lStylesheet.setCataloguePathToTop(lServicemoduleStylesheet
1249:                            .getCataloguePathToTop()
1250:                            + "../");
1251:                    lStylesheet
1252:                            .setCataloguePathFromTop(lServicemoduleStylesheet
1253:                                    .getCataloguePathFromTop()
1254:                                    + lServicemoduleStylesheet
1255:                                            .getNormalisedTypedName() + "/");
1256:
1257:                    BSCodeGenerationStylesheet.STGetServiceStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetServiceStylesheetResult();
1258:                    lResult.setStylesheet(lStylesheet);
1259:                    return lResult;
1260:                } catch (com.metaboss.enterprise.bo.BOException e) {
1261:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1262:                            "Caught error while generating Service stylesheet. ServiceRef: "
1263:                                    + pInput.getServiceRef(), e);
1264:                }
1265:            }
1266:
1267:            /* Returns the stylesheet which describes names pertained to the service */
1268:            public BSCodeGenerationStylesheet.STGetEventSubscriptionStylesheetResult getEventSubscriptionStylesheet(
1269:                    BSCodeGenerationStylesheet.STGetEventSubscriptionStylesheetInput pInput)
1270:                    throws BSException {
1271:                try {
1272:                    // Get access to required model elements
1273:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1274:                            .getDefaultModelExtent();
1275:                    EventSubscription lEventSubscription = (EventSubscription) lMetaBossModelPackage
1276:                            .getModelElement().getByRef(
1277:                                    pInput.getEventSubscriptionRef());
1278:                    Servicemodule lServicemodule = lEventSubscription
1279:                            .getServicemodule();
1280:
1281:                    String lNormalisedEventSubscriptionName = StringUtils
1282:                            .suggestName(lEventSubscription.getName(), true,
1283:                                    false);
1284:                    String lNormalisedEventSubscriptionNameLowerCase = lNormalisedEventSubscriptionName
1285:                            .toLowerCase();
1286:
1287:                    // Obtain servicemodule stylesheet
1288:                    BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput lServicemoduleStylesheetInput = new BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput();
1289:                    lServicemoduleStylesheetInput
1290:                            .setServicemoduleRef(lServicemodule.getRef());
1291:                    STServicemoduleStylesheet lServicemoduleStylesheet = getStylesheetService()
1292:                            .getServicemoduleStylesheet(
1293:                                    lServicemoduleStylesheetInput)
1294:                            .getStylesheet();
1295:
1296:                    // Generate stylesheet
1297:                    STEventSubscriptionStylesheet lStylesheet = new STEventSubscriptionStylesheet();
1298:                    lStylesheet.setEventSubscriptionRef(pInput
1299:                            .getEventSubscriptionRef());
1300:                    lStylesheet
1301:                            .setNormalisedName(lNormalisedEventSubscriptionName);
1302:                    lStylesheet.setNormalisedTypedName("EventSubscription"
1303:                            + lNormalisedEventSubscriptionName);
1304:                    lStylesheet.setInterfaceName("BE"
1305:                            + lNormalisedEventSubscriptionName);
1306:                    lStylesheet.setPackageName(lServicemoduleStylesheet
1307:                            .getPackageName());
1308:                    lStylesheet.setInterfaceFullName(lStylesheet
1309:                            .getPackageName()
1310:                            + "." + lStylesheet.getInterfaceName());
1311:                    lStylesheet.setSubscriberInterfaceName("Subscriber");
1312:                    lStylesheet.setSubscriberAdapterClassName("ADSubscriber");
1313:                    //	        lStylesheet.setSubscriberInterfaceFullName(lStylesheet.getPackageName() + "." + lStylesheet.getSubscriberInterfaceName());
1314:                    lStylesheet
1315:                            .setAdaptersRootPackageName(lServicemoduleStylesheet
1316:                                    .getAdaptersRootPackageName());
1317:                    lStylesheet
1318:                            .setAdapterRootPackageDir(lServicemoduleStylesheet
1319:                                    .getAdapterRootPackageDir());
1320:                    lStylesheet.setNamespaceURI(lServicemoduleStylesheet
1321:                            .getNamespaceURI()
1322:                            + "/" + lNormalisedEventSubscriptionName);
1323:                    lStylesheet.setAdapterClassName("AD"
1324:                            + lStylesheet.getInterfaceName());
1325:                    lStylesheet.setImplementationClassName(lStylesheet
1326:                            .getInterfaceName()
1327:                            + "Impl");
1328:                    lStylesheet.setImplementationFactoryClassName(lStylesheet
1329:                            .getInterfaceName()
1330:                            + "Factory");
1331:                    lStylesheet.setGeneratedImplementationNamePrefix("");
1332:                    lStylesheet
1333:                            .setGeneratedImplementationNameSuffix("Autogenerated");
1334:                    lStylesheet
1335:                            .setGeneratedImplementationBasePackageName(lStylesheet
1336:                                    .getPackageName()
1337:                                    + ".generatedimpl");
1338:                    lStylesheet.setGeneratedProxyRefSuffix("Autogenerated");
1339:                    lStylesheet
1340:                            .setGeneratedProxyBasePackageName(lServicemoduleStylesheet
1341:                                    .getGeneratedProxyRootPackageName());
1342:                    lStylesheet
1343:                            .setSubscriberSubscriptionInitiatedHandlerName("subscriptionInitiated");
1344:                    lStylesheet
1345:                            .setSubscriberSubscriptionInterruptedHandlerName("subscriptionInterrupted");
1346:                    lStylesheet
1347:                            .setSubscriberSubscriptionRestoredHandlerName("subscriptionRestored");
1348:                    lStylesheet
1349:                            .setSubscriberSubscriptionTerminatedHandlerName("subscriptionTerminated");
1350:                    // The event subscription is located inside servicemodule catalogue
1351:                    lStylesheet.setCataloguePathToTop(lServicemoduleStylesheet
1352:                            .getCataloguePathToTop()
1353:                            + "../");
1354:                    lStylesheet
1355:                            .setCataloguePathFromTop(lServicemoduleStylesheet
1356:                                    .getCataloguePathFromTop()
1357:                                    + lServicemoduleStylesheet
1358:                                            .getNormalisedTypedName() + "/");
1359:
1360:                    // Obtain system stylesheet
1361:                    BSCodeGenerationStylesheet.STGetSystemStylesheetInput lSystemStylesheetInput = new BSCodeGenerationStylesheet.STGetSystemStylesheetInput();
1362:                    lSystemStylesheetInput.setSystemRef(lServicemodule
1363:                            .getSystem().getRef());
1364:                    STSystemStylesheet lSystemStylesheet = getStylesheetService()
1365:                            .getSystemStylesheet(lSystemStylesheetInput)
1366:                            .getStylesheet();
1367:                    lStylesheet.setPublisherPackageName(lSystemStylesheet
1368:                            .getRootPackageName()
1369:                            + ".eventpublishers."
1370:                            + lServicemoduleStylesheet.getNormalisedName()
1371:                                    .toLowerCase());
1372:                    lStylesheet.setPublisherEventSinkInterfaceName("BE"
1373:                            + lNormalisedEventSubscriptionName + "EventSink");
1374:                    lStylesheet
1375:                            .setPublisherEventSinkInterfaceFullName(lStylesheet
1376:                                    .getPublisherPackageName()
1377:                                    + "."
1378:                                    + lStylesheet
1379:                                            .getPublisherEventSinkInterfaceName());
1380:                    lStylesheet
1381:                            .setPublisherEventSinkImplementationClassName(lStylesheet
1382:                                    .getPublisherEventSinkInterfaceName()
1383:                                    + "Impl");
1384:                    lStylesheet
1385:                            .setPublisherEventSinkImplementationFactoryClassName(lStylesheet
1386:                                    .getPublisherEventSinkInterfaceName()
1387:                                    + "Factory");
1388:                    lStylesheet
1389:                            .setPublisherSynchroniserInterfaceName("BE"
1390:                                    + lNormalisedEventSubscriptionName
1391:                                    + "Synchroniser");
1392:                    lStylesheet
1393:                            .setPublisherSynchroniserInterfaceFullName(lStylesheet
1394:                                    .getPublisherPackageName()
1395:                                    + "."
1396:                                    + lStylesheet
1397:                                            .getPublisherSynchroniserInterfaceName());
1398:                    lStylesheet
1399:                            .setPublisherSynchroniserImplementationClassName(lStylesheet
1400:                                    .getPublisherSynchroniserInterfaceName()
1401:                                    + "Impl");
1402:                    lStylesheet
1403:                            .setPublisherSynchroniserImplementationFactoryClassName(lStylesheet
1404:                                    .getPublisherSynchroniserInterfaceName()
1405:                                    + "Factory");
1406:
1407:                    BSCodeGenerationStylesheet.STGetEventSubscriptionStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetEventSubscriptionStylesheetResult();
1408:                    lResult.setStylesheet(lStylesheet);
1409:                    return lResult;
1410:                } catch (com.metaboss.enterprise.bo.BOException e) {
1411:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1412:                            "Caught error while generating EventSubscription stylesheet. EventSubscriptionRef: "
1413:                                    + pInput.getEventSubscriptionRef(), e);
1414:                }
1415:            }
1416:
1417:            /* Returns the stylesheet which describes names pertained to the structure */
1418:            public BSCodeGenerationStylesheet.STGetStructureStylesheetResult getStructureStylesheet(
1419:                    BSCodeGenerationStylesheet.STGetStructureStylesheetInput pInput)
1420:                    throws BSException {
1421:                try {
1422:                    // Get access to required model elements
1423:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1424:                            .getDefaultModelExtent();
1425:                    Structure lStructure = (Structure) lMetaBossModelPackage
1426:                            .getModelElement().getByRef(
1427:                                    pInput.getStructureRef());
1428:
1429:                    String lNormalisedStructureName = StringUtils.suggestName(
1430:                            lStructure.getName(), true, false);
1431:
1432:                    // Generate stylesheet
1433:                    STStructureStylesheet lStylesheet = new STStructureStylesheet();
1434:                    lStylesheet.setStructureRef(pInput.getStructureRef());
1435:                    lStylesheet.setNormalisedName(lNormalisedStructureName);
1436:                    lStylesheet.setNormalisedTypedName("Structure"
1437:                            + lNormalisedStructureName);
1438:                    // We prefix Structures with ST, so they look different from the data types
1439:                    lStylesheet.setClassName("ST" + lNormalisedStructureName);
1440:                    lStylesheet.setProxyClassName("PX"
1441:                            + lStylesheet.getClassName());
1442:                    lStylesheet.setProxyTranslatorClassName("TR"
1443:                            + lStylesheet.getClassName());
1444:                    lStylesheet.setValidatorClassName("VR"
1445:                            + lStylesheet.getClassName());
1446:
1447:                    // Work on location in the catalogue 
1448:                    Servicemodule lServicemodule = lStructure
1449:                            .getServicemodule();
1450:                    AbstractNamespace lNamespace = lStructure.getNamespace();
1451:                    if (lServicemodule != null) {
1452:                        // This Structure belongs to the servicemodule. Obtain servicemodule stylesheet
1453:                        BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput lServicemoduleStylesheetInput = new BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput();
1454:                        lServicemoduleStylesheetInput
1455:                                .setServicemoduleRef(lServicemodule.getRef());
1456:                        STServicemoduleStylesheet lServicemoduleStylesheet = getStylesheetService()
1457:                                .getServicemoduleStylesheet(
1458:                                        lServicemoduleStylesheetInput)
1459:                                .getStylesheet();
1460:
1461:                        // This structure is inside servicemodule catalogue
1462:                        lStylesheet
1463:                                .setCataloguePathToTop(lServicemoduleStylesheet
1464:                                        .getCataloguePathToTop()
1465:                                        + "../");
1466:                        lStylesheet
1467:                                .setCataloguePathFromTop(lServicemoduleStylesheet
1468:                                        .getCataloguePathFromTop()
1469:                                        + lServicemoduleStylesheet
1470:                                                .getNormalisedTypedName() + "/");
1471:
1472:                        // This structure is inside servicemodule package
1473:                        lStylesheet.setPackageName(lServicemoduleStylesheet
1474:                                .getPackageName());
1475:                        lStylesheet.setNamespaceURI(lServicemoduleStylesheet
1476:                                .getNamespaceURI());
1477:                    } else if (lNamespace != null) {
1478:                        // Work out the package name for this case
1479:                        if (lNamespace instanceof  Namespace) {
1480:                            // This Structure belongs to the namespace. Obtain namespace stylesheet
1481:                            BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput lNamespaceStylesheetInput = new BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput();
1482:                            lNamespaceStylesheetInput
1483:                                    .setNamespaceRef(lNamespace.getRef());
1484:                            STNamespaceStylesheet lNamespaceStylesheet = getStylesheetService()
1485:                                    .getNamespaceStylesheet(
1486:                                            lNamespaceStylesheetInput)
1487:                                    .getStylesheet();
1488:
1489:                            // This structure is inside namespace catalogue
1490:                            lStylesheet
1491:                                    .setCataloguePathToTop(lNamespaceStylesheet
1492:                                            .getCataloguePathToTop()
1493:                                            + "../");
1494:                            lStylesheet
1495:                                    .setCataloguePathFromTop(lNamespaceStylesheet
1496:                                            .getCataloguePathFromTop()
1497:                                            + lNamespaceStylesheet
1498:                                                    .getNormalisedTypedName()
1499:                                            + "/");
1500:
1501:                            // This structure is inside namespace package
1502:                            lStylesheet.setPackageName(lNamespaceStylesheet
1503:                                    .getPackageName());
1504:                            lStylesheet.setNamespaceURI(lNamespaceStylesheet
1505:                                    .getNamespaceURI());
1506:                        } else if (lNamespace instanceof  DataDictionary) {
1507:                            // This Structure belongs to the data dictionary. Obtain DataDictionary stylesheet
1508:                            BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput lDataDictionaryStylesheetInput = new BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput();
1509:                            lDataDictionaryStylesheetInput
1510:                                    .setDataDictionaryRef(lNamespace.getRef());
1511:                            STDataDictionaryStylesheet lDataDictionaryStylesheet = getStylesheetService()
1512:                                    .getDataDictionaryStylesheet(
1513:                                            lDataDictionaryStylesheetInput)
1514:                                    .getStylesheet();
1515:
1516:                            // This structure is inside datadictionary catalogue
1517:                            lStylesheet
1518:                                    .setCataloguePathToTop(lDataDictionaryStylesheet
1519:                                            .getCataloguePathToTop()
1520:                                            + "../");
1521:                            lStylesheet
1522:                                    .setCataloguePathFromTop(lDataDictionaryStylesheet
1523:                                            .getCataloguePathFromTop()
1524:                                            + lDataDictionaryStylesheet
1525:                                                    .getNormalisedTypedName()
1526:                                            + "/");
1527:
1528:                            // This structure is inside datadictionary package
1529:                            lStylesheet
1530:                                    .setPackageName(lDataDictionaryStylesheet
1531:                                            .getPackageName());
1532:                            lStylesheet
1533:                                    .setNamespaceURI(lDataDictionaryStylesheet
1534:                                            .getNamespaceURI());
1535:                        } else
1536:                            throw new BSUnexpectedProgramConditionException(
1537:                                    "AbstractNamespace can either be Namespace or DataDictionary. AbstractNamespaceRef: "
1538:                                            + lNamespace.getRef());
1539:                    } else
1540:                        throw new BSUnexpectedProgramConditionException(
1541:                                "Structure must belong to Namespace or Servicemodule. StructureRef: "
1542:                                        + pInput.getStructureRef());
1543:
1544:                    // Do this only after the package name is determined
1545:                    lStylesheet.setClassFullName(lStylesheet.getPackageName()
1546:                            + "." + lStylesheet.getClassName());
1547:
1548:                    // Prepare result and return
1549:                    BSCodeGenerationStylesheet.STGetStructureStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetStructureStylesheetResult();
1550:                    lResult.setStylesheet(lStylesheet);
1551:                    return lResult;
1552:                } catch (com.metaboss.enterprise.bo.BOException e) {
1553:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1554:                            "Caught error while generating Structure stylesheet. StructureRef: "
1555:                                    + pInput.getStructureRef(), e);
1556:                }
1557:            }
1558:
1559:            /* Returns the stylesheet which describes names pertained to the TypeTemplate */
1560:            public BSCodeGenerationStylesheet.STGetTypeTemplateStylesheetResult getTypeTemplateStylesheet(
1561:                    BSCodeGenerationStylesheet.STGetTypeTemplateStylesheetInput pInput)
1562:                    throws BSException {
1563:                try {
1564:                    // Get access to required model elements
1565:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1566:                            .getDefaultModelExtent();
1567:                    TypeTemplate lTypeTemplate = (TypeTemplate) lMetaBossModelPackage
1568:                            .getModelElement().getByRef(
1569:                                    pInput.getTypeTemplateRef());
1570:
1571:                    String lNormalisedTypeTemplateName = StringUtils
1572:                            .suggestName(lTypeTemplate.getName(), true, false);
1573:
1574:                    // Generate stylesheet
1575:                    STTypeTemplateStylesheet lStylesheet = new STTypeTemplateStylesheet();
1576:                    lStylesheet.setTypeTemplateRef(pInput.getTypeTemplateRef());
1577:                    lStylesheet.setNormalisedName(lNormalisedTypeTemplateName);
1578:                    lStylesheet.setNormalisedTypedName("TypeTemplate"
1579:                            + lNormalisedTypeTemplateName);
1580:                    AbstractNamespace lNamespace = lTypeTemplate.getNamespace();
1581:                    if (lNamespace instanceof  Namespace) {
1582:                        // This Structure belongs to the namespace. Obtain namespace stylesheet
1583:                        BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput lNamespaceStylesheetInput = new BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput();
1584:                        lNamespaceStylesheetInput.setNamespaceRef(lNamespace
1585:                                .getRef());
1586:                        STNamespaceStylesheet lNamespaceStylesheet = getStylesheetService()
1587:                                .getNamespaceStylesheet(
1588:                                        lNamespaceStylesheetInput)
1589:                                .getStylesheet();
1590:                        // This structure is inside namespace catalogue
1591:                        lStylesheet.setCataloguePathToTop(lNamespaceStylesheet
1592:                                .getCataloguePathToTop()
1593:                                + "../");
1594:                        lStylesheet
1595:                                .setCataloguePathFromTop(lNamespaceStylesheet
1596:                                        .getCataloguePathFromTop()
1597:                                        + lNamespaceStylesheet
1598:                                                .getNormalisedTypedName() + "/");
1599:                    } else if (lNamespace instanceof  DataDictionary) {
1600:                        // This Structure belongs to the data dictionary. Obtain DataDictionary stylesheet
1601:                        BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput lDataDictionaryStylesheetInput = new BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput();
1602:                        lDataDictionaryStylesheetInput
1603:                                .setDataDictionaryRef(lNamespace.getRef());
1604:                        STDataDictionaryStylesheet lDataDictionaryStylesheet = getStylesheetService()
1605:                                .getDataDictionaryStylesheet(
1606:                                        lDataDictionaryStylesheetInput)
1607:                                .getStylesheet();
1608:                        // This structure is inside namespace catalogue
1609:                        lStylesheet
1610:                                .setCataloguePathToTop(lDataDictionaryStylesheet
1611:                                        .getCataloguePathToTop()
1612:                                        + "../");
1613:                        lStylesheet
1614:                                .setCataloguePathFromTop(lDataDictionaryStylesheet
1615:                                        .getCataloguePathFromTop()
1616:                                        + lDataDictionaryStylesheet
1617:                                                .getNormalisedTypedName() + "/");
1618:                    } else
1619:                        throw new BSUnexpectedProgramConditionException(
1620:                                "AbstractNamespace can either be Namespace or DataDictionary. AbstractNamespaceRef: "
1621:                                        + lNamespace.getRef());
1622:
1623:                    // Prepare result and return
1624:                    BSCodeGenerationStylesheet.STGetTypeTemplateStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetTypeTemplateStylesheetResult();
1625:                    lResult.setStylesheet(lStylesheet);
1626:                    return lResult;
1627:                } catch (com.metaboss.enterprise.bo.BOException e) {
1628:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1629:                            "Caught error while generating TypeTemplate stylesheet. TypeTemplateRef: "
1630:                                    + pInput.getTypeTemplateRef(), e);
1631:                }
1632:            }
1633:
1634:            /* Returns the stylesheet which describes names pertained to the operation */
1635:            public BSCodeGenerationStylesheet.STGetOperationStylesheetResult getOperationStylesheet(
1636:                    BSCodeGenerationStylesheet.STGetOperationStylesheetInput pInput)
1637:                    throws BSException {
1638:                try {
1639:                    // Get access to required model elements
1640:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1641:                            .getDefaultModelExtent();
1642:                    Operation lOperation = (Operation) lMetaBossModelPackage
1643:                            .getModelElement().getByRef(
1644:                                    pInput.getOperationRef());
1645:                    Service lService = lOperation.getService();
1646:                    Servicemodule lServicemodule = lService.getServicemodule();
1647:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lServicemodule
1648:                            .getSystem();
1649:                    Enterprise lEnterprise = (Enterprise) lSystem
1650:                            .getEnterprise();
1651:
1652:                    String lNormalisedOperationName = StringUtils.suggestName(
1653:                            lOperation.getName(), true, false);
1654:
1655:                    // Obtain service stylesheet
1656:                    BSCodeGenerationStylesheet.STGetServiceStylesheetInput lServiceStylesheetInput = new BSCodeGenerationStylesheet.STGetServiceStylesheetInput();
1657:                    lServiceStylesheetInput.setServiceRef(lService.getRef());
1658:                    STServiceStylesheet lServiceStylesheet = getStylesheetService()
1659:                            .getServiceStylesheet(lServiceStylesheetInput)
1660:                            .getStylesheet();
1661:
1662:                    // The method name has first character lowered
1663:                    String lMethodName = lNormalisedOperationName.substring(0,
1664:                            1).toLowerCase()
1665:                            + lNormalisedOperationName.substring(1);
1666:
1667:                    // Generate stylesheet
1668:                    STOperationStylesheet lStylesheet = new STOperationStylesheet();
1669:                    lStylesheet.setOperationRef(pInput.getOperationRef());
1670:                    lStylesheet.setNormalisedName(lNormalisedOperationName);
1671:                    lStylesheet.setMethodName(lMethodName);
1672:                    lStylesheet.setInputClassName("ST"
1673:                            + lStylesheet.getNormalisedName() + "Input");
1674:                    lStylesheet.setInputClassFullName(lServiceStylesheet
1675:                            .getInterfaceFullName()
1676:                            + "." + lStylesheet.getInputClassName());
1677:                    lStylesheet.setInputProxyInnerClassName("PXST"
1678:                            + lStylesheet.getNormalisedName() + "Input");
1679:                    lStylesheet.setInputProxyTranslatorInnerClassName("TRST"
1680:                            + lStylesheet.getNormalisedName() + "Input");
1681:                    lStylesheet.setInputProxyOuterClassName("PXST"
1682:                            + lServiceStylesheet.getNormalisedName()
1683:                            + lStylesheet.getNormalisedName() + "Input");
1684:                    lStylesheet.setInputProxyTranslatorOuterClassName("TRST"
1685:                            + lServiceStylesheet.getNormalisedName()
1686:                            + lStylesheet.getNormalisedName() + "Input");
1687:                    lStylesheet.setInputValidatorInnerClassName("VRST"
1688:                            + lStylesheet.getNormalisedName() + "Input");
1689:                    lStylesheet.setInputValidatorOuterClassName("VRST"
1690:                            + lServiceStylesheet.getNormalisedName()
1691:                            + lStylesheet.getNormalisedName() + "Input");
1692:                    lStylesheet.setResultClassName("ST"
1693:                            + lStylesheet.getNormalisedName() + "Result");
1694:                    lStylesheet.setResultClassFullName(lServiceStylesheet
1695:                            .getInterfaceFullName()
1696:                            + "." + lStylesheet.getResultClassName());
1697:                    lStylesheet.setResultProxyInnerClassName("PXST"
1698:                            + lStylesheet.getNormalisedName() + "Result");
1699:                    lStylesheet.setResultProxyTranslatorInnerClassName("TRST"
1700:                            + lStylesheet.getNormalisedName() + "Result");
1701:                    lStylesheet.setResultProxyOuterClassName("PXST"
1702:                            + lServiceStylesheet.getNormalisedName()
1703:                            + lStylesheet.getNormalisedName() + "Result");
1704:                    lStylesheet.setResultProxyTranslatorOuterClassName("TRST"
1705:                            + lServiceStylesheet.getNormalisedName()
1706:                            + lStylesheet.getNormalisedName() + "Result");
1707:                    lStylesheet
1708:                            .setInvalidOperationInputOperationOutputMessageName("InvalidOperationInputError");
1709:                    BSCodeGenerationStylesheet.STGetOperationStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetOperationStylesheetResult();
1710:                    lResult.setStylesheet(lStylesheet);
1711:                    return lResult;
1712:                } catch (com.metaboss.enterprise.bo.BOException e) {
1713:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1714:                            "Caught error while generating Operation stylesheet. OperationRef: "
1715:                                    + pInput.getOperationRef(), e);
1716:                }
1717:            }
1718:
1719:            /* Returns the stylesheet which describes names pertained to the event subsription operation */
1720:            public BSCodeGenerationStylesheet.STGetEventSubscriptionOperationStylesheetResult getEventSubscriptionOperationStylesheet(
1721:                    BSCodeGenerationStylesheet.STGetEventSubscriptionOperationStylesheetInput pInput)
1722:                    throws BSException {
1723:                try {
1724:                    // Get access to required model elements
1725:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1726:                            .getDefaultModelExtent();
1727:                    EventSubscriptionOperation lEventSubscriptionOperation = (EventSubscriptionOperation) lMetaBossModelPackage
1728:                            .getModelElement().getByRef(
1729:                                    pInput.getEventSubscriptionOperationRef());
1730:                    EventSubscription lEventSubscription = lEventSubscriptionOperation
1731:                            .getSubscription();
1732:                    Servicemodule lServicemodule = lEventSubscription
1733:                            .getServicemodule();
1734:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lServicemodule
1735:                            .getSystem();
1736:                    Enterprise lEnterprise = (Enterprise) lSystem
1737:                            .getEnterprise();
1738:
1739:                    // Obtain event subscription stylesheet
1740:                    BSCodeGenerationStylesheet.STGetEventSubscriptionStylesheetInput lEventSubscriptionStylesheetInput = new BSCodeGenerationStylesheet.STGetEventSubscriptionStylesheetInput();
1741:                    lEventSubscriptionStylesheetInput
1742:                            .setEventSubscriptionRef(lEventSubscription
1743:                                    .getRef());
1744:                    STEventSubscriptionStylesheet lEventSubscriptionStylesheet = getStylesheetService()
1745:                            .getEventSubscriptionStylesheet(
1746:                                    lEventSubscriptionStylesheetInput)
1747:                            .getStylesheet();
1748:
1749:                    // Obtain servicemodule stylesheet
1750:                    BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput lServicemoduleStylesheetInput = new BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput();
1751:                    lServicemoduleStylesheetInput
1752:                            .setServicemoduleRef(lServicemodule.getRef());
1753:                    STServicemoduleStylesheet lServicemoduleStylesheet = getStylesheetService()
1754:                            .getServicemoduleStylesheet(
1755:                                    lServicemoduleStylesheetInput)
1756:                            .getStylesheet();
1757:
1758:                    // Generate stylesheet
1759:                    STEventSubscriptionOperationStylesheet lStylesheet = new STEventSubscriptionOperationStylesheet();
1760:                    lStylesheet.setEventSubscriptionOperationRef(pInput
1761:                            .getEventSubscriptionOperationRef());
1762:                    lStylesheet.setSubscribeMethodName("subscribe");
1763:                    lStylesheet.setUnsubscribeMethodName("unsubscribe");
1764:                    lStylesheet.setInputClassName("STSubscriptionInput");
1765:
1766:                    lStylesheet
1767:                            .setInputClassFullName(lEventSubscriptionStylesheet
1768:                                    .getInterfaceFullName()
1769:                                    + "." + lStylesheet.getInputClassName());
1770:                    lStylesheet
1771:                            .setInputProxyInnerClassName("PXSTSubscriptionInput");
1772:                    lStylesheet
1773:                            .setInputProxyTranslatorInnerClassName("TRSTSubscriptionInput");
1774:                    lStylesheet.setInputProxyOuterClassName("PXST"
1775:                            + lEventSubscriptionStylesheet.getNormalisedName()
1776:                            + "SubscriptionInput");
1777:                    lStylesheet.setInputProxyTranslatorOuterClassName("TRST"
1778:                            + lEventSubscriptionStylesheet.getNormalisedName()
1779:                            + "SubscriptionInput");
1780:                    lStylesheet
1781:                            .setInputValidatorInnerClassName("VRSTSubscriptionInput");
1782:                    lStylesheet.setInputValidatorOuterClassName("VRST"
1783:                            + lEventSubscriptionStylesheet.getNormalisedName()
1784:                            + "SubscriptionInput");
1785:                    lStylesheet.setResultClassName("STSubscriptionResult");
1786:                    lStylesheet
1787:                            .setResultClassFullName(lEventSubscriptionStylesheet
1788:                                    .getInterfaceFullName()
1789:                                    + "." + lStylesheet.getResultClassName());
1790:                    lStylesheet
1791:                            .setResultProxyInnerClassName("PXSTSubscriptionResult");
1792:                    lStylesheet
1793:                            .setResultProxyTranslatorInnerClassName("TRSTSubscriptionResult");
1794:                    lStylesheet.setResultProxyOuterClassName("PXST"
1795:                            + lEventSubscriptionStylesheet.getNormalisedName()
1796:                            + "SubscriptionResult");
1797:                    lStylesheet.setResultProxyTranslatorOuterClassName("TRST"
1798:                            + lEventSubscriptionStylesheet.getNormalisedName()
1799:                            + "SubscriptionResult");
1800:                    lStylesheet
1801:                            .setInvalidOperationInputOperationOutputMessageName("InvalidOperationInputError");
1802:                    BSCodeGenerationStylesheet.STGetEventSubscriptionOperationStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetEventSubscriptionOperationStylesheetResult();
1803:                    lResult.setStylesheet(lStylesheet);
1804:                    return lResult;
1805:                } catch (com.metaboss.enterprise.bo.BOException e) {
1806:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1807:                            "Caught error while generating EventSubscriptionOperation stylesheet. EventSubscriptionOperationRef: "
1808:                                    + pInput.getEventSubscriptionOperationRef(),
1809:                            e);
1810:                }
1811:            }
1812:
1813:            /* Returns the stylesheet which describes names pertained to the event */
1814:            public BSCodeGenerationStylesheet.STGetEventStylesheetResult getEventStylesheet(
1815:                    BSCodeGenerationStylesheet.STGetEventStylesheetInput pInput)
1816:                    throws BSException {
1817:                try {
1818:                    // Get access to required model elements
1819:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1820:                            .getDefaultModelExtent();
1821:                    Event lEvent = (Event) lMetaBossModelPackage
1822:                            .getModelElement().getByRef(pInput.getEventRef());
1823:                    EventSubscription lEventSubscription = lEvent
1824:                            .getSubscription();
1825:                    Servicemodule lServicemodule = lEventSubscription
1826:                            .getServicemodule();
1827:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lServicemodule
1828:                            .getSystem();
1829:                    Enterprise lEnterprise = (Enterprise) lSystem
1830:                            .getEnterprise();
1831:
1832:                    String lNormalisedEventName = StringUtils.suggestName(
1833:                            lEvent.getName(), true, false);
1834:
1835:                    // Obtain service stylesheet
1836:                    BSCodeGenerationStylesheet.STGetEventSubscriptionStylesheetInput lEventSubscriptionStylesheetInput = new BSCodeGenerationStylesheet.STGetEventSubscriptionStylesheetInput();
1837:                    lEventSubscriptionStylesheetInput
1838:                            .setEventSubscriptionRef(lEventSubscription
1839:                                    .getRef());
1840:                    STEventSubscriptionStylesheet lEventSubscriptionStylesheet = getStylesheetService()
1841:                            .getEventSubscriptionStylesheet(
1842:                                    lEventSubscriptionStylesheetInput)
1843:                            .getStylesheet();
1844:
1845:                    // Generate stylesheet
1846:                    STEventStylesheet lStylesheet = new STEventStylesheet();
1847:                    lStylesheet.setEventRef(pInput.getEventRef());
1848:                    lStylesheet.setNormalisedName(lNormalisedEventName);
1849:                    lStylesheet.setClassName("ST"
1850:                            + lStylesheet.getNormalisedName() + "Event");
1851:                    lStylesheet.setMethodName("on"
1852:                            + lStylesheet.getNormalisedName());
1853:                    lStylesheet.setClassFullName(lEventSubscriptionStylesheet
1854:                            .getInterfaceFullName()
1855:                            + "." + lStylesheet.getClassName());
1856:                    lStylesheet.setProxyInnerClassName("PXST"
1857:                            + lStylesheet.getNormalisedName() + "Event");
1858:                    lStylesheet.setProxyTranslatorInnerClassName("TRST"
1859:                            + lStylesheet.getNormalisedName() + "Event");
1860:                    lStylesheet.setProxyOuterClassName("PXST"
1861:                            + lEventSubscriptionStylesheet.getNormalisedName()
1862:                            + lStylesheet.getNormalisedName() + "Event");
1863:                    lStylesheet.setProxyTranslatorOuterClassName("TRST"
1864:                            + lEventSubscriptionStylesheet.getNormalisedName()
1865:                            + lStylesheet.getNormalisedName() + "Event");
1866:                    BSCodeGenerationStylesheet.STGetEventStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetEventStylesheetResult();
1867:                    lResult.setStylesheet(lStylesheet);
1868:                    return lResult;
1869:                } catch (com.metaboss.enterprise.bo.BOException e) {
1870:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
1871:                            "Caught error while generating Event stylesheet. EventRef: "
1872:                                    + pInput.getEventRef(), e);
1873:                }
1874:            }
1875:
1876:            /* Returns the stylesheet which describes names pertained to the entity */
1877:            public BSCodeGenerationStylesheet.STGetEntityStylesheetResult getEntityStylesheet(
1878:                    BSCodeGenerationStylesheet.STGetEntityStylesheetInput pInput)
1879:                    throws BSException {
1880:                try {
1881:                    // Get access to required model elements
1882:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
1883:                            .getDefaultModelExtent();
1884:                    Entity lEntity = (Entity) lMetaBossModelPackage
1885:                            .getModelElement().getByRef(pInput.getEntityRef());
1886:                    Domain lDomain = lEntity.getDomain();
1887:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
1888:                            .getSystem();
1889:                    Enterprise lEnterprise = (Enterprise) lSystem
1890:                            .getEnterprise();
1891:
1892:                    String lEnterpriseName = lEnterprise.getName();
1893:                    String lSystemName = lSystem.getName();
1894:                    String lDomainName = lDomain.getName();
1895:
1896:                    String lNormalisedEntityName = StringUtils.suggestName(
1897:                            lEntity.getName(), true, false);
1898:                    String lNormalisedEntityPluralName = StringUtils
1899:                            .suggestName(lEntity.getPluralName(), true, false);
1900:
1901:                    // Obtain domain stylesheet
1902:                    BSCodeGenerationStylesheet.STGetDomainStylesheetInput lDomainStylesheetInput = new BSCodeGenerationStylesheet.STGetDomainStylesheetInput();
1903:                    lDomainStylesheetInput.setDomainRef(lDomain.getRef());
1904:                    STDomainStylesheet lDomainStylesheet = getStylesheetService()
1905:                            .getDomainStylesheet(lDomainStylesheetInput)
1906:                            .getStylesheet();
1907:
1908:                    // Generate stylesheet
1909:                    STEntityStylesheet lStylesheet = new STEntityStylesheet();
1910:                    lStylesheet.setEntityRef(pInput.getEntityRef());
1911:                    lStylesheet.setNormalisedName(lNormalisedEntityName);
1912:                    lStylesheet
1913:                            .setNormalisedPluralName(lNormalisedEntityPluralName);
1914:                    lStylesheet.setNormalisedTypedName("Entity"
1915:                            + lNormalisedEntityName);
1916:                    lStylesheet.setDomainInterfaceName("BO"
1917:                            + lNormalisedEntityName);
1918:                    lStylesheet.setDomainImplementationName(lStylesheet
1919:                            .getDomainInterfaceName()
1920:                            + "Impl");
1921:                    lStylesheet.setDomainPackageName(lDomainStylesheet
1922:                            .getDomainPackageName());
1923:                    lStylesheet.setDomainInterfaceFullName(lStylesheet
1924:                            .getDomainPackageName()
1925:                            + "." + lStylesheet.getDomainInterfaceName());
1926:                    lStylesheet.setDomainCollectionInterfaceName(lStylesheet
1927:                            .getDomainInterfaceName()
1928:                            + "Collection");
1929:                    lStylesheet
1930:                            .setDomainCollectionInterfaceFullName(lStylesheet
1931:                                    .getDomainPackageName()
1932:                                    + "."
1933:                                    + lStylesheet
1934:                                            .getDomainCollectionInterfaceName());
1935:                    lStylesheet
1936:                            .setDomainCollectionImplementationName(lStylesheet
1937:                                    .getDomainCollectionInterfaceName()
1938:                                    + "Impl");
1939:                    lStylesheet
1940:                            .setServiceDetailsStructureName(lNormalisedEntityName
1941:                                    + "Details");
1942:                    lStylesheet
1943:                            .setServiceKeyStructureName(lNormalisedEntityName
1944:                                    + "Key");
1945:                    lStylesheet
1946:                            .setServiceInstanceNotFoundMessageName(lNormalisedEntityName
1947:                                    + "InstanceNotFoundError");
1948:                    lStylesheet
1949:                            .setServiceDuplicateCreateFailedMessageName(lNormalisedEntityName
1950:                                    + "CreationDuplicateKeyError");
1951:                    lStylesheet
1952:                            .setServiceVersionMismatchMessageName(lNormalisedEntityName
1953:                                    + "VersionMismatchError");
1954:                    lStylesheet.setServiceDetailsStructureTranslatorName("TR"
1955:                            + lStylesheet.getDomainInterfaceName());
1956:                    lStylesheet
1957:                            .setInstanceIdServiceStructureAttributeName("InstanceId");
1958:                    lStylesheet
1959:                            .setInstanceIdStorageStructureAttributeName("InstanceId");
1960:                    lStylesheet
1961:                            .setInstanceIdDomainObjectAttributeName(lNormalisedEntityName
1962:                                    + "InstanceId");
1963:                    lStylesheet
1964:                            .setVersionIdServiceStructureAttributeName("VersionId");
1965:                    lStylesheet
1966:                            .setVersionIdStorageStructureAttributeName("VersionId");
1967:                    lStylesheet
1968:                            .setVersionIdDomainObjectAttributeName(lNormalisedEntityName
1969:                                    + "VersionId");
1970:                    lStylesheet.setStateServiceStructureAttributeName("State");
1971:                    lStylesheet.setStateStorageStructureAttributeName("State");
1972:                    lStylesheet.setStateDomainObjectAttributeName("State");
1973:                    lStylesheet
1974:                            .setSupertypeStorageStructureAttributeName("SupertypeRecord");
1975:                    lStylesheet.setStorageInterfaceName("PS"
1976:                            + lNormalisedEntityName);
1977:                    lStylesheet.setStorageRecordName("ST"
1978:                            + lNormalisedEntityName + "Record");
1979:                    lStylesheet.setStorageImplementationName(lStylesheet
1980:                            .getStorageInterfaceName()
1981:                            + "Impl");
1982:                    lStylesheet.setStorageFactoryName(lStylesheet
1983:                            .getStorageInterfaceName()
1984:                            + "Factory");
1985:                    lStylesheet.setStoragePackageName(lDomainStylesheet
1986:                            .getStoragePackageName());
1987:                    lStylesheet.setStorageInterfaceFullName(lStylesheet
1988:                            .getStoragePackageName()
1989:                            + "." + lStylesheet.getStorageInterfaceName());
1990:                    lStylesheet.setStorageRecordFullName(lStylesheet
1991:                            .getStoragePackageName()
1992:                            + "." + lStylesheet.getStorageRecordName());
1993:                    // Entity is always inside the domain catalogue
1994:                    lStylesheet.setCataloguePathToTop(lDomainStylesheet
1995:                            .getCataloguePathToTop()
1996:                            + "../");
1997:                    lStylesheet.setCataloguePathFromTop(lDomainStylesheet
1998:                            .getCataloguePathFromTop()
1999:                            + lDomainStylesheet.getNormalisedTypedName() + "/");
2000:                    // Prepare result and return
2001:                    BSCodeGenerationStylesheet.STGetEntityStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetEntityStylesheetResult();
2002:                    lResult.setStylesheet(lStylesheet);
2003:                    return lResult;
2004:                } catch (com.metaboss.enterprise.bo.BOException e) {
2005:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2006:                            "Caught error while generating Entity stylesheet. EntityRef: "
2007:                                    + pInput.getEntityRef(), e);
2008:                }
2009:            }
2010:
2011:            /* Returns the stylesheet which describes names pertained to the entity */
2012:            public BSCodeGenerationStylesheet.STGetReportStylesheetResult getReportStylesheet(
2013:                    BSCodeGenerationStylesheet.STGetReportStylesheetInput pInput)
2014:                    throws BSException {
2015:                try {
2016:                    // Get access to required model elements
2017:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
2018:                            .getDefaultModelExtent();
2019:                    Report lReport = (Report) lMetaBossModelPackage
2020:                            .getModelElement().getByRef(pInput.getReportRef());
2021:                    String lNormalisedReportName = StringUtils.suggestName(
2022:                            lReport.getName(), true, false);
2023:
2024:                    Domain lDomain = lReport.getDomain();
2025:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
2026:                            .getSystem();
2027:                    Enterprise lEnterprise = (Enterprise) lSystem
2028:                            .getEnterprise();
2029:
2030:                    String lEnterpriseName = lEnterprise.getName();
2031:                    String lSystemName = lSystem.getName();
2032:                    String lDomainName = lDomain.getName();
2033:                    String lReportName = lReport.getName();
2034:                    String lReportNameWithCapitalStart = lReportName.substring(
2035:                            0, 1).toUpperCase()
2036:                            + lReportName.substring(1);
2037:                    int lReportOutputLevelsCount = lReport
2038:                            .getOutputLevelsCount();
2039:
2040:                    // Obtain domain stylesheet
2041:                    BSCodeGenerationStylesheet.STGetDomainStylesheetInput lDomainStylesheetInput = new BSCodeGenerationStylesheet.STGetDomainStylesheetInput();
2042:                    lDomainStylesheetInput.setDomainRef(lDomain.getRef());
2043:                    STDomainStylesheet lDomainStylesheet = getStylesheetService()
2044:                            .getDomainStylesheet(lDomainStylesheetInput)
2045:                            .getStylesheet();
2046:
2047:                    // Generate stylesheet
2048:                    STReportStylesheet lStylesheet = new STReportStylesheet();
2049:                    lStylesheet.setReportRef(pInput.getReportRef());
2050:                    lStylesheet.setNormalisedName(lNormalisedReportName);
2051:                    lStylesheet.setNormalisedTypedName("Report"
2052:                            + lNormalisedReportName);
2053:                    lStylesheet.setStoragePackageName(lDomainStylesheet
2054:                            .getStoragePackageName());
2055:                    lStylesheet.setStorageInterfaceName("PS"
2056:                            + lReportNameWithCapitalStart + "Report");
2057:                    lStylesheet.setStorageInterfaceFullName(lStylesheet
2058:                            .getStoragePackageName()
2059:                            + "." + lStylesheet.getStorageInterfaceName());
2060:                    lStylesheet.setDomainPackageName(lDomainStylesheet
2061:                            .getDomainPackageName());
2062:                    lStylesheet.setDomainInterfaceName("BO"
2063:                            + lReportNameWithCapitalStart);
2064:                    lStylesheet.setDomainImplementationName(lStylesheet
2065:                            .getDomainInterfaceName()
2066:                            + "Impl");
2067:                    lStylesheet.setDomainInterfaceFullName(lStylesheet
2068:                            .getDomainPackageName()
2069:                            + "." + lStylesheet.getDomainInterfaceName());
2070:                    lStylesheet.setDomainCollectionInterfaceName(lStylesheet
2071:                            .getDomainInterfaceName()
2072:                            + "Collection");
2073:                    lStylesheet
2074:                            .setDomainCollectionInterfaceFullName(lStylesheet
2075:                                    .getDomainPackageName()
2076:                                    + "."
2077:                                    + lStylesheet
2078:                                            .getDomainCollectionInterfaceName());
2079:                    lStylesheet
2080:                            .setDomainCollectionImplementationName(lStylesheet
2081:                                    .getDomainCollectionInterfaceName()
2082:                                    + "Impl");
2083:                    lStylesheet.setServiceDetailsStructureTranslatorName("TR"
2084:                            + lStylesheet.getDomainInterfaceName());
2085:                    lStylesheet
2086:                            .setInstanceIdServiceStructureAttributeName("InstanceId");
2087:                    lStylesheet
2088:                            .setInstanceIdStorageStructureAttributeName("InstanceId");
2089:                    lStylesheet
2090:                            .setInstanceIdDomainObjectAttributeName(lReportName
2091:                                    + "InstanceId");
2092:                    lStylesheet
2093:                            .setVersionIdServiceStructureAttributeName("VersionId");
2094:                    lStylesheet
2095:                            .setVersionIdStorageStructureAttributeName("VersionId");
2096:                    lStylesheet
2097:                            .setVersionIdDomainObjectAttributeName(lReportName
2098:                                    + "VersionId");
2099:                    lStylesheet.setStateServiceStructureAttributeName("State");
2100:                    lStylesheet.setStateStorageStructureAttributeName("State");
2101:                    lStylesheet.setStateDomainObjectAttributeName("State");
2102:                    lStylesheet
2103:                            .setSupertypeStorageStructureAttributeName("SupertypeRecord");
2104:                    lStylesheet.setStorageImplementationName(lStylesheet
2105:                            .getStorageInterfaceName()
2106:                            + "Impl");
2107:                    lStylesheet.setStorageFactoryName(lStylesheet
2108:                            .getStorageInterfaceName()
2109:                            + "Factory");
2110:                    // Report is always inside the domain catalogue
2111:                    lStylesheet.setCataloguePathToTop(lDomainStylesheet
2112:                            .getCataloguePathToTop()
2113:                            + "../");
2114:                    lStylesheet.setCataloguePathFromTop(lDomainStylesheet
2115:                            .getCataloguePathFromTop()
2116:                            + lDomainStylesheet.getNormalisedTypedName() + "/");
2117:                    // Prepare result and return
2118:                    BSCodeGenerationStylesheet.STGetReportStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetReportStylesheetResult();
2119:                    lResult.setStylesheet(lStylesheet);
2120:                    return lResult;
2121:                } catch (com.metaboss.enterprise.bo.BOException e) {
2122:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2123:                            "Caught error while generating Report stylesheet. ReportRef: "
2124:                                    + pInput.getReportRef(), e);
2125:                }
2126:            }
2127:
2128:            /* Returns the stylesheet which describes names pertained to the entity */
2129:            public BSCodeGenerationStylesheet.STGetReportOutputElementStylesheetResult getReportOutputElementStylesheet(
2130:                    BSCodeGenerationStylesheet.STGetReportOutputElementStylesheetInput pInput)
2131:                    throws BSException {
2132:                try {
2133:                    // Get access to required model elements
2134:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
2135:                            .getDefaultModelExtent();
2136:                    ReportOutputElement lReportOutputElement = (ReportOutputElement) lMetaBossModelPackage
2137:                            .getModelElement().getByRef(
2138:                                    pInput.getReportOutputElementRef());
2139:                    Report lReport = null;
2140:                    // Get to the top level
2141:                    {
2142:                        ReportOutputElement lTempReportOutputElement = lReportOutputElement;
2143:                        while (lTempReportOutputElement.getReport() == null)
2144:                            lTempReportOutputElement = lTempReportOutputElement
2145:                                    .getParenElement();
2146:                        lReport = lTempReportOutputElement.getReport();
2147:                    }
2148:                    Domain lDomain = lReport.getDomain();
2149:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
2150:                            .getSystem();
2151:                    Enterprise lEnterprise = (Enterprise) lSystem
2152:                            .getEnterprise();
2153:
2154:                    String lEnterpriseName = lEnterprise.getName();
2155:                    String lSystemName = lSystem.getName();
2156:                    String lDomainName = lDomain.getName();
2157:                    String lReportName = lReport.getName();
2158:                    String lReportNameWithCapitalStart = lReportName.substring(
2159:                            0, 1).toUpperCase()
2160:                            + lReportName.substring(1);
2161:
2162:                    // Obtain domain stylesheet
2163:                    BSCodeGenerationStylesheet.STGetReportStylesheetInput lReportStylesheetInput = new BSCodeGenerationStylesheet.STGetReportStylesheetInput();
2164:                    lReportStylesheetInput.setReportRef(lReport.getRef());
2165:                    STReportStylesheet lReportStylesheet = getReportStylesheet(
2166:                            lReportStylesheetInput).getStylesheet();
2167:
2168:                    // Generate stylesheet
2169:                    STReportOutputElementStylesheet lStylesheet = new STReportOutputElementStylesheet();
2170:                    lStylesheet.setReportOutputElementRef(pInput
2171:                            .getReportOutputElementRef());
2172:                    lStylesheet.setStoragePackageName(lReportStylesheet
2173:                            .getStoragePackageName());
2174:                    int lReportOutputLevelIndex = lReportOutputElement
2175:                            .getLevelIndex();
2176:                    if (lReportOutputLevelIndex == 0) {
2177:                        lStylesheet.setStorageRecordName("ST"
2178:                                + lReport.getName() + "Report");
2179:                        lStylesheet.setDomainInterfaceName("BO"
2180:                                + lReport.getName() + "Report");
2181:                    } else {
2182:                        lStylesheet.setStorageRecordName("ST"
2183:                                + lReport.getName() + "ReportSubLevel"
2184:                                + Integer.toString(lReportOutputLevelIndex));
2185:                        lStylesheet.setDomainInterfaceName("BO"
2186:                                + lReport.getName() + "ReportSubLevel"
2187:                                + Integer.toString(lReportOutputLevelIndex));
2188:                    }
2189:                    lStylesheet.setStorageRecordFullName(lStylesheet
2190:                            .getStoragePackageName()
2191:                            + "." + lStylesheet.getStorageRecordName());
2192:                    lStylesheet.setStorageRecordProxyName("PX"
2193:                            + lStylesheet.getStorageRecordName());
2194:                    lStylesheet.setStorageRecordProxyTranslatorName("TR"
2195:                            + lStylesheet.getStorageRecordName());
2196:                    lStylesheet.setDomainPackageName(lReportStylesheet
2197:                            .getDomainPackageName());
2198:                    lStylesheet.setDomainInterfaceFullName(lStylesheet
2199:                            .getDomainPackageName()
2200:                            + "." + lStylesheet.getDomainInterfaceName());
2201:                    lStylesheet.setDomainImplementationName(lStylesheet
2202:                            .getDomainInterfaceName()
2203:                            + "Impl");
2204:
2205:                    BSCodeGenerationStylesheet.STGetReportOutputElementStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetReportOutputElementStylesheetResult();
2206:                    lResult.setStylesheet(lStylesheet);
2207:                    return lResult;
2208:                } catch (com.metaboss.enterprise.bo.BOException e) {
2209:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2210:                            "Caught error while generating ReportOutputElement stylesheet. ReportOutputElementRef: "
2211:                                    + pInput.getReportOutputElementRef(), e);
2212:                }
2213:            }
2214:
2215:            /* Returns the stylesheet which describes names pertained to the datatype */
2216:            public BSCodeGenerationStylesheet.STGetDatatypeStylesheetResult getDatatypeStylesheet(
2217:                    BSCodeGenerationStylesheet.STGetDatatypeStylesheetInput pInput)
2218:                    throws BSException {
2219:                try {
2220:                    // Get the datatype object from the model
2221:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
2222:                            .getDefaultModelExtent();
2223:                    DataType lDatatype = (DataType) lMetaBossModelPackage
2224:                            .getModelElement()
2225:                            .getByRef(pInput.getDatatypeRef());
2226:                    String lNormalisedDatatypeName = StringUtils.suggestName(
2227:                            lDatatype.getName(), true, false);
2228:
2229:                    // Build stylesheet and do some validation at the same time
2230:                    STDatatypeStylesheet lStylesheet = new STDatatypeStylesheet();
2231:                    lStylesheet.setDatatypeRef(pInput.getDatatypeRef());
2232:                    lStylesheet.setNormalisedName(lNormalisedDatatypeName);
2233:                    lStylesheet.setNormalisedTypedName("DataType"
2234:                            + lNormalisedDatatypeName);
2235:                    lStylesheet.setClassName(lStylesheet.getNormalisedName());
2236:
2237:                    // Work on description
2238:                    String lDescriptionText = lDatatype.getDescription();
2239:                    if (lDescriptionText != null
2240:                            && lDescriptionText.trim().length() > 0) {
2241:                        lStylesheet.setDescriptionHtmlText(lDescriptionText);
2242:                        lStylesheet.setDescriptionPlainText(lDescriptionText);
2243:                    } else {
2244:                        BSCodeGenerationStylesheet.STGetDocumentationStylesheetInput lDocumentationStylesheetInput = new BSCodeGenerationStylesheet.STGetDocumentationStylesheetInput();
2245:                        STDocumentationStylesheet lDocumentationStylesheet = getStylesheetService()
2246:                                .getDocumentationStylesheet(
2247:                                        lDocumentationStylesheetInput)
2248:                                .getStylesheet();
2249:                        lStylesheet
2250:                                .setDescriptionHtmlText(lDocumentationStylesheet
2251:                                        .getMissingDescriptionHtmlText());
2252:                        lStylesheet
2253:                                .setDescriptionPlainText(lDocumentationStylesheet
2254:                                        .getMissingDescriptionPlainText());
2255:                    }
2256:
2257:                    // Set typetemplate properties if applicable
2258:                    if (lDatatype.getTypetemplate() != null)
2259:                        lStylesheet
2260:                                .setTypetemplateProperties(DataTypeUtils
2261:                                        .getTypetemplatePropertiesAsProperties(lDatatype));
2262:
2263:                    AbstractNamespace lNamespace = lDatatype.getNamespace();
2264:                    if (lNamespace instanceof  Namespace) {
2265:                        // This Datatype belongs to the namespace. Obtain namespace stylesheet
2266:                        BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput lNamespaceStylesheetInput = new BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput();
2267:                        lNamespaceStylesheetInput.setNamespaceRef(lNamespace
2268:                                .getRef());
2269:                        STNamespaceStylesheet lNamespaceStylesheet = getStylesheetService()
2270:                                .getNamespaceStylesheet(
2271:                                        lNamespaceStylesheetInput)
2272:                                .getStylesheet();
2273:
2274:                        // This datatype is inside namespace catalogue
2275:                        lStylesheet.setCataloguePathToTop(lNamespaceStylesheet
2276:                                .getCataloguePathToTop()
2277:                                + "../");
2278:                        lStylesheet
2279:                                .setCataloguePathFromTop(lNamespaceStylesheet
2280:                                        .getCataloguePathFromTop()
2281:                                        + lNamespaceStylesheet
2282:                                                .getNormalisedTypedName() + "/");
2283:
2284:                        // This datatype is inside namespace package
2285:                        lStylesheet.setPackageName(lNamespaceStylesheet
2286:                                .getPackageName());
2287:                        lStylesheet.setNamespaceURI(lNamespaceStylesheet
2288:                                .getNamespaceURI());
2289:
2290:                    } else if (lNamespace instanceof  DataDictionary) {
2291:                        // This Datatype belongs to the data dictionary. Obtain DataDictionary stylesheet
2292:                        BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput lDataDictionaryStylesheetInput = new BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput();
2293:                        lDataDictionaryStylesheetInput
2294:                                .setDataDictionaryRef(lNamespace.getRef());
2295:                        STDataDictionaryStylesheet lDataDictionaryStylesheet = getStylesheetService()
2296:                                .getDataDictionaryStylesheet(
2297:                                        lDataDictionaryStylesheetInput)
2298:                                .getStylesheet();
2299:
2300:                        // This datatype is inside namespace catalogue
2301:                        lStylesheet
2302:                                .setCataloguePathToTop(lDataDictionaryStylesheet
2303:                                        .getCataloguePathToTop()
2304:                                        + "../");
2305:                        lStylesheet
2306:                                .setCataloguePathFromTop(lDataDictionaryStylesheet
2307:                                        .getCataloguePathFromTop()
2308:                                        + lDataDictionaryStylesheet
2309:                                                .getNormalisedTypedName() + "/");
2310:
2311:                        // This datatype is inside datadictionary package
2312:                        lStylesheet.setPackageName(lDataDictionaryStylesheet
2313:                                .getPackageName());
2314:                        lStylesheet.setNamespaceURI(lDataDictionaryStylesheet
2315:                                .getNamespaceURI());
2316:                    } else
2317:                        throw new BSUnexpectedProgramConditionException(
2318:                                "AbstractNamespace can either be Namespace or DataDictionary. AbstractNamespaceRef: "
2319:                                        + lNamespace.getRef());
2320:
2321:                    // This must be here because it is using the package name 
2322:                    lStylesheet.setClassFullName(lStylesheet.getPackageName()
2323:                            + "." + lStylesheet.getClassName());
2324:
2325:                    // Package and return the result
2326:                    BSCodeGenerationStylesheet.STGetDatatypeStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetDatatypeStylesheetResult();
2327:                    lResult.setStylesheet(lStylesheet);
2328:                    return lResult;
2329:                } catch (com.metaboss.enterprise.bo.BOException e) {
2330:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2331:                            "Caught error while generating DataType stylesheet. DataTypeRef: "
2332:                                    + pInput.getDatatypeRef(), e);
2333:                }
2334:            }
2335:
2336:            private static HashMap sIDLTypeInformation = new HashMap();
2337:            static {
2338:                sIDLTypeInformation.put("PRIMITIVE_BOOLEAN", new String[] {
2339:                        "boolean", "sequence < boolean >",
2340:                        "sequence_of_sequences_of_boolean", "boolean", "{0}",
2341:                        "{0}" });
2342:                sIDLTypeInformation.put("PRIMITIVE_BYTE",
2343:                        new String[] { "octet", "sequence < octet >",
2344:                                "sequence_of_sequences_of_octet", "byte",
2345:                                "{0}", "{0}" });
2346:                sIDLTypeInformation.put("PRIMITIVE_SHORTINT",
2347:                        new String[] { "short", "sequence < short >",
2348:                                "sequence_of_sequences_of_short", "short",
2349:                                "{0}", "{0}" });
2350:                sIDLTypeInformation.put("PRIMITIVE_INT", new String[] { "long",
2351:                        "sequence < long >", "sequence_of_sequences_of_long",
2352:                        "int", "{0}", "{0}" });
2353:                sIDLTypeInformation.put("PRIMITIVE_LONGINT", new String[] {
2354:                        "long long", "sequence < long long >",
2355:                        "sequence_of_sequences_of_longlong", "long", "{0}",
2356:                        "{0}" });
2357:                sIDLTypeInformation.put("PRIMITIVE_DECIMAL", new String[] {
2358:                        "string", "sequence < string >",
2359:                        "sequence_of_sequences_of_string", "java.lang.String",
2360:                        "{0}.toString()", "new java.math.BigDecimal({0})" });
2361:                sIDLTypeInformation.put("PRIMITIVE_FLOAT",
2362:                        new String[] { "float", "sequence < float >",
2363:                                "sequence_of_sequences_of_float", "float",
2364:                                "{0}", "{0}" });
2365:                sIDLTypeInformation.put("PRIMITIVE_DOUBLE", new String[] {
2366:                        "double", "sequence < double >",
2367:                        "sequence_of_sequences_of_double", "double", "{0}",
2368:                        "{0}" });
2369:                sIDLTypeInformation.put("PRIMITIVE_STRING", new String[] {
2370:                        "string", "sequence < string >",
2371:                        "sequence_of_sequences_of_string", "java.lang.String",
2372:                        "{0}", "{0}" });
2373:                sIDLTypeInformation.put("PRIMITIVE_BOOLEANARRAY", new String[] {
2374:                        "sequence < boolean >",
2375:                        "sequence < sequence < boolean > >",
2376:                        "sequence_of_sequences_of_sequences_of_boolean",
2377:                        "boolean[]", "{0}", "{0}" });
2378:                sIDLTypeInformation.put("PRIMITIVE_BYTEARRAY", new String[] {
2379:                        "sequence < octet >",
2380:                        "sequence < sequence < octet > >",
2381:                        "sequence_of_sequences_of_sequences_of_octet",
2382:                        "byte[]", "{0}", "{0}" });
2383:                sIDLTypeInformation.put("PRIMITIVE_SHORTINTARRAY",
2384:                        new String[] { "sequence < short >",
2385:                                "sequence < sequence < short > >",
2386:                                "sequence_of_sequences_of_sequences_of_short",
2387:                                "short[]", "{0}", "{0}" });
2388:                sIDLTypeInformation.put("PRIMITIVE_INTARRAY", new String[] {
2389:                        "sequence < long >", "sequence < sequence < long > >",
2390:                        "sequence_of_sequences_of_sequences_of_long", "int[]",
2391:                        "{0}", "{0}" });
2392:                sIDLTypeInformation.put("PRIMITIVE_LONGINTARRAY", new String[] {
2393:                        "sequence < long long >",
2394:                        "sequence < sequence < long long > >",
2395:                        "sequence_of_sequences_of_sequences_of_longlong",
2396:                        "long[]", "{0}", "{0}" });
2397:                sIDLTypeInformation.put("PRIMITIVE_DECIMALARRAY", new String[] {
2398:                        "sequence < string >",
2399:                        "sequence < sequence < string > >",
2400:                        "sequence_of_sequences_of_sequences_of_string",
2401:                        "java.lang.String[]",
2402:                        "convertFromBigDecimalArray({0})",
2403:                        "convertToBigDecimalArray({0})" });
2404:                sIDLTypeInformation.put("PRIMITIVE_FLOATARRAY", new String[] {
2405:                        "sequence < float >",
2406:                        "sequence < sequence < float > >",
2407:                        "sequence_of_sequences_of_sequences_of_float",
2408:                        "float[]", "{0}", "{0}" });
2409:                sIDLTypeInformation.put("PRIMITIVE_DOUBLEARRAY", new String[] {
2410:                        "sequence < double >",
2411:                        "sequence < sequence < double > >",
2412:                        "sequence_of_sequences_of_sequences_of_double",
2413:                        "double[]", "{0}", "{0}" });
2414:                sIDLTypeInformation.put("PRIMITIVE_STRINGARRAY", new String[] {
2415:                        "sequence < string >",
2416:                        "sequence < sequence < string > >",
2417:                        "sequence_of_sequences_of_sequences_of_string",
2418:                        "java.lang.String", "{0}", "{0}" });
2419:            }
2420:
2421:            // Helper. Retirves mapping from the specified index for the specified java class
2422:            private static String getPrimitiveTypeMapping(
2423:                    DataTypeTranslationMetadata.PrimitiveType pPrimitiveType,
2424:                    int pMappingIndex) throws BSException {
2425:                String[] lMappings = (String[]) sIDLTypeInformation
2426:                        .get(pPrimitiveType.getName());
2427:                if (lMappings == null)
2428:                    throw new BSUnexpectedProgramConditionException(
2429:                            "Primitive type "
2430:                                    + pPrimitiveType.getName()
2431:                                    + " is not supported in IDL to Java mapping");
2432:                return lMappings[pMappingIndex]; // Return specified mapping
2433:            }
2434:
2435:            /* Returns the stylesheet which describes names pertained to the datatype translation */
2436:            public BSCodeGenerationStylesheet.STGetDatatypeTranslationStylesheetResult getDatatypeTranslationStylesheet(
2437:                    BSCodeGenerationStylesheet.STGetDatatypeTranslationStylesheetInput pInput)
2438:                    throws BSException {
2439:                try {
2440:                    // Get the datatype object from the model
2441:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
2442:                            .getDefaultModelExtent();
2443:                    DataType lDatatype = (DataType) lMetaBossModelPackage
2444:                            .getModelElement()
2445:                            .getByRef(pInput.getDatatypeRef());
2446:
2447:                    // Build stylesheet and do some validation at the same time
2448:                    STDatatypeTranslationStylesheet lStylesheet = new STDatatypeTranslationStylesheet();
2449:                    lStylesheet.setDatatypeRef(pInput.getDatatypeRef());
2450:
2451:                    // Obtain data type stylesheet
2452:                    BSCodeGenerationStylesheet.STGetDatatypeStylesheetInput lDatatypeStylesheetInput = new BSCodeGenerationStylesheet.STGetDatatypeStylesheetInput();
2453:                    lDatatypeStylesheetInput.setDatatypeRef(pInput
2454:                            .getDatatypeRef());
2455:                    STDatatypeStylesheet lDatatypeStylesheet = getStylesheetService()
2456:                            .getDatatypeStylesheet(lDatatypeStylesheetInput)
2457:                            .getStylesheet();
2458:
2459:                    DataTypeTranslationMetadata lDataTypeMetadata = DatatypeTranslationMetadataLoader
2460:                            .loadDataTypeTranslationMetadata(lDatatype,
2461:                                    lDatatypeStylesheet.getClassFullName());
2462:                    lStylesheet.setPrimitiveTypeName(lDataTypeMetadata
2463:                            .getPrimitiveType().getName());
2464:                    lStylesheet.setPrimitiveJavaTypeName(lDataTypeMetadata
2465:                            .getPrimitiveType().getJavaType().getName());
2466:                    lStylesheet.setPrimitiveArray(lDataTypeMetadata
2467:                            .getPrimitiveType().isArray());
2468:                    lStylesheet.setPrimitiveTypeProperties(lDataTypeMetadata
2469:                            .getPrimitiveTypeProperties());
2470:                    lStylesheet
2471:                            .setPrimitiveTranslatorClassName(lDataTypeMetadata
2472:                                    .getPrimitiveType().getTranslatorType()
2473:                                    .getName());
2474:                    lStylesheet.setSqlTypeName(lDataTypeMetadata.getSqlType()
2475:                            .getName());
2476:                    lStylesheet.setSqlTypeProperties(lDataTypeMetadata
2477:                            .getSqlTypeProperties());
2478:                    lStylesheet.setSqlTranslatorClassName(lDataTypeMetadata
2479:                            .getSqlType().getTranslatorType().getName());
2480:                    lStylesheet.setXmlTypeName(lDataTypeMetadata.getXmlType()
2481:                            .getName());
2482:                    lStylesheet.setXmlTypeProperties(lDataTypeMetadata
2483:                            .getXmlTypeProperties());
2484:                    lStylesheet.setXmlTranslatorClassName(lDataTypeMetadata
2485:                            .getXmlType().getTranslatorType().getName());
2486:                    // Set up derived CORBA values
2487:                    lStylesheet.setCORBAIDLTypeName(getPrimitiveTypeMapping(
2488:                            lDataTypeMetadata.getPrimitiveType(), 0));
2489:                    lStylesheet
2490:                            .setCORBAIDLArrayTypeName(getPrimitiveTypeMapping(
2491:                                    lDataTypeMetadata.getPrimitiveType(), 1));
2492:                    lStylesheet
2493:                            .setCORBAIDLJavaTypeName(getPrimitiveTypeMapping(
2494:                                    lDataTypeMetadata.getPrimitiveType(), 3));
2495:                    lStylesheet
2496:                            .setToCORBAIDLJavaTypeConversionFormat(getPrimitiveTypeMapping(
2497:                                    lDataTypeMetadata.getPrimitiveType(), 4));
2498:                    lStylesheet
2499:                            .setFromCORBAIDLJavaTypeConversionFormat(getPrimitiveTypeMapping(
2500:                                    lDataTypeMetadata.getPrimitiveType(), 5));
2501:
2502:                    // Package and return the result
2503:                    BSCodeGenerationStylesheet.STGetDatatypeTranslationStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetDatatypeTranslationStylesheetResult();
2504:                    lResult.setStylesheet(lStylesheet);
2505:                    return lResult;
2506:                } catch (com.metaboss.enterprise.bo.BOException e) {
2507:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2508:                            "Caught error while generating DataType stylesheet. DataTypeRef: "
2509:                                    + pInput.getDatatypeRef(), e);
2510:                }
2511:            }
2512:
2513:            /* Returns the stylesheet which describes names pertained to the structure */
2514:            public BSCodeGenerationStylesheet.STGetDocumentationStylesheetResult getDocumentationStylesheet(
2515:                    BSCodeGenerationStylesheet.STGetDocumentationStylesheetInput pInput)
2516:                    throws BSException {
2517:                // Generate stylesheet
2518:                STDocumentationStylesheet lStylesheet = new STDocumentationStylesheet();
2519:                lStylesheet
2520:                        .setMissingDescriptionPlainText("Description is missing in the model");
2521:                lStylesheet
2522:                        .setMissingDescriptionHtmlText("<font color=\"red\">"
2523:                                + lStylesheet.getMissingDescriptionPlainText()
2524:                                + "</font>");
2525:                lStylesheet.setDescriptionOpeningTags("<i>");
2526:                lStylesheet.setDescriptionClosingTags("</i>");
2527:                try {
2528:                    StringWriter lStringWriter = null;
2529:                    // Work on xml comment
2530:                    try {
2531:                        lStringWriter = new StringWriter();
2532:                        PrintWriter lPrintWriter = null;
2533:                        try {
2534:                            lPrintWriter = new PrintWriter(lStringWriter);
2535:                            CopyrightUtils
2536:                                    .writeCopyrightToGeneratedXMLFile(lPrintWriter);
2537:                            lPrintWriter.flush();
2538:                        } finally {
2539:                            if (lPrintWriter != null)
2540:                                lPrintWriter.close();
2541:                        }
2542:                        lStringWriter.flush();
2543:                        lStylesheet.setCopyrightCommentInXml(lStringWriter
2544:                                .toString());
2545:                        lStylesheet.setCopyrightCommentInHtml(lStringWriter
2546:                                .toString());
2547:                    } finally {
2548:                        if (lStringWriter != null)
2549:                            lStringWriter.close();
2550:                    }
2551:                    // Work on html comment
2552:                    try {
2553:                        lStringWriter = new StringWriter();
2554:                        PrintWriter lPrintWriter = null;
2555:                        try {
2556:                            lPrintWriter = new PrintWriter(lStringWriter);
2557:                            CopyrightUtils
2558:                                    .writeCopyrightToGeneratedHTMLFile(lPrintWriter);
2559:                            lPrintWriter.flush();
2560:                        } finally {
2561:                            if (lPrintWriter != null)
2562:                                lPrintWriter.close();
2563:                        }
2564:                        lStringWriter.flush();
2565:                        lStylesheet.setCopyrightCommentInHtml(lStringWriter
2566:                                .toString());
2567:                    } finally {
2568:                        if (lStringWriter != null)
2569:                            lStringWriter.close();
2570:                    }
2571:                    // Work on java comment
2572:                    try {
2573:                        lStringWriter = new StringWriter();
2574:                        PrintWriter lPrintWriter = null;
2575:                        try {
2576:                            lPrintWriter = new PrintWriter(lStringWriter);
2577:                            CopyrightUtils
2578:                                    .writeCopyrightToGeneratedJavaSource(lPrintWriter);
2579:                            lPrintWriter.flush();
2580:                        } finally {
2581:                            if (lPrintWriter != null)
2582:                                lPrintWriter.close();
2583:                        }
2584:                        lStringWriter.flush();
2585:                        lStylesheet.setCopyrightCommentInJava(lStringWriter
2586:                                .toString());
2587:                    } finally {
2588:                        if (lStringWriter != null)
2589:                            lStringWriter.close();
2590:                    }
2591:                    // Work on C comment
2592:                    try {
2593:                        lStringWriter = new StringWriter();
2594:                        PrintWriter lPrintWriter = null;
2595:                        try {
2596:                            lPrintWriter = new PrintWriter(lStringWriter);
2597:                            CopyrightUtils
2598:                                    .writeCopyrightToGeneratedCSource(lPrintWriter);
2599:                            lPrintWriter.flush();
2600:                        } finally {
2601:                            if (lPrintWriter != null)
2602:                                lPrintWriter.close();
2603:                        }
2604:                        lStringWriter.flush();
2605:                        lStylesheet.setCopyrightCommentInC(lStringWriter
2606:                                .toString());
2607:                    } finally {
2608:                        if (lStringWriter != null)
2609:                            lStringWriter.close();
2610:                    }
2611:                    // Work on properties comment
2612:                    try {
2613:                        lStringWriter = new StringWriter();
2614:                        PrintWriter lPrintWriter = null;
2615:                        try {
2616:                            lPrintWriter = new PrintWriter(lStringWriter);
2617:                            CopyrightUtils
2618:                                    .writeCopyrightToGeneratedPropertiesFile(lPrintWriter);
2619:                            lPrintWriter.flush();
2620:                        } finally {
2621:                            if (lPrintWriter != null)
2622:                                lPrintWriter.close();
2623:                        }
2624:                        lStringWriter.flush();
2625:                        lStylesheet
2626:                                .setCopyrightCommentInProperties(lStringWriter
2627:                                        .toString());
2628:                    } finally {
2629:                        if (lStringWriter != null)
2630:                            lStringWriter.close();
2631:                    }
2632:                    // Work on sql comment
2633:                    try {
2634:                        lStringWriter = new StringWriter();
2635:                        PrintWriter lPrintWriter = null;
2636:                        try {
2637:                            lPrintWriter = new PrintWriter(lStringWriter);
2638:                            CopyrightUtils
2639:                                    .writeCopyrightToGeneratedSQLFile(lPrintWriter);
2640:                            lPrintWriter.flush();
2641:                        } finally {
2642:                            if (lPrintWriter != null)
2643:                                lPrintWriter.close();
2644:                        }
2645:                        lStringWriter.flush();
2646:                        lStylesheet.setCopyrightCommentInSql(lStringWriter
2647:                                .toString());
2648:                    } finally {
2649:                        if (lStringWriter != null)
2650:                            lStringWriter.close();
2651:                    }
2652:                } catch (IOException e) {
2653:                    throw new BSUnexpectedProgramConditionException(
2654:                            "Unable to use StringWriter.", e);
2655:                }
2656:
2657:                // Build the module name using the following strategy
2658:                // FIX Version 4.4(Tiger) Design Library
2659:                //                        ^^^^^^^^^^^^^^--------- Root Element Type Name
2660:                //                 ^^^^^------------------------- ModelVersion Name (Optional any name but 'Default' will be displayed here)
2661:                //             ^^^^------------------------------ ModelVersion Identifier (Optional)
2662:                // ^^^^------------------------------------------ Root Element Name
2663:                //
2664:                try {
2665:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
2666:                            .getDefaultModelExtent();
2667:                    ModelElementClass lModelElementClass = lMetaBossModelPackage
2668:                            .getModelElement();
2669:                    String lVersionElementName = null;
2670:                    String lVersionElementIdentifier = null;
2671:                    String lRootElementName = null;
2672:                    String lRootElementType = null;
2673:
2674:                    // First find out if we have ModelVersion element
2675:                    ModelVersion lModelVersion = (ModelVersion) lModelElementClass
2676:                            .findByRef("ModelVersion");
2677:                    if (lModelVersion != null) {
2678:                        lVersionElementName = lModelVersion.getName();
2679:                        if (lVersionElementName.equals("Default"))
2680:                            lVersionElementName = null; // Default name means no special name for this version
2681:                        lVersionElementIdentifier = lModelVersion
2682:                                .getIdentifier();
2683:                    }
2684:                    // Now get one of the possible top level elements
2685:                    Enterprise lEnterprise = (Enterprise) lModelElementClass
2686:                            .findByRef("Enterprise");
2687:                    DesignLibrary lDesignLibrary = (DesignLibrary) lModelElementClass
2688:                            .findByRef("DesignLibrary");
2689:                    TechnologyLibrary lTechnologyLibrary = (TechnologyLibrary) lModelElementClass
2690:                            .findByRef("TechnologyLibrary");
2691:                    if (lEnterprise != null) {
2692:                        lRootElementName = lEnterprise.getName();
2693:                        lRootElementType = "Enterprise";
2694:                    } else if (lDesignLibrary != null) {
2695:                        lRootElementName = lDesignLibrary.getName();
2696:                        lRootElementType = "Design Library";
2697:                    } else if (lTechnologyLibrary != null) {
2698:                        lRootElementName = lTechnologyLibrary.getName();
2699:                        lRootElementType = "Technology Library";
2700:                    } else
2701:                        throw new BSUnexpectedProgramConditionException(
2702:                                "Unrecognised model type.");
2703:                    // Build model name
2704:                    StringBuffer lModelName = new StringBuffer();
2705:                    lModelName.append(lRootElementName);
2706:                    if (lVersionElementIdentifier != null) {
2707:                        lModelName.append(" Version ");
2708:                        lModelName.append(lVersionElementIdentifier);
2709:                    }
2710:                    if (lVersionElementName != null) {
2711:                        lModelName.append("(");
2712:                        lModelName.append(lVersionElementName);
2713:                        lModelName.append(")");
2714:                    }
2715:                    lModelName.append(" ");
2716:                    lModelName.append(lRootElementType);
2717:                    lStylesheet.setModelName(lModelName.toString());
2718:                } catch (com.metaboss.enterprise.bo.BOException e) {
2719:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2720:                            "Caught error while generating Documentation stylesheet.",
2721:                            e);
2722:                }
2723:
2724:                BSCodeGenerationStylesheet.STGetDocumentationStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetDocumentationStylesheetResult();
2725:                lResult.setStylesheet(lStylesheet);
2726:                return lResult;
2727:            }
2728:
2729:            /* Returns the stylesheet which describes names pertained to the message */
2730:            public BSCodeGenerationStylesheet.STGetMessageStylesheetResult getMessageStylesheet(
2731:                    BSCodeGenerationStylesheet.STGetMessageStylesheetInput pInput)
2732:                    throws BSException {
2733:                try {
2734:                    // Get access to required model elements
2735:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
2736:                            .getDefaultModelExtent();
2737:                    Message lMessage = (Message) lMetaBossModelPackage
2738:                            .getModelElement().getByRef(pInput.getMessageRef());
2739:                    String lNormalisedMessageName = StringUtils.suggestName(
2740:                            lMessage.getName(), true, false);
2741:
2742:                    // Generate stylesheet
2743:                    STMessageStylesheet lStylesheet = new STMessageStylesheet();
2744:                    lStylesheet.setMessageRef(pInput.getMessageRef());
2745:                    lStylesheet.setNormalisedName(lNormalisedMessageName);
2746:                    lStylesheet.setNormalisedTypedName("Message"
2747:                            + lNormalisedMessageName);
2748:                    lStylesheet.setClassName("MO" + lNormalisedMessageName);
2749:
2750:                    // Work on location in the catalogue 
2751:                    Servicemodule lServicemodule = lMessage.getServicemodule();
2752:                    AbstractNamespace lNamespace = lMessage.getNamespace();
2753:                    if (lServicemodule != null) {
2754:                        // This Structure belongs to the servicemodule. Obtain servicemodule stylesheet
2755:                        BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput lServicemoduleStylesheetInput = new BSCodeGenerationStylesheet.STGetServicemoduleStylesheetInput();
2756:                        lServicemoduleStylesheetInput
2757:                                .setServicemoduleRef(lServicemodule.getRef());
2758:                        STServicemoduleStylesheet lServicemoduleStylesheet = getStylesheetService()
2759:                                .getServicemoduleStylesheet(
2760:                                        lServicemoduleStylesheetInput)
2761:                                .getStylesheet();
2762:
2763:                        // This structure is inside servicemodule catalogue
2764:                        lStylesheet
2765:                                .setCataloguePathToTop(lServicemoduleStylesheet
2766:                                        .getCataloguePathToTop()
2767:                                        + "../");
2768:                        lStylesheet
2769:                                .setCataloguePathFromTop(lServicemoduleStylesheet
2770:                                        .getCataloguePathFromTop()
2771:                                        + lServicemoduleStylesheet
2772:                                                .getNormalisedTypedName() + "/");
2773:
2774:                        // This structure is inside servicemodule package
2775:                        lStylesheet.setPackageName(lServicemoduleStylesheet
2776:                                .getPackageName());
2777:                        lStylesheet.setNamespaceURI(lServicemoduleStylesheet
2778:                                .getNamespaceURI());
2779:                    } else if (lNamespace != null) {
2780:                        // Work out the package name for this case
2781:                        if (lNamespace instanceof  Namespace) {
2782:                            // This Structure belongs to the namespace. Obtain namespace stylesheet
2783:                            BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput lNamespaceStylesheetInput = new BSCodeGenerationStylesheet.STGetNamespaceStylesheetInput();
2784:                            lNamespaceStylesheetInput
2785:                                    .setNamespaceRef(lNamespace.getRef());
2786:                            STNamespaceStylesheet lNamespaceStylesheet = getStylesheetService()
2787:                                    .getNamespaceStylesheet(
2788:                                            lNamespaceStylesheetInput)
2789:                                    .getStylesheet();
2790:
2791:                            // This structure is inside namespace catalogue
2792:                            lStylesheet
2793:                                    .setCataloguePathToTop(lNamespaceStylesheet
2794:                                            .getCataloguePathToTop()
2795:                                            + "../");
2796:                            lStylesheet
2797:                                    .setCataloguePathFromTop(lNamespaceStylesheet
2798:                                            .getCataloguePathFromTop()
2799:                                            + lNamespaceStylesheet
2800:                                                    .getNormalisedTypedName()
2801:                                            + "/");
2802:
2803:                            // This structure is inside namespace package
2804:                            lStylesheet.setPackageName(lNamespaceStylesheet
2805:                                    .getPackageName());
2806:                            lStylesheet.setNamespaceURI(lNamespaceStylesheet
2807:                                    .getNamespaceURI());
2808:                        } else if (lNamespace instanceof  DataDictionary) {
2809:                            // This Structure belongs to the data dictionary. Obtain DataDictionary stylesheet
2810:                            BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput lDataDictionaryStylesheetInput = new BSCodeGenerationStylesheet.STGetDataDictionaryStylesheetInput();
2811:                            lDataDictionaryStylesheetInput
2812:                                    .setDataDictionaryRef(lNamespace.getRef());
2813:                            STDataDictionaryStylesheet lDataDictionaryStylesheet = getStylesheetService()
2814:                                    .getDataDictionaryStylesheet(
2815:                                            lDataDictionaryStylesheetInput)
2816:                                    .getStylesheet();
2817:
2818:                            // This structure is inside datadictionary catalogue
2819:                            lStylesheet
2820:                                    .setCataloguePathToTop(lDataDictionaryStylesheet
2821:                                            .getCataloguePathToTop()
2822:                                            + "../");
2823:                            lStylesheet
2824:                                    .setCataloguePathFromTop(lDataDictionaryStylesheet
2825:                                            .getCataloguePathFromTop()
2826:                                            + lDataDictionaryStylesheet
2827:                                                    .getNormalisedTypedName()
2828:                                            + "/");
2829:
2830:                            // This structure is inside datadictionary package
2831:                            lStylesheet
2832:                                    .setPackageName(lDataDictionaryStylesheet
2833:                                            .getPackageName());
2834:                            lStylesheet
2835:                                    .setNamespaceURI(lDataDictionaryStylesheet
2836:                                            .getNamespaceURI());
2837:                        } else
2838:                            throw new BSUnexpectedProgramConditionException(
2839:                                    "AbstractNamespace can either be Namespace or DataDictionary. AbstractNamespaceRef: "
2840:                                            + lNamespace.getRef());
2841:                    } else
2842:                        throw new BSUnexpectedProgramConditionException(
2843:                                "Message must belong to Namespace or Servicemodule. MessageRef: "
2844:                                        + pInput.getMessageRef());
2845:
2846:                    lStylesheet.setClassFullName(lStylesheet.getPackageName()
2847:                            + "." + lStylesheet.getClassName());
2848:                    lStylesheet.setProxyClassName("PX"
2849:                            + lStylesheet.getClassName());
2850:                    lStylesheet.setProxyTranslatorClassName("TR"
2851:                            + lStylesheet.getClassName());
2852:
2853:                    // Prepare result and return
2854:                    BSCodeGenerationStylesheet.STGetMessageStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetMessageStylesheetResult();
2855:                    lResult.setStylesheet(lStylesheet);
2856:                    return lResult;
2857:                } catch (BOException e) {
2858:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2859:                            "Caught error while generating Message stylesheet. MessageRef: "
2860:                                    + pInput.getMessageRef(), e);
2861:                }
2862:            }
2863:
2864:            /* Returns the stylesheet which describes names pertained to the entity */
2865:            public BSCodeGenerationStylesheet.STGetAssociationStylesheetResult getAssociationStylesheet(
2866:                    BSCodeGenerationStylesheet.STGetAssociationStylesheetInput pInput)
2867:                    throws BSException {
2868:                try {
2869:                    // Get access to required model elements
2870:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
2871:                            .getDefaultModelExtent();
2872:                    Association lAssociation = (Association) lMetaBossModelPackage
2873:                            .getModelElement().getByRef(
2874:                                    pInput.getAssociationRef());
2875:                    Domain lDomain = lAssociation.getDomain();
2876:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
2877:                            .getSystem();
2878:                    Enterprise lEnterprise = (Enterprise) lSystem
2879:                            .getEnterprise();
2880:
2881:                    String lEnterpriseName = lEnterprise.getName();
2882:                    String lDomainName = lDomain.getName();
2883:                    String lSystemName = lSystem.getName();
2884:                    String lNormalisedAssociationName = StringUtils
2885:                            .suggestName(lAssociation.getName(), true, false);
2886:
2887:                    // Obtain domain stylesheet
2888:                    BSCodeGenerationStylesheet.STGetDomainStylesheetInput lDomainStylesheetInput = new BSCodeGenerationStylesheet.STGetDomainStylesheetInput();
2889:                    lDomainStylesheetInput.setDomainRef(lDomain.getRef());
2890:                    STDomainStylesheet lDomainStylesheet = getStylesheetService()
2891:                            .getDomainStylesheet(lDomainStylesheetInput)
2892:                            .getStylesheet();
2893:
2894:                    // Generate stylesheet
2895:                    STAssociationStylesheet lStylesheet = new STAssociationStylesheet();
2896:                    lStylesheet.setAssociationRef(pInput.getAssociationRef());
2897:                    lStylesheet.setNormalisedName(lNormalisedAssociationName);
2898:                    lStylesheet.setNormalisedTypedName("Association"
2899:                            + lNormalisedAssociationName);
2900:                    lStylesheet.setStorageRecordName("ST"
2901:                            + lNormalisedAssociationName + "Association");
2902:                    lStylesheet.setStoragePackageName(lDomainStylesheet
2903:                            .getStoragePackageName());
2904:                    lStylesheet.setStorageRecordFullName(lStylesheet
2905:                            .getStoragePackageName()
2906:                            + "." + lStylesheet.getStorageRecordName());
2907:                    // Association is always inside the domain catalogue
2908:                    lStylesheet.setCataloguePathToTop(lDomainStylesheet
2909:                            .getCataloguePathToTop()
2910:                            + "../");
2911:                    lStylesheet.setCataloguePathFromTop(lDomainStylesheet
2912:                            .getCataloguePathFromTop()
2913:                            + lDomainStylesheet.getNormalisedTypedName() + "/");
2914:                    // Prepare result and return
2915:                    BSCodeGenerationStylesheet.STGetAssociationStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetAssociationStylesheetResult();
2916:                    lResult.setStylesheet(lStylesheet);
2917:                    return lResult;
2918:                } catch (com.metaboss.enterprise.bo.BOException e) {
2919:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2920:                            "Caught error while generating Association stylesheet. AssociationRef: "
2921:                                    + pInput.getAssociationRef(), e);
2922:                }
2923:            }
2924:
2925:            /* Returns the stylesheet which describes names pertained to the entity */
2926:            public BSCodeGenerationStylesheet.STGetAssociationRoleStylesheetResult getAssociationRoleStylesheet(
2927:                    BSCodeGenerationStylesheet.STGetAssociationRoleStylesheetInput pInput)
2928:                    throws BSException {
2929:                try {
2930:                    // Get access to required model elements
2931:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) getModelRepository()
2932:                            .getDefaultModelExtent();
2933:                    AssociationRole lAssociationRole = (AssociationRole) lMetaBossModelPackage
2934:                            .getModelElement().getByRef(
2935:                                    pInput.getAssociationRoleRef());
2936:                    Entity lReferencingEntity = lAssociationRole
2937:                            .getReferencingEntity();
2938:
2939:                    String lNormalisedAssociationRoleName = StringUtils
2940:                            .suggestName(lAssociationRole.getName(), true,
2941:                                    false);
2942:                    String lNormalisedAssociationRolePluralName = StringUtils
2943:                            .suggestName(lAssociationRole.getPluralName(),
2944:                                    true, false);
2945:
2946:                    // Obtain referencing entity stylesheet
2947:                    BSCodeGenerationStylesheet.STGetEntityStylesheetInput lEntityStylesheetInput = new BSCodeGenerationStylesheet.STGetEntityStylesheetInput();
2948:                    lEntityStylesheetInput.setEntityRef(lReferencingEntity
2949:                            .getRef());
2950:                    STEntityStylesheet lEntityStylesheet = getStylesheetService()
2951:                            .getEntityStylesheet(lEntityStylesheetInput)
2952:                            .getStylesheet();
2953:
2954:                    // Generate stylesheet
2955:                    STAssociationRoleStylesheet lStylesheet = new STAssociationRoleStylesheet();
2956:                    lStylesheet.setAssociationRoleRef(pInput
2957:                            .getAssociationRoleRef());
2958:                    lStylesheet
2959:                            .setNormalisedName(lNormalisedAssociationRoleName);
2960:                    lStylesheet
2961:                            .setNormalisedPluralName(lNormalisedAssociationRolePluralName);
2962:
2963:                    BSCodeGenerationStylesheet.STGetAssociationRoleStylesheetResult lResult = new BSCodeGenerationStylesheet.STGetAssociationRoleStylesheetResult();
2964:                    lResult.setStylesheet(lStylesheet);
2965:                    return lResult;
2966:                } catch (com.metaboss.enterprise.bo.BOException e) {
2967:                    throw new com.metaboss.enterprise.bs.BSDomainObjectInvocationException(
2968:                            "Caught error while generating association role stylesheet. AssociationRoleRef: "
2969:                                    + pInput.getAssociationRoleRef(), e);
2970:                }
2971:            }
2972:
2973:            // Helper. Gets model repository. Looks it up in the context if necessary	
2974:            private ModelRepository getModelRepository() throws BSException {
2975:                if (mModelRepository == null) {
2976:                    synchronized (mModelRepositoryCreationSemaphore) {
2977:                        if (mModelRepository == null) {
2978:                            try {
2979:                                Context lContext = new InitialContext();
2980:                                mModelRepository = (ModelRepository) lContext
2981:                                        .lookup(ModelRepository.COMPONENT_URL);
2982:                            } catch (javax.naming.NamingException e) {
2983:                                throw new BSNamingAndDirectoryServiceInvocationException(
2984:                                        "Unable to access model repository.", e);
2985:                            }
2986:                        }
2987:                    }
2988:                }
2989:                return mModelRepository;
2990:            }
2991:
2992:            // Helper. Gets implementation stylesheet service. Looks it up in the context if necessary	
2993:            private BSCodeGenerationStylesheet getStylesheetService()
2994:                    throws BSException {
2995:                if (mStylesheetService == null) {
2996:                    synchronized (mStylesheetServiceCreationSemaphore) {
2997:                        if (mStylesheetService == null) {
2998:                            try {
2999:                                Context lContext = new InitialContext();
3000:                                mStylesheetService = (BSCodeGenerationStylesheet) lContext
3001:                                        .lookup(BSCodeGenerationStylesheet.COMPONENT_URL);
3002:                            } catch (javax.naming.NamingException e) {
3003:                                throw new BSNamingAndDirectoryServiceInvocationException(
3004:                                        "Unable to access stylesheet service.",
3005:                                        e);
3006:                            }
3007:                        }
3008:                    }
3009:                }
3010:                return mStylesheetService;
3011:            }
3012:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.