1 package org.andromda.cartridges.ejb3.metafacades;
2
3 import org.andromda.core.common.ExceptionRecorder;
4 import org.andromda.metafacades.uml.TypeMappings;
5 import org.apache.commons.lang.StringUtils;
6
7
8
9
10
11
12 public class EJB3TypeFacadeLogicImpl
13 extends EJB3TypeFacadeLogic
14 {
15 private static final long serialVersionUID = 34L;
16
17
18
19
20 public EJB3TypeFacadeLogicImpl(final Object metaObject, final String context)
21 {
22 super (metaObject, context);
23 }
24
25
26
27
28 @Override
29 protected String handleGetFullyQualifiedEJB3Type()
30 {
31 String fullyQualifiedName = super.getFullyQualifiedName();
32 final TypeMappings mappings = this.getEJB3TypeMappings();
33 if (mappings != null)
34 {
35 final String fullyQualifiedModelName = super.getFullyQualifiedName(true);
36 if (mappings.getMappings().containsFrom(fullyQualifiedModelName))
37 {
38 fullyQualifiedName = mappings.getTo(fullyQualifiedModelName);
39 }
40 }
41 return fullyQualifiedName;
42 }
43
44
45
46
47
48
49 protected TypeMappings getEJB3TypeMappings()
50 {
51 TypeMappings mappings = null;
52 final String propertyName = "ejb3TypeMappingsUri";
53 if (this.isConfiguredProperty(propertyName))
54 {
55 final Object property = this.getConfiguredProperty(propertyName);
56 if (property instanceof String)
57 {
58 String uri = (String)property;
59 if (StringUtils.isNotBlank(uri))
60 {
61 try
62 {
63 mappings = TypeMappings.getInstance((String)property);
64 this.setProperty(propertyName, mappings);
65 }
66 catch (final Throwable throwable)
67 {
68 final String message = "Error getting '" + propertyName + "' --> '" + uri + '\'';
69
70
71 ExceptionRecorder.instance().record(message, throwable);
72 }
73 }
74 }
75 else
76 {
77 mappings = (TypeMappings)property;
78 }
79 }
80 return mappings;
81 }
82 }