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