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


001:        package org.andromda.cartridges.jsf.metafacades;
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.List;
008:        import java.util.Map;
009:
010:        import org.andromda.cartridges.jsf.JSFGlobals;
011:        import org.andromda.cartridges.jsf.JSFProfile;
012:        import org.andromda.cartridges.jsf.JSFUtils;
013:        import org.andromda.metafacades.uml.FrontEndAction;
014:        import org.andromda.metafacades.uml.FrontEndParameter;
015:        import org.andromda.metafacades.uml.ModelElementFacade;
016:        import org.andromda.metafacades.uml.UseCaseFacade;
017:        import org.andromda.utils.StringUtilsHelper;
018:        import org.apache.commons.lang.ObjectUtils;
019:        import org.apache.commons.lang.StringUtils;
020:
021:        /**
022:         * MetafacadeLogic implementation for org.andromda.cartridges.jsf.metafacades.JSFView.
023:         *
024:         * @see org.andromda.cartridges.jsf.metafacades.JSFView
025:         */
026:        public class JSFViewLogicImpl extends JSFViewLogic {
027:            public JSFViewLogicImpl(Object metaObject, String context) {
028:                super (metaObject, context);
029:            }
030:
031:            /**
032:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getDocumentationKey()
033:             */
034:            protected String handleGetDocumentationKey() {
035:                return getMessageKey() + '.'
036:                        + JSFGlobals.DOCUMENTATION_MESSAGE_KEY_SUFFIX;
037:            }
038:
039:            /**
040:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getMessageKey()
041:             */
042:            protected String handleGetMessageKey() {
043:                final StringBuffer messageKey = new StringBuffer();
044:
045:                if (!this .isNormalizeMessages()) {
046:                    final UseCaseFacade useCase = this .getUseCase();
047:                    if (useCase != null) {
048:                        messageKey.append(StringUtilsHelper
049:                                .toResourceMessageKey(useCase.getName()));
050:                        messageKey.append('.');
051:                    }
052:                }
053:
054:                messageKey.append(StringUtilsHelper
055:                        .toResourceMessageKey(getName()));
056:                return messageKey.toString();
057:            }
058:
059:            /**
060:             * Indicates whether or not we should normalize messages.
061:             *
062:             * @return true/false
063:             */
064:            private final boolean isNormalizeMessages() {
065:                final String normalizeMessages = (String) getConfiguredProperty(JSFGlobals.NORMALIZE_MESSAGES);
066:                return Boolean.valueOf(normalizeMessages).booleanValue();
067:            }
068:
069:            protected String handleGetMessageValue() {
070:                return StringUtilsHelper.toPhrase(getName());
071:            }
072:
073:            /**
074:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getDocumentationValue()
075:             */
076:            protected String handleGetDocumentationValue() {
077:                final String value = StringUtilsHelper
078:                        .toResourceMessage(getDocumentation(""));
079:                return value == null ? "" : value;
080:            }
081:
082:            /**
083:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getTitleKey()
084:             */
085:            protected String handleGetTitleKey() {
086:                return this .getMessageKey() + '.'
087:                        + JSFGlobals.TITLE_MESSAGE_KEY_SUFFIX;
088:            }
089:
090:            /**
091:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getTitleValue()
092:             */
093:            protected String handleGetTitleValue() {
094:                return StringUtilsHelper.toPhrase(getName());
095:            }
096:
097:            /**
098:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getPath()
099:             */
100:            protected java.lang.String handleGetPath() {
101:                final StringBuffer path = new StringBuffer();
102:                final String packageName = this .getPackageName();
103:                if (StringUtils.isNotBlank(packageName)) {
104:                    path.append(packageName + '.');
105:                }
106:                path.append(JSFUtils.toWebResourceName(
107:                        StringUtils.trimToEmpty(this .getName())).replace('.',
108:                        '/'));
109:                return '/' + path.toString().replace('.', '/');
110:            }
111:
112:            /**
113:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getForwards()
114:             */
115:            protected List handleGetForwards() {
116:                final Map forwards = new LinkedHashMap();
117:                for (final Iterator iterator = this .getActions().iterator(); iterator
118:                        .hasNext();) {
119:                    final FrontEndAction action = (FrontEndAction) iterator
120:                            .next();
121:                    if (action != null && !action.isUseCaseStart()) {
122:                        for (final Iterator forwardIterator = action
123:                                .getActionForwards().iterator(); forwardIterator
124:                                .hasNext();) {
125:                            final Object forward = forwardIterator.next();
126:                            if (forward instanceof  JSFForward) {
127:                                forwards.put(((JSFForward) forward).getName(),
128:                                        forward);
129:                            } else if (forward instanceof  JSFAction) {
130:                                forwards.put(((JSFAction) forward).getName(),
131:                                        forward);
132:                            }
133:                        }
134:                    }
135:                }
136:                return new ArrayList(forwards.values());
137:            }
138:
139:            /**
140:             * @see org.andromda.cartridges.jsf.metafacades.JSFAction#isTableLink()
141:             */
142:            protected List handleGetTables() {
143:                final List tables = new ArrayList();
144:                final List variables = this .getVariables();
145:                for (int ctr = 0; ctr < variables.size(); ctr++) {
146:                    final Object object = variables.get(ctr);
147:                    if (object instanceof  JSFParameter) {
148:                        final JSFParameter variable = (JSFParameter) object;
149:                        if (variable.isTable()) {
150:                            tables.add(variable);
151:                        }
152:                    }
153:                }
154:                return tables;
155:            }
156:
157:            /**
158:             * @see org.andromda.cartridges.jsf.metafacades.JSFAction#getActionForwards()
159:             */
160:            protected List handleGetActionForwards() {
161:                final List actionForwards = new ArrayList(this .getForwards());
162:                for (final Iterator iterator = actionForwards.iterator(); iterator
163:                        .hasNext();) {
164:                    if (!(iterator.next() instanceof  JSFAction)) {
165:                        iterator.remove();
166:                    }
167:                }
168:                return actionForwards;
169:            }
170:
171:            /**
172:             * @see org.andromda.cartridges.jsf.metafacades.JSFAction#getFullyQuailifiedPopulator()
173:             */
174:            protected String handleGetFullyQualifiedPopulator() {
175:                final StringBuffer name = new StringBuffer();
176:                final String packageName = this .getPackageName();
177:                if (StringUtils.isNotBlank(packageName)) {
178:                    name.append(packageName);
179:                    name.append('.');
180:                }
181:                name.append(this .getPopulator());
182:                return name.toString();
183:            }
184:
185:            /**
186:             * @see org.andromda.cartridges.jsf.metafacades.JSFAction#getPopulator()
187:             */
188:            protected String handleGetPopulator() {
189:                return ObjectUtils
190:                        .toString(
191:                                this 
192:                                        .getConfiguredProperty(JSFGlobals.VIEW_POPULATOR_PATTERN))
193:                        .replaceAll(
194:                                "\\{0\\}",
195:                                StringUtilsHelper.upperCamelCaseName(this 
196:                                        .getName()));
197:            }
198:
199:            /**
200:             * @see org.andromda.cartridges.jsf.metafacades.JSFAction#getFormActions()
201:             */
202:            protected List handleGetFormActions() {
203:                final List actions = new ArrayList(this .getActions());
204:                for (final Iterator iterator = actions.iterator(); iterator
205:                        .hasNext();) {
206:                    final JSFAction action = (JSFAction) iterator.next();
207:                    if (action.getFormFields().isEmpty()) {
208:                        iterator.remove();
209:                    }
210:                }
211:                return actions;
212:            }
213:
214:            /**
215:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getFormKey()
216:             */
217:            protected String handleGetFormKey() {
218:                final Object formKeyValue = this 
219:                        .findTaggedValue(JSFProfile.TAGGEDVALUE_ACTION_FORM_KEY);
220:                return formKeyValue == null ? ObjectUtils.toString(this 
221:                        .getConfiguredProperty(JSFGlobals.ACTION_FORM_KEY))
222:                        : String.valueOf(formKeyValue);
223:            }
224:
225:            /**
226:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getPopulatorPath()
227:             */
228:            protected String handleGetPopulatorPath() {
229:                return this .getFullyQualifiedPopulator().replace('.', '/');
230:            }
231:
232:            /**
233:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#isPopulatorRequired()
234:             */
235:            protected boolean handleIsPopulatorRequired() {
236:                return !this .getFormActions().isEmpty()
237:                        || !this .getVariables().isEmpty();
238:            }
239:
240:            /**
241:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#isPopulatorRequired()
242:             */
243:            protected boolean handleIsValidationRequired() {
244:                boolean required = false;
245:                final Collection actions = getActions();
246:                for (final Iterator actionIterator = actions.iterator(); actionIterator
247:                        .hasNext();) {
248:                    final JSFAction action = (JSFAction) actionIterator.next();
249:                    if (action.isValidationRequired()) {
250:                        required = true;
251:                        break;
252:                    }
253:                }
254:                return required;
255:            }
256:
257:            /**
258:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#isPopup()
259:             */
260:            protected boolean handleIsPopup() {
261:                return ObjectUtils.toString(
262:                        this .findTaggedValue(JSFProfile.TAGGEDVALUE_VIEW_TYPE))
263:                        .equalsIgnoreCase(JSFGlobals.VIEW_TYPE_POPUP);
264:            }
265:
266:            /**
267:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#isNonTableVariablesPresent()
268:             */
269:            protected boolean handleIsNonTableVariablesPresent() {
270:                boolean present = false;
271:                for (final Iterator iterator = this .getVariables().iterator(); iterator
272:                        .hasNext();) {
273:                    final Object object = iterator.next();
274:                    if (object instanceof  FrontEndParameter) {
275:                        final FrontEndParameter variable = (FrontEndParameter) object;
276:                        if (!variable.isTable()) {
277:                            present = true;
278:                            break;
279:                        }
280:                    }
281:                }
282:                return present;
283:            }
284:
285:            /**
286:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#isHasNameOfUseCase()
287:             */
288:            protected boolean handleIsHasNameOfUseCase() {
289:                boolean sameName = false;
290:                final ModelElementFacade useCase = this .getUseCase();
291:                final String useCaseName = useCase != null ? useCase.getName()
292:                        : null;
293:                if (useCaseName != null
294:                        && useCaseName.equalsIgnoreCase(this .getName())) {
295:                    sameName = true;
296:                }
297:                return sameName;
298:            }
299:
300:            /**
301:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getBackingValueVariables()
302:             */
303:            protected List handleGetBackingValueVariables() {
304:                final Map variables = new LinkedHashMap();
305:                for (final Iterator iterator = this .getAllActionParameters()
306:                        .iterator(); iterator.hasNext();) {
307:                    final Object object = iterator.next();
308:                    if (object instanceof  JSFParameter) {
309:                        final JSFParameter parameter = (JSFParameter) object;
310:                        final String parameterName = parameter.getName();
311:                        final Collection attributes = parameter.getAttributes();
312:                        if (attributes.isEmpty()) {
313:                            if (parameter.isBackingValueRequired()
314:                                    || parameter.isSelectable()) {
315:                                variables.put(parameterName, parameter);
316:                            }
317:                        } else {
318:                            boolean hasBackingValue = false;
319:                            for (final Iterator attributeIterator = attributes
320:                                    .iterator(); attributeIterator.hasNext();) {
321:                                final JSFAttribute attribute = (JSFAttribute) attributeIterator
322:                                        .next();
323:                                if (attribute.isSelectable(parameter)
324:                                        || attribute
325:                                                .isBackingValueRequired(parameter)) {
326:                                    hasBackingValue = true;
327:                                    break;
328:                                }
329:                            }
330:                            if (hasBackingValue) {
331:                                variables.put(parameterName, parameter);
332:                            }
333:                        }
334:                    }
335:                }
336:                return new ArrayList(variables.values());
337:            }
338:
339:            /**
340:             * @see org.andromda.cartridges.jsf.metafacades.JSFView#getFromOutcome()
341:             */
342:            protected String handleGetFromOutcome() {
343:                return JSFUtils.toWebResourceName(this .getUseCase().getName()
344:                        + "-" + this.getName());
345:            }
346:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.