Source Code Cross Referenced for DatatypeMetadataGenerator.java in  » UML » MetaBoss » com » metaboss » sdlctools » services » metadatamanagement » domainimplicitelementsmanagement » 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.metadatamanagement.domainimplicitelementsmanagement 
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.metadatamanagement.domainimplicitelementsmanagement;
0016:
0017:        import java.util.ArrayList;
0018:        import java.util.Collection;
0019:        import java.util.Comparator;
0020:        import java.util.Iterator;
0021:        import java.util.List;
0022:        import java.util.Set;
0023:        import java.util.TreeSet;
0024:
0025:        import javax.jmi.reflect.JmiException;
0026:
0027:        import org.apache.log4j.Logger;
0028:
0029:        import com.metaboss.enterprise.bs.BSException;
0030:        import com.metaboss.enterprise.bs.BSModelRepositoryInvocationException;
0031:        import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
0032:        import com.metaboss.sdlctools.models.metabossmodel.ModelElementClass;
0033:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
0034:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionaryModelPackage;
0035:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
0036:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataTypeClass;
0037:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Namespace;
0038:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.NamespaceClass;
0039:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Property;
0040:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.PropertyClass;
0041:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.PropertyDescriptor;
0042:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.TypeTemplate;
0043:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
0044:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
0045:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
0046:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
0047:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.EntityStereotypeEnum;
0048:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Report;
0049:        import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.State;
0050:        import com.metaboss.sdlctools.models.metabossmodel.statemachinemodel.Transition;
0051:        import com.metaboss.sdlctools.services.codegeneration.CodeGenerationStylesheetAccessor;
0052:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEntityStylesheet;
0053:
0054:        public class DatatypeMetadataGenerator {
0055:            private static Logger sLogger = Logger
0056:                    .getLogger(DatatypeMetadataGenerator.class);
0057:
0058:            // Utility comparator, which is used to sort properties in order of deletion
0059:            // The problem is that when parent property is deleted - the child property is deleted too, so
0060:            // the refDelete() may be issued against already deleted property. This comparator sorst the properties in the 
0061:            // reverse string sort order of the keys, which ensures that properties are sorted in the right order
0062:            // for deletion (child properties before parent ones)
0063:            private static Comparator sPropertiesToDeleteComparator = new Comparator() {
0064:                public int compare(Object o1, Object o2) {
0065:                    return ((Property) o2).getKey().compareTo(
0066:                            ((Property) o1).getKey());
0067:                }
0068:            };
0069:
0070:            public static void updateMetadata(Domain pDomain)
0071:                    throws BSException {
0072:                try {
0073:                    sLogger.info("Updating implicit datatypes metadata for "
0074:                            + pDomain.getRef() + " domain....");
0075:
0076:                    // Set up class objects, which will be used to create instances
0077:                    MetaBossModelPackage lRootPackage = (MetaBossModelPackage) pDomain
0078:                            .refOutermostPackage();
0079:                    DataDictionaryModelPackage lDataDictionaryModelPackage = lRootPackage
0080:                            .getDataDictionaryModel();
0081:                    NamespaceClass lNamespaceClass = lDataDictionaryModelPackage
0082:                            .getNamespace();
0083:                    DataTypeClass lDataTypeClass = lDataDictionaryModelPackage
0084:                            .getDataType();
0085:                    PropertyClass lPropertyClass = lDataDictionaryModelPackage
0086:                            .getProperty();
0087:
0088:                    // Setup typetemplates necessary for the datatypes
0089:                    ModelElementClass lModelElementClass = lRootPackage
0090:                            .getModelElement();
0091:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = pDomain
0092:                            .getSystem();
0093:                    DataDictionary lSystemDataDictionary = lSystem
0094:                            .getDataDictionary();
0095:                    Enterprise lEnterprise = lSystem.getEnterprise();
0096:                    DataDictionary lCoreDataDictionary = lEnterprise
0097:                            .getDesignLibrary().getDataDictionary("core");
0098:                    TypeTemplate lInstanceIdTypeTemplate = lCoreDataDictionary
0099:                            .getTypeTemplate("EntityInstanceIdentifierField");
0100:                    TypeTemplate lVersionIdTypeTemplate = lCoreDataDictionary
0101:                            .getTypeTemplate("EntityVersionIdentifierField");
0102:                    TypeTemplate lStateTypeTemplate = lCoreDataDictionary
0103:                            .getTypeTemplate("EntityStateField");
0104:                    TypeTemplate lEnumerableValueTypeTemplate = lCoreDataDictionary
0105:                            .getTypeTemplate("EnumerableValueField");
0106:                    // Setup some stock standard datatypes to set into entities and reports
0107:                    DataType lBooleanFlagDataType = lCoreDataDictionary
0108:                            .getDataType("BooleanField");
0109:                    DataType lCollectionOffsetDataType = lCoreDataDictionary
0110:                            .getDataType("CollectionOffset");
0111:                    DataType lCollectionSizeDataType = lCoreDataDictionary
0112:                            .getDataType("CollectionSize");
0113:                    DataType lSubsetSizeDataType = lCoreDataDictionary
0114:                            .getDataType("SubsetSize");
0115:                    DataType lReportPageOffsetDataType = lCoreDataDictionary
0116:                            .getDataType("ReportPageOffset");
0117:                    DataType lReportPageSizeDataType = lCoreDataDictionary
0118:                            .getDataType("ReportPageSize");
0119:                    DataType lReportSizeDataType = lCoreDataDictionary
0120:                            .getDataType("ReportSize");
0121:
0122:                    // First obtain list of datatypes and create hash set of the implicit types.
0123:                    Namespace lImplicitSystemDatatypesNamespace = lSystemDataDictionary
0124:                            .findSubNamespace("System");
0125:                    if (lImplicitSystemDatatypesNamespace == null) {
0126:                        lImplicitSystemDatatypesNamespace = lNamespaceClass
0127:                                .createNamespace();
0128:                        lImplicitSystemDatatypesNamespace.setName("System");
0129:                        lImplicitSystemDatatypesNamespace
0130:                                .setDescription("This namespace contains all implicit (i.e. autogenerated) datatypes used in the system.");
0131:                        lSystemDataDictionary.getSubNamespaces().add(
0132:                                lImplicitSystemDatatypesNamespace);
0133:                    }
0134:                    Namespace lImplicitDomainDatatypesNamespace = lImplicitSystemDatatypesNamespace
0135:                            .findSubNamespace(pDomain.getName());
0136:                    if (lImplicitDomainDatatypesNamespace == null) {
0137:                        lImplicitDomainDatatypesNamespace = lNamespaceClass
0138:                                .createNamespace();
0139:                        lImplicitDomainDatatypesNamespace.setName(pDomain
0140:                                .getName());
0141:                        lImplicitDomainDatatypesNamespace
0142:                                .setDescription("This namespace contains all implicit (i.e. autogenerated) datatypes used in the system.");
0143:                        lImplicitSystemDatatypesNamespace.getSubNamespaces()
0144:                                .add(lImplicitDomainDatatypesNamespace);
0145:                    }
0146:                    Collection lImplicitDatatypes = lImplicitDomainDatatypesNamespace
0147:                            .getDataTypes();
0148:                    // Put collection of datatypes aside, so we can keep track of processed ones and the ones need to be deleted
0149:                    List lUnprocessedDataTypes = new ArrayList();
0150:                    lUnprocessedDataTypes.addAll(lImplicitDatatypes);
0151:                    // Now we are ready to do reconcilitaion of the datatypes
0152:                    Collection lEntities = pDomain.getEntities();
0153:                    for (Iterator lEntitiesIterator = lEntities.iterator(); lEntitiesIterator
0154:                            .hasNext();) {
0155:                        Entity lEntity = (Entity) lEntitiesIterator.next();
0156:                        // Set all fixed datatypes
0157:                        lEntity
0158:                                .setCollectionContainsFlagDataType(lBooleanFlagDataType);
0159:                        lEntity
0160:                                .setCollectionEmptyFlagDataType(lBooleanFlagDataType);
0161:                        lEntity
0162:                                .setCollectionOffsetDataType(lCollectionOffsetDataType);
0163:                        lEntity
0164:                                .setCollectionSizeDataType(lCollectionSizeDataType);
0165:                        lEntity.setSubsetSizeDataType(lSubsetSizeDataType);
0166:
0167:                        STEntityStylesheet lEntityStylesheet = CodeGenerationStylesheetAccessor
0168:                                .getEntityStylesheet(lEntity);
0169:                        // Work on instanceId datatype
0170:                        {
0171:                            DataType lInstanceIdDatatype = lEntity
0172:                                    .getInstanceIdDataType();
0173:                            if (lInstanceIdDatatype == null) {
0174:                                lInstanceIdDatatype = lDataTypeClass
0175:                                        .createDataType();
0176:                                lInstanceIdDatatype
0177:                                        .setTypetemplate(lInstanceIdTypeTemplate);
0178:                                lImplicitDatatypes.add(lInstanceIdDatatype);
0179:                                lEntity
0180:                                        .setInstanceIdDataType(lInstanceIdDatatype);
0181:                            } else {
0182:                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0183:                                lUnprocessedDataTypes
0184:                                        .remove(lInstanceIdDatatype);
0185:                            }
0186:                            // Refresh some of the values, so even if datatype was there already - it will be updated
0187:                            lInstanceIdDatatype.setName(lEntity.getName()
0188:                                    + "InstanceId");
0189:                            lInstanceIdDatatype
0190:                                    .setDescription("This datatype is the instance identifier for the "
0191:                                            + lEntity.getName()
0192:                                            + " entity. It is created and destroyed from the model automatically at the same time as entity's definition itself is created or destroyed.");
0193:                            // Work on typetemplate properties
0194:                            Set lUnprocessedProperties = new TreeSet(
0195:                                    sPropertiesToDeleteComparator);
0196:                            lUnprocessedProperties.addAll(lInstanceIdDatatype
0197:                                    .getCombinedTypetemplateProperties());
0198:                            // Delete all unprocessed properties
0199:                            for (Iterator lUnprocessedPropertiesIterator = lUnprocessedProperties
0200:                                    .iterator(); lUnprocessedPropertiesIterator
0201:                                    .hasNext();) {
0202:                                Property lProperty = (Property) lUnprocessedPropertiesIterator
0203:                                        .next();
0204:                                lProperty.refDelete();
0205:                            }
0206:                        }
0207:
0208:                        // Do the same for version only if this entity is updatable
0209:                        if (lEntity.getStereotype().equals(
0210:                                EntityStereotypeEnum.CARD_FILE)) {
0211:                            DataType lVersionIdDatatype = lEntity
0212:                                    .getVersionIdDataType();
0213:                            if (lVersionIdDatatype == null) {
0214:                                lVersionIdDatatype = lDataTypeClass
0215:                                        .createDataType();
0216:                                lVersionIdDatatype
0217:                                        .setTypetemplate(lVersionIdTypeTemplate);
0218:                                lImplicitDatatypes.add(lVersionIdDatatype);
0219:                                lEntity
0220:                                        .setVersionIdDataType(lVersionIdDatatype);
0221:                            } else {
0222:                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0223:                                lUnprocessedDataTypes
0224:                                        .remove(lVersionIdDatatype);
0225:                            }
0226:                            // Refresh some of the values, so even if datatype was there already - it will be updated
0227:                            lVersionIdDatatype.setName(lEntity.getName()
0228:                                    + "VersionId");
0229:                            lVersionIdDatatype
0230:                                    .setDescription("This datatype is the version identifier for the "
0231:                                            + lEntity.getName()
0232:                                            + " entity. It is created and destroyed from the model automatically at the same time as entity's definition itself is created or destroyed.");
0233:                            // Work on typetemplate properties
0234:                            Set lUnprocessedProperties = new TreeSet(
0235:                                    sPropertiesToDeleteComparator);
0236:                            lUnprocessedProperties.addAll(lVersionIdDatatype
0237:                                    .getCombinedTypetemplateProperties());
0238:                            // Delete all unprocessed properties
0239:                            for (Iterator lUnprocessedPropertiesIterator = lUnprocessedProperties
0240:                                    .iterator(); lUnprocessedPropertiesIterator
0241:                                    .hasNext();) {
0242:                                Property lProperty = (Property) lUnprocessedPropertiesIterator
0243:                                        .next();
0244:                                lProperty.refDelete();
0245:                            }
0246:                        } else {
0247:                            // Just in case - set the datatype to null
0248:                            lEntity.setVersionIdDataType(null);
0249:                        }
0250:                        // Do the same for state only if this entity has one
0251:                        // Note that if entity has a state - it will also be used in ordering
0252:                        if (lEntity.getStateMachine() != null) {
0253:                            DataType lStateDatatype = lEntity
0254:                                    .getStateDataType();
0255:                            if (lStateDatatype == null) {
0256:                                lStateDatatype = lDataTypeClass
0257:                                        .createDataType();
0258:                                lStateDatatype
0259:                                        .setTypetemplate(lStateTypeTemplate);
0260:                                lImplicitDatatypes.add(lStateDatatype);
0261:                                lEntity.setStateDataType(lStateDatatype);
0262:                            } else {
0263:                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0264:                                lUnprocessedDataTypes.remove(lStateDatatype);
0265:                            }
0266:                            // Refresh some of the values, so even if datatype was there already - it will be updated
0267:                            lStateDatatype.setName(lEntity.getName() + "State");
0268:                            lStateDatatype
0269:                                    .setDescription("This datatype is the state for the "
0270:                                            + lEntity.getName()
0271:                                            + " entity. It is created and destroyed from the model automatically at the same time as entity's definition itself is created or destroyed.");
0272:                            // Work on typetemplate properties
0273:                            Set lUnprocessedProperties = new TreeSet(
0274:                                    sPropertiesToDeleteComparator);
0275:                            lUnprocessedProperties.addAll(lStateDatatype
0276:                                    .getCombinedTypetemplateProperties());
0277:                            {
0278:                                // This template requires whole state transition as properties
0279:                                PropertyDescriptor lStateRootPropertyDescriptor = lStateTypeTemplate
0280:                                        .getPropertyDescriptor("State");
0281:                                PropertyDescriptor lStateNamePropertyDescriptor = lStateRootPropertyDescriptor
0282:                                        .getPropertyDescriptor("Name");
0283:                                PropertyDescriptor lStateDescriptionPropertyDescriptor = lStateRootPropertyDescriptor
0284:                                        .getPropertyDescriptor("Description");
0285:                                PropertyDescriptor lStateTypePropertyDescriptor = lStateRootPropertyDescriptor
0286:                                        .getPropertyDescriptor("Type");
0287:                                PropertyDescriptor lStateTransitionPropertyDescriptor = lStateRootPropertyDescriptor
0288:                                        .getPropertyDescriptor("Transition");
0289:                                PropertyDescriptor lStateTransitionDestinationStateNamePropertyDescriptor = lStateTransitionPropertyDescriptor
0290:                                        .getPropertyDescriptor("DestinationStateName");
0291:                                PropertyDescriptor lStateTransitionDescriptionPropertyDescriptor = lStateTransitionPropertyDescriptor
0292:                                        .getPropertyDescriptor("Description");
0293:                                Collection lStates = lEntity.getStateMachine()
0294:                                        .getStates();
0295:                                int k = 0;
0296:                                for (Iterator lStatesIterator = lStates
0297:                                        .iterator(); lStatesIterator.hasNext(); k++) {
0298:                                    State lState = (State) lStatesIterator
0299:                                            .next();
0300:                                    String lStatePropertyKey = "State["
0301:                                            + Integer.toString(k + 1) + "]";
0302:                                    Property lStateRootProperty = lStateDatatype
0303:                                            .findTypetemplatePropertyByKey(lStatePropertyKey);
0304:                                    if (lStateRootProperty == null) {
0305:                                        lStateRootProperty = lPropertyClass
0306:                                                .createProperty();
0307:                                        lStateRootProperty.setName("State");
0308:                                        lStateRootProperty
0309:                                                .setDescription("The root property of all properties related to the '"
0310:                                                        + lState.getName()
0311:                                                        + "' state.");
0312:                                        lStateDatatype
0313:                                                .getTypetemplateProperties()
0314:                                                .add(lStateRootProperty);
0315:                                        lStateRootPropertyDescriptor
0316:                                                .getProperties().add(
0317:                                                        lStateRootProperty);
0318:                                    } else {
0319:                                        // Remove this datatype from the list of unprocessed ones, so it is not deleted
0320:                                        lUnprocessedProperties
0321:                                                .remove(lStateRootProperty);
0322:                                    }
0323:                                    {
0324:                                        Property lStateNameProperty = lStateRootProperty
0325:                                                .findPropertyByKey("Name");
0326:                                        if (lStateNameProperty == null) {
0327:                                            lStateNameProperty = lPropertyClass
0328:                                                    .createProperty();
0329:                                            lStateNameProperty.setName("Name");
0330:                                            lStateNameProperty
0331:                                                    .setDescription("The name of the state.");
0332:                                            lStateRootProperty
0333:                                                    .getSubProperties().add(
0334:                                                            lStateNameProperty);
0335:                                            lStateNamePropertyDescriptor
0336:                                                    .getProperties().add(
0337:                                                            lStateNameProperty);
0338:                                        } else {
0339:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0340:                                            lUnprocessedProperties
0341:                                                    .remove(lStateNameProperty);
0342:                                        }
0343:                                        lStateNameProperty.setValue(lState
0344:                                                .getName());
0345:                                    }
0346:                                    {
0347:                                        Property lStateDescriptionProperty = lStateRootProperty
0348:                                                .findPropertyByKey("Description");
0349:                                        if (lStateDescriptionProperty == null) {
0350:                                            lStateDescriptionProperty = lPropertyClass
0351:                                                    .createProperty();
0352:                                            lStateDescriptionProperty
0353:                                                    .setName("Description");
0354:                                            lStateDescriptionProperty
0355:                                                    .setDescription("The description of the state.");
0356:                                            lStateRootProperty
0357:                                                    .getSubProperties()
0358:                                                    .add(
0359:                                                            lStateDescriptionProperty);
0360:                                            lStateDescriptionPropertyDescriptor
0361:                                                    .getProperties()
0362:                                                    .add(
0363:                                                            lStateDescriptionProperty);
0364:                                        } else {
0365:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0366:                                            lUnprocessedProperties
0367:                                                    .remove(lStateDescriptionProperty);
0368:                                        }
0369:                                        lStateDescriptionProperty
0370:                                                .setValue(lState
0371:                                                        .getDescription());
0372:                                    }
0373:                                    {
0374:                                        Property lStateTypeProperty = lStateRootProperty
0375:                                                .findPropertyByKey("Type");
0376:                                        if (lStateTypeProperty == null) {
0377:                                            lStateTypeProperty = lPropertyClass
0378:                                                    .createProperty();
0379:                                            lStateTypeProperty.setName("Type");
0380:                                            lStateTypeProperty
0381:                                                    .setDescription("The type of the state.");
0382:                                            lStateRootProperty
0383:                                                    .getSubProperties().add(
0384:                                                            lStateTypeProperty);
0385:                                            lStateTypePropertyDescriptor
0386:                                                    .getProperties().add(
0387:                                                            lStateTypeProperty);
0388:                                        } else {
0389:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0390:                                            lUnprocessedProperties
0391:                                                    .remove(lStateTypeProperty);
0392:                                        }
0393:                                        lStateTypeProperty.setValue(lState
0394:                                                .getType().toString());
0395:                                    }
0396:                                    Collection lOutgoingTransitions = lState
0397:                                            .getOutgoingTranstions();
0398:                                    int m = 0;
0399:                                    for (Iterator lOutgoingTransitionsIterator = lOutgoingTransitions
0400:                                            .iterator(); lOutgoingTransitionsIterator
0401:                                            .hasNext(); m++) {
0402:                                        Transition lStateTransition = (Transition) lOutgoingTransitionsIterator
0403:                                                .next();
0404:                                        String lStateTransitionKey = "Transition["
0405:                                                + Integer.toString(m + 1) + "]";
0406:                                        Property lStateTransitionRootProperty = lStateRootProperty
0407:                                                .findPropertyByKey(lStateTransitionKey);
0408:                                        if (lStateTransitionRootProperty == null) {
0409:                                            lStateTransitionRootProperty = lPropertyClass
0410:                                                    .createProperty();
0411:                                            lStateTransitionRootProperty
0412:                                                    .setName("Transition");
0413:                                            lStateTransitionRootProperty
0414:                                                    .setDescription("The root property of all properties related to the '"
0415:                                                            + lStateTransition
0416:                                                                    .getName()
0417:                                                            + "' state transition information.");
0418:                                            lStateRootProperty
0419:                                                    .getSubProperties()
0420:                                                    .add(
0421:                                                            lStateTransitionRootProperty);
0422:                                            lStateTransitionPropertyDescriptor
0423:                                                    .getProperties()
0424:                                                    .add(
0425:                                                            lStateTransitionRootProperty);
0426:                                        } else {
0427:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0428:                                            lUnprocessedProperties
0429:                                                    .remove(lStateTransitionRootProperty);
0430:                                        }
0431:                                        {
0432:                                            Property lStateTransitionDestinationStateNameProperty = lStateTransitionRootProperty
0433:                                                    .findPropertyByKey("DestinationStateName");
0434:                                            if (lStateTransitionDestinationStateNameProperty == null) {
0435:                                                lStateTransitionDestinationStateNameProperty = lPropertyClass
0436:                                                        .createProperty();
0437:                                                lStateTransitionDestinationStateNameProperty
0438:                                                        .setName("DestinationStateName");
0439:                                                lStateTransitionDestinationStateNameProperty
0440:                                                        .setDescription("The name of the destination state in this transition.");
0441:                                                lStateTransitionRootProperty
0442:                                                        .getSubProperties()
0443:                                                        .add(
0444:                                                                lStateTransitionDestinationStateNameProperty);
0445:                                                lStateTransitionDestinationStateNamePropertyDescriptor
0446:                                                        .getProperties()
0447:                                                        .add(
0448:                                                                lStateTransitionDestinationStateNameProperty);
0449:                                            } else {
0450:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0451:                                                lUnprocessedProperties
0452:                                                        .remove(lStateTransitionDestinationStateNameProperty);
0453:                                            }
0454:                                            lStateTransitionDestinationStateNameProperty
0455:                                                    .setValue(lStateTransition
0456:                                                            .getEndState()
0457:                                                            .getName());
0458:                                        }
0459:                                        {
0460:                                            Property lStateTransitionDescriptionProperty = lStateTransitionRootProperty
0461:                                                    .findPropertyByKey("Description");
0462:                                            if (lStateTransitionDescriptionProperty == null) {
0463:                                                lStateTransitionDescriptionProperty = lPropertyClass
0464:                                                        .createProperty();
0465:                                                lStateTransitionDescriptionProperty
0466:                                                        .setName("Description");
0467:                                                lStateTransitionDescriptionProperty
0468:                                                        .setDescription("The description of the transition.");
0469:                                                lStateTransitionRootProperty
0470:                                                        .getSubProperties()
0471:                                                        .add(
0472:                                                                lStateTransitionDescriptionProperty);
0473:                                                lStateTransitionDescriptionPropertyDescriptor
0474:                                                        .getProperties()
0475:                                                        .add(
0476:                                                                lStateTransitionDescriptionProperty);
0477:                                            } else {
0478:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0479:                                                lUnprocessedProperties
0480:                                                        .remove(lStateTransitionDescriptionProperty);
0481:                                            }
0482:                                        }
0483:                                    }
0484:                                }
0485:                            }
0486:                            // Delete all unprocessed properties
0487:                            for (Iterator lUnprocessedPropertiesIterator = lUnprocessedProperties
0488:                                    .iterator(); lUnprocessedPropertiesIterator
0489:                                    .hasNext();) {
0490:                                Property lProperty = (Property) lUnprocessedPropertiesIterator
0491:                                        .next();
0492:                                lProperty.refDelete();
0493:                            }
0494:                        } else {
0495:                            // Just in case - set the datatype to null
0496:                            lEntity.setStateDataType(null);
0497:                        }
0498:
0499:                        // See if we need to support ordering in this entity. If we do - we need to 
0500:                        // generate special enumerated type with all possible ordering options
0501:                        // Note that all attributes which can be used for ordering in this entity and
0502:                        // in the supertypes are included
0503:                        Collection lOrderByAttributes = lEntity
0504:                                .getCombinedAttributesUsedForOrdering();
0505:                        if (!lOrderByAttributes.isEmpty()) {
0506:                            // Reuse existing object if it is present. If it is not present - create it
0507:                            DataType lOrderingInstructionDatatype = lEntity
0508:                                    .getOrderingInstructionDataType();
0509:                            if (lOrderingInstructionDatatype == null) {
0510:                                // Need to create one
0511:                                lOrderingInstructionDatatype = lDataTypeClass
0512:                                        .createDataType();
0513:                                lOrderingInstructionDatatype
0514:                                        .setTypetemplate(lEnumerableValueTypeTemplate);
0515:                                lImplicitDatatypes
0516:                                        .add(lOrderingInstructionDatatype);
0517:                                lEntity
0518:                                        .setOrderingInstructionDataType(lOrderingInstructionDatatype);
0519:                            } else {
0520:                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0521:                                lUnprocessedDataTypes
0522:                                        .remove(lOrderingInstructionDatatype);
0523:                            }
0524:                            // Refresh some of the values, so even if datatype was there already - it will be updated
0525:                            lOrderingInstructionDatatype.setName(lEntity
0526:                                    .getName()
0527:                                    + "OrderingInstruction");
0528:                            lOrderingInstructionDatatype
0529:                                    .setDescription("This datatype is the ordering instruction for the collections of "
0530:                                            + lEntity.getName()
0531:                                            + " entities. It is created and destroyed from the model automatically at the same time as entity's definition itself is created or destroyed.");
0532:
0533:                            Set lUnprocessedProperties = new TreeSet(
0534:                                    sPropertiesToDeleteComparator);
0535:                            lUnprocessedProperties
0536:                                    .addAll(lOrderingInstructionDatatype
0537:                                            .getCombinedTypetemplateProperties());
0538:                            {
0539:
0540:                                {
0541:                                    Property lComparableProperty = lOrderingInstructionDatatype
0542:                                            .findTypetemplatePropertyByKey("Comparable");
0543:                                    if (lComparableProperty == null) {
0544:                                        lComparableProperty = lPropertyClass
0545:                                                .createProperty();
0546:                                        lComparableProperty
0547:                                                .setName("Comparable");
0548:                                        lOrderingInstructionDatatype
0549:                                                .getTypetemplateProperties()
0550:                                                .add(lComparableProperty);
0551:                                        PropertyDescriptor lPropertyDescriptor = lEnumerableValueTypeTemplate
0552:                                                .getPropertyDescriptor("Comparable");
0553:                                        lPropertyDescriptor.getProperties()
0554:                                                .add(lComparableProperty);
0555:                                    } else {
0556:                                        // Remove this datatype from the list of unprocessed ones, so it is not deleted
0557:                                        lUnprocessedProperties
0558:                                                .remove(lComparableProperty);
0559:                                    }
0560:                                    // Set value even for existing property
0561:                                    lComparableProperty
0562:                                            .setDescription("Makes this enumerable type not comparable.");
0563:                                    lComparableProperty.setValue("false");
0564:                                }
0565:                                int lNextValueIndex = 0;
0566:                                int lNextCategoryIndex = 0;
0567:                                // Get some commonly used property descriptors
0568:                                PropertyDescriptor lCategoryPropertyDescriptor = lEnumerableValueTypeTemplate
0569:                                        .getPropertyDescriptor("Category");
0570:                                PropertyDescriptor lCategoryNamePropertyDescriptor = lCategoryPropertyDescriptor
0571:                                        .getPropertyDescriptor("Name");
0572:                                PropertyDescriptor lCategoryDescriptionPropertyDescriptor = lCategoryPropertyDescriptor
0573:                                        .getPropertyDescriptor("Description");
0574:                                PropertyDescriptor lCategoryValueNamePropertyDescriptor = lCategoryPropertyDescriptor
0575:                                        .getPropertyDescriptor("ValueName");
0576:                                PropertyDescriptor lValuePropertyDescriptor = lEnumerableValueTypeTemplate
0577:                                        .getPropertyDescriptor("Value");
0578:                                PropertyDescriptor lValueNamePropertyDescriptor = lValuePropertyDescriptor
0579:                                        .getPropertyDescriptor("Name");
0580:                                PropertyDescriptor lValueDescriptionPropertyDescriptor = lValuePropertyDescriptor
0581:                                        .getPropertyDescriptor("Description");
0582:
0583:                                // Introduce ascending category
0584:                                lNextCategoryIndex++;
0585:                                int lAscendingCategoryIndex = lNextCategoryIndex;
0586:                                int lNextAscendingCategoryValueIndex = 0;
0587:                                Property lAscendingCategoryPropertiesRootProperty = null;
0588:                                {
0589:                                    String lAscendingCategoryPropertiesRootKey = "Category["
0590:                                            + lNextCategoryIndex + "]";
0591:                                    lAscendingCategoryPropertiesRootProperty = lOrderingInstructionDatatype
0592:                                            .findTypetemplatePropertyByKey(lAscendingCategoryPropertiesRootKey);
0593:                                    if (lAscendingCategoryPropertiesRootProperty == null) {
0594:                                        lAscendingCategoryPropertiesRootProperty = lPropertyClass
0595:                                                .createProperty();
0596:                                        lAscendingCategoryPropertiesRootProperty
0597:                                                .setName("Category");
0598:                                        lOrderingInstructionDatatype
0599:                                                .getTypetemplateProperties()
0600:                                                .add(
0601:                                                        lAscendingCategoryPropertiesRootProperty);
0602:                                        lCategoryPropertyDescriptor
0603:                                                .getProperties()
0604:                                                .add(
0605:                                                        lAscendingCategoryPropertiesRootProperty);
0606:                                    } else {
0607:                                        // Remove this datatype from the list of unprocessed ones, so it is not deleted
0608:                                        lUnprocessedProperties
0609:                                                .remove(lAscendingCategoryPropertiesRootProperty);
0610:                                    }
0611:                                    lAscendingCategoryPropertiesRootProperty
0612:                                            .setDescription("The root category of the ascending ordering instructions.");
0613:                                    // Add name subproperty
0614:                                    {
0615:                                        Property lCategoryNameProperty = lAscendingCategoryPropertiesRootProperty
0616:                                                .findPropertyByKey("Name");
0617:                                        if (lCategoryNameProperty == null) {
0618:                                            lCategoryNameProperty = lPropertyClass
0619:                                                    .createProperty();
0620:                                            lCategoryNameProperty
0621:                                                    .setName("Name");
0622:                                            lAscendingCategoryPropertiesRootProperty
0623:                                                    .getSubProperties()
0624:                                                    .add(lCategoryNameProperty);
0625:                                            lCategoryNamePropertyDescriptor
0626:                                                    .getProperties()
0627:                                                    .add(lCategoryNameProperty);
0628:                                        } else {
0629:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0630:                                            lUnprocessedProperties
0631:                                                    .remove(lCategoryNameProperty);
0632:                                        }
0633:                                        lCategoryNameProperty
0634:                                                .setDescription("The name of the category.");
0635:                                        lCategoryNameProperty
0636:                                                .setValue("Ascending");
0637:                                    }
0638:                                    // Add description subproperty
0639:                                    {
0640:                                        Property lCategoryDescriptionProperty = lAscendingCategoryPropertiesRootProperty
0641:                                                .findPropertyByKey("Description");
0642:                                        if (lCategoryDescriptionProperty == null) {
0643:                                            lCategoryDescriptionProperty = lPropertyClass
0644:                                                    .createProperty();
0645:                                            lCategoryDescriptionProperty
0646:                                                    .setName("Description");
0647:                                            lAscendingCategoryPropertiesRootProperty
0648:                                                    .getSubProperties()
0649:                                                    .add(
0650:                                                            lCategoryDescriptionProperty);
0651:                                            lCategoryDescriptionPropertyDescriptor
0652:                                                    .getProperties()
0653:                                                    .add(
0654:                                                            lCategoryDescriptionProperty);
0655:                                        } else {
0656:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0657:                                            lUnprocessedProperties
0658:                                                    .remove(lCategoryDescriptionProperty);
0659:                                        }
0660:                                        lCategoryDescriptionProperty
0661:                                                .setDescription("The description of the category.");
0662:                                        lCategoryDescriptionProperty
0663:                                                .setValue("All possible ascending ordering instructions.");
0664:                                    }
0665:                                }
0666:                                // Introduce descending category
0667:                                lNextCategoryIndex++;
0668:                                int lDescendingCategoryIndex = lNextCategoryIndex;
0669:                                int lNextDescendingCategoryValueIndex = 0;
0670:                                Property lDescendingCategoryPropertiesRootProperty = null;
0671:                                {
0672:                                    String lDescendingCategoryPropertiesRootKey = "Category["
0673:                                            + lNextCategoryIndex + "]";
0674:                                    lDescendingCategoryPropertiesRootProperty = lOrderingInstructionDatatype
0675:                                            .findTypetemplatePropertyByKey(lDescendingCategoryPropertiesRootKey);
0676:                                    if (lDescendingCategoryPropertiesRootProperty == null) {
0677:                                        lDescendingCategoryPropertiesRootProperty = lPropertyClass
0678:                                                .createProperty();
0679:                                        lDescendingCategoryPropertiesRootProperty
0680:                                                .setName("Category");
0681:                                        lOrderingInstructionDatatype
0682:                                                .getTypetemplateProperties()
0683:                                                .add(
0684:                                                        lDescendingCategoryPropertiesRootProperty);
0685:                                        lCategoryPropertyDescriptor
0686:                                                .getProperties()
0687:                                                .add(
0688:                                                        lDescendingCategoryPropertiesRootProperty);
0689:                                    } else {
0690:                                        // Remove this datatype from the list of unprocessed ones, so it is not deleted
0691:                                        lUnprocessedProperties
0692:                                                .remove(lDescendingCategoryPropertiesRootProperty);
0693:                                    }
0694:                                    lDescendingCategoryPropertiesRootProperty
0695:                                            .setDescription("The root category of the descending ordering instructions.");
0696:                                    // Add name subproperty
0697:                                    {
0698:                                        Property lCategoryNameProperty = lDescendingCategoryPropertiesRootProperty
0699:                                                .findPropertyByKey("Name");
0700:                                        if (lCategoryNameProperty == null) {
0701:                                            lCategoryNameProperty = lPropertyClass
0702:                                                    .createProperty();
0703:                                            lCategoryNameProperty
0704:                                                    .setName("Name");
0705:                                            lDescendingCategoryPropertiesRootProperty
0706:                                                    .getSubProperties()
0707:                                                    .add(lCategoryNameProperty);
0708:                                            lCategoryNamePropertyDescriptor
0709:                                                    .getProperties()
0710:                                                    .add(lCategoryNameProperty);
0711:                                        } else {
0712:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0713:                                            lUnprocessedProperties
0714:                                                    .remove(lCategoryNameProperty);
0715:                                        }
0716:                                        lCategoryNameProperty
0717:                                                .setDescription("The name of the category.");
0718:                                        lCategoryNameProperty
0719:                                                .setValue("Descending");
0720:                                    }
0721:                                    // Add description subproperty
0722:                                    {
0723:                                        Property lCategoryDescriptionProperty = lDescendingCategoryPropertiesRootProperty
0724:                                                .findPropertyByKey("Description");
0725:                                        if (lCategoryDescriptionProperty == null) {
0726:                                            lCategoryDescriptionProperty = lPropertyClass
0727:                                                    .createProperty();
0728:                                            lCategoryDescriptionProperty
0729:                                                    .setName("Description");
0730:                                            lDescendingCategoryPropertiesRootProperty
0731:                                                    .getSubProperties()
0732:                                                    .add(
0733:                                                            lCategoryDescriptionProperty);
0734:                                            lCategoryDescriptionPropertyDescriptor
0735:                                                    .getProperties()
0736:                                                    .add(
0737:                                                            lCategoryDescriptionProperty);
0738:                                        } else {
0739:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0740:                                            lUnprocessedProperties
0741:                                                    .remove(lCategoryDescriptionProperty);
0742:                                        }
0743:                                        lCategoryDescriptionProperty
0744:                                                .setDescription("The description of the category.");
0745:                                        lCategoryDescriptionProperty
0746:                                                .setValue("All possible descending ordering instructions.");
0747:                                    }
0748:                                }
0749:
0750:                                for (Iterator lOrderByAttributesIterator = lOrderByAttributes
0751:                                        .iterator(); lOrderByAttributesIterator
0752:                                        .hasNext();) {
0753:                                    Attribute lAttribute = (Attribute) lOrderByAttributesIterator
0754:                                            .next();
0755:                                    ;
0756:                                    // First create this attribute's category	
0757:                                    lNextCategoryIndex++;
0758:                                    int lAttributeCategoryIndex = lNextCategoryIndex;
0759:                                    int lNextAttributeCategoryValueIndex = 0;
0760:                                    Property lByAttributeCategoryPropertiesRootProperty = null;
0761:                                    {
0762:                                        String lByAttributeCategoryPropertiesRootKey = "Category["
0763:                                                + lNextCategoryIndex + "]";
0764:                                        lByAttributeCategoryPropertiesRootProperty = lOrderingInstructionDatatype
0765:                                                .findTypetemplatePropertyByKey(lByAttributeCategoryPropertiesRootKey);
0766:                                        if (lByAttributeCategoryPropertiesRootProperty == null) {
0767:                                            lByAttributeCategoryPropertiesRootProperty = lPropertyClass
0768:                                                    .createProperty();
0769:                                            lByAttributeCategoryPropertiesRootProperty
0770:                                                    .setName("Category");
0771:                                            lOrderingInstructionDatatype
0772:                                                    .getTypetemplateProperties()
0773:                                                    .add(
0774:                                                            lByAttributeCategoryPropertiesRootProperty);
0775:                                            lCategoryPropertyDescriptor
0776:                                                    .getProperties()
0777:                                                    .add(
0778:                                                            lByAttributeCategoryPropertiesRootProperty);
0779:                                        } else {
0780:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0781:                                            lUnprocessedProperties
0782:                                                    .remove(lByAttributeCategoryPropertiesRootProperty);
0783:                                        }
0784:                                        lByAttributeCategoryPropertiesRootProperty
0785:                                                .setDescription("The root category of all properties related to ordering by "
0786:                                                        + lAttribute.getName()
0787:                                                        + " attribute.");
0788:                                        // Add name subproperty
0789:                                        {
0790:                                            Property lCategoryNameProperty = lByAttributeCategoryPropertiesRootProperty
0791:                                                    .findPropertyByKey("Name");
0792:                                            if (lCategoryNameProperty == null) {
0793:                                                lCategoryNameProperty = lPropertyClass
0794:                                                        .createProperty();
0795:                                                lCategoryNameProperty
0796:                                                        .setName("Name");
0797:                                                lByAttributeCategoryPropertiesRootProperty
0798:                                                        .getSubProperties()
0799:                                                        .add(
0800:                                                                lCategoryNameProperty);
0801:                                                lCategoryNamePropertyDescriptor
0802:                                                        .getProperties()
0803:                                                        .add(
0804:                                                                lCategoryNameProperty);
0805:                                            } else {
0806:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0807:                                                lUnprocessedProperties
0808:                                                        .remove(lCategoryNameProperty);
0809:                                            }
0810:                                            lCategoryNameProperty
0811:                                                    .setDescription("The name of the category.");
0812:                                            lCategoryNameProperty.setValue("By"
0813:                                                    + lAttribute.getName());
0814:                                        }
0815:                                        // Add description subproperty
0816:                                        {
0817:                                            Property lCategoryDescriptionProperty = lByAttributeCategoryPropertiesRootProperty
0818:                                                    .findPropertyByKey("Description");
0819:                                            if (lCategoryDescriptionProperty == null) {
0820:                                                lCategoryDescriptionProperty = lPropertyClass
0821:                                                        .createProperty();
0822:                                                lCategoryDescriptionProperty
0823:                                                        .setName("Description");
0824:                                                lByAttributeCategoryPropertiesRootProperty
0825:                                                        .getSubProperties()
0826:                                                        .add(
0827:                                                                lCategoryDescriptionProperty);
0828:                                                lCategoryDescriptionPropertyDescriptor
0829:                                                        .getProperties()
0830:                                                        .add(
0831:                                                                lCategoryDescriptionProperty);
0832:                                            } else {
0833:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0834:                                                lUnprocessedProperties
0835:                                                        .remove(lCategoryDescriptionProperty);
0836:                                            }
0837:                                            lCategoryDescriptionProperty
0838:                                                    .setDescription("The description of the category.");
0839:                                            lCategoryDescriptionProperty
0840:                                                    .setValue("All ordering instructions involving "
0841:                                                            + lAttribute
0842:                                                                    .getName()
0843:                                                            + " attribute");
0844:                                        }
0845:                                    }
0846:                                    // Add ascending ordering by this attribute							
0847:                                    {
0848:                                        lNextValueIndex++;
0849:                                        String lValueName = "By "
0850:                                                + lAttribute.getName()
0851:                                                + " In Ascending Order";
0852:                                        Property lValueRootProperty = lOrderingInstructionDatatype
0853:                                                .findTypetemplatePropertyByKey("Value["
0854:                                                        + lNextValueIndex + "]");
0855:                                        if (lValueRootProperty == null) {
0856:                                            lValueRootProperty = lPropertyClass
0857:                                                    .createProperty();
0858:                                            lValueRootProperty.setName("Value");
0859:                                            lValueRootProperty
0860:                                                    .setDescription("Root property for the properties related to a particular value.");
0861:                                            lOrderingInstructionDatatype
0862:                                                    .getTypetemplateProperties()
0863:                                                    .add(lValueRootProperty);
0864:                                            lValuePropertyDescriptor
0865:                                                    .getProperties().add(
0866:                                                            lValueRootProperty);
0867:                                        } else {
0868:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
0869:                                            lUnprocessedProperties
0870:                                                    .remove(lValueRootProperty);
0871:                                        }
0872:                                        // Add name subproperty
0873:                                        {
0874:                                            Property lValueNameProperty = lValueRootProperty
0875:                                                    .findPropertyByKey("Name");
0876:                                            if (lValueNameProperty == null) {
0877:                                                lValueNameProperty = lPropertyClass
0878:                                                        .createProperty();
0879:                                                lValueNameProperty
0880:                                                        .setName("Name");
0881:                                                lValueRootProperty
0882:                                                        .getSubProperties()
0883:                                                        .add(lValueNameProperty);
0884:                                                lValueNamePropertyDescriptor
0885:                                                        .getProperties()
0886:                                                        .add(lValueNameProperty);
0887:                                            } else {
0888:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0889:                                                lUnprocessedProperties
0890:                                                        .remove(lValueNameProperty);
0891:                                            }
0892:                                            lValueNameProperty
0893:                                                    .setDescription("The name of the possible value.");
0894:                                            lValueNameProperty
0895:                                                    .setValue(lValueName);
0896:                                        }
0897:                                        // Add description subproperty
0898:                                        {
0899:                                            Property lValueDescriptionProperty = lValueRootProperty
0900:                                                    .findPropertyByKey("Description");
0901:                                            if (lValueDescriptionProperty == null) {
0902:                                                lValueDescriptionProperty = lPropertyClass
0903:                                                        .createProperty();
0904:                                                lValueDescriptionProperty
0905:                                                        .setName("Description");
0906:                                                lValueRootProperty
0907:                                                        .getSubProperties()
0908:                                                        .add(
0909:                                                                lValueDescriptionProperty);
0910:                                                lValueDescriptionPropertyDescriptor
0911:                                                        .getProperties()
0912:                                                        .add(
0913:                                                                lValueDescriptionProperty);
0914:                                            } else {
0915:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0916:                                                lUnprocessedProperties
0917:                                                        .remove(lValueDescriptionProperty);
0918:                                            }
0919:                                            lValueDescriptionProperty
0920:                                                    .setDescription("The description of the possible value.");
0921:                                            lValueDescriptionProperty
0922:                                                    .setValue("Denotes the ascending sort based on values in the "
0923:                                                            + lAttribute
0924:                                                                    .getName()
0925:                                                            + " attribute.");
0926:                                        }
0927:                                        // Add value name to the ascending category
0928:                                        lNextAscendingCategoryValueIndex++;
0929:                                        {
0930:                                            String lAscendingCategoryValueKey = "ValueName["
0931:                                                    + lNextAscendingCategoryValueIndex
0932:                                                    + "]";
0933:                                            Property lValueNameProperty = lAscendingCategoryPropertiesRootProperty
0934:                                                    .findPropertyByKey(lAscendingCategoryValueKey);
0935:                                            if (lValueNameProperty == null) {
0936:                                                lValueNameProperty = lPropertyClass
0937:                                                        .createProperty();
0938:                                                lValueNameProperty
0939:                                                        .setName("ValueName");
0940:                                                lAscendingCategoryPropertiesRootProperty
0941:                                                        .getSubProperties()
0942:                                                        .add(lValueNameProperty);
0943:                                                lCategoryValueNamePropertyDescriptor
0944:                                                        .getProperties()
0945:                                                        .add(lValueNameProperty);
0946:                                            } else {
0947:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0948:                                                lUnprocessedProperties
0949:                                                        .remove(lValueNameProperty);
0950:                                            }
0951:                                            lValueNameProperty
0952:                                                    .setDescription("The name of the category member.");
0953:                                            lValueNameProperty
0954:                                                    .setValue(lValueName);
0955:                                        }
0956:                                        // Add value name to the attribute category
0957:                                        lNextAttributeCategoryValueIndex++;
0958:                                        {
0959:                                            String lAttributeCategoryValueKey = "ValueName["
0960:                                                    + lNextAttributeCategoryValueIndex
0961:                                                    + "]";
0962:                                            Property lValueNameProperty = lByAttributeCategoryPropertiesRootProperty
0963:                                                    .findPropertyByKey(lAttributeCategoryValueKey);
0964:                                            if (lValueNameProperty == null) {
0965:                                                lValueNameProperty = lPropertyClass
0966:                                                        .createProperty();
0967:                                                lValueNameProperty
0968:                                                        .setName("ValueName");
0969:                                                lByAttributeCategoryPropertiesRootProperty
0970:                                                        .getSubProperties()
0971:                                                        .add(lValueNameProperty);
0972:                                                lCategoryValueNamePropertyDescriptor
0973:                                                        .getProperties()
0974:                                                        .add(lValueNameProperty);
0975:                                            } else {
0976:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
0977:                                                lUnprocessedProperties
0978:                                                        .remove(lValueNameProperty);
0979:                                            }
0980:                                            lValueNameProperty
0981:                                                    .setDescription("The name of the category member.");
0982:                                            lValueNameProperty
0983:                                                    .setValue(lValueName);
0984:                                        }
0985:                                    }
0986:                                    // Add descending ordering by this argument
0987:                                    {
0988:                                        lNextValueIndex++;
0989:                                        String lValueName = "By "
0990:                                                + lAttribute.getName()
0991:                                                + " In Descending Order";
0992:                                        Property lValueRootProperty = lOrderingInstructionDatatype
0993:                                                .findTypetemplatePropertyByKey("Value["
0994:                                                        + lNextValueIndex + "]");
0995:                                        if (lValueRootProperty == null) {
0996:                                            lValueRootProperty = lPropertyClass
0997:                                                    .createProperty();
0998:                                            lValueRootProperty.setName("Value");
0999:                                            lValueRootProperty
1000:                                                    .setDescription("Root property for the properties related to a particular value.");
1001:                                            lOrderingInstructionDatatype
1002:                                                    .getTypetemplateProperties()
1003:                                                    .add(lValueRootProperty);
1004:                                            lValuePropertyDescriptor
1005:                                                    .getProperties().add(
1006:                                                            lValueRootProperty);
1007:                                        } else {
1008:                                            // Remove this datatype from the list of unprocessed ones, so it is not deleted
1009:                                            lUnprocessedProperties
1010:                                                    .remove(lValueRootProperty);
1011:                                        }
1012:                                        // Add name subproperty
1013:                                        {
1014:                                            Property lValueNameProperty = lValueRootProperty
1015:                                                    .findPropertyByKey("Name");
1016:                                            if (lValueNameProperty == null) {
1017:                                                lValueNameProperty = lPropertyClass
1018:                                                        .createProperty();
1019:                                                lValueNameProperty
1020:                                                        .setName("Name");
1021:                                                lValueRootProperty
1022:                                                        .getSubProperties()
1023:                                                        .add(lValueNameProperty);
1024:                                                lValueNamePropertyDescriptor
1025:                                                        .getProperties()
1026:                                                        .add(lValueNameProperty);
1027:                                            } else {
1028:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
1029:                                                lUnprocessedProperties
1030:                                                        .remove(lValueNameProperty);
1031:                                            }
1032:                                            lValueNameProperty
1033:                                                    .setDescription("The name of the possible value.");
1034:                                            lValueNameProperty
1035:                                                    .setValue(lValueName);
1036:                                        }
1037:                                        // Add description subproperty
1038:                                        {
1039:                                            Property lValueDescriptionProperty = lValueRootProperty
1040:                                                    .findPropertyByKey("Description");
1041:                                            if (lValueDescriptionProperty == null) {
1042:                                                lValueDescriptionProperty = lPropertyClass
1043:                                                        .createProperty();
1044:                                                lValueDescriptionProperty
1045:                                                        .setName("Description");
1046:                                                lValueRootProperty
1047:                                                        .getSubProperties()
1048:                                                        .add(
1049:                                                                lValueDescriptionProperty);
1050:                                                lValueDescriptionPropertyDescriptor
1051:                                                        .getProperties()
1052:                                                        .add(
1053:                                                                lValueDescriptionProperty);
1054:                                            } else {
1055:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
1056:                                                lUnprocessedProperties
1057:                                                        .remove(lValueDescriptionProperty);
1058:                                            }
1059:                                            lValueDescriptionProperty
1060:                                                    .setDescription("The description of the possible value.");
1061:                                            lValueDescriptionProperty
1062:                                                    .setValue("Denotes the descending sort based on values in the "
1063:                                                            + lAttribute
1064:                                                                    .getName()
1065:                                                            + " attribute.");
1066:                                        }
1067:                                        // Add value name to the descending category
1068:                                        lNextDescendingCategoryValueIndex++;
1069:                                        {
1070:                                            String lDescendingCategoryValueKey = "ValueName["
1071:                                                    + lNextDescendingCategoryValueIndex
1072:                                                    + "]";
1073:                                            Property lValueNameProperty = lDescendingCategoryPropertiesRootProperty
1074:                                                    .findPropertyByKey(lDescendingCategoryValueKey);
1075:                                            if (lValueNameProperty == null) {
1076:                                                lValueNameProperty = lPropertyClass
1077:                                                        .createProperty();
1078:                                                lValueNameProperty
1079:                                                        .setName("ValueName");
1080:                                                lDescendingCategoryPropertiesRootProperty
1081:                                                        .getSubProperties()
1082:                                                        .add(lValueNameProperty);
1083:                                                lCategoryValueNamePropertyDescriptor
1084:                                                        .getProperties()
1085:                                                        .add(lValueNameProperty);
1086:                                            } else {
1087:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
1088:                                                lUnprocessedProperties
1089:                                                        .remove(lValueNameProperty);
1090:                                            }
1091:                                            lValueNameProperty
1092:                                                    .setDescription("The name of the category member.");
1093:                                            lValueNameProperty
1094:                                                    .setValue(lValueName);
1095:                                        }
1096:                                        // Add value name to the attribute category
1097:                                        lNextAttributeCategoryValueIndex++;
1098:                                        {
1099:                                            String lAttributeCategoryValueKey = "ValueName["
1100:                                                    + lNextAttributeCategoryValueIndex
1101:                                                    + "]";
1102:                                            Property lValueNameProperty = lByAttributeCategoryPropertiesRootProperty
1103:                                                    .findPropertyByKey(lAttributeCategoryValueKey);
1104:                                            if (lValueNameProperty == null) {
1105:                                                lValueNameProperty = lPropertyClass
1106:                                                        .createProperty();
1107:                                                lValueNameProperty
1108:                                                        .setName("ValueName");
1109:                                                lByAttributeCategoryPropertiesRootProperty
1110:                                                        .getSubProperties()
1111:                                                        .add(lValueNameProperty);
1112:                                                lCategoryValueNamePropertyDescriptor
1113:                                                        .getProperties()
1114:                                                        .add(lValueNameProperty);
1115:                                            } else {
1116:                                                // Remove this datatype from the list of unprocessed ones, so it is not deleted
1117:                                                lUnprocessedProperties
1118:                                                        .remove(lValueNameProperty);
1119:                                            }
1120:                                            lValueNameProperty
1121:                                                    .setDescription("The name of the category member.");
1122:                                            lValueNameProperty
1123:                                                    .setValue(lValueName);
1124:                                        }
1125:                                    }
1126:                                }
1127:                            }
1128:                            // Delete all unprocessed properties
1129:                            for (Iterator lUnprocessedPropertiesIterator = lUnprocessedProperties
1130:                                    .iterator(); lUnprocessedPropertiesIterator
1131:                                    .hasNext();) {
1132:                                Property lProperty = (Property) lUnprocessedPropertiesIterator
1133:                                        .next();
1134:                                lProperty.refDelete();
1135:                            }
1136:                        } else {
1137:                            // Just in case - set the datatype to null
1138:                            lEntity.setOrderingInstructionDataType(null);
1139:                        }
1140:                    }
1141:                    // Now work on reports
1142:                    // Now we are ready to do reconcilitaion of the datatypes
1143:                    Collection lReports = pDomain.getReports();
1144:                    for (Iterator lReportsIterator = lReports.iterator(); lReportsIterator
1145:                            .hasNext();) {
1146:                        Report lReport = (Report) lReportsIterator.next();
1147:                        // Set all fixed datatypes
1148:                        lReport
1149:                                .setReportPageOffsetDataType(lReportPageOffsetDataType);
1150:                        lReport
1151:                                .setReportPageSizeDataType(lReportPageSizeDataType);
1152:                        lReport.setReportSizeDataType(lReportSizeDataType);
1153:                    }
1154:                    // Last - all unused system datatypes must be deleted
1155:                    for (Iterator lUnprocessedDataTypesIterator = lUnprocessedDataTypes
1156:                            .iterator(); lUnprocessedDataTypesIterator
1157:                            .hasNext();) {
1158:                        DataType lDatatype = (DataType) lUnprocessedDataTypesIterator
1159:                                .next();
1160:                        lDatatype.refDelete();
1161:                    }
1162:                    sLogger
1163:                            .info("Done updating implicit datatypes metadata for "
1164:                                    + pDomain.getRef() + " domain");
1165:                } catch (JmiException e) {
1166:                    throw new BSModelRepositoryInvocationException(
1167:                            "Exception caught during updating of implicit datatypes",
1168:                            e);
1169:                }
1170:            }
1171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.