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


001:        package org.andromda.metafacades.uml14;
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.apache.log4j.Logger;
020:        import org.omg.uml.UmlPackage;
021:        import org.omg.uml.foundation.core.ModelElement;
022:
023:        /**
024:         * Contains a UML model, follows the {@link ModelAccessFacade} interface and can therefore be processed by AndroMDA.
025:         *
026:         * @author <a href="http://www.mbohlen.de">Matthias Bohlen </a>
027:         * @author Chad Brandon
028:         */
029:        public class UMLModelAccessFacade implements  ModelAccessFacade {
030:            private static final Logger logger = Logger
031:                    .getLogger(UMLModelAccessFacade.class);
032:            private UmlPackage model;
033:
034:            /**
035:             * @see org.andromda.core.metafacade.ModelAccessFacade#setModel(java.lang.Object)
036:             */
037:            public void setModel(final Object model) {
038:                ExceptionUtils.checkNull("model", model);
039:                ExceptionUtils.checkAssignable(UmlPackage.class,
040:                        "modelElement", model.getClass());
041:                this .model = (UmlPackage) model;
042:            }
043:
044:            /**
045:             * @see org.andromda.core.metafacade.ModelAccessFacade#getModel()
046:             */
047:            public Object getModel() {
048:                return model;
049:            }
050:
051:            /**
052:             * @see org.andromda.core.metafacade.ModelAccessFacade#getName(java.lang.Object)
053:             */
054:            public String getName(final Object modelElement) {
055:                ExceptionUtils.checkNull("modelElement", modelElement);
056:                ExceptionUtils.checkAssignable(ModelElementFacade.class,
057:                        "modelElement", modelElement.getClass());
058:                return ((ModelElementFacade) modelElement).getName();
059:            }
060:
061:            /**
062:             * @see org.andromda.core.metafacade.ModelAccessFacade#getPackageName(java.lang.Object)
063:             */
064:            public String getPackageName(final Object modelElement) {
065:                ExceptionUtils.checkNull("modelElement", modelElement);
066:                ExceptionUtils.checkAssignable(ModelElementFacade.class,
067:                        "modelElement", modelElement.getClass());
068:                final ModelElementFacade modelElementFacade = (ModelElementFacade) modelElement;
069:                final StringBuffer packageName = new StringBuffer(
070:                        modelElementFacade.getPackageName(true));
071:
072:                // - if the model element is a package then the package name will be the name 
073:                //   of the package with its package name
074:                if (modelElement instanceof  PackageFacade) {
075:                    final String name = modelElementFacade.getName();
076:                    if (StringUtils.isNotBlank(name)) {
077:                        packageName
078:                                .append(MetafacadeConstants.NAMESPACE_SCOPE_OPERATOR);
079:                        packageName.append(name);
080:                    }
081:                }
082:                return packageName.toString();
083:            }
084:
085:            /**
086:             * @see org.andromda.core.metafacade.ModelAccessFacade#getStereotypeNames(java.lang.Object)
087:             */
088:            public Collection getStereotypeNames(final Object modelElement) {
089:                Collection stereotypeNames = new ArrayList();
090:                if (modelElement instanceof  ModelElement) {
091:                    ModelElement element = (ModelElement) modelElement;
092:                    Collection stereotypes = element.getStereotype();
093:                    for (final Iterator iterator = stereotypes.iterator(); iterator
094:                            .hasNext();) {
095:                        ModelElement stereotype = (ModelElement) iterator
096:                                .next();
097:                        stereotypeNames.add(stereotype.getName());
098:                    }
099:                } else if (modelElement instanceof  ModelElementFacade) {
100:                    stereotypeNames = ((ModelElementFacade) modelElement)
101:                            .getStereotypeNames();
102:                }
103:                return stereotypeNames;
104:            }
105:
106:            /**
107:             * @see org.andromda.core.metafacade.ModelAccessFacade#findByStereotype(java.lang.String)
108:             */
109:            public Collection findByStereotype(String stereotype) {
110:                final String methodName = "UMLModelAccessFacade.findByStereotype";
111:                final Collection metafacades = new ArrayList();
112:                stereotype = StringUtils.trimToEmpty(stereotype);
113:                if (StringUtils.isNotEmpty(stereotype)) {
114:                    if (this .model != null) {
115:                        final Collection underlyingElements = model.getCore()
116:                                .getModelElement().refAllOfType();
117:                        if (underlyingElements != null
118:                                && !underlyingElements.isEmpty()) {
119:                            for (final Iterator iterator = underlyingElements
120:                                    .iterator(); iterator.hasNext();) {
121:                                ModelElement element = (ModelElement) iterator
122:                                        .next();
123:                                Collection stereotypeNames = this 
124:                                        .getStereotypeNames(element);
125:                                if (stereotypeNames != null
126:                                        && stereotypeNames.contains(stereotype)) {
127:                                    metafacades.add(MetafacadeFactory
128:                                            .getInstance().createMetafacade(
129:                                                    element));
130:                                }
131:                            }
132:                        }
133:                        if (logger.isDebugEnabled()) {
134:                            logger.debug("completed " + methodName + " with "
135:                                    + metafacades.size() + " modelElements");
136:                        }
137:                    }
138:                    this .filterMetafacades(metafacades);
139:                }
140:                return metafacades;
141:            }
142:
143:            /**
144:             * @see org.andromda.core.metafacade.ModelAccessFacade#getModelElements()
145:             */
146:            public Collection getModelElements() {
147:                Collection metafacades = Collections.EMPTY_LIST;
148:                if (this .model != null) {
149:                    metafacades = MetafacadeFactory.getInstance()
150:                            .createMetafacades(
151:                                    this .model.getCore().getModelElement()
152:                                            .refAllOfType());
153:                    this .filterMetafacades(metafacades);
154:                }
155:                return metafacades;
156:            }
157:
158:            /**
159:             * Stores the package filter information.  Protected
160:             * visibility for better inner class access performance.
161:             */
162:            protected Filters modelPackages;
163:
164:            /**
165:             * @see org.andromda.core.metafacade.ModelAccessFacade#setPackageFilter(org.andromda.core.configuration.Filters)
166:             */
167:            public void setPackageFilter(final Filters modelPackages) {
168:                this .modelPackages = modelPackages;
169:            }
170:
171:            /**
172:             * Filters out those metafacades which <strong>should </strong> be processed.
173:             *
174:             * @param metafacades the Collection of modelElements.
175:             */
176:            private void filterMetafacades(final Collection metafacades) {
177:                if (this .modelPackages != null && !this .modelPackages.isEmpty()) {
178:                    CollectionUtils.filter(metafacades, new Predicate() {
179:                        public boolean evaluate(final Object metafacade) {
180:                            boolean valid = false;
181:                            if (metafacade instanceof  MetafacadeBase) {
182:                                final ModelElementFacade modelElementFacade = (ModelElementFacade) metafacade;
183:                                final StringBuffer packageName = new StringBuffer(
184:                                        modelElementFacade.getPackageName(true));
185:
186:                                // - if the model element is a package then the package name will be the name 
187:                                //   of the package with its package name
188:                                if (metafacade instanceof  PackageFacade) {
189:                                    final String name = modelElementFacade
190:                                            .getName();
191:                                    if (StringUtils.isNotBlank(name)) {
192:                                        packageName
193:                                                .append(MetafacadeConstants.NAMESPACE_SCOPE_OPERATOR);
194:                                        packageName.append(name);
195:                                    }
196:                                }
197:                                valid = modelPackages.isApply(packageName
198:                                        .toString());
199:                            }
200:                            return valid;
201:                        }
202:                    });
203:                }
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.