Source Code Cross Referenced for Util.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.Iterator;
020:        import java.util.List;
021:        import java.util.Set;
022:
023:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
024:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
025:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.PrimaryKeyElement;
026:
027:        /** Implementation of the simple stylesheet class, which is
028:         * responsible for creation of derived names */
029:        public class Util {
030:            // Helper method. Collects entities, instances of which may be not be found when
031:            // attempting to load given top entity. This helper is basically expected to
032:            // study elements of the primary key for this entity and add all associated entities, which are part of the primary key
033:            // The method is called recirsively to deal with primary keys of the associated entities, which areparts of primary key
034:            // to any depth.
035:            static void collectEntitiesWhichMayBeNotFoundWhenLoadingInstance(
036:                    Entity pInstanceEntity, Set pCollectedEntities) {
037:                // Look at all associations, which are parts of primary key
038:                // We also may have entities, which are parts of primary key not found
039:                for (Iterator lPrimaryKeyElementsIterator = pInstanceEntity
040:                        .getPrimaryKeyElements().iterator(); lPrimaryKeyElementsIterator
041:                        .hasNext();) {
042:                    PrimaryKeyElement lPrimaryKeyElement = (PrimaryKeyElement) lPrimaryKeyElementsIterator
043:                            .next();
044:                    if (lPrimaryKeyElement instanceof  AssociationRole) {
045:                        AssociationRole lRole = (AssociationRole) lPrimaryKeyElement;
046:                        // Only register this entity and its dependents if it is not already in the list
047:                        Entity lAssociatedEntityInPrimaryKey = lRole
048:                                .getEntity();
049:                        if (!pCollectedEntities
050:                                .contains(lAssociatedEntityInPrimaryKey)) {
051:                            // Add this entity to collected entities and call this operation recursively
052:                            pCollectedEntities
053:                                    .add(lAssociatedEntityInPrimaryKey);
054:                            collectEntitiesWhichMayBeNotFoundWhenLoadingInstance(
055:                                    lAssociatedEntityInPrimaryKey,
056:                                    pCollectedEntities);
057:                        }
058:                    }
059:                }
060:            }
061:
062:            // Helper method. Opposite to the one above. It will collect all
063:            // instance entities which may need to find the given entity when loading
064:            static void collectInstancesWhichMayNeedToFindEntityWhenLoading(
065:                    Entity pEntity, Set pCollectedEntities) {
066:                // Look at all associations, which are parts of primary key
067:                for (Iterator lReferencesIterator = pEntity.getReferences()
068:                        .iterator(); lReferencesIterator.hasNext();) {
069:                    AssociationRole lReference = (AssociationRole) lReferencesIterator
070:                            .next();
071:                    AssociationRole lOppositeReference = lReference
072:                            .getOppositeRole();
073:                    Entity lInstanceEntity = lReference.getEntity();
074:                    List lEntitiesToConsider = new ArrayList();
075:                    lEntitiesToConsider.add(lInstanceEntity);
076:                    lEntitiesToConsider.addAll(lInstanceEntity
077:                            .getCombinedSubtypes());
078:                    for (Iterator lInstanceEntitiesIterator = lEntitiesToConsider
079:                            .iterator(); lInstanceEntitiesIterator.hasNext();) {
080:                        Entity lEntityElement = (Entity) lInstanceEntitiesIterator
081:                                .next();
082:                        if (!pCollectedEntities.contains(lEntityElement)
083:                                && lEntityElement.getPrimaryKeyElements()
084:                                        .contains(lOppositeReference)) {
085:                            pCollectedEntities.add(lEntityElement);
086:                            collectInstancesWhichMayNeedToFindEntityWhenLoading(
087:                                    lEntityElement, pCollectedEntities);
088:                        }
089:                    }
090:                }
091:            }
092:
093:            // Helper method. Collects entities, instances of which may be not be found when
094:            // attempting to update or create given top entity. This helper is basically expected to
095:            // add all association roles present in the entity
096:            static void collectEntitiesWhichMayBeNotFoundWhenUpdatingOrCreatingInstance(
097:                    Entity pEntity, Set pCollectedEntities) {
098:                // Now look through all associations for which we have a reference
099:                Collection lReferences = pEntity.getCombinedReferences();
100:                for (Iterator lReferencesIterator = lReferences.iterator(); lReferencesIterator
101:                        .hasNext();) {
102:                    AssociationRole lRole = (AssociationRole) lReferencesIterator
103:                            .next();
104:                    // Singular multiplicities resolved simply by having the other entity id as the member of the structure
105:                    // Not singular cardinality is resolved by having a separate service call
106:                    if (lRole.isSingular()) {
107:                        // Only register this entity and its dependents if it is not already in the list
108:                        Entity lAssociatedEntityInRole = lRole.getEntity();
109:                        if (!pCollectedEntities
110:                                .contains(lAssociatedEntityInRole)) {
111:                            // Add this entity to collected entities and collect all entities, which may go wrong when editing this one
112:                            pCollectedEntities.add(lAssociatedEntityInRole);
113:                            collectEntitiesWhichMayBeNotFoundWhenLoadingInstance(
114:                                    lAssociatedEntityInRole, pCollectedEntities);
115:                        }
116:                    }
117:                }
118:            }
119:        }
ww_w_.___j__av___a___2___s_.__co_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.