Source Code Cross Referenced for ModelAssistantImpl.java in  » UML » MetaBoss » com » metaboss » sdlctools » models » modelassistant » metabossmodel » domainsupport » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » MetaBoss » com.metaboss.sdlctools.models.modelassistant.metabossmodel.domainsupport 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.sdlctools.models.modelassistant.metabossmodel.domainsupport;
016:
017:        import java.util.ArrayList;
018:        import java.util.Collection;
019:        import java.util.Collections;
020:        import java.util.Iterator;
021:        import java.util.List;
022:
023:        import javax.jmi.reflect.ConstraintViolationException;
024:        import javax.jmi.reflect.RefObject;
025:        import javax.jmi.reflect.RefPackage;
026:        import javax.naming.Context;
027:        import javax.naming.InitialContext;
028:        import javax.naming.NamingException;
029:
030:        import com.metaboss.sdlctools.models.ModelRepository;
031:        import com.metaboss.sdlctools.models.ModelRepositoryException;
032:        import com.metaboss.sdlctools.models.ModelRepositoryInternalException;
033:        import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
034:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
035:        import com.metaboss.sdlctools.models.metabossmodel.ModelElementClass;
036:        import com.metaboss.sdlctools.models.metabossmodel.ModelElementConstraintClass;
037:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionaryModelPackage;
038:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.StructureClass;
039:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.StructureFieldClass;
040:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EnterpriseModelPackage;
041:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.MessageClass;
042:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.MessageFieldClass;
043:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationClass;
044:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationInputFieldClass;
045:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationOutputFieldClass;
046:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.OperationOutputMessageClass;
047:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
048:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.ServiceClass;
049:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
050:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.ServicemoduleClass;
051:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
052:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
053:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AttributeClass;
054:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
055:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.DomainClass;
056:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
057:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.EntityClass;
058:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SystemImplementationModelPackage;
059:        import com.metaboss.sdlctools.models.modelassistant.metabossmodel.SingleModelAssistantImplBase;
060:
061:        /** Implementation of the assistant to MetaBoss models.
062:         * Looks after some implicit data types in the systems.
063:         * This implementation is always only serving one model. This is guaranteed
064:         * by special factory implementation */
065:        public class ModelAssistantImpl extends SingleModelAssistantImplBase {
066:            /** String constant which is used to identify this assistant as an owner of certain model elements */
067:            public static final String ASSISTANT_IDENTIFIER = ModelAssistantImpl.class
068:                    .getPackage().getName();
069:
070:            // Variables below are cached for whole session with the model regardless of the kind of model it is
071:            ModelRepository mModelRepository = null;
072:            MetaBossModelPackage mRootPackage = null;
073:            ModelElementClass mModelElementClass = null;
074:            ModelElementConstraintClass mModelElementConstraintClass = null;
075:            EnterpriseModelPackage mEnterpriseModelPackage = null;
076:            DataDictionaryModelPackage mDataDictionaryModelPackage = null;
077:            ServicemoduleClass mServicemoduleClass = null;
078:            ServiceClass mServiceClass = null;
079:            StructureClass mStructureClass = null;
080:            StructureFieldClass mStructureFieldClass = null;
081:            MessageClass mMessageClass = null;
082:            MessageFieldClass mMessageFieldClass = null;
083:            OperationClass mOperationClass = null;
084:            OperationOutputFieldClass mOperationOutputFieldClass = null;
085:            OperationInputFieldClass mOperationInputFieldClass = null;
086:            OperationOutputMessageClass mOperationOutputMessageClass = null;
087:            SystemImplementationModelPackage mSystemImplementationModelPackage = null;
088:            DomainClass mDomainClass = null;
089:            EntityClass mEntityClass = null;
090:            AttributeClass mAttributeClass = null;
091:
092:            // Source model element helpers
093:            SourceEntityHelper mSourceEntityHelper = null;
094:            SourceAttributeHelper mSourceAttributeHelper = null;
095:            SourceAssociationRoleHelper mSourceAssociationRoleHelper = null;
096:
097:            // Target model element helpers
098:            TargetDomainSupportServicemoduleHelper mTargetDomainSupportServicemoduleHelper = null;
099:            TargetInstanceNotFoundMessageHelper mTargetInstanceNotFoundMessageHelper = null;
100:            TargetVersionMismatchMessageHelper mTargetVersionMismatchMessageHelper = null;
101:            TargetDuplicateCreateFailedMessageHelper mTargetDuplicateCreateFailedMessageHelper = null;
102:            TargetEntityKeyStructureHelper mTargetEntityKeyStructureHelper = null;
103:            TargetEntityDetailsStructureHelper mTargetEntityDetailsStructureHelper = null;
104:            TargetGetAllEntitiesCountOperationHelper mTargetGetAllEntitiesCountOperationHelper = null;
105:            TargetGetAllEntitiesOperationHelper mTargetGetAllEntitiesOperationHelper = null;
106:            TargetGetSubsetOfEntitiesOperationHelper mTargetGetSubsetOfEntitiesOperationHelper = null;
107:            TargetGetEntityOperationHelper mTargetGetEntityOperationHelper = null;
108:            TargetCreateEntityOperationHelper mTargetCreateEntityOperationHelper = null;
109:            TargetDeleteEntityOperationHelper mTargetDeleteEntityOperationHelper = null;
110:            TargetUpdateEntityOperationHelper mTargetUpdateEntityOperationHelper = null;
111:            TargetAddReferencedEntityOperationHelper mTargetAddReferencedEntityOperationHelper = null;
112:            TargetRemoveReferencedEntityOperationHelper mTargetRemoveReferencedEntityOperationHelper = null;
113:            TargetGetAllReferencedEntitiesOperationHelper mTargetGetAllReferencedEntitiesOperationHelper = null;
114:
115:            public ModelAssistantImpl() {
116:                // Create source and target helpers
117:                mSourceEntityHelper = new SourceEntityHelper(this );
118:                mSourceAttributeHelper = new SourceAttributeHelper(this );
119:                mSourceAssociationRoleHelper = new SourceAssociationRoleHelper(
120:                        this );
121:                mTargetDomainSupportServicemoduleHelper = new TargetDomainSupportServicemoduleHelper(
122:                        this );
123:                mTargetInstanceNotFoundMessageHelper = new TargetInstanceNotFoundMessageHelper(
124:                        this );
125:                mTargetVersionMismatchMessageHelper = new TargetVersionMismatchMessageHelper(
126:                        this );
127:                mTargetDuplicateCreateFailedMessageHelper = new TargetDuplicateCreateFailedMessageHelper(
128:                        this );
129:                mTargetEntityKeyStructureHelper = new TargetEntityKeyStructureHelper(
130:                        this );
131:                mTargetEntityDetailsStructureHelper = new TargetEntityDetailsStructureHelper(
132:                        this );
133:                // Instantiate operation helpers last because they are using messages and structures
134:                mTargetGetAllEntitiesCountOperationHelper = new TargetGetAllEntitiesCountOperationHelper(
135:                        this );
136:                mTargetGetAllEntitiesOperationHelper = new TargetGetAllEntitiesOperationHelper(
137:                        this );
138:                mTargetGetSubsetOfEntitiesOperationHelper = new TargetGetSubsetOfEntitiesOperationHelper(
139:                        this );
140:                mTargetGetEntityOperationHelper = new TargetGetEntityOperationHelper(
141:                        this );
142:                mTargetCreateEntityOperationHelper = new TargetCreateEntityOperationHelper(
143:                        this );
144:                mTargetDeleteEntityOperationHelper = new TargetDeleteEntityOperationHelper(
145:                        this );
146:                mTargetUpdateEntityOperationHelper = new TargetUpdateEntityOperationHelper(
147:                        this );
148:                mTargetAddReferencedEntityOperationHelper = new TargetAddReferencedEntityOperationHelper(
149:                        this );
150:                mTargetRemoveReferencedEntityOperationHelper = new TargetRemoveReferencedEntityOperationHelper(
151:                        this );
152:                mTargetGetAllReferencedEntitiesOperationHelper = new TargetGetAllReferencedEntitiesOperationHelper(
153:                        this );
154:            }
155:
156:            // As per interface 
157:            public void assignToModel(String pModelName)
158:                    throws ModelRepositoryException {
159:                super .assignToModel(pModelName);
160:                try {
161:                    Context lContext = new InitialContext();
162:                    mModelRepository = (ModelRepository) lContext
163:                            .lookup(ModelRepository.COMPONENT_URL);
164:                    mRootPackage = (MetaBossModelPackage) mModelRepository
165:                            .getModelExtent(pModelName);
166:                    mModelElementClass = mRootPackage.getModelElement();
167:                    mModelElementConstraintClass = mRootPackage
168:                            .getModelElementConstraint();
169:                    mDataDictionaryModelPackage = mRootPackage
170:                            .getDataDictionaryModel();
171:                    mStructureClass = mDataDictionaryModelPackage
172:                            .getStructure();
173:                    mStructureFieldClass = mDataDictionaryModelPackage
174:                            .getStructureField();
175:                    mEnterpriseModelPackage = mRootPackage.getEnterpriseModel();
176:                    mServicemoduleClass = mEnterpriseModelPackage
177:                            .getServicemodule();
178:                    mServiceClass = mEnterpriseModelPackage.getService();
179:                    mMessageClass = mEnterpriseModelPackage.getMessage();
180:                    mMessageFieldClass = mEnterpriseModelPackage
181:                            .getMessageField();
182:                    mOperationClass = mEnterpriseModelPackage.getOperation();
183:                    mOperationOutputFieldClass = mEnterpriseModelPackage
184:                            .getOperationOutputField();
185:                    mOperationInputFieldClass = mEnterpriseModelPackage
186:                            .getOperationInputField();
187:                    mOperationOutputMessageClass = mEnterpriseModelPackage
188:                            .getOperationOutputMessage();
189:                    mSystemImplementationModelPackage = mEnterpriseModelPackage
190:                            .getSystemImplementationModel();
191:                    mDomainClass = mSystemImplementationModelPackage
192:                            .getDomain();
193:                    mEntityClass = mSystemImplementationModelPackage
194:                            .getEntity();
195:                    mAttributeClass = mSystemImplementationModelPackage
196:                            .getAttribute();
197:                } catch (NamingException e) {
198:                    throw new ModelRepositoryInternalException(
199:                            "Unable to lookup repository", e);
200:                }
201:            }
202:
203:            // As per interface 
204:            public void dismissFromModel(String pModelName) {
205:                mRootPackage = null;
206:                mModelRepository = null;
207:                mModelElementClass = null;
208:                mModelElementConstraintClass = null;
209:                mDataDictionaryModelPackage = null;
210:                mMessageClass = null;
211:                mMessageFieldClass = null;
212:                mEnterpriseModelPackage = null;
213:                mServicemoduleClass = null;
214:                mServiceClass = null;
215:                mStructureClass = null;
216:                mStructureFieldClass = null;
217:                mOperationClass = null;
218:                mOperationOutputFieldClass = null;
219:                mOperationInputFieldClass = null;
220:                mOperationOutputMessageClass = null;
221:                mSystemImplementationModelPackage = null;
222:                mDomainClass = null;
223:                mEntityClass = null;
224:                mAttributeClass = null;
225:                super .dismissFromModel(pModelName);
226:            }
227:
228:            // As per interface		
229:            public void onModelElementReferenceBeingUpdated(String pModelName,
230:                    RefObject pModelElementBeingUpdated, String pReferenceName,
231:                    RefObject pReferencedModelElementToRemove,
232:                    RefObject pReferencedModelElementToAdd)
233:                    throws ModelRepositoryException {
234:                // See if this element is of the type we are interested in
235:                // Find out kind of package first and than the kind of element
236:                // This way the search will be faster
237:                RefPackage lImmeditePackage = pModelElementBeingUpdated
238:                        .refImmediatePackage();
239:                if (lImmeditePackage instanceof  SystemImplementationModelPackage) {
240:                    if (pModelElementBeingUpdated instanceof  Entity)
241:                        mSourceEntityHelper.onChangingReference(
242:                                (Entity) pModelElementBeingUpdated,
243:                                pReferenceName,
244:                                pReferencedModelElementToRemove,
245:                                pReferencedModelElementToAdd);
246:                    else if (pModelElementBeingUpdated instanceof  AssociationRole)
247:                        mSourceAssociationRoleHelper.onChangingReference(
248:                                (AssociationRole) pModelElementBeingUpdated,
249:                                pReferenceName,
250:                                pReferencedModelElementToRemove,
251:                                pReferencedModelElementToAdd);
252:                }
253:                // Call superclass which will dispatch to the generic listeners
254:                super .onModelElementReferenceBeingUpdated(pModelName,
255:                        pModelElementBeingUpdated, pReferenceName,
256:                        pReferencedModelElementToRemove,
257:                        pReferencedModelElementToAdd);
258:            }
259:
260:            // As per interface 
261:            public void onModelElementBeingDeleted(String pModelName,
262:                    RefObject pModelElementToBeDeleted)
263:                    throws ModelRepositoryException {
264:                // See if this element is of the type we are interested in
265:                // Find out kind of package first and than the kind of element
266:                // This way the search will be faster
267:                RefPackage lImmeditePackage = pModelElementToBeDeleted
268:                        .refImmediatePackage();
269:                if (lImmeditePackage instanceof  SystemImplementationModelPackage) {
270:                    if (pModelElementToBeDeleted instanceof  Entity)
271:                        mSourceEntityHelper
272:                                .onDeleting((Entity) pModelElementToBeDeleted);
273:                    else if (pModelElementToBeDeleted instanceof  Attribute)
274:                        mSourceAttributeHelper
275:                                .onDeleting((Attribute) pModelElementToBeDeleted);
276:                    else if (pModelElementToBeDeleted instanceof  AssociationRole)
277:                        mSourceAssociationRoleHelper
278:                                .onDeleting((AssociationRole) pModelElementToBeDeleted);
279:                }
280:                // Call superclass which will dispatch to the generic listeners
281:                super .onModelElementBeingDeleted(pModelName,
282:                        pModelElementToBeDeleted);
283:            }
284:
285:            // As per interface 
286:            public void onModelElementJustCreated(String pModelName,
287:                    RefObject pModelElementJustCreated)
288:                    throws ModelRepositoryException {
289:                // Now see if this element is of the type we are interested in
290:                // Find out kind of package first and than the kind of element
291:                // This way the search will be faster
292:                RefPackage lImmeditePackage = pModelElementJustCreated
293:                        .refImmediatePackage();
294:                if (lImmeditePackage instanceof  SystemImplementationModelPackage) {
295:                    if (pModelElementJustCreated instanceof  Entity)
296:                        mSourceEntityHelper
297:                                .onJustCreated((Entity) pModelElementJustCreated);
298:                    else if (pModelElementJustCreated instanceof  Attribute)
299:                        mSourceAttributeHelper
300:                                .onJustCreated((Attribute) pModelElementJustCreated);
301:                    else if (pModelElementJustCreated instanceof  AssociationRole)
302:                        mSourceAssociationRoleHelper
303:                                .onJustCreated((AssociationRole) pModelElementJustCreated);
304:                }
305:                // Call superclass which will dispatch to the generic listeners
306:                super .onModelElementJustCreated(pModelName,
307:                        pModelElementJustCreated);
308:            }
309:
310:            // As per interface 
311:            public void rectifyModel(String pModelName)
312:                    throws ModelRepositoryException {
313:                // Ensure that every domain has a fully featured domain support servicemodule
314:                for (Iterator lDomainsIterator = mDomainClass.refAllOfType()
315:                        .iterator(); lDomainsIterator.hasNext();) {
316:                    Domain lDomain = (Domain) lDomainsIterator.next();
317:                    String lDomainName = lDomain.getName();
318:                    if (lDomainName == null || lDomainName.length() == 0)
319:                        return; // Domain does not have a name yet
320:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
321:                            .getSystem();
322:                    if (lSystem == null)
323:                        return; // Domain is not associated with system
324:                    mTargetDomainSupportServicemoduleHelper.ensurePresent(
325:                            lSystem, lDomainName);
326:                    // We need to have list of all messages, operations and structures for this servicemodule so we can remove surplus elements at the end
327:                    Collection lUnclaimedMessages = new ArrayList();
328:                    Collection lUnclaimedStructures = new ArrayList();
329:                    Collection lUnclaimedDataManagementOperations = new ArrayList();
330:                    String lServicemoduleName = StylesheetImpl
331:                            .getDomainSupportServicemoduleName(lDomain
332:                                    .getName());
333:                    Servicemodule lServicemodule = lSystem
334:                            .findServicemodule(lServicemoduleName);
335:                    if (lServicemodule == null)
336:                        continue; // This is in fact an unexpected situation. Servie module should have been created by now - if not just skip to the next domain
337:                    Service lDataManagementService = lServicemodule
338:                            .findService(StylesheetImpl
339:                                    .getDataManagementServiceName(lDomainName));
340:                    lUnclaimedMessages.addAll(lServicemodule.getMessages());
341:                    lUnclaimedStructures.addAll(lServicemodule.getStructures());
342:                    if (lDataManagementService != null)
343:                        lUnclaimedDataManagementOperations
344:                                .addAll(lDataManagementService.getOperations());
345:
346:                    for (Iterator lEntitiesIterator = lDomain.getEntities()
347:                            .iterator(); lEntitiesIterator.hasNext();) {
348:                        Entity lEntity = (Entity) lEntitiesIterator.next();
349:                        String lEntityName = lEntity.getName();
350:                        if (lEntityName == null || lEntityName.length() == 0)
351:                            continue; // Entity does not have a name
352:                        // Work on structures
353:                        mTargetEntityKeyStructureHelper.rectifyModel(
354:                                lServicemodule, lEntity, lUnclaimedStructures);
355:                        mTargetEntityDetailsStructureHelper.rectifyModel(
356:                                lServicemodule, lEntity, lUnclaimedStructures);
357:                        // Work on messages found everywhere
358:                        mTargetInstanceNotFoundMessageHelper.rectifyModel(
359:                                lServicemodule, lEntity, lUnclaimedMessages);
360:                        // Work on messages found in modifiable entity
361:                        mTargetVersionMismatchMessageHelper.rectifyModel(
362:                                lServicemodule, lEntity, lUnclaimedMessages);
363:                        // Work on messages found in the entities with the primary keys
364:                        mTargetDuplicateCreateFailedMessageHelper.rectifyModel(
365:                                lServicemodule, lEntity, lUnclaimedMessages);
366:                        // Work on Data Management Operations
367:                        if (lDataManagementService != null) {
368:                            mTargetGetAllEntitiesCountOperationHelper
369:                                    .rectifyModel(lDataManagementService,
370:                                            lEntity,
371:                                            lUnclaimedDataManagementOperations);
372:                            mTargetGetAllEntitiesOperationHelper.rectifyModel(
373:                                    lDataManagementService, lEntity,
374:                                    lUnclaimedDataManagementOperations);
375:                            mTargetGetSubsetOfEntitiesOperationHelper
376:                                    .rectifyModel(lDataManagementService,
377:                                            lEntity,
378:                                            lUnclaimedDataManagementOperations);
379:                            mTargetGetEntityOperationHelper.rectifyModel(
380:                                    lDataManagementService, lEntity,
381:                                    lUnclaimedDataManagementOperations);
382:                            mTargetCreateEntityOperationHelper.rectifyModel(
383:                                    lDataManagementService, lEntity,
384:                                    lUnclaimedDataManagementOperations);
385:                            mTargetDeleteEntityOperationHelper.rectifyModel(
386:                                    lDataManagementService, lEntity,
387:                                    lUnclaimedDataManagementOperations);
388:                            mTargetUpdateEntityOperationHelper.rectifyModel(
389:                                    lDataManagementService, lEntity,
390:                                    lUnclaimedDataManagementOperations);
391:                        }
392:                        // Iterate through entity references
393:                        for (Iterator lEntityReferencesIterator = lEntity
394:                                .getCombinedReferences().iterator(); lEntityReferencesIterator
395:                                .hasNext();) {
396:                            AssociationRole lReference = (AssociationRole) lEntityReferencesIterator
397:                                    .next();
398:                            // Work on Data Management Operations
399:                            if (lDataManagementService != null) {
400:                                mTargetAddReferencedEntityOperationHelper
401:                                        .rectifyModel(lDataManagementService,
402:                                                lReference,
403:                                                lUnclaimedDataManagementOperations);
404:                                mTargetRemoveReferencedEntityOperationHelper
405:                                        .rectifyModel(lDataManagementService,
406:                                                lReference,
407:                                                lUnclaimedDataManagementOperations);
408:                                mTargetGetAllReferencedEntitiesOperationHelper
409:                                        .rectifyModel(lDataManagementService,
410:                                                lReference,
411:                                                lUnclaimedDataManagementOperations);
412:                            }
413:                        }
414:                    }
415:                    // Remove unclaimed elements which are not owned by anyone in partcular
416:                    for (Iterator lUnclaimedMessagesIterator = lUnclaimedMessages
417:                            .iterator(); lUnclaimedMessagesIterator.hasNext();) {
418:                        ModelElement lModelElement = (ModelElement) lUnclaimedMessagesIterator
419:                                .next();
420:                        if (!lModelElement.isDerived())
421:                            lModelElement.refDelete();
422:                    }
423:                    for (Iterator lUnclaimedStructuresIterator = lUnclaimedStructures
424:                            .iterator(); lUnclaimedStructuresIterator.hasNext();) {
425:                        ModelElement lModelElement = (ModelElement) lUnclaimedStructuresIterator
426:                                .next();
427:                        if (!lModelElement.isDerived())
428:                            lModelElement.refDelete();
429:                    }
430:                    for (Iterator lUnclaimedDataManagementOperationsIterator = lUnclaimedDataManagementOperations
431:                            .iterator(); lUnclaimedDataManagementOperationsIterator
432:                            .hasNext();) {
433:                        ModelElement lModelElement = (ModelElement) lUnclaimedDataManagementOperationsIterator
434:                                .next();
435:                        if (!lModelElement.isDerived())
436:                            lModelElement.refDelete();
437:                    }
438:                }
439:            }
440:
441:            // As per interface 
442:            public Collection verifyConstraints(String pModelName) {
443:                List lViolations = new ArrayList();
444:                // Validate that every domain has a fully featured domain support servicemodule
445:                for (Iterator lDomainsIterator = mDomainClass.refAllOfType()
446:                        .iterator(); lDomainsIterator.hasNext();) {
447:                    Domain lDomain = (Domain) lDomainsIterator.next();
448:                    String lDomainName = lDomain.getName();
449:                    if (lDomainName == null || lDomainName.length() == 0)
450:                        continue; // Domain does not have a name
451:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
452:                            .getSystem();
453:                    if (lSystem == null)
454:                        continue; // Domain is not associated with system
455:                    mTargetDomainSupportServicemoduleHelper.verifyConstraints(
456:                            lViolations, lSystem, lDomain);
457:
458:                    String lServicemoduleName = StylesheetImpl
459:                            .getDomainSupportServicemoduleName(lDomain
460:                                    .getName());
461:                    Servicemodule lServicemodule = lSystem
462:                            .findServicemodule(lServicemoduleName);
463:                    if (lServicemodule == null)
464:                        continue; // There is no support servicemodule yet
465:                    Service lDataManagementService = lServicemodule
466:                            .findService(StylesheetImpl
467:                                    .getDataManagementServiceName(lDomainName));
468:
469:                    // We need to have list of all messages, operations and structures for this servicemodule so we can complain about surplus elements at the end
470:                    Collection lUnclaimedMessages = new ArrayList();
471:                    Collection lUnclaimedStructures = new ArrayList();
472:                    Collection lUnclaimedDataManagementOperations = new ArrayList();
473:                    lUnclaimedMessages.addAll(lServicemodule.getMessages());
474:                    lUnclaimedStructures.addAll(lServicemodule.getStructures());
475:                    if (lDataManagementService != null)
476:                        lUnclaimedDataManagementOperations
477:                                .addAll(lDataManagementService.getOperations());
478:                    for (Iterator lEntitiesIterator = lDomain.getEntities()
479:                            .iterator(); lEntitiesIterator.hasNext();) {
480:                        Entity lEntity = (Entity) lEntitiesIterator.next();
481:                        String lEntityName = lEntity.getName();
482:                        if (lEntityName == null || lEntityName.length() == 0)
483:                            continue; // Entity does not have a name
484:                        // Work on structures
485:                        mTargetEntityKeyStructureHelper.verifyConstraints(
486:                                lViolations, lServicemodule, lEntity,
487:                                lUnclaimedStructures);
488:                        mTargetEntityDetailsStructureHelper.verifyConstraints(
489:                                lViolations, lServicemodule, lEntity,
490:                                lUnclaimedStructures);
491:                        // Work on messages found everywhere
492:                        mTargetInstanceNotFoundMessageHelper.verifyConstraints(
493:                                lViolations, lServicemodule, lEntity,
494:                                lUnclaimedMessages);
495:                        // Work on messages found in modifiable entity
496:                        mTargetVersionMismatchMessageHelper.verifyConstraints(
497:                                lViolations, lServicemodule, lEntity,
498:                                lUnclaimedMessages);
499:                        // Work on messages found in the entities with the primary keys
500:                        mTargetDuplicateCreateFailedMessageHelper
501:                                .verifyConstraints(lViolations, lServicemodule,
502:                                        lEntity, lUnclaimedMessages);
503:                        // Work on Data Management Operations
504:                        if (lDataManagementService != null) {
505:                            mTargetGetAllEntitiesCountOperationHelper
506:                                    .verifyConstraints(lViolations,
507:                                            lDataManagementService, lEntity,
508:                                            lUnclaimedDataManagementOperations);
509:                            mTargetGetAllEntitiesOperationHelper
510:                                    .verifyConstraints(lViolations,
511:                                            lDataManagementService, lEntity,
512:                                            lUnclaimedDataManagementOperations);
513:                            mTargetGetSubsetOfEntitiesOperationHelper
514:                                    .verifyConstraints(lViolations,
515:                                            lDataManagementService, lEntity,
516:                                            lUnclaimedDataManagementOperations);
517:                            mTargetGetEntityOperationHelper
518:                                    .verifyConstraints(lViolations,
519:                                            lDataManagementService, lEntity,
520:                                            lUnclaimedDataManagementOperations);
521:                            mTargetCreateEntityOperationHelper
522:                                    .verifyConstraints(lViolations,
523:                                            lDataManagementService, lEntity,
524:                                            lUnclaimedDataManagementOperations);
525:                            mTargetDeleteEntityOperationHelper
526:                                    .verifyConstraints(lViolations,
527:                                            lDataManagementService, lEntity,
528:                                            lUnclaimedDataManagementOperations);
529:                            mTargetUpdateEntityOperationHelper
530:                                    .verifyConstraints(lViolations,
531:                                            lDataManagementService, lEntity,
532:                                            lUnclaimedDataManagementOperations);
533:                        }
534:                        // Iterate through entity references
535:                        for (Iterator lEntityReferencesIterator = lEntity
536:                                .getCombinedReferences().iterator(); lEntityReferencesIterator
537:                                .hasNext();) {
538:                            AssociationRole lReference = (AssociationRole) lEntityReferencesIterator
539:                                    .next();
540:                            // Work on Data Management Operations
541:                            if (lDataManagementService != null) {
542:                                mTargetAddReferencedEntityOperationHelper
543:                                        .verifyConstraints(lViolations,
544:                                                lDataManagementService,
545:                                                lReference,
546:                                                lUnclaimedDataManagementOperations);
547:                                mTargetRemoveReferencedEntityOperationHelper
548:                                        .verifyConstraints(lViolations,
549:                                                lDataManagementService,
550:                                                lReference,
551:                                                lUnclaimedDataManagementOperations);
552:                                mTargetGetAllReferencedEntitiesOperationHelper
553:                                        .verifyConstraints(lViolations,
554:                                                lDataManagementService,
555:                                                lReference,
556:                                                lUnclaimedDataManagementOperations);
557:                            }
558:                        }
559:                    }
560:                    // Warn about unclaimed elements which are not owned by anyone in partcular
561:                    for (Iterator lUnclaimedMessagesIterator = lUnclaimedMessages
562:                            .iterator(); lUnclaimedMessagesIterator.hasNext();) {
563:                        ModelElement lModelElement = (ModelElement) lUnclaimedMessagesIterator
564:                                .next();
565:                        if (!lModelElement.isDerived())
566:                            lViolations
567:                                    .add(new ConstraintViolationException(
568:                                            lModelElement,
569:                                            lModelElement.refMetaObject(),
570:                                            "All Messages inside the Domain Support Servicemodule must be related to the elements of the corresponding domain. The '"
571:                                                    + lModelElement.getName()
572:                                                    + "' element is redundant."));
573:                    }
574:                    for (Iterator lUnclaimedStructuresIterator = lUnclaimedStructures
575:                            .iterator(); lUnclaimedStructuresIterator.hasNext();) {
576:                        ModelElement lModelElement = (ModelElement) lUnclaimedStructuresIterator
577:                                .next();
578:                        if (!lModelElement.isDerived())
579:                            lViolations
580:                                    .add(new ConstraintViolationException(
581:                                            lModelElement,
582:                                            lModelElement.refMetaObject(),
583:                                            "All Structures inside the Domain Support Servicemodule must be related to the elements of the corresponding domain. The '"
584:                                                    + lModelElement.getName()
585:                                                    + "' element is redundant."));
586:                    }
587:                    for (Iterator lUnclaimedDataManagementOperationsIterator = lUnclaimedDataManagementOperations
588:                            .iterator(); lUnclaimedDataManagementOperationsIterator
589:                            .hasNext();) {
590:                        ModelElement lModelElement = (ModelElement) lUnclaimedDataManagementOperationsIterator
591:                                .next();
592:                        if (!lModelElement.isDerived())
593:                            lViolations
594:                                    .add(new ConstraintViolationException(
595:                                            lModelElement,
596:                                            lModelElement.refMetaObject(),
597:                                            "All Operations inside the Data Management Service must be related to the elements of the corresponding domain. The '"
598:                                                    + lModelElement.getName()
599:                                                    + "' operation is redundant."));
600:                    }
601:                }
602:                // Return what we have
603:                return Collections.unmodifiableCollection(lViolations);
604:            }
605:        }
w___w___w.__j__a__v_a___2_s___._c__o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.