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


001:        package org.andromda.cartridges.bpm4struts.metafacades;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.Collections;
006:        import java.util.Iterator;
007:        import java.util.LinkedHashMap;
008:        import java.util.LinkedHashSet;
009:        import java.util.Map;
010:        import java.util.Set;
011:
012:        import org.andromda.cartridges.bpm4struts.Bpm4StrutsProfile;
013:        import org.andromda.metafacades.uml.EventFacade;
014:        import org.andromda.metafacades.uml.GuardFacade;
015:        import org.andromda.metafacades.uml.PseudostateFacade;
016:        import org.andromda.metafacades.uml.StateVertexFacade;
017:        import org.andromda.utils.StringUtilsHelper;
018:        import org.apache.commons.lang.StringUtils;
019:
020:        /**
021:         * MetafacadeLogic implementation.
022:         *
023:         * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsForward
024:         */
025:        public class StrutsForwardLogicImpl extends StrutsForwardLogic {
026:            public StrutsForwardLogicImpl(java.lang.Object metaObject,
027:                    java.lang.String context) {
028:                super (metaObject, context);
029:            }
030:
031:            protected String handleGetGuardName() {
032:                final GuardFacade guard = this .getGuard();
033:                return (guard == null) ? null : guard.getName();
034:            }
035:
036:            protected boolean handleIsEnteringPage() {
037:                return this .isEnteringView();
038:            }
039:
040:            protected java.lang.String handleGetForwardName() {
041:                return StringUtilsHelper.toResourceMessageKey(this 
042:                        .resolveName());
043:            }
044:
045:            protected java.lang.String handleGetForwardPath() {
046:                String forwardPath = null;
047:
048:                final StateVertexFacade target = this .getTarget();
049:                if (isEnteringPage()) {
050:                    forwardPath = ((StrutsJsp) target).getFullPath() + ".jsp";
051:                } else if (isEnteringFinalState()) {
052:                    forwardPath = ((StrutsFinalState) target).getFullPath();
053:                }
054:
055:                return forwardPath;
056:            }
057:
058:            protected String handleGetActionMethodName() {
059:                return StringUtilsHelper.lowerCamelCaseName(this .resolveName());
060:            }
061:
062:            protected String handleGetTargetNameKey() {
063:                if (this .isEnteringPage()) {
064:                    return ((StrutsJsp) this .getTarget()).getTitleKey();
065:                } else if (this .isEnteringFinalState()) {
066:                    return ((StrutsUseCase) ((StrutsFinalState) this 
067:                            .getTarget()).getTargetUseCase()).getTitleKey();
068:                }
069:                return null;
070:            }
071:
072:            /**
073:             * If this forward has a trigger this method returns that trigger's name, otherwise if this forward
074:             * has a name this method returns that name, otherwise if this forward's target has a name this
075:             * method returns that name, otherwise simply returns <code>"unknown"</code>
076:             */
077:            private String resolveName() {
078:                String forwardName = null;
079:                //trigger
080:                final EventFacade trigger = this .getTrigger();
081:                if (trigger != null)
082:                    forwardName = trigger.getName();
083:                //name
084:                if (StringUtils.isEmpty(forwardName))
085:                    forwardName = this .getName();
086:                //target
087:                if (StringUtils.isEmpty(forwardName))
088:                    forwardName = this .getTarget().getName();
089:                // else
090:                if (StringUtils.isEmpty(forwardName))
091:                    forwardName = "unknown";
092:                // return
093:                return forwardName;
094:            }
095:
096:            protected boolean handleIsExitingPage() {
097:                return this .isExitingView();
098:            }
099:
100:            protected boolean handleIsSuccessMessagesPresent() {
101:                return !this .getSuccessMessages().isEmpty();
102:            }
103:
104:            protected boolean handleIsWarningMessagesPresent() {
105:                return !this .getWarningMessages().isEmpty();
106:            }
107:
108:            /**
109:             * Collects specific messages in a map.
110:             *
111:             * @param taggedValue the tagged value from which to read the message
112:             * @return maps message keys to message values, but only those that match the arguments
113:             *         will have been recorded
114:             */
115:            private Map getMessages(String taggedValue) {
116:                Map messages;
117:
118:                final Collection taggedValues = this 
119:                        .findTaggedValues(taggedValue);
120:                if (taggedValues.isEmpty()) {
121:                    messages = Collections.EMPTY_MAP;
122:                } else {
123:                    messages = new LinkedHashMap(); // we want to keep the order
124:
125:                    for (final Iterator iterator = taggedValues.iterator(); iterator
126:                            .hasNext();) {
127:                        final String value = (String) iterator.next();
128:                        messages.put(StringUtilsHelper
129:                                .toResourceMessageKey(value), value);
130:                    }
131:                }
132:
133:                return messages;
134:            }
135:
136:            protected Map handleGetSuccessMessages() {
137:                return this 
138:                        .getMessages(Bpm4StrutsProfile.TAGGEDVALUE_ACTION_SUCCESS_MESSAGE);
139:            }
140:
141:            protected Map handleGetWarningMessages() {
142:                return this 
143:                        .getMessages(Bpm4StrutsProfile.TAGGEDVALUE_ACTION_WARNING_MESSAGE);
144:            }
145:
146:            protected Object handleGetStrutsActivityGraph() {
147:                return this .getFrontEndActivityGraph();
148:            }
149:
150:            /**
151:             * Overridden since StrutsAction doesn't extend FrontEndAction.
152:             *
153:             * @see org.andromda.metafacades.uml.FrontEndForward#getActions()
154:             */
155:            public java.util.List getActions() {
156:                final Set actions = new LinkedHashSet();
157:                this .findActions(actions, new LinkedHashSet());
158:                return new ArrayList(actions);
159:            }
160:
161:            /**
162:             * Recursively finds all actions for this forward, what this means depends on the context in which
163:             * this forward is used: if the source is a page action state it will collect all actions going out
164:             * of this page, if the source is a regular action state it will collect all actions that might traverse
165:             * this action state, if the source is the initial state it will collect all actions forwarding to this
166:             * forward's use-case (please not that those actions most likely are defined in other use-cases).
167:             *
168:             * @param actions         the default set of actions, duplicates will not be recorded
169:             * @param handledForwards the forwards already processed
170:             */
171:            private final void findActions(final Set actions,
172:                    final Set handledForwards) {
173:                if (!handledForwards.contains(this )) {
174:                    handledForwards.add(this );
175:
176:                    if (this  instanceof  StrutsAction) // @todo this is not so nice because StrutsAction extends StrutsForward, solution would be to override in StrutsAction
177:                    {
178:                        actions.add(this );
179:                    } else {
180:                        final StateVertexFacade vertex = getSource();
181:                        if (vertex instanceof  StrutsJsp) {
182:                            final StrutsJsp jsp = (StrutsJsp) vertex;
183:                            actions.addAll(jsp.getActions());
184:                        } else if (vertex instanceof  StrutsActionState) {
185:                            final StrutsActionState actionState = (StrutsActionState) vertex;
186:                            actions.addAll(actionState.getContainerActions());
187:                        } else if (vertex instanceof  PseudostateFacade) {
188:                            final PseudostateFacade pseudostate = (PseudostateFacade) vertex;
189:                            if (!pseudostate.isInitialState()) {
190:                                final Collection incomingForwards = pseudostate
191:                                        .getIncoming();
192:                                for (final Iterator forwardIterator = incomingForwards
193:                                        .iterator(); forwardIterator.hasNext();) {
194:                                    final StrutsForward forward = (StrutsForward) forwardIterator
195:                                            .next();
196:                                    actions.addAll(forward.getActions());
197:                                }
198:                            }
199:                        }
200:                    }
201:                }
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.