Source Code Cross Referenced for TargetDomainSupportServicemoduleHelper.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:
019:        import javax.jmi.reflect.ConstraintViolationException;
020:        import javax.jmi.reflect.RefObject;
021:
022:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
023:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
024:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
025:
026:        /** This class containse helper methods dealing with the Domain Support Servicemodule model element  */
027:        class TargetDomainSupportServicemoduleHelper {
028:            private ModelAssistantImpl mModelAssistantImpl;
029:
030:            TargetDomainSupportServicemoduleHelper(
031:                    ModelAssistantImpl pModelAssistantImpl) {
032:                mModelAssistantImpl = pModelAssistantImpl;
033:
034:                // Add domain lifecycle listener
035:                mModelAssistantImpl.addLifecycleListener(Domain.class,
036:                        new ModelAssistantImpl.ModelElementLifecycleListener() {
037:                            public void onElementJustCreated(
038:                                    RefObject pModelElementJustCreated) {
039:                                Domain lDomain = (Domain) pModelElementJustCreated;
040:                                String lDomainName = lDomain.getName();
041:                                if (lDomainName == null)
042:                                    return; // Domain does not have a name
043:                                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
044:                                        .getSystem();
045:                                if (lSystem == null)
046:                                    return; // Domain is not associated with system
047:                                ensurePresent(lSystem, lDomainName);
048:                            }
049:
050:                            public void onElementBeingDeleted(
051:                                    RefObject pModelElementBeingDeleted) {
052:                                Domain lDomain = (Domain) pModelElementBeingDeleted;
053:                                String lDomainName = lDomain.getName();
054:                                if (lDomainName == null)
055:                                    return; // Domain does not have a name
056:                                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
057:                                        .getSystem();
058:                                if (lSystem == null)
059:                                    return; // Domain is not associated with system
060:                                ensureAbsent(lSystem, lDomainName);
061:                            }
062:                        });
063:                // Add domain Name attribute change listener
064:                mModelAssistantImpl
065:                        .addAttributeChangeListener(
066:                                Domain.class,
067:                                "Name",
068:                                new ModelAssistantImpl.ModelElementAttributeChangeListener() {
069:                                    public void onAttributeBeingUpdated(
070:                                            RefObject pModelElementBeingUpdated,
071:                                            String pAttributeName,
072:                                            Object pOldValue, Object pNewValue) {
073:                                        Domain lDomain = (Domain) pModelElementBeingUpdated;
074:                                        String lDomainName = lDomain.getName();
075:                                        if (lDomainName == null)
076:                                            return; // Domain does not have a name
077:                                        com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lDomain
078:                                                .getSystem();
079:                                        if (lSystem == null)
080:                                            return; // Domain is not associated with system
081:                                        if (pNewValue == null) {
082:                                            // Only old value is known - ensure that the element is deleted
083:                                            ensureAbsent(lSystem,
084:                                                    (String) pOldValue);
085:                                        } else {
086:                                            // The element must be present - rename or create
087:                                            if (pOldValue != null)
088:                                                ensureRenamedPresent(lSystem,
089:                                                        (String) pOldValue,
090:                                                        (String) pNewValue);
091:                                            else
092:                                                ensurePresent(lSystem,
093:                                                        (String) pNewValue);
094:                                        }
095:                                    }
096:                                });
097:                // Add domain system reference change listener
098:                mModelAssistantImpl
099:                        .addReferenceChangeListener(
100:                                Domain.class,
101:                                "system",
102:                                new ModelAssistantImpl.ModelElementReferenceChangeListener() {
103:                                    public void onReferenceBeingUpdated(
104:                                            RefObject pModelElementBeingUpdated,
105:                                            String pReferenceName,
106:                                            RefObject pReferencedModelElementToRemove,
107:                                            RefObject pReferencedModelElementToAdd) {
108:                                        Domain lDomain = (Domain) pModelElementBeingUpdated;
109:                                        String lDomainName = lDomain.getName();
110:                                        if (lDomainName == null)
111:                                            return; // Domain does not have a name
112:                                        String lServicemoduleName = StylesheetImpl
113:                                                .getDomainSupportServicemoduleName(lDomainName);
114:                                        if (pReferencedModelElementToAdd != null) {
115:                                            com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lNewSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) pReferencedModelElementToAdd;
116:                                            // It it is possible - replace the system in the existing servicemodule
117:                                            if (pReferencedModelElementToRemove != null) {
118:                                                // This looks like moving the servicemodule around
119:                                                com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lOldSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) pReferencedModelElementToRemove;
120:                                                Servicemodule lServicemodule = lOldSystem
121:                                                        .findServicemodule(lServicemoduleName);
122:                                                // Be relaxed here - allow for old servicemodule not found and silently fix it
123:                                                if (lServicemodule != null)
124:                                                    lServicemodule
125:                                                            .setSystem(lNewSystem);
126:                                                else
127:                                                    ensurePresent(lNewSystem,
128:                                                            lDomainName);
129:                                            } else
130:                                                ensurePresent(lNewSystem,
131:                                                        lDomainName);
132:                                        } else if (pReferencedModelElementToRemove != null) {
133:                                            // This looks like moving the servicemodule around
134:                                            com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lOldSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) pReferencedModelElementToRemove;
135:                                            ensureAbsent(lOldSystem,
136:                                                    lDomainName);
137:                                        }
138:                                    }
139:                                });
140:            }
141:
142:            // This helper verifies constraints which are dealing with entity structures
143:            void verifyConstraints(
144:                    Collection pViolations,
145:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem,
146:                    Domain pDomain) {
147:                String lDomainName = pDomain.getName();
148:                if (lDomainName == null || lDomainName.length() == 0)
149:                    return; // Domain does not have a name
150:                String lServicemoduleName = StylesheetImpl
151:                        .getDomainSupportServicemoduleName(lDomainName);
152:                // Find and fix the servicemodule
153:                Servicemodule lServicemodule = pSystem
154:                        .findServicemodule(lServicemoduleName);
155:                if (lServicemodule != null) {
156:                    String lDataManagementServiceName = StylesheetImpl
157:                            .getDataManagementServiceName(lDomainName);
158:                    Service lDataManagementService = lServicemodule
159:                            .findService(lDataManagementServiceName);
160:                    if (lDataManagementService == null)
161:                        pViolations.add(new ConstraintViolationException(
162:                                lServicemodule, lServicemodule.refMetaObject(),
163:                                "A Domain Support Servicemodule must have Data Management Service. The '"
164:                                        + lDataManagementService
165:                                        + "' Service not found."));
166:                } else
167:                    pViolations
168:                            .add(new ConstraintViolationException(
169:                                    pSystem,
170:                                    pSystem.refMetaObject(),
171:                                    "A System must have dedicated Domain Support Servicemodule for each contained Domain. The '"
172:                                            + lServicemoduleName
173:                                            + "' Servicemodule not found."));
174:            }
175:
176:            // This helper renames the key and details structures
177:            void ensureRenamedPresent(
178:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem,
179:                    String pOldDomainName, String pNewDomainName) {
180:                // Note that this method only deals with renaming and than calls the ensure present method  
181:                String lOldServicemoduleName = StylesheetImpl
182:                        .getDomainSupportServicemoduleName(pOldDomainName);
183:                Servicemodule lOldServicemodule = pSystem
184:                        .findServicemodule(lOldServicemoduleName);
185:                String lNewServicemoduleName = StylesheetImpl
186:                        .getDomainSupportServicemoduleName(pNewDomainName);
187:                Servicemodule lNewServicemodule = pSystem
188:                        .findServicemodule(lNewServicemoduleName);
189:                // Be relaxed here - allow for all sorts of mishaps
190:                if (lOldServicemodule != null) {
191:                    if (lNewServicemodule != null) {
192:                        // New and old structures are present - just delete the old one
193:                        lOldServicemodule.refDelete();
194:                    } else {
195:                        // Old structure is present - new one is not - rename
196:                        lOldServicemodule.setName(lNewServicemoduleName);
197:                    }
198:                }
199:                // Call the ensure present bit
200:                ensurePresent(pSystem, pNewDomainName);
201:            }
202:
203:            // This helper makes sure that the version id attribute is present in the details structure
204:            void ensurePresent(
205:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem,
206:                    String pDomainName) {
207:                // Work on the servicemodule
208:                String lServicemoduleName = StylesheetImpl
209:                        .getDomainSupportServicemoduleName(pDomainName);
210:                Servicemodule lServicemodule = pSystem
211:                        .findServicemodule(lServicemoduleName);
212:                if (lServicemodule == null) {
213:                    lServicemodule = mModelAssistantImpl.mServicemoduleClass
214:                            .createServicemodule();
215:                    lServicemodule.setSystem(pSystem);
216:                    lServicemodule.setName(lServicemoduleName);
217:                }
218:                lServicemodule.setDescription(StylesheetImpl
219:                        .getDomainSupportServicemoduleDescription(pDomainName));
220:                // Work on service
221:                String lServiceName = StylesheetImpl
222:                        .getDataManagementServiceName(pDomainName);
223:                Service lService = lServicemodule.findService(lServiceName);
224:                if (lService == null) {
225:                    lService = mModelAssistantImpl.mServiceClass
226:                            .createService();
227:                    lService.setName(lServiceName);
228:                    lService.setServicemodule(lServicemodule);
229:                }
230:                lService.setDescription(StylesheetImpl
231:                        .getDataManagementServiceDescription(pDomainName));
232:            }
233:
234:            // This helper makes sure that the version id attribute is absent in the details structure
235:            void ensureAbsent(
236:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem,
237:                    String pDomainName) {
238:                // Work on the details structure
239:                Servicemodule lServicemodule = pSystem
240:                        .findServicemodule(StylesheetImpl
241:                                .getDomainSupportServicemoduleName(pDomainName));
242:                if (lServicemodule != null)
243:                    lServicemodule.refDelete();
244:            }
245:        }
w_ww.__j__av___a_2s__.___c___o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.