1 package org.andromda.cartridges.ejb3.metafacades;
2
3 import org.andromda.cartridges.ejb3.EJB3Globals;
4 import org.andromda.cartridges.ejb3.EJB3Profile;
5 import org.andromda.metafacades.uml.AttributeFacade;
6 import org.andromda.metafacades.uml.ClassifierFacade;
7 import org.apache.commons.lang.StringUtils;
8
9
10
11
12
13
14 public class EJB3FinderMethodArgumentFacadeLogicImpl
15 extends EJB3FinderMethodArgumentFacadeLogic
16 {
17 private static final long serialVersionUID = 34L;
18
19
20
21
22 public EJB3FinderMethodArgumentFacadeLogicImpl(final Object metaObject, final String context)
23 {
24 super (metaObject, context);
25 }
26
27
28
29
30 @Override
31 protected String handleGetTemporalType()
32 {
33 String temporalType =
34 (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_PERSISTENCE_TEMPORAL_TYPE);
35 if (StringUtils.isBlank(temporalType))
36 {
37 ClassifierFacade classifier = this.getType();
38 if (classifier != null)
39 {
40 if (!classifier.isPrimitive())
41 {
42 if (classifier.isDateType())
43 {
44 temporalType = EJB3Globals.TEMPORAL_TYPE_DATE;
45 }
46 else if (classifier.isTimeType())
47 {
48 temporalType = EJB3Globals.TEMPORAL_TYPE_TIME;
49 }
50 else if ("Timestamp".equals(classifier.getName()))
51 {
52 temporalType = EJB3Globals.TEMPORAL_TYPE_TIMESTAMP;
53 }
54 }
55 }
56 }
57 return temporalType;
58 }
59
60
61
62
63 @Override
64 protected boolean handleIsFirstResult()
65 {
66 return this.hasStereotype(EJB3Profile.STEREOTYPE_FINDER_RESULT_TYPE_FIRST);
67 }
68
69
70
71
72 @Override
73 protected boolean handleIsMaxResults()
74 {
75 return this.hasStereotype(EJB3Profile.STEREOTYPE_FINDER_RESULT_TYPE_MAX);
76 }
77
78
79
80
81 @Override
82 protected boolean handleIsEnumerationTypeOrdinal()
83 {
84 boolean ordinalType = false;
85 if (this.getType().isEnumeration())
86 {
87 AttributeFacade literal = this.getType().getAttributes().iterator().next();
88 if (!literal.getType().isStringType())
89 {
90 ordinalType = true;
91 }
92 }
93 return ordinalType;
94 }
95
96
97
98
99 @Override
100 protected boolean handleIsEnumerationTypeString()
101 {
102 boolean stringType = false;
103 if (this.getType().isEnumeration())
104 {
105 AttributeFacade literal = this.getType().getAttributes().iterator().next();
106 if (literal.getType().isStringType())
107 {
108 stringType = true;
109 }
110 }
111 return stringType;
112 }
113 }