Source Code Cross Referenced for JSFAttributeLogicImpl.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.Collection;
004:        import java.util.Iterator;
005:
006:        import org.andromda.cartridges.jsf.JSFGlobals;
007:        import org.andromda.cartridges.jsf.JSFProfile;
008:        import org.andromda.cartridges.jsf.JSFUtils;
009:        import org.andromda.metafacades.uml.ClassifierFacade;
010:        import org.andromda.metafacades.uml.FrontEndParameter;
011:        import org.andromda.metafacades.uml.FrontEndView;
012:        import org.andromda.metafacades.uml.ModelElementFacade;
013:        import org.andromda.metafacades.uml.ParameterFacade;
014:        import org.andromda.utils.StringUtilsHelper;
015:        import org.apache.commons.lang.ObjectUtils;
016:        import org.apache.commons.lang.StringUtils;
017:
018:        /**
019:         * MetafacadeLogic implementation for org.andromda.cartridges.jsf.metafacades.JSFAttribute.
020:         *
021:         * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute
022:         */
023:        public class JSFAttributeLogicImpl extends JSFAttributeLogic {
024:            public JSFAttributeLogicImpl(Object metaObject, String context) {
025:                super (metaObject, context);
026:            }
027:
028:            /**
029:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getMessageKey()
030:             */
031:            protected java.lang.String handleGetMessageKey() {
032:                final StringBuffer messageKey = new StringBuffer();
033:                if (!this .isNormalizeMessages()) {
034:                    final ClassifierFacade owner = this .getOwner();
035:                    if (owner != null) {
036:                        messageKey.append(StringUtilsHelper
037:                                .toResourceMessageKey(owner.getName()));
038:                        messageKey.append('.');
039:                    }
040:                }
041:                final String name = this .getName();
042:                if (name != null && name.trim().length() > 0) {
043:                    messageKey.append(StringUtilsHelper
044:                            .toResourceMessageKey(name));
045:                }
046:                return messageKey.toString();
047:            }
048:
049:            /**
050:             * Indicates whether or not we should normalize messages.
051:             *
052:             * @return true/false
053:             */
054:            private final boolean isNormalizeMessages() {
055:                final String normalizeMessages = ObjectUtils.toString(this 
056:                        .getConfiguredProperty(JSFGlobals.NORMALIZE_MESSAGES));
057:                return Boolean.valueOf(normalizeMessages).booleanValue();
058:            }
059:
060:            /**
061:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getMessageValue()
062:             */
063:            protected java.lang.String handleGetMessageValue() {
064:                return StringUtilsHelper.toPhrase(super .getName());
065:            }
066:
067:            /**
068:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getFormat()
069:             */
070:            protected String handleGetFormat() {
071:                return JSFUtils.getFormat((ModelElementFacade) this .THIS(),
072:                        this .getType(), this .getDefaultDateFormat(), this 
073:                                .getDefaultTimeFormat());
074:            }
075:
076:            /**
077:             * @return the default time format pattern as defined using the configured property
078:             */
079:            private String getDefaultTimeFormat() {
080:                return (String) this 
081:                        .getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_TIMEFORMAT);
082:            }
083:
084:            /**
085:             * @return the default date format pattern as defined using the configured property
086:             */
087:            private String getDefaultDateFormat() {
088:                return (String) this 
089:                        .getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_DATEFORMAT);
090:            }
091:
092:            /**
093:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getDummyValue()
094:             */
095:            protected String handleGetDummyValue() {
096:                final ClassifierFacade type = this .getType();
097:                if (type != null) {
098:                    final String typeName = type.getFullyQualifiedName();
099:                    final String name = this .getName();
100:                    if ("java.lang.String".equals(typeName)) {
101:                        return "\"" + name + "-test" + "\"";
102:                    }
103:                    if ("java.util.Date".equals(typeName)) {
104:                        return "new java.util.Date()";
105:                    }
106:                    if ("java.sql.Date".equals(typeName)) {
107:                        return "new java.sql.Date(new java.util.Date().getTime())";
108:                    }
109:                    if ("java.sql.Timestamp".equals(typeName)) {
110:                        return "new java.sql.Timestamp(new Date().getTime())";
111:                    }
112:                    if ("java.util.Calendar".equals(typeName)) {
113:                        return "java.util.Calendar.getInstance()";
114:                    }
115:                    if ("int".equals(typeName)) {
116:                        return "(int)" + name.hashCode();
117:                    }
118:                    if ("boolean".equals(typeName)) {
119:                        return "false";
120:                    }
121:                    if ("long".equals(typeName)) {
122:                        return "(long)" + name.hashCode();
123:                    }
124:                    if ("char".equals(typeName)) {
125:                        return "(char)" + name.hashCode();
126:                    }
127:                    if ("float".equals(typeName)) {
128:                        return "(float)" + name.hashCode() / hashCode();
129:                    }
130:                    if ("double".equals(typeName)) {
131:                        return "(double)" + name.hashCode() / hashCode();
132:                    }
133:                    if ("short".equals(typeName)) {
134:                        return "(short)" + name.hashCode();
135:                    }
136:                    if ("byte".equals(typeName)) {
137:                        return "(byte)" + name.hashCode();
138:                    }
139:                    if ("java.lang.Integer".equals(typeName)) {
140:                        return "new Integer((int)" + name.hashCode() + ")";
141:                    }
142:                    if ("java.lang.Boolean".equals(typeName)) {
143:                        return "Boolean.FALSE";
144:                    }
145:                    if ("java.lang.Long".equals(typeName)) {
146:                        return "new Long((long)" + name.hashCode() + ")";
147:                    }
148:                    if ("java.lang.Character".equals(typeName)) {
149:                        return "new Character(char)" + name.hashCode() + ")";
150:                    }
151:                    if ("java.lang.Float".equals(typeName)) {
152:                        return "new Float((float)" + name.hashCode()
153:                                / hashCode() + ")";
154:                    }
155:                    if ("java.lang.Double".equals(typeName)) {
156:                        return "new Double((double)" + name.hashCode()
157:                                / hashCode() + ")";
158:                    }
159:                    if ("java.lang.Short".equals(typeName)) {
160:                        return "new Short((short)" + name.hashCode() + ")";
161:                    }
162:                    if ("java.lang.Byte".equals(typeName)) {
163:                        return "new Byte((byte)" + name.hashCode() + ")";
164:                    }
165:
166:                    //if (type.isArrayType()) return constructDummyArray();
167:                    if (type.isSetType()) {
168:                        return "new java.util.HashSet(java.util.Arrays.asList("
169:                                + constructDummyArray() + "))";
170:                    }
171:                    if (type.isCollectionType()) {
172:                        return "java.util.Arrays.asList("
173:                                + constructDummyArray() + ")";
174:                    }
175:
176:                    // maps and others types will simply not be treated
177:                }
178:                return "null";
179:            }
180:
181:            /**
182:             * Constructs a string representing an array initialization in Java.
183:             *
184:             * @return A String representing Java code for the initialization of an array.
185:             */
186:            private final String constructDummyArray() {
187:                return JSFUtils.constructDummyArrayDeclaration(this .getName(),
188:                        JSFGlobals.DUMMY_ARRAY_COUNT);
189:            }
190:
191:            /**
192:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getFormPropertyName(org.andromda.metafacades.uml.ParameterFacade)
193:             */
194:            protected String handleGetFormPropertyName(
195:                    final ParameterFacade ownerParameter) {
196:                final StringBuffer propertyName = new StringBuffer();
197:                if (ownerParameter != null) {
198:                    propertyName.append(ownerParameter.getName());
199:                    propertyName.append('.');
200:                }
201:                final String name = this .getName();
202:                if (name != null && name.trim().length() > 0) {
203:                    propertyName.append(name);
204:                }
205:                return propertyName.toString();
206:            }
207:
208:            /**
209:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getBackingListName(org.andromda.metafacades.uml.ParameterFacade)
210:             */
211:            protected String handleGetBackingListName(
212:                    final ParameterFacade ownerParameter) {
213:                final String backingListName = StringUtils
214:                        .replace(
215:                                ObjectUtils
216:                                        .toString(this 
217:                                                .getConfiguredProperty(JSFGlobals.BACKING_LIST_PATTERN)),
218:                                "{0}", this .getFormPropertyId(ownerParameter));
219:                return org.andromda.utils.StringUtilsHelper
220:                        .lowerCamelCaseName(backingListName);
221:            }
222:
223:            /**
224:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getBackingValueName(org.andromda.metafacades.uml.ParameterFacade)
225:             */
226:            protected String handleGetBackingValueName(
227:                    final ParameterFacade ownerParameter) {
228:                final String backingListName = StringUtils
229:                        .replace(
230:                                ObjectUtils
231:                                        .toString(this 
232:                                                .getConfiguredProperty(JSFGlobals.BACKING_VALUE_PATTERN)),
233:                                "{0}", this .getFormPropertyId(ownerParameter));
234:                return org.andromda.utils.StringUtilsHelper
235:                        .lowerCamelCaseName(backingListName);
236:            }
237:
238:            /**
239:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getLabelListName(org.andromda.metafacades.uml.ParameterFacade)
240:             */
241:            protected String handleGetLabelListName(
242:                    final ParameterFacade ownerParameter) {
243:                return StringUtils.replace(ObjectUtils.toString(this 
244:                        .getConfiguredProperty(JSFGlobals.LABEL_LIST_PATTERN)),
245:                        "{0}", this .getFormPropertyId(ownerParameter));
246:            }
247:
248:            /**
249:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getValueListName(org.andromda.metafacades.uml.ParameterFacade)
250:             */
251:            protected String handleGetValueListName(
252:                    final ParameterFacade ownerParameter) {
253:                return StringUtils.replace(ObjectUtils.toString(this 
254:                        .getConfiguredProperty(JSFGlobals.VALUE_LIST_PATTERN)),
255:                        "{0}", this .getFormPropertyId(ownerParameter));
256:            }
257:
258:            /**
259:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getFormPropertyId(java.lang.String)
260:             */
261:            protected String handleGetFormPropertyId(
262:                    final ParameterFacade ownerParameter) {
263:                return StringUtilsHelper.lowerCamelCaseName(this 
264:                        .getFormPropertyName(ownerParameter));
265:            }
266:
267:            /**
268:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isSelectable(org.andromda.metafacades.uml.FrontEndParameter)
269:             */
270:            protected boolean handleIsSelectable(
271:                    final FrontEndParameter ownerParameter) {
272:                boolean selectable = false;
273:                if (ownerParameter != null) {
274:                    if (ownerParameter.isActionParameter()) {
275:                        selectable = this .isInputMultibox()
276:                                || this .isInputSelect() || this .isInputRadio();
277:                        final ClassifierFacade type = this .getType();
278:
279:                        if (!selectable && type != null) {
280:                            final String name = this .getName();
281:                            final String typeName = type
282:                                    .getFullyQualifiedName();
283:
284:                            // - if the parameter is not selectable but on a targetting page it IS selectable we must
285:                            //   allow the user to set the backing list too                 
286:                            final Collection views = ownerParameter.getAction()
287:                                    .getTargetViews();
288:                            for (final Iterator iterator = views.iterator(); iterator
289:                                    .hasNext()
290:                                    && !selectable;) {
291:                                final FrontEndView view = (FrontEndView) iterator
292:                                        .next();
293:                                final Collection parameters = view
294:                                        .getAllActionParameters();
295:                                for (final Iterator parameterIterator = parameters
296:                                        .iterator(); parameterIterator
297:                                        .hasNext()
298:                                        && !selectable;) {
299:                                    final Object object = parameterIterator
300:                                            .next();
301:                                    if (object instanceof  JSFParameter) {
302:                                        final JSFParameter parameter = (JSFParameter) object;
303:                                        final String parameterName = parameter
304:                                                .getName();
305:                                        final ClassifierFacade parameterType = parameter
306:                                                .getType();
307:                                        if (parameterType != null) {
308:                                            final String parameterTypeName = parameterType
309:                                                    .getFullyQualifiedName();
310:                                            if (name.equals(parameterName)
311:                                                    && typeName
312:                                                            .equals(parameterTypeName)) {
313:                                                selectable = parameter
314:                                                        .isInputMultibox()
315:                                                        || parameter
316:                                                                .isInputSelect()
317:                                                        || parameter
318:                                                                .isInputRadio();
319:                                            }
320:                                        }
321:                                    }
322:                                }
323:                            }
324:                        }
325:                    } else if (ownerParameter.isControllerOperationArgument()) {
326:                        final String name = this .getName();
327:                        final Collection actions = ownerParameter
328:                                .getControllerOperation().getDeferringActions();
329:                        for (final Iterator actionIterator = actions.iterator(); actionIterator
330:                                .hasNext();) {
331:                            final JSFAction action = (JSFAction) actionIterator
332:                                    .next();
333:                            final Collection formFields = action
334:                                    .getFormFields();
335:                            for (final Iterator fieldIterator = formFields
336:                                    .iterator(); fieldIterator.hasNext()
337:                                    && !selectable;) {
338:                                final Object object = fieldIterator.next();
339:                                if (object instanceof  JSFParameter) {
340:                                    final JSFParameter parameter = (JSFParameter) object;
341:                                    if (name.equals(parameter.getName())) {
342:                                        selectable = parameter.isSelectable();
343:                                    }
344:                                }
345:                            }
346:                        }
347:                    }
348:                }
349:                return selectable;
350:            }
351:
352:            /**
353:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isValidationRequired()
354:             */
355:            protected boolean handleIsValidationRequired() {
356:                return !this .getValidatorTypes().isEmpty();
357:            }
358:
359:            /**
360:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getValidatorTypes()
361:             */
362:            protected java.util.Collection handleGetValidatorTypes() {
363:                return JSFUtils.getValidatorTypes((ModelElementFacade) this 
364:                        .THIS(), this .getType());
365:            }
366:
367:            /**
368:             * @see org.andromda.cartridges.jsf.metafacades.JSFParameter#getValidatorVars()
369:             */
370:            protected java.util.Collection handleGetValidatorVars() {
371:                return JSFUtils.getValidatorVars(((ModelElementFacade) this 
372:                        .THIS()), this .getType());
373:            }
374:
375:            /**
376:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getValidWhen()
377:             */
378:            protected java.lang.String handleGetValidWhen() {
379:                return JSFUtils.getValidWhen(this );
380:            }
381:
382:            /**
383:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputTextarea()
384:             */
385:            protected boolean handleIsInputTextarea() {
386:                return this .isInputType(JSFGlobals.INPUT_TEXTAREA);
387:            }
388:
389:            /**
390:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputSelect()
391:             */
392:            protected boolean handleIsInputSelect() {
393:                return this .isInputType(JSFGlobals.INPUT_SELECT);
394:            }
395:
396:            /**
397:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputSecret()
398:             */
399:            protected boolean handleIsInputSecret() {
400:                return this .isInputType(JSFGlobals.INPUT_PASSWORD);
401:            }
402:
403:            /**
404:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputHidden()
405:             */
406:            protected boolean handleIsInputHidden() {
407:                return this .isInputType(JSFGlobals.INPUT_HIDDEN);
408:            }
409:
410:            /**
411:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isPlaintext()
412:             */
413:            protected boolean handleIsPlaintext() {
414:                return this .isInputType(JSFGlobals.PLAIN_TEXT);
415:            }
416:
417:            /**
418:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputRadio()
419:             */
420:            protected boolean handleIsInputRadio() {
421:                return this .isInputType(JSFGlobals.INPUT_RADIO);
422:            }
423:
424:            /**
425:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputText()
426:             */
427:            protected boolean handleIsInputText() {
428:                return this .isInputType(JSFGlobals.INPUT_TEXT);
429:            }
430:
431:            /**
432:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputMultibox()
433:             */
434:            protected boolean handleIsInputMultibox() {
435:                return this .isInputType(JSFGlobals.INPUT_MULTIBOX);
436:            }
437:
438:            /**
439:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputTable()
440:             */
441:            protected boolean handleIsInputTable() {
442:                return this .getInputTableIdentifierColumns().length() > 0
443:                        || this .isInputType(JSFGlobals.INPUT_TABLE);
444:            }
445:
446:            /**
447:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputCheckbox()
448:             */
449:            protected boolean handleIsInputCheckbox() {
450:                boolean checkbox = this .isInputType(JSFGlobals.INPUT_CHECKBOX);
451:                if (!checkbox && this .getInputType().length() == 0) {
452:                    final ClassifierFacade type = this .getType();
453:                    checkbox = type != null ? type.isBooleanType() : false;
454:                }
455:                return checkbox;
456:            }
457:
458:            /**
459:             * Gets the current value of the specified input type (or an empty string
460:             * if one isn't specified).
461:             *
462:             * @return the input type name.
463:             */
464:            private final String getInputType() {
465:                return ObjectUtils
466:                        .toString(
467:                                this 
468:                                        .findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_TYPE))
469:                        .trim();
470:            }
471:
472:            /**
473:             * Indicates whether or not this parameter is of the given input type.
474:             *
475:             * @param inputType the name of the input type to check for.
476:             * @return true/false
477:             */
478:            private final boolean isInputType(final String inputType) {
479:                return inputType.equalsIgnoreCase(this .getInputType());
480:            }
481:
482:            /**
483:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputFile()
484:             */
485:            protected boolean handleIsInputFile() {
486:                boolean file = false;
487:                ClassifierFacade type = getType();
488:                if (type != null) {
489:                    file = type.isFileType();
490:                }
491:                return file;
492:            }
493:
494:            /**
495:             * Overridden to provide consistent behavior with {@link JSFParameter#isReadOnly()}.
496:             *
497:             * @see org.andromda.metafacades.uml.AttributeFacade#isReadOnly()
498:             */
499:            public boolean isReadOnly() {
500:                return JSFUtils.isReadOnly(this );
501:            }
502:
503:            /**
504:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getValueListDummyValue()
505:             */
506:            protected String handleGetValueListDummyValue() {
507:                return this .constructDummyArray();
508:            }
509:
510:            /**
511:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getValidatorArgs(java.lang.String)
512:             */
513:            protected Collection handleGetValidatorArgs(
514:                    final String validatorType) {
515:                return JSFUtils.getValidatorArgs((ModelElementFacade) this 
516:                        .THIS(), validatorType);
517:            }
518:
519:            /**
520:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isStrictDateFormat()
521:             */
522:            protected boolean handleIsStrictDateFormat() {
523:                return JSFUtils.isStrictDateFormat((ModelElementFacade) this 
524:                        .THIS());
525:            }
526:
527:            /**
528:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getDateFormatter(org.andromda.cartridges.jsf.metafacades.JSFParameter)
529:             */
530:            protected String handleGetDateFormatter(
531:                    final JSFParameter ownerParameter) {
532:                final ClassifierFacade type = this .getType();
533:                return type != null && type.isDateType() ? this 
534:                        .getFormPropertyId(ownerParameter)
535:                        + "DateFormatter" : null;
536:            }
537:
538:            /**
539:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#getTimeFormatter(org.andromda.cartridges.jsf.metafacades.JSFParameter)
540:             */
541:            protected String handleGetTimeFormatter(
542:                    final JSFParameter ownerParameter) {
543:                final ClassifierFacade type = this .getType();
544:                return type != null && type.isTimeType() ? this 
545:                        .getFormPropertyId(ownerParameter)
546:                        + "TimeFormatter" : null;
547:            }
548:
549:            /**
550:             * Overridden to provide quotes around string types.
551:             *
552:             * @see org.andromda.metafacades.uml.AttributeFacade#getDefaultValue()
553:             */
554:            public String getDefaultValue() {
555:                String defaultValue = super .getDefaultValue();
556:                if (StringUtils.isNotBlank(defaultValue)) {
557:                    final ClassifierFacade type = this .getType();
558:                    if (type != null && type.isStringType()) {
559:                        defaultValue = "\"" + defaultValue + "\"";
560:                    }
561:                }
562:                return defaultValue;
563:            }
564:
565:            /**
566:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isEqualValidator()
567:             */
568:            protected boolean handleIsEqualValidator() {
569:                final String equal = JSFUtils
570:                        .getEqual((ModelElementFacade) this .THIS());
571:                return equal != null && equal.trim().length() > 0;
572:            }
573:
574:            /**
575:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isBackingValueRequired(org.andromda.metafacades.uml.FrontEndParameter)
576:             */
577:            protected boolean handleIsBackingValueRequired(
578:                    final FrontEndParameter ownerParameter) {
579:                boolean required = false;
580:                if (ownerParameter != null) {
581:                    if (ownerParameter.isActionParameter()) {
582:                        required = this .isInputTable();
583:                        final ClassifierFacade type = this .getType();
584:
585:                        if (!required && type != null) {
586:                            final String name = this .getName();
587:                            final String typeName = type
588:                                    .getFullyQualifiedName();
589:
590:                            // - if the parameter is not selectable but on a targetting page it IS selectable we must
591:                            //   allow the user to set the backing list too                 
592:                            final Collection views = ownerParameter.getAction()
593:                                    .getTargetViews();
594:                            for (final Iterator iterator = views.iterator(); iterator
595:                                    .hasNext()
596:                                    && !required;) {
597:                                final FrontEndView view = (FrontEndView) iterator
598:                                        .next();
599:                                final Collection parameters = view
600:                                        .getAllActionParameters();
601:                                for (final Iterator parameterIterator = parameters
602:                                        .iterator(); parameterIterator
603:                                        .hasNext()
604:                                        && !required;) {
605:                                    final Object object = parameterIterator
606:                                            .next();
607:                                    if (object instanceof  JSFParameter) {
608:                                        final JSFParameter parameter = (JSFParameter) object;
609:                                        final String parameterName = parameter
610:                                                .getName();
611:                                        final ClassifierFacade parameterType = parameter
612:                                                .getType();
613:                                        if (parameterType != null) {
614:                                            final String parameterTypeName = parameterType
615:                                                    .getFullyQualifiedName();
616:                                            if (name.equals(parameterName)
617:                                                    && typeName
618:                                                            .equals(parameterTypeName)) {
619:                                                required = parameter
620:                                                        .isInputTable();
621:                                            }
622:                                        }
623:                                    }
624:                                }
625:                            }
626:                        }
627:                    } else if (ownerParameter.isControllerOperationArgument()) {
628:                        final String name = this .getName();
629:                        final Collection actions = ownerParameter
630:                                .getControllerOperation().getDeferringActions();
631:                        for (final Iterator actionIterator = actions.iterator(); actionIterator
632:                                .hasNext();) {
633:                            final JSFAction action = (JSFAction) actionIterator
634:                                    .next();
635:                            final Collection formFields = action
636:                                    .getFormFields();
637:                            for (final Iterator fieldIterator = formFields
638:                                    .iterator(); fieldIterator.hasNext()
639:                                    && !required;) {
640:                                final Object object = fieldIterator.next();
641:                                if (object instanceof  JSFParameter) {
642:                                    final JSFParameter parameter = (JSFParameter) object;
643:                                    if (name.equals(parameter.getName())) {
644:                                        required = parameter
645:                                                .isBackingValueRequired();
646:                                    }
647:                                }
648:                            }
649:                        }
650:                    }
651:                }
652:                return required;
653:            }
654:
655:            /**
656:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttribute#isInputTypePresent()
657:             */
658:            protected boolean handleIsInputTypePresent() {
659:                boolean present = false;
660:                final ClassifierFacade type = this .getType();
661:                if (type != null) {
662:                    present = (StringUtils.isNotBlank(this .getInputType())
663:                            || type.isDateType() || type.isBooleanType())
664:                            && !this .isPlaintext();
665:                }
666:                return present;
667:            }
668:
669:            /**
670:             * @see org.andromda.cartridges.jsf.metafacades.JSFAttributer#getInputTableIdentifierColumns()
671:             */
672:            protected String handleGetInputTableIdentifierColumns() {
673:                return ObjectUtils
674:                        .toString(
675:                                this
676:                                        .findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_TABLE_IDENTIFIER_COLUMNS))
677:                        .trim();
678:            }
679:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.