Source Code Cross Referenced for UMLModelAccessFacade.java in  » UML » AndroMDA-3.2 » org » andromda » metafacades » emf » uml2 » 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 » AndroMDA 3.2 » org.andromda.metafacades.emf.uml2 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.metafacades.emf.uml2;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.Collections;
006:        import java.util.Iterator;
007:
008:        import org.andromda.core.common.ExceptionUtils;
009:        import org.andromda.core.configuration.Filters;
010:        import org.andromda.core.metafacade.MetafacadeBase;
011:        import org.andromda.core.metafacade.MetafacadeConstants;
012:        import org.andromda.core.metafacade.MetafacadeFactory;
013:        import org.andromda.core.metafacade.ModelAccessFacade;
014:        import org.andromda.metafacades.uml.ModelElementFacade;
015:        import org.andromda.metafacades.uml.PackageFacade;
016:        import org.apache.commons.collections.CollectionUtils;
017:        import org.apache.commons.collections.Predicate;
018:        import org.apache.commons.lang.StringUtils;
019:        import org.eclipse.emf.common.util.TreeIterator;
020:        import org.eclipse.emf.ecore.EObject;
021:        import org.eclipse.uml2.Element;
022:        import org.eclipse.uml2.NamedElement;
023:        import org.eclipse.uml2.util.UML2Resource;
024:
025:        /**
026:         * Model access facade implementation for the EMF/UML2 metafacades
027:         *
028:         * @author Steve Jerman
029:         * @author Chad Brandon
030:         */
031:        public class UMLModelAccessFacade implements  ModelAccessFacade {
032:            /**
033:             * Protected to improve performance.
034:             */
035:            protected Filters modelPackages = new Filters();
036:
037:            /**
038:             * @see org.andromda.core.metafacade.ModelAccessFacade#setModel(java.lang.Object)
039:             */
040:            public void setModel(final Object model) {
041:                ExceptionUtils.checkNull("model", model);
042:                ExceptionUtils.checkAssignable(UML2Resource.class,
043:                        "modelElement", model.getClass());
044:                this .model = (UML2Resource) model;
045:            }
046:
047:            /**
048:             * @see org.andromda.core.metafacade.ModelAccessFacade#getModel()
049:             */
050:            public Object getModel() {
051:                return this .model;
052:            }
053:
054:            /**
055:             * @see org.andromda.core.metafacade.ModelAccessFacade#getName(java.lang.Object)
056:             */
057:            public String getName(final Object modelElement) {
058:                ExceptionUtils.checkNull("modelElement", modelElement);
059:                ExceptionUtils.checkAssignable(ModelElementFacade.class,
060:                        "modelElement", modelElement.getClass());
061:                return ((ModelElementFacade) modelElement).getName();
062:            }
063:
064:            /**
065:             * @see org.andromda.core.metafacade.ModelAccessFacade#getPackageName(java.lang.Object)
066:             */
067:            public String getPackageName(final Object modelElement) {
068:                ExceptionUtils.checkNull("modelElement", modelElement);
069:                ExceptionUtils.checkAssignable(ModelElementFacade.class,
070:                        "modelElement", modelElement.getClass());
071:                final ModelElementFacade modelElementFacade = (ModelElementFacade) modelElement;
072:                final StringBuffer packageName = new StringBuffer(
073:                        modelElementFacade.getPackageName(true));
074:
075:                // - if the model element is a package then the package name will be the
076:                // name
077:                // of the package with its package name
078:                if (modelElement instanceof  PackageFacade) {
079:                    final String name = modelElementFacade.getName();
080:                    if (StringUtils.isNotBlank(name)) {
081:                        packageName
082:                                .append(MetafacadeConstants.NAMESPACE_SCOPE_OPERATOR);
083:                        packageName.append(name);
084:                    }
085:                }
086:                return packageName.toString();
087:            }
088:
089:            /**
090:             * The actual underlying model instance.
091:             */
092:            private UML2Resource model;
093:
094:            /**
095:             * @see org.andromda.core.metafacade.ModelAccessFacade#setPackageFilter(org.andromda.core.configuration.Filters)
096:             */
097:            public void setPackageFilter(final Filters modelPackages) {
098:                this .modelPackages = modelPackages;
099:            }
100:
101:            /**
102:             * @see org.andromda.core.metafacade.ModelAccessFacade#getStereotypeNames(java.lang.Object)
103:             */
104:            public Collection getStereotypeNames(final Object modelElement) {
105:                ExceptionUtils.checkNull("modelElement", modelElement);
106:
107:                Collection stereotypeNames = Collections.EMPTY_LIST;
108:                if (modelElement instanceof  Element) {
109:                    Element element = (Element) modelElement;
110:                    stereotypeNames = UmlUtilities.getStereotypeNames(element);
111:                } else if (modelElement instanceof  ModelElementFacade) {
112:                    stereotypeNames = ((ModelElementFacade) modelElement)
113:                            .getStereotypeNames();
114:                }
115:                return stereotypeNames;
116:            }
117:
118:            /**
119:             * @see org.andromda.core.metafacade.ModelAccessFacade#findByStereotype(java.lang.String)
120:             */
121:            public Collection findByStereotype(final String name) {
122:                final ArrayList elements = new ArrayList();
123:                for (TreeIterator iterator = UmlUtilities.findModel(this .model)
124:                        .eAllContents(); iterator.hasNext();) {
125:                    final EObject object = (EObject) iterator.next();
126:                    if (object instanceof  NamedElement) {
127:                        final NamedElement element = (NamedElement) object;
128:                        if (UmlUtilities.containsStereotype(element, name)) {
129:                            elements.add(MetafacadeFactory.getInstance()
130:                                    .createMetafacade(element));
131:                        }
132:                    }
133:                }
134:                return elements;
135:            }
136:
137:            /**
138:             * @see org.andromda.core.metafacade.ModelAccessFacade#getModelElements()
139:             */
140:            public Collection getModelElements() {
141:                final ArrayList elements = new ArrayList();
142:
143:                for (final Iterator iterator = UmlUtilities.findModel(
144:                        this .model).eAllContents(); iterator.hasNext();) {
145:                    final EObject object = (EObject) iterator.next();
146:                    if (object instanceof  NamedElement) {
147:                        elements.add(object);
148:                    }
149:                }
150:
151:                // Don't forget to transform properties
152:                CollectionUtils.transform(elements,
153:                        UmlUtilities.ELEMENT_TRANSFORMER);
154:
155:                final Collection metafacades;
156:
157:                if (elements.isEmpty()) {
158:                    metafacades = Collections.EMPTY_LIST;
159:                } else {
160:                    metafacades = MetafacadeFactory.getInstance()
161:                            .createMetafacades(elements);
162:                    this .filterMetafacades(metafacades);
163:                }
164:
165:                return metafacades;
166:            }
167:
168:            /**
169:             * Filters out those metafacades which <strong>should </strong> be
170:             * processed.
171:             *
172:             * @param metafacades the Collection of metafacades.
173:             */
174:            private void filterMetafacades(final Collection metafacades) {
175:                if (this .modelPackages != null && !this .modelPackages.isEmpty()) {
176:                    CollectionUtils.filter(metafacades, new Predicate() {
177:                        public boolean evaluate(final Object metafacade) {
178:                            boolean valid = false;
179:                            if (metafacade instanceof  MetafacadeBase) {
180:                                final ModelElementFacade modelElementFacade = (ModelElementFacade) metafacade;
181:                                final StringBuffer packageName = new StringBuffer(
182:                                        modelElementFacade.getPackageName(true));
183:
184:                                // - if the model element is a package then the package
185:                                // name will be the name
186:                                // of the package with its package name
187:                                if (metafacade instanceof  PackageFacade) {
188:                                    final String name = modelElementFacade
189:                                            .getName();
190:                                    if (StringUtils.isNotBlank(name)) {
191:                                        packageName
192:                                                .append(MetafacadeConstants.NAMESPACE_SCOPE_OPERATOR);
193:                                        packageName.append(name);
194:                                    }
195:                                }
196:                                valid = UMLModelAccessFacade.this.modelPackages
197:                                        .isApply(packageName.toString());
198:                            }
199:                            return valid;
200:                        }
201:                    });
202:                }
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.