Source Code Cross Referenced for SourceAssociationRoleHelper.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.HashSet;
018:        import java.util.Iterator;
019:        import java.util.Set;
020:
021:        import javax.jmi.reflect.RefObject;
022:
023:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
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.Domain;
029:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
030:
031:        /** This class is looking after actions on attributes */
032:        class SourceAssociationRoleHelper {
033:            private ModelAssistantImpl mModelAssistantImpl;
034:
035:            SourceAssociationRoleHelper(ModelAssistantImpl pModelAssistantImpl) {
036:                mModelAssistantImpl = pModelAssistantImpl;
037:            }
038:
039:            // Handle the creation
040:            void onJustCreated(AssociationRole pAssociationRole) {
041:                String lReferenceName = pAssociationRole.getName();
042:                if (lReferenceName == null || lReferenceName.length() == 0)
043:                    return; // lReferenceName does not have a name
044:                Entity lReferencingEntity = pAssociationRole
045:                        .getReferencingEntity();
046:                if (lReferencingEntity == null)
047:                    return; // Role is not referenced yet
048:                Domain lDomain = lReferencingEntity.getDomain();
049:                if (lDomain == null)
050:                    return; // Entity is not associated with domain
051:                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
052:                        .getSystem();
053:                if (lSystem == null)
054:                    return; // Domain is not associated with system
055:                String lDomainName = lDomain.getName();
056:                if (lDomainName == null || lDomainName.length() == 0)
057:                    return; // Domain does not have a name
058:                String lServicemoduleName = StylesheetImpl
059:                        .getDomainSupportServicemoduleName(lDomainName);
060:                Servicemodule lServicemodule = lSystem
061:                        .findServicemodule(lServicemoduleName);
062:                if (lServicemodule == null)
063:                    return; // There is no support servicemodule yet
064:                // Work on domain support operations
065:                String lDomainSupportServiceName = StylesheetImpl
066:                        .getDataManagementServiceName(lDomainName);
067:                Service lDomainSupportService = lServicemodule
068:                        .findService(lDomainSupportServiceName);
069:                DataType lReferenceDataType = (pAssociationRole.getEntity() != null ? pAssociationRole
070:                        .getEntity().getInstanceIdDataType()
071:                        : null);
072:                AssociationRole lOppositeRole = pAssociationRole
073:                        .getOppositeRole();
074:                String lReferencePluralName = pAssociationRole.getPluralName();
075:
076:                // We will have to work on the entity and all subtypes
077:                Set lAllEntitiesToConsider = new HashSet();
078:                lAllEntitiesToConsider.add(lReferencingEntity);
079:                lAllEntitiesToConsider.addAll(lReferencingEntity
080:                        .getCombinedSubtypes());
081:                for (Iterator lEntityElementsIterator = lAllEntitiesToConsider
082:                        .iterator(); lEntityElementsIterator.hasNext();) {
083:                    Entity lEntityElement = (Entity) lEntityElementsIterator
084:                            .next();
085:                    String lEntityName = lEntityElement.getName();
086:                    if (lEntityName == null || lEntityName.length() == 0)
087:                        continue; // Entity does not have a name
088:                    // Work on the details structure
089:                    if (pAssociationRole.isSingular())
090:                        mModelAssistantImpl.mTargetEntityDetailsStructureHelper
091:                                .reference_EnsurePresent(lServicemodule,
092:                                        lEntityElement, lReferenceName,
093:                                        pAssociationRole.getDescription(),
094:                                        pAssociationRole.getEntity());
095:                    else
096:                        mModelAssistantImpl.mTargetEntityDetailsStructureHelper
097:                                .reference_EnsureAbsent(lServicemodule,
098:                                        lEntityElement, lReferenceName);
099:
100:                    // Association may be a part of the primary key
101:                    if (lEntityElement.getPrimaryKeyElements().contains(
102:                            pAssociationRole)) {
103:                        mModelAssistantImpl.mTargetEntityKeyStructureHelper
104:                                .primaryKeyReference_EnsurePresent(
105:                                        lServicemodule, lEntityElement,
106:                                        lReferenceName, pAssociationRole
107:                                                .getDescription(),
108:                                        pAssociationRole.getEntity());
109:                        mModelAssistantImpl.mTargetDuplicateCreateFailedMessageHelper
110:                                .primaryKeyReference_EnsurePresent(
111:                                        lServicemodule, lEntityElement,
112:                                        lReferenceName, pAssociationRole
113:                                                .getEntity());
114:                    } else {
115:                        mModelAssistantImpl.mTargetEntityKeyStructureHelper
116:                                .primaryKeyReference_EnsureAbsent(
117:                                        lServicemodule, lEntityElement,
118:                                        lReferenceName);
119:                        mModelAssistantImpl.mTargetDuplicateCreateFailedMessageHelper
120:                                .primaryKeyReference_EnsureAbsent(
121:                                        lServicemodule, lEntityElement,
122:                                        lReferenceName);
123:                    }
124:
125:                    // Work on entity reference related domain support operations
126:                    if (lDomainSupportService != null
127:                            && lReferencePluralName != null) {
128:                        if (lOppositeRole != null
129:                                && pAssociationRole.isPlural()
130:                                && lOppositeRole.isPlural()
131:                                && AggregationTypeEnum.AGGREGATION
132:                                        .equals(lOppositeRole
133:                                                .getAggregationType())) {
134:                            mModelAssistantImpl.mTargetAddReferencedEntityOperationHelper
135:                                    .ensurePresent(lDomainSupportService,
136:                                            pAssociationRole, lEntityName,
137:                                            lReferencePluralName);
138:                            mModelAssistantImpl.mTargetRemoveReferencedEntityOperationHelper
139:                                    .ensurePresent(lDomainSupportService,
140:                                            pAssociationRole, lEntityName,
141:                                            lReferencePluralName);
142:                            mModelAssistantImpl.mTargetGetAllReferencedEntitiesOperationHelper
143:                                    .ensurePresent(lDomainSupportService,
144:                                            pAssociationRole, lEntityName,
145:                                            lReferencePluralName);
146:                        } else {
147:                            mModelAssistantImpl.mTargetAddReferencedEntityOperationHelper
148:                                    .ensureAbsent(lDomainSupportService,
149:                                            lEntityName, lReferencePluralName);
150:                            mModelAssistantImpl.mTargetRemoveReferencedEntityOperationHelper
151:                                    .ensureAbsent(lDomainSupportService,
152:                                            lEntityName, lReferencePluralName);
153:                            mModelAssistantImpl.mTargetGetAllReferencedEntitiesOperationHelper
154:                                    .ensureAbsent(lDomainSupportService,
155:                                            lEntityName, lReferencePluralName);
156:                        }
157:                    }
158:                }
159:            }
160:
161:            // Handle the deletion
162:            void onDeleting(AssociationRole pAssociationRole) {
163:                String lReferenceName = pAssociationRole.getName();
164:                if (lReferenceName == null || lReferenceName.length() == 0)
165:                    return; // lReferenceName does not have a name
166:                Entity lReferencingEntity = pAssociationRole
167:                        .getReferencingEntity();
168:                if (lReferencingEntity == null)
169:                    return; // Role is not referenced yet
170:                Domain lDomain = lReferencingEntity.getDomain();
171:                if (lDomain == null)
172:                    return; // Entity is not associated with domain
173:                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
174:                        .getSystem();
175:                if (lSystem == null)
176:                    return; // Domain is not associated with system
177:                String lDomainName = lDomain.getName();
178:                if (lDomainName == null || lDomainName.length() == 0)
179:                    return; // Domain does not have a name yet
180:                String lServicemoduleName = StylesheetImpl
181:                        .getDomainSupportServicemoduleName(lDomainName);
182:                Servicemodule lServicemodule = lSystem
183:                        .findServicemodule(lServicemoduleName);
184:                if (lServicemodule == null)
185:                    return; // There is no support servicemodule yet
186:                String lDomainSupportServiceName = StylesheetImpl
187:                        .getDataManagementServiceName(lDomainName);
188:                Service lDomainSupportService = lServicemodule
189:                        .findService(lDomainSupportServiceName);
190:                String lReferencePluralName = pAssociationRole.getPluralName();
191:                // We will have to work on the entity and all subtypes
192:                Set lAllEntitiesToConsider = new HashSet();
193:                lAllEntitiesToConsider.add(lReferencingEntity);
194:                lAllEntitiesToConsider.addAll(lReferencingEntity
195:                        .getCombinedSubtypes());
196:                for (Iterator lEntityElementsIterator = lAllEntitiesToConsider
197:                        .iterator(); lEntityElementsIterator.hasNext();) {
198:                    Entity lEntityElement = (Entity) lEntityElementsIterator
199:                            .next();
200:                    String lEntityName = lEntityElement.getName();
201:                    if (lEntityName == null || lEntityName.length() == 0)
202:                        continue; // Entity does not have a name
203:                    // Reference is being deleted. Make sure it is not present in the key and details structures
204:                    mModelAssistantImpl.mTargetEntityDetailsStructureHelper
205:                            .reference_EnsureAbsent(lServicemodule,
206:                                    lEntityElement, lReferenceName);
207:                    mModelAssistantImpl.mTargetEntityKeyStructureHelper
208:                            .primaryKeyReference_EnsureAbsent(lServicemodule,
209:                                    lEntityElement, lReferenceName);
210:                    mModelAssistantImpl.mTargetDuplicateCreateFailedMessageHelper
211:                            .primaryKeyReference_EnsureAbsent(lServicemodule,
212:                                    lEntityElement, lReferenceName);
213:                    // Work on entity reference related domain support operations
214:                    if (lDomainSupportService != null
215:                            && lReferencePluralName != null) {
216:                        mModelAssistantImpl.mTargetAddReferencedEntityOperationHelper
217:                                .ensureAbsent(lDomainSupportService,
218:                                        lEntityName, lReferencePluralName);
219:                        mModelAssistantImpl.mTargetRemoveReferencedEntityOperationHelper
220:                                .ensureAbsent(lDomainSupportService,
221:                                        lEntityName, lReferencePluralName);
222:                        mModelAssistantImpl.mTargetGetAllReferencedEntitiesOperationHelper
223:                                .ensureAbsent(lDomainSupportService,
224:                                        lEntityName, lReferencePluralName);
225:                    }
226:                }
227:            }
228:
229:            // Handle changes to references of the association role
230:            void onChangingReference(AssociationRole pAssociationRole,
231:                    String pReferenceName,
232:                    RefObject pReferencedModelElementToRemove,
233:                    RefObject pReferencedModelElementToAdd) {
234:                AssociationRole lReference = pAssociationRole.getOppositeRole();
235:                if (lReference == null)
236:                    return; // Reference is not set yet
237:                Entity lReferencedEntity = lReference.getEntity();
238:                if (lReferencedEntity == null)
239:                    return; // Entity is not set yet
240:                String lReferenceName = lReference.getName();
241:                if (lReferenceName == null)
242:                    return; // The name of the reference is not set yet
243:                Domain lDomain = lReferencedEntity.getDomain();
244:                if (lDomain == null)
245:                    return; // Entity is not associated with domain
246:                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
247:                        .getSystem();
248:                if (lSystem == null)
249:                    return; // Domain is not associated with system
250:                String lDomainName = lDomain.getName();
251:                if (lDomainName == null || lDomainName.length() == 0)
252:                    return; // Domain does not have a name
253:                String lServicemoduleName = StylesheetImpl
254:                        .getDomainSupportServicemoduleName(lDomainName);
255:                Servicemodule lServicemodule = lSystem
256:                        .findServicemodule(lServicemoduleName);
257:                if (lServicemodule == null)
258:                    return; // There is no support servicemodule yet
259:                if (pReferenceName.equals("entity")) {
260:                    // If the referencing entity is known, than we may have to look after the structures and messages
261:                    Entity lReferencedEntityBeingRemoved = (Entity) pReferencedModelElementToRemove;
262:                    if (lReferencedEntityBeingRemoved != null) {
263:                        // Remove elements, which are dependent on this side of the reference  
264:                        Set lAllEntitiesToConsider = new HashSet();
265:                        lAllEntitiesToConsider
266:                                .add(lReferencedEntityBeingRemoved);
267:                        lAllEntitiesToConsider
268:                                .addAll(lReferencedEntityBeingRemoved
269:                                        .getCombinedSubtypes());
270:                        for (Iterator lEntityElementsIterator = lAllEntitiesToConsider
271:                                .iterator(); lEntityElementsIterator.hasNext();) {
272:                            Entity lEntityElement = (Entity) lEntityElementsIterator
273:                                    .next();
274:                            String lEntityName = lEntityElement.getName();
275:                            if (lEntityName == null
276:                                    || lEntityName.length() == 0)
277:                                continue; // Entity does not have a name
278:                            // Make sure this reference is not present anywhere
279:                            mModelAssistantImpl.mTargetEntityDetailsStructureHelper
280:                                    .reference_EnsureAbsent(lServicemodule,
281:                                            lEntityElement, lReferenceName);
282:                            mModelAssistantImpl.mTargetEntityKeyStructureHelper
283:                                    .primaryKeyReference_EnsureAbsent(
284:                                            lServicemodule, lEntityElement,
285:                                            lReferenceName);
286:                            mModelAssistantImpl.mTargetDuplicateCreateFailedMessageHelper
287:                                    .primaryKeyReference_EnsureAbsent(
288:                                            lServicemodule, lEntityElement,
289:                                            lReferenceName);
290:                        }
291:                    }
292:                    Entity lReferencedEntityBeingAdded = (Entity) pReferencedModelElementToAdd;
293:                    if (lReferencedEntityBeingAdded != null) {
294:                        Set lAllEntitiesToConsider = new HashSet();
295:                        lAllEntitiesToConsider.add(lReferencedEntityBeingAdded);
296:                        lAllEntitiesToConsider
297:                                .addAll(lReferencedEntityBeingAdded
298:                                        .getCombinedSubtypes());
299:                        for (Iterator lEntityElementsIterator = lAllEntitiesToConsider
300:                                .iterator(); lEntityElementsIterator.hasNext();) {
301:                            Entity lEntityElement = (Entity) lEntityElementsIterator
302:                                    .next();
303:                            String lEntityName = lEntityElement.getName();
304:                            if (lEntityName == null
305:                                    || lEntityName.length() == 0)
306:                                continue; // Entity does not have a name
307:                            // Work on the details structure
308:                            if (lReference.isSingular())
309:                                mModelAssistantImpl.mTargetEntityDetailsStructureHelper
310:                                        .reference_EnsurePresent(
311:                                                lServicemodule, lEntityElement,
312:                                                lReferenceName, lReference
313:                                                        .getDescription(),
314:                                                lReferencedEntity);
315:                            // Association may be a part of the primary key
316:                            if (lEntityElement.getPrimaryKeyElements()
317:                                    .contains(lReference)) {
318:                                mModelAssistantImpl.mTargetEntityKeyStructureHelper
319:                                        .primaryKeyReference_EnsurePresent(
320:                                                lServicemodule, lEntityElement,
321:                                                lReferenceName, lReference
322:                                                        .getDescription(),
323:                                                lReferencedEntity);
324:                                mModelAssistantImpl.mTargetDuplicateCreateFailedMessageHelper
325:                                        .primaryKeyReference_EnsurePresent(
326:                                                lServicemodule, lEntityElement,
327:                                                lReferenceName,
328:                                                lReferencedEntity);
329:                            }
330:
331:                        }
332:                    }
333:                }
334:                return; // Thats it
335:            }
336:        }
ww__w_.j__a___v_a2___s.__co_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.