1 package org.andromda.cartridges.hibernate.metafacades;
2
3 import org.andromda.utils.JavaTypeConverter;
4 import org.apache.commons.lang.StringUtils;
5
6
7
8
9
10
11
12
13 public class HibernateEnumerationLogicImpl
14 extends HibernateEnumerationLogic
15 {
16 private static final long serialVersionUID = 34L;
17
18
19
20
21
22 public HibernateEnumerationLogicImpl(
23 Object metaObject,
24 String context)
25 {
26 super(metaObject, context);
27 }
28
29
30
31
32 private static final String ENUMERATION_NAME_PATTERN = "enumerationNamePattern";
33
34
35
36
37
38
39 private String getEnumerationNamePattern()
40 {
41 return String.valueOf(this.getConfiguredProperty(ENUMERATION_NAME_PATTERN));
42 }
43
44
45
46
47 @Override
48 protected String handleGetFullyQualifiedHibernateType()
49 {
50 return JavaTypeConverter.getJavaLangTypeName(super.getFullyQualifiedName());
51 }
52
53
54
55
56 @Override
57 protected String handleGetEnumerationName()
58 {
59 return StringUtils.trimToEmpty(this.getEnumerationNamePattern()).replaceAll(
60 "\\{0\\}",
61 super.getName());
62 }
63
64
65
66
67 @Override
68 protected String handleGetFullyQualifiedHibernateEnumerationType()
69 {
70 return HibernateMetafacadeUtils.getFullyQualifiedName(
71 this.getHibernateEnumerationPackageName(),
72 this.getEnumerationName(),
73 null);
74 }
75
76
77
78
79 private String getHibernateEnumerationPackageName() {
80 String enumPackageName = (String) this.getConfiguredProperty(HibernateGlobals.ENUM_TYPES_PACKAGE);
81 if (enumPackageName != null) {
82 return enumPackageName;
83 } else {
84 return super.getPackageName();
85 }
86 }
87
88
89
90
91 @Override
92 protected int handleGetVersion()
93 {
94 return Integer.parseInt(((String)this.getConfiguredProperty(HibernateGlobals.HIBERNATE_VERSION)).substring(0, 1));
95 }
96 }