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


001:        package org.andromda.metafacades.emf.uml2;
002:
003:        import java.util.Collection;
004:
005:        import org.andromda.metafacades.uml.AttributeFacade;
006:        import org.andromda.metafacades.uml.ClassifierFacade;
007:        import org.andromda.metafacades.uml.Entity;
008:        import org.andromda.metafacades.uml.EntityAttribute;
009:        import org.andromda.metafacades.uml.EntityMetafacadeUtils;
010:        import org.andromda.metafacades.uml.NameMasker;
011:        import org.andromda.metafacades.uml.TypeMappings;
012:        import org.andromda.metafacades.uml.UMLMetafacadeProperties;
013:        import org.andromda.metafacades.uml.UMLProfile;
014:        import org.apache.commons.lang.ObjectUtils;
015:        import org.apache.commons.lang.StringUtils;
016:
017:        /**
018:         * MetafacadeLogic implementation for
019:         * org.andromda.metafacades.uml.EntityAssociationEnd.
020:         *
021:         * @see org.andromda.metafacades.uml.EntityAssociationEnd
022:         */
023:        public class EntityAssociationEndLogicImpl extends
024:                EntityAssociationEndLogic {
025:            public EntityAssociationEndLogicImpl(final Object metaObject,
026:                    final String context) {
027:                super (metaObject, context);
028:            }
029:
030:            /**
031:             * Overridden to provide name masking.
032:             *
033:             * @see org.andromda.metafacades.uml.ModelElementFacade#getName()
034:             */
035:            protected String handleGetName() {
036:                final String nameMask = String
037:                        .valueOf(this 
038:                                .getConfiguredProperty(UMLMetafacadeProperties.ENTITY_PROPERTY_NAME_MASK));
039:                return NameMasker.mask(super .handleGetName(), nameMask);
040:            }
041:
042:            /**
043:             * @see org.andromda.metafacades.uml.EntityAssociationEnd#getColumnName()
044:             */
045:            protected java.lang.String handleGetColumnName() {
046:                String columnName = null;
047:
048:                // prevent ClassCastException if the association isn't an Entity
049:                if (this .getType() instanceof  Entity) {
050:                    final String columnNamePrefix = this 
051:                            .isConfiguredProperty(UMLMetafacadeProperties.COLUMN_NAME_PREFIX) ? ObjectUtils
052:                            .toString(this 
053:                                    .getConfiguredProperty(UMLMetafacadeProperties.COLUMN_NAME_PREFIX))
054:                            : null;
055:                    columnName = EntityMetafacadeUtils
056:                            .getSqlNameFromTaggedValue(
057:                                    columnNamePrefix,
058:                                    this ,
059:                                    UMLProfile.TAGGEDVALUE_PERSISTENCE_COLUMN,
060:                                    ((Entity) this .getType())
061:                                            .getMaxSqlNameLength(),
062:                                    this .getForeignKeySuffix(),
063:                                    this 
064:                                            .getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR));
065:                }
066:                return columnName;
067:            }
068:
069:            /**
070:             * @see org.andromda.metafacades.uml.EntityAssociationEnd#getForeignKeySuffix()
071:             */
072:            protected java.lang.String handleGetForeignKeySuffix() {
073:                return (String) this 
074:                        .getConfiguredProperty(UMLMetafacadeProperties.FOREIGN_KEY_SUFFIX);
075:            }
076:
077:            /**
078:             * @see org.andromda.metafacades.uml.EntityAssociationEnd#isForeignIdentifier()
079:             */
080:            protected boolean handleIsForeignIdentifier() {
081:                final Object value = this 
082:                        .findTaggedValue(UMLProfile.TAGGEDVALUE_PERSISTENCE_FOREIGN_IDENTIFIER);
083:                return value != null
084:                        && Boolean.valueOf(String.valueOf(value))
085:                                .booleanValue();
086:            }
087:
088:            /**
089:             * @see org.andromda.metafacades.uml.EntityAssociationEnd#getForeignKeyConstraintName()
090:             */
091:            protected java.lang.String handleGetForeignKeyConstraintName() {
092:                String constraintName;
093:
094:                final Object taggedValueObject = findTaggedValue(UMLProfile.TAGGEDVALUE_PERSISTENCE_FOREIGN_KEY_CONSTRAINT_NAME);
095:                if (taggedValueObject == null) {
096:                    // we construct our own foreign key constraint name here
097:                    StringBuffer buffer = new StringBuffer();
098:
099:                    final ClassifierFacade type = getOtherEnd().getType();
100:                    if (type instanceof  Entity) {
101:                        Entity entity = (Entity) type;
102:                        buffer.append(entity.getTableName());
103:                    } else {
104:                        // should not happen
105:                        buffer.append(type.getName().toUpperCase());
106:                    }
107:
108:                    buffer
109:                            .append(this 
110:                                    .getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR));
111:                    buffer.append(this .getColumnName());
112:                    constraintName = buffer.toString();
113:
114:                    final String suffix = ObjectUtils
115:                            .toString(
116:                                    this 
117:                                            .getConfiguredProperty(UMLMetafacadeProperties.CONSTRAINT_SUFFIX))
118:                            .trim();
119:                    // we take into consideration the maximum length allowed
120:                    final String maxLengthString = (String) getConfiguredProperty(UMLMetafacadeProperties.MAX_SQL_NAME_LENGTH);
121:                    final short maxLength = (short) (Short.valueOf(
122:                            maxLengthString).shortValue() - suffix.length());
123:                    buffer = new StringBuffer(EntityMetafacadeUtils
124:                            .ensureMaximumNameLength(constraintName, new Short(
125:                                    maxLength)));
126:                    buffer.append(suffix);
127:                    constraintName = buffer.toString();
128:                } else {
129:                    // use the tagged value
130:                    constraintName = taggedValueObject.toString();
131:                }
132:                return constraintName;
133:            }
134:
135:            /**
136:             * @see org.andromda.metafacades.uml.EntityAssociationEnd#getColumnIndex()
137:             */
138:            protected java.lang.String handleGetColumnIndex() {
139:                final String index = (String) this 
140:                        .findTaggedValue(UMLProfile.TAGGEDVALUE_PERSISTENCE_COLUMN_INDEX);
141:                return index != null ? StringUtils.trimToEmpty(index) : null;
142:            }
143:
144:            /**
145:             * @see org.andromda.metafacades.uml.EntityAssociationEnd#getSqlType()
146:             */
147:            protected java.lang.String handleGetSqlType() {
148:                String value = null;
149:                if (this .getSqlMappings() != null) {
150:                    EntityAttribute identifier = null;
151:
152:                    // we retrieve the column length from the first identifier of the
153:                    // primary key
154:                    // on the other side (since that should correspond to the foreign
155:                    // key).
156:                    if (this .getType() instanceof  Entity) {
157:                        final Entity type = (Entity) this .getType();
158:                        final Collection identifiers = type.getIdentifiers();
159:                        if (identifiers != null && !identifiers.isEmpty()) {
160:                            AttributeFacade attribute = (AttributeFacade) identifiers
161:                                    .iterator().next();
162:                            if (attribute instanceof  EntityAttribute) {
163:                                identifier = (EntityAttribute) attribute;
164:                            }
165:                        }
166:                    }
167:                    if (identifier != null && identifier.getType() != null) {
168:                        String typeName = identifier.getType()
169:                                .getFullyQualifiedName(true);
170:                        value = this .getSqlMappings().getTo(typeName);
171:                        final String columnLength = identifier
172:                                .getColumnLength();
173:                        if (StringUtils.isNotEmpty(columnLength)) {
174:                            value = EntityMetafacadeUtils.constructSqlTypeName(
175:                                    value, columnLength);
176:                        }
177:                    }
178:                }
179:                return value;
180:            }
181:
182:            /**
183:             * Gets the SQL mappings that have been set for this entity attribute.
184:             *
185:             * @return the SQL Mappings instance.
186:             */
187:            public TypeMappings getSqlMappings() {
188:                final String propertyName = UMLMetafacadeProperties.SQL_MAPPINGS_URI;
189:                final Object property = this 
190:                        .getConfiguredProperty(propertyName);
191:                TypeMappings mappings = null;
192:                String uri;
193:                if (property instanceof  String) {
194:                    uri = (String) property;
195:                    try {
196:                        mappings = TypeMappings.getInstance(uri);
197:                        this .setProperty(propertyName, mappings);
198:                    } catch (Throwable throwable) {
199:                        String errMsg = "Error getting '" + propertyName
200:                                + "' --> '" + uri + "'";
201:                        this .logger.error(errMsg, throwable);
202:
203:                        // don't throw the exception
204:                    }
205:                } else {
206:                    mappings = (TypeMappings) property;
207:                }
208:                return mappings;
209:            }
210:
211:            protected boolean handleIsTransient() {
212:                return this .hasStereotype(UMLProfile.STEREOTYPE_TRANSIENT);
213:            }
214:
215:            /**
216:             * @see org.andromda.metafacades.uml.EntityAssociationEnd#isIdentifiersPresent()
217:             */
218:            protected boolean handleIsIdentifiersPresent() {
219:                return this.hasStereotype(UMLProfile.STEREOTYPE_IDENTIFIER);
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.