Source Code Cross Referenced for FrontEndControllerOperationLogicImpl.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.Iterator;
006:        import java.util.LinkedHashMap;
007:        import java.util.LinkedHashSet;
008:        import java.util.List;
009:        import java.util.Map;
010:        import java.util.Set;
011:
012:        import org.andromda.metafacades.uml.ClassifierFacade;
013:        import org.andromda.metafacades.uml.EventFacade;
014:        import org.andromda.metafacades.uml.FrontEndAction;
015:        import org.andromda.metafacades.uml.FrontEndActionState;
016:        import org.andromda.metafacades.uml.FrontEndActivityGraph;
017:        import org.andromda.metafacades.uml.FrontEndController;
018:        import org.andromda.metafacades.uml.FrontEndControllerOperation;
019:        import org.andromda.metafacades.uml.FrontEndEvent;
020:        import org.andromda.metafacades.uml.FrontEndForward;
021:        import org.andromda.metafacades.uml.FrontEndParameter;
022:        import org.andromda.metafacades.uml.FrontEndPseudostate;
023:        import org.andromda.metafacades.uml.FrontEndUseCase;
024:        import org.andromda.metafacades.uml.ModelElementFacade;
025:        import org.andromda.metafacades.uml.OperationFacade;
026:        import org.andromda.metafacades.uml.ParameterFacade;
027:        import org.andromda.metafacades.uml.StateVertexFacade;
028:
029:        /**
030:         * MetafacadeLogic implementation for
031:         * org.andromda.metafacades.uml.FrontEndControllerOperation.
032:         *
033:         * @see org.andromda.metafacades.uml.FrontEndControllerOperation
034:         */
035:        public class FrontEndControllerOperationLogicImpl extends
036:                FrontEndControllerOperationLogic {
037:            public FrontEndControllerOperationLogicImpl(
038:                    final Object metaObject, final String context) {
039:                super (metaObject, context);
040:            }
041:
042:            /**
043:             * Override to return the owner's package as the package name.
044:             *
045:             * @see org.andromda.metafacades.emf.uml2.ModelElementFacadeLogic#handleGetPackageName()
046:             */
047:            public String handleGetPackageName() {
048:                final ClassifierFacade owner = this .getOwner();
049:                return owner != null ? owner.getPackageName() : "";
050:            }
051:
052:            /**
053:             * @see org.andromda.metafacades.uml.FrontEndControllerOperation#isOwnerIsController()
054:             */
055:            protected boolean handleIsOwnerIsController() {
056:                return this .getOwner() instanceof  FrontEndController;
057:            }
058:
059:            /**
060:             * @see org.andromda.metafacades.uml.FrontEndControllerOperation#getFormFields()
061:             */
062:            protected java.util.List handleGetFormFields() {
063:                final Map formFieldsMap = new LinkedHashMap();
064:
065:                // for quick lookup we use a hashset for the argument names, we only
066:                // consider parameters with a name
067:                // which is also present in this set
068:                final Set argumentNames = new LinkedHashSet();
069:                final Collection arguments = this .getArguments();
070:                for (final Iterator argumentIterator = arguments.iterator(); argumentIterator
071:                        .hasNext();) {
072:                    final ModelElementFacade element = (ModelElementFacade) argumentIterator
073:                            .next();
074:                    argumentNames.add(element.getName());
075:                }
076:
077:                // - get all actions deferring to this operation
078:                final List deferringActions = this .getDeferringActions();
079:                for (final Iterator iterator = deferringActions.iterator(); iterator
080:                        .hasNext();) {
081:                    final FrontEndAction action = (FrontEndAction) iterator
082:                            .next();
083:
084:                    // store the action parameters
085:                    final List actionFormFields = action.getFormFields();
086:                    for (final Iterator fieldIterator = actionFormFields
087:                            .iterator(); fieldIterator.hasNext();) {
088:                        final FrontEndParameter parameter = (FrontEndParameter) fieldIterator
089:                                .next();
090:                        final String name = parameter.getName();
091:
092:                        // - only add if the parameter is an action parameter and its an
093:                        // argument of this operation
094:                        if (parameter.getAction() != null
095:                                && argumentNames.contains(name)) {
096:                            formFieldsMap.put(name, parameter);
097:                        }
098:                    }
099:
100:                    // get all forwards and overwrite when we find a table (or add when
101:                    // not yet present)
102:                    final List forwards = action.getActionForwards();
103:                    for (final Iterator forwardIterator = forwards.iterator(); forwardIterator
104:                            .hasNext();) {
105:                        final FrontEndForward forward = (FrontEndForward) forwardIterator
106:                                .next();
107:
108:                        // - only consider forwards directly entering a view
109:                        if (forward.isEnteringView()) {
110:                            final List viewVariables = forward
111:                                    .getForwardParameters();
112:                            for (final Iterator variableIterator = viewVariables
113:                                    .iterator(); variableIterator.hasNext();) {
114:                                final FrontEndParameter viewVariable = (FrontEndParameter) variableIterator
115:                                        .next();
116:                                final String name = viewVariable.getName();
117:                                if (argumentNames.contains(name)) {
118:                                    if (!formFieldsMap.containsKey(name)
119:                                            || viewVariable.isTable()) {
120:                                        formFieldsMap.put(name, viewVariable);
121:                                    }
122:                                }
123:                            }
124:                        }
125:                    }
126:                }
127:
128:                // since all arguments need to be present we add those that haven't yet
129:                // been stored in the map
130:                for (final Iterator argumentIterator = arguments.iterator(); argumentIterator
131:                        .hasNext();) {
132:                    final FrontEndParameter argument = (FrontEndParameter) argumentIterator
133:                            .next();
134:                    final String name = argument.getName();
135:                    if (!formFieldsMap.containsKey(name)) {
136:                        formFieldsMap.put(name, argument);
137:                    }
138:                }
139:                return new ArrayList(formFieldsMap.values());
140:            }
141:
142:            /**
143:             * @see org.andromda.metafacades.uml.FrontEndControllerOperation#getActivityGraph()
144:             */
145:            protected Object handleGetActivityGraph() {
146:                Object graph = null;
147:
148:                final ClassifierFacade owner = this .getOwner();
149:                if (owner instanceof  FrontEndController) {
150:                    final FrontEndController controller = (FrontEndController) owner;
151:                    if (controller != null) {
152:                        final FrontEndUseCase useCase = controller.getUseCase();
153:                        if (useCase != null) {
154:                            graph = useCase.getActivityGraph();
155:                        }
156:                    }
157:                }
158:                return graph;
159:            }
160:
161:            /**
162:             * @see org.andromda.metafacades.uml.FrontEndControllerOperation#getDeferringActions()
163:             */
164:            protected java.util.List handleGetDeferringActions() {
165:                final Collection deferringActions = new LinkedHashSet();
166:
167:                final FrontEndActivityGraph graph = this .getActivityGraph();
168:                if (graph != null) {
169:                    final Collection actionStates = graph.getActionStates();
170:                    for (final Iterator actionStateIterator = actionStates
171:                            .iterator(); actionStateIterator.hasNext();) {
172:                        final Object actionStateObject = actionStateIterator
173:                                .next();
174:                        if (actionStateObject instanceof  FrontEndActionState) {
175:                            final FrontEndActionState actionState = (FrontEndActionState) actionStateObject;
176:                            final Collection controllerCalls = actionState
177:                                    .getControllerCalls();
178:                            for (final Iterator controllerCallIterator = controllerCalls
179:                                    .iterator(); controllerCallIterator
180:                                    .hasNext();) {
181:                                final OperationFacade operation = (OperationFacade) controllerCallIterator
182:                                        .next();
183:                                if (this .equals(operation)) {
184:                                    deferringActions.addAll(actionState
185:                                            .getContainerActions());
186:                                }
187:                            }
188:                        }
189:                    }
190:
191:                    final Collection transitions = graph.getTransitions();
192:                    for (final Iterator transitionIterator = transitions
193:                            .iterator(); transitionIterator.hasNext();) {
194:                        final FrontEndForward transition = (FrontEndForward) transitionIterator
195:                                .next();
196:                        final EventFacade event = transition.getTrigger();
197:                        if (event instanceof  FrontEndEvent) {
198:                            final FrontEndEvent trigger = (FrontEndEvent) event;
199:                            final FrontEndControllerOperation operation = trigger
200:                                    .getControllerCall();
201:                            if (this .equals(operation)) {
202:                                // we have two types of controller calls: the ones in
203:                                // action states and the ones for decisions
204:                                final StateVertexFacade source = transition
205:                                        .getSource();
206:                                if (source instanceof  FrontEndActionState) {
207:                                    final FrontEndActionState sourceActionState = (FrontEndActionState) source;
208:                                    deferringActions.addAll(sourceActionState
209:                                            .getContainerActions());
210:                                }
211:
212:                                // test for decision
213:                                final StateVertexFacade target = transition
214:                                        .getTarget();
215:                                if (target instanceof  FrontEndPseudostate) {
216:                                    final FrontEndPseudostate targetPseudoState = (FrontEndPseudostate) target;
217:                                    if (targetPseudoState.isDecisionPoint()) {
218:                                        deferringActions
219:                                                .addAll(targetPseudoState
220:                                                        .getContainerActions());
221:                                    }
222:                                }
223:                            }
224:                        }
225:                    }
226:                }
227:                return new ArrayList(deferringActions);
228:            }
229:
230:            /**
231:             * @see org.andromda.metafacades.uml.FrontEndControllerOperation#isAllArgumentsHaveFormFields()
232:             */
233:            protected boolean handleIsAllArgumentsHaveFormFields() {
234:                final Collection arguments = this .getArguments();
235:                final Collection deferringActions = this .getDeferringActions();
236:
237:                boolean allArgumentsHaveFormFields = true;
238:                for (final Iterator iterator = arguments.iterator(); iterator
239:                        .hasNext()
240:                        && allArgumentsHaveFormFields;) {
241:                    final ParameterFacade parameter = (ParameterFacade) iterator
242:                            .next();
243:                    final String parameterName = parameter.getName();
244:                    final ClassifierFacade parameterType = parameter.getType();
245:                    final String parameterTypeName = parameterType != null ? parameterType
246:                            .getFullyQualifiedName()
247:                            : "";
248:
249:                    boolean actionMissingField = false;
250:                    for (final Iterator actionIterator = deferringActions
251:                            .iterator(); actionIterator.hasNext()
252:                            && !actionMissingField;) {
253:                        final FrontEndAction action = (FrontEndAction) actionIterator
254:                                .next();
255:                        final Collection actionFormFields = action
256:                                .getFormFields();
257:
258:                        boolean fieldPresent = false;
259:                        for (final Iterator fieldIterator = actionFormFields
260:                                .iterator(); fieldIterator.hasNext()
261:                                && !fieldPresent;) {
262:                            final ParameterFacade field = (ParameterFacade) fieldIterator
263:                                    .next();
264:                            final ClassifierFacade fieldType = field.getType();
265:                            final String fieldTypeName = fieldType != null ? fieldType
266:                                    .getFullyQualifiedName()
267:                                    : "";
268:                            if (parameterName.equals(field.getName())
269:                                    && parameterTypeName.equals(fieldTypeName)) {
270:                                fieldPresent = true;
271:                            }
272:                        }
273:                        actionMissingField = !fieldPresent;
274:                    }
275:                    allArgumentsHaveFormFields = !actionMissingField;
276:                }
277:                return allArgumentsHaveFormFields;
278:            }
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.