Source Code Cross Referenced for SourceEntityHelper.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.Collection;
018:        import java.util.HashSet;
019:        import java.util.Iterator;
020:        import java.util.Set;
021:
022:        import javax.jmi.reflect.RefObject;
023:
024:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
025:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
026:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AggregationTypeEnum;
027:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
028:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
029:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
030:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
031:
032:        /** This class holds details about Entity State Selector
033:         * being processed. Used internally in the Assistant impl */
034:        class SourceEntityHelper {
035:            private ModelAssistantImpl mModelAssistantImpl;
036:
037:            SourceEntityHelper(ModelAssistantImpl pModelAssistantImpl) {
038:                mModelAssistantImpl = pModelAssistantImpl;
039:            }
040:
041:            // Handle the creation of the domain
042:            void onJustCreated(Entity pEntity) {
043:                // Automatically create operations, structures and messages pertained to the entity - if possible
044:                String lEntityName = pEntity.getName();
045:                if (lEntityName == null || lEntityName.length() == 0)
046:                    return; // Entity does not have a name
047:                Domain lDomain = pEntity.getDomain();
048:                if (lDomain == null)
049:                    return; // Entity is not associated with domain
050:                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
051:                        .getSystem();
052:                if (lSystem == null)
053:                    return; // Domain is not associated with system
054:                String lDomainName = lDomain.getName();
055:                if (lDomainName == null || lDomainName.length() == 0)
056:                    return; // Domain does not have a name
057:                String lServicemoduleName = StylesheetImpl
058:                        .getDomainSupportServicemoduleName(lDomainName);
059:                Servicemodule lServicemodule = lSystem
060:                        .findServicemodule(lServicemoduleName);
061:                if (lServicemodule == null)
062:                    return; // There is no support servicemodule yet
063:                // Work on structures
064:                mModelAssistantImpl.mTargetEntityKeyStructureHelper
065:                        .ensurePresent(lServicemodule, pEntity, lEntityName);
066:                mModelAssistantImpl.mTargetEntityDetailsStructureHelper
067:                        .ensurePresent(lServicemodule, pEntity, lEntityName);
068:                // Work on messages found in modifiable entity
069:                if (pEntity.isModifiable())
070:                    mModelAssistantImpl.mTargetVersionMismatchMessageHelper
071:                            .ensurePresent(lServicemodule, pEntity, lEntityName);
072:                else
073:                    mModelAssistantImpl.mTargetVersionMismatchMessageHelper
074:                            .ensureAbsent(lServicemodule, lEntityName);
075:                // Work on messages found in the entities with the primary keys
076:                if (!pEntity.getPrimaryKeyElements().isEmpty())
077:                    mModelAssistantImpl.mTargetDuplicateCreateFailedMessageHelper
078:                            .ensurePresent(lServicemodule, pEntity, lEntityName);
079:                else
080:                    mModelAssistantImpl.mTargetDuplicateCreateFailedMessageHelper
081:                            .ensureAbsent(lServicemodule, lEntityName);
082:
083:                // Work on domain support operations
084:                String lDomainSupportServiceName = StylesheetImpl
085:                        .getDataManagementServiceName(lDomainName);
086:                Service lDomainSupportService = lServicemodule
087:                        .findService(lDomainSupportServiceName);
088:                // Iterate through references and ensure that reference related elements are dealt with
089:                for (Iterator lEntityReferencesIterator = pEntity
090:                        .getCombinedReferences().iterator(); lEntityReferencesIterator
091:                        .hasNext();) {
092:                    AssociationRole lReference = (AssociationRole) lEntityReferencesIterator
093:                            .next();
094:                    // Work on entity reference related domain support operations
095:                    if (lDomainSupportService != null) {
096:                        String lReferencePluralName = lReference
097:                                .getPluralName();
098:                        if (lReferencePluralName != null) {
099:                            AssociationRole lOppositeRole = lReference
100:                                    .getOppositeRole();
101:                            if (lOppositeRole != null
102:                                    && lReference.isPlural()
103:                                    && lOppositeRole.isPlural()
104:                                    && AggregationTypeEnum.AGGREGATION
105:                                            .equals(lOppositeRole
106:                                                    .getAggregationType())) {
107:                                mModelAssistantImpl.mTargetAddReferencedEntityOperationHelper
108:                                        .ensurePresent(lDomainSupportService,
109:                                                lReference, lEntityName,
110:                                                lReferencePluralName);
111:                                mModelAssistantImpl.mTargetRemoveReferencedEntityOperationHelper
112:                                        .ensurePresent(lDomainSupportService,
113:                                                lReference, lEntityName,
114:                                                lReferencePluralName);
115:                                mModelAssistantImpl.mTargetGetAllReferencedEntitiesOperationHelper
116:                                        .ensurePresent(lDomainSupportService,
117:                                                lReference, lEntityName,
118:                                                lReferencePluralName);
119:                            } else {
120:                                mModelAssistantImpl.mTargetAddReferencedEntityOperationHelper
121:                                        .ensureAbsent(lDomainSupportService,
122:                                                lEntityName,
123:                                                lReferencePluralName);
124:                                mModelAssistantImpl.mTargetRemoveReferencedEntityOperationHelper
125:                                        .ensureAbsent(lDomainSupportService,
126:                                                lEntityName,
127:                                                lReferencePluralName);
128:                                mModelAssistantImpl.mTargetGetAllReferencedEntitiesOperationHelper
129:                                        .ensureAbsent(lDomainSupportService,
130:                                                lEntityName,
131:                                                lReferencePluralName);
132:                            }
133:                        }
134:                    }
135:                }
136:            }
137:
138:            // Handle the deletion of the domain
139:            void onDeleting(Entity pEntity) {
140:                String lEntityName = pEntity.getName();
141:                if (lEntityName == null || lEntityName.length() == 0)
142:                    return; // Entity does not have a name
143:                Domain lDomain = pEntity.getDomain();
144:                if (lDomain == null)
145:                    return; // Entity is not associated with domain
146:                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
147:                        .getSystem();
148:                if (lSystem == null)
149:                    return; // Domain is not associated with system
150:                String lDomainName = lDomain.getName();
151:                if (lDomainName == null || lDomainName.length() == 0)
152:                    return; // Domain does not have a name yet
153:                String lServicemoduleName = StylesheetImpl
154:                        .getDomainSupportServicemoduleName(lDomainName);
155:                Servicemodule lServicemodule = lSystem
156:                        .findServicemodule(lServicemoduleName);
157:                if (lServicemodule == null)
158:                    return; // There is no support servicemodule yet
159:                // Work on structures
160:                mModelAssistantImpl.mTargetEntityKeyStructureHelper
161:                        .ensureAbsent(lServicemodule, lEntityName);
162:                mModelAssistantImpl.mTargetEntityDetailsStructureHelper
163:                        .ensureAbsent(lServicemodule, lEntityName);
164:                // Work on messages found in modifiable entity
165:                mModelAssistantImpl.mTargetVersionMismatchMessageHelper
166:                        .ensureAbsent(lServicemodule, lEntityName);
167:                // Work on messages found in the entities with the primary keys
168:                mModelAssistantImpl.mTargetDuplicateCreateFailedMessageHelper
169:                        .ensureAbsent(lServicemodule, lEntityName);
170:
171:                // Work on domain support operations
172:                String lDomainSupportServiceName = StylesheetImpl
173:                        .getDataManagementServiceName(lDomainName);
174:                Service lDomainSupportService = lServicemodule
175:                        .findService(lDomainSupportServiceName);
176:                if (lDomainSupportService == null)
177:                    return; // There is no support servicemodule yet
178:                // Work on operations which depend on the plural name		
179:                String lEntityPluralName = pEntity.getPluralName();
180:                // Iterate through references and ensure that reference related elements are absent
181:                for (Iterator lEntityReferencesIterator = pEntity
182:                        .getCombinedReferences().iterator(); lEntityReferencesIterator
183:                        .hasNext();) {
184:                    AssociationRole lReference = (AssociationRole) lEntityReferencesIterator
185:                            .next();
186:                    // Work on entity reference related domain support operations
187:                    if (lDomainSupportService != null) {
188:                        String lReferencePluralName = lReference
189:                                .getPluralName();
190:                        if (lReferencePluralName != null) {
191:                            mModelAssistantImpl.mTargetAddReferencedEntityOperationHelper
192:                                    .ensureAbsent(lDomainSupportService,
193:                                            lEntityName, lReferencePluralName);
194:                            mModelAssistantImpl.mTargetRemoveReferencedEntityOperationHelper
195:                                    .ensureAbsent(lDomainSupportService,
196:                                            lEntityName, lReferencePluralName);
197:                            mModelAssistantImpl.mTargetGetAllReferencedEntitiesOperationHelper
198:                                    .ensureAbsent(lDomainSupportService,
199:                                            lEntityName, lReferencePluralName);
200:                        }
201:                    }
202:                }
203:            }
204:
205:            // Handle changes to references of the domain
206:            void onChangingReference(Entity pEntity, String pReferenceName,
207:                    RefObject pReferencedModelElementToRemove,
208:                    RefObject pReferencedModelElementToAdd) {
209:                String lEntityName = pEntity.getName();
210:                if (lEntityName == null || lEntityName.length() == 0)
211:                    return; // Entity does not have a name
212:                Domain lDomain = pEntity.getDomain();
213:                if (lDomain == null)
214:                    return; // Entity is not associated with domain
215:                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
216:                        .getSystem();
217:                if (lSystem == null)
218:                    return; // Domain is not associated with system
219:                String lDomainName = lDomain.getName();
220:                if (lDomainName == null || lDomainName.length() == 0)
221:                    return; // Domain does not have a name
222:                String lServicemoduleName = StylesheetImpl
223:                        .getDomainSupportServicemoduleName(lDomainName);
224:                Servicemodule lServicemodule = lSystem
225:                        .findServicemodule(lServicemoduleName);
226:                if (lServicemodule == null)
227:                    return; // There is no support servicemodule yet
228:                // Detect the change of the entity's supertype
229:                if (pReferenceName.equals("supertype")) {
230:                    // For this entity as well as all supertype entities
231:                    // (1) We need to remove all attributes from the old supertype and add all attributes from the new supertype
232:                    //TODO: I think that we need to remove all primary key elements from the old supertype and add all prmary key elements of the new supertype
233:
234:                    // Collect what needs to be done first
235:                    Set lAttributesToAdd = new HashSet();
236:                    if (pReferencedModelElementToAdd != null) {
237:                        Entity lNewSupertype = (Entity) pReferencedModelElementToAdd;
238:                        lAttributesToAdd.addAll(lNewSupertype
239:                                .getCombinedAttributes());
240:                    }
241:                    Set lAttributesToRemove = new HashSet();
242:                    if (pReferencedModelElementToRemove != null) {
243:                        Entity lOldSupertype = (Entity) pReferencedModelElementToRemove;
244:                        lAttributesToRemove.addAll(lOldSupertype
245:                                .getCombinedAttributes());
246:                    }
247:                    Set lAllEntitiesToConsider = new HashSet();
248:                    lAllEntitiesToConsider.add(pEntity);
249:                    lAllEntitiesToConsider
250:                            .addAll(pEntity.getCombinedSubtypes());
251:                    for (Iterator lEntityElementsIterator = lAllEntitiesToConsider
252:                            .iterator(); lEntityElementsIterator.hasNext();) {
253:                        Entity lEntityElement = (Entity) lEntityElementsIterator
254:                                .next();
255:                        String lEntityElementName = lEntityElement.getName();
256:                        if (lEntityElementName == null
257:                                || lEntityElementName.length() == 0)
258:                            continue; // Entity does not have a name
259:                        Collection lEntityElementPrimaryKeyElements = lEntityElement
260:                                .getPrimaryKeyElements();
261:                        for (Iterator lAttributesToRemoveIterator = lAttributesToRemove
262:                                .iterator(); lAttributesToRemoveIterator
263:                                .hasNext();) {
264:                            Attribute lAttributeToRemove = (Attribute) lAttributesToRemoveIterator
265:                                    .next();
266:                            mModelAssistantImpl.mTargetEntityDetailsStructureHelper
267:                                    .attribute_EnsureAbsent(lServicemodule,
268:                                            lEntityElement, lAttributeToRemove
269:                                                    .getName());
270:                            mModelAssistantImpl.mTargetEntityKeyStructureHelper
271:                                    .primaryKeyAttribute_EnsureAbsent(
272:                                            lServicemodule, lEntityElement,
273:                                            lAttributeToRemove.getName());
274:                        }
275:                        for (Iterator lAttributesToAddIterator = lAttributesToAdd
276:                                .iterator(); lAttributesToAddIterator.hasNext();) {
277:                            Attribute lAttributeToAdd = (Attribute) lAttributesToAddIterator
278:                                    .next();
279:                            mModelAssistantImpl.mTargetEntityDetailsStructureHelper
280:                                    .attribute_EnsurePresent(lServicemodule,
281:                                            lEntityElement, lAttributeToAdd
282:                                                    .getName(), lAttributeToAdd
283:                                                    .getDescription(),
284:                                            lAttributeToAdd.getDataType());
285:                            if (lEntityElementPrimaryKeyElements
286:                                    .contains(lAttributeToAdd))
287:                                mModelAssistantImpl.mTargetEntityKeyStructureHelper
288:                                        .primaryKeyAttribute_EnsurePresent(
289:                                                lServicemodule, lEntityElement,
290:                                                lAttributeToAdd.getName(),
291:                                                lAttributeToAdd
292:                                                        .getDescription(),
293:                                                lAttributeToAdd.getDataType());
294:                        }
295:                    }
296:                }
297:                return; // Thats it
298:            }
299:        }
w___w_w___.__j__av_a2___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.