Source Code Cross Referenced for ModelAssistantImpl.java in  » UML » MetaBoss » com » metaboss » sdlctools » models » modelassistant » metabossmodel » implicitselectors » 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.implicitselectors 
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.implicitselectors;
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.naming.Context;
025:        import javax.naming.InitialContext;
026:        import javax.naming.NamingException;
027:
028:        import com.metaboss.sdlctools.models.ModelRepository;
029:        import com.metaboss.sdlctools.models.ModelRepositoryException;
030:        import com.metaboss.sdlctools.models.ModelRepositoryInternalException;
031:        import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
032:        import com.metaboss.sdlctools.models.metabossmodel.ModelElementClass;
033:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionaryModelPackage;
034:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
035:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.EntityClass;
036:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Selector;
037:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorClass;
038:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorInputFieldClass;
039:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SystemImplementationModelPackage;
040:        import com.metaboss.sdlctools.models.modelassistant.metabossmodel.SingleModelAssistantImplBase;
041:
042:        /** Implementation of the assistant to MetaBoss models.
043:         * Looks after some implicit data types in the systems.
044:         * This implementation is always only serving one model. This is guaranteed
045:         * by special factory implementation */
046:        public class ModelAssistantImpl extends SingleModelAssistantImplBase {
047:            /** String constant which is used to identify this assistant as an owner of certain model elements */
048:            public static final String ASSISTANT_IDENTIFIER = ModelAssistantImpl.class
049:                    .getPackage().getName();
050:
051:            // Variables below are cached for whole session with the model regardless of the kind of model it is
052:            ModelRepository mModelRepository = null;
053:            MetaBossModelPackage mRootPackage = null;
054:            ModelElementClass mModelElementClass = null;
055:            SystemImplementationModelPackage mSystemImplementationModelPackage = null;
056:            EntityClass mEntityClass = null;
057:            SelectorClass mSelectorClass = null;
058:            SelectorInputFieldClass mSelectorInputFieldClass = null;
059:            DataDictionaryModelPackage mDataDictionaryModel = null;
060:
061:            TargetEntityStateSelectorHelper mTargetEntityStateSelectorHelper = null;
062:            TargetEnumerableAttributeSelectorHelper mTargetEnumerableAttributeSelectorHelper = null;
063:
064:            public ModelAssistantImpl() {
065:                mTargetEntityStateSelectorHelper = new TargetEntityStateSelectorHelper(
066:                        this );
067:                mTargetEnumerableAttributeSelectorHelper = new TargetEnumerableAttributeSelectorHelper(
068:                        this );
069:            }
070:
071:            // As per interface 
072:            public void assignToModel(String pModelName)
073:                    throws ModelRepositoryException {
074:                super .assignToModel(pModelName);
075:                try {
076:                    Context lContext = new InitialContext();
077:                    mModelRepository = (ModelRepository) lContext
078:                            .lookup(ModelRepository.COMPONENT_URL);
079:                    mRootPackage = (MetaBossModelPackage) mModelRepository
080:                            .getModelExtent(pModelName);
081:                    mModelElementClass = mRootPackage.getModelElement();
082:                    mSystemImplementationModelPackage = mRootPackage
083:                            .getEnterpriseModel()
084:                            .getSystemImplementationModel();
085:                    mEntityClass = mSystemImplementationModelPackage
086:                            .getEntity();
087:                    mSelectorClass = mSystemImplementationModelPackage
088:                            .getSelector();
089:                    mSelectorInputFieldClass = mSystemImplementationModelPackage
090:                            .getSelectorInputField();
091:                    mDataDictionaryModel = mRootPackage
092:                            .getDataDictionaryModel();
093:
094:                } catch (NamingException e) {
095:                    throw new ModelRepositoryInternalException(
096:                            "Unable to lookup repository", e);
097:                }
098:            }
099:
100:            // As per interface 
101:            public void dismissFromModel(String pModelName) {
102:                mRootPackage = null;
103:                mModelRepository = null;
104:                mModelElementClass = null;
105:                mSystemImplementationModelPackage = null;
106:                mEntityClass = null;
107:                mSelectorClass = null;
108:                mSelectorInputFieldClass = null;
109:                mDataDictionaryModel = null;
110:                super .dismissFromModel(pModelName);
111:            }
112:
113:            // As per interface 
114:            public void rectifyModel(String pModelName)
115:                    throws ModelRepositoryException {
116:                // Ensure that every entity has all necessary selectors
117:                for (Iterator lEntitiesIterator = mEntityClass.refAllOfType()
118:                        .iterator(); lEntitiesIterator.hasNext();) {
119:                    Entity lEntity = (Entity) lEntitiesIterator.next();
120:                    HelperContext lHelperContext = new HelperContext(lEntity);
121:                    // Collect all  selectors with the view of deleting the ones we do not need
122:                    List lUnclaimedSelectors = new ArrayList(lEntity
123:                            .getSelectors());
124:                    mTargetEntityStateSelectorHelper.rectifyModel(lEntity,
125:                            lUnclaimedSelectors);
126:                    mTargetEnumerableAttributeSelectorHelper.rectifyModel(
127:                            lEntity, lUnclaimedSelectors);
128:                    for (Iterator lUnclaimedSelectorsIterator = lUnclaimedSelectors
129:                            .iterator(); lUnclaimedSelectorsIterator.hasNext();) {
130:                        Selector lSelector = (Selector) lUnclaimedSelectorsIterator
131:                                .next();
132:                        if (lSelector.isDerived()
133:                                && lSelector.getOwnerIdentifier().equals(
134:                                        ASSISTANT_IDENTIFIER))
135:                            lSelector.refDelete();
136:                    }
137:                }
138:            }
139:
140:            // As per interface 
141:            public Collection verifyConstraints(String pModelName) {
142:                List lViolations = new ArrayList();
143:                // Ensure that every entity has all necessary selectors
144:                for (Iterator lEntitiesIterator = mEntityClass.refAllOfType()
145:                        .iterator(); lEntitiesIterator.hasNext();) {
146:                    Entity lEntity = (Entity) lEntitiesIterator.next();
147:                    HelperContext lHelperContext = new HelperContext(lEntity);
148:                    // Collect all selectors with the view of deleting the ones we do not need
149:                    List lUnclaimedSelectors = new ArrayList(lEntity
150:                            .getSelectors());
151:                    // Verify integrity
152:                    mTargetEntityStateSelectorHelper.verifyConstraints(
153:                            lViolations, lEntity, lUnclaimedSelectors);
154:                    mTargetEnumerableAttributeSelectorHelper.verifyConstraints(
155:                            lViolations, lEntity, lUnclaimedSelectors);
156:                    // Report unprocessed selectors
157:                    for (Iterator lUnclaimedSelectorsIterator = lUnclaimedSelectors
158:                            .iterator(); lUnclaimedSelectorsIterator.hasNext();) {
159:                        Selector lSelector = (Selector) lUnclaimedSelectorsIterator
160:                                .next();
161:                        if (lSelector.isDerived()
162:                                && lSelector.getOwnerIdentifier().equals(
163:                                        ASSISTANT_IDENTIFIER))
164:                            lViolations
165:                                    .add(new ConstraintViolationException(
166:                                            lSelector,
167:                                            lSelector.refMetaObject(),
168:                                            "Implicit selector must be associated with Entity State or Enumerable Attribute. Selector '"
169:                                                    + lSelector.getName()
170:                                                    + "' appears to have no reason to exist."));
171:                    }
172:                }
173:                // Return what we have
174:                return Collections.unmodifiableCollection(lViolations);
175:            }
176:        }
ww___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.