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


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