/** * Gets the SQL name. (i.e. column name, table name, etc.). If it can't find * the corresponding tagged value with the specified <code>name</code>, * then it uses the element name by default and just returns that. * * @param element from which to retrieve the SQL name. * @param name the name of the tagged value. * @param nameMaxLength if this is not null, then the name returned will be * trimmed to this length (if it happens to be longer). * @param separator character used to separate words * @return the SQL name as a String. */ public static String getSqlNameFromTaggedValue( ModelElementFacade element, String name, Short nameMaxLength, Object separator) { return getSqlNameFromTaggedValue( null, element, name, nameMaxLength, null, separator); }
/** * @see org.andromda.metafacades.uml.Entity#getIdentifiers(boolean) */ @Override protected Collection<EntityAttribute> handleGetIdentifiers(final boolean follow) { return EntityMetafacadeUtils.getIdentifiers( this, follow); }
/** * @param prefix * @param name * @return returnValue prefix + this.getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR) + name * @see org.andromda.cartridges.hibernate.metafacades.HibernateEntityAttribute#concatColumnName(String, String) */ @Override protected String handleConcatColumnName( String prefix, String name) { String returnValue = name; if (StringUtils.isNotBlank(prefix)) { returnValue = prefix + this.getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR) + name; // handle maxSqlNameLength Short maxSqlNameLength = Short.valueOf((String)this.getConfiguredProperty(UMLMetafacadeProperties.MAX_SQL_NAME_LENGTH)); returnValue = EntityMetafacadeUtils.ensureMaximumNameLength(returnValue, maxSqlNameLength); } return returnValue; }
EntityMetafacadeUtils.toSqlName( element.getName(), separator)); buffer = new StringBuilder( EntityMetafacadeUtils.ensureMaximumNameLength( buffer.toString(), new Short(maxLength)));
final Collection<EntityAttribute> identifiers = EntityMetafacadeUtils.getIdentifiers(entity, follow); if (classifier instanceof Entity) Collection<EntityAttribute> entityIdentifiers = getIdentifierAttributes((Entity)classifier, true); identifierAttributes.addAll(entityIdentifiers); identifierAttributes.addAll(getIdentifiers((Entity)entity.getGeneralization(), follow));
buffer = new StringBuilder(EntityMetafacadeUtils.ensureMaximumNameLength(constraintName, Short.valueOf(maxLength))); buffer.append(suffix); constraintName = EntityMetafacadeUtils.getUniqueForeignKeyConstraintName(buffer.toString());
if (StringUtils.isNotBlank(columnLength)) value = EntityMetafacadeUtils.constructSqlTypeName(value, columnLength);
/** * @see org.andromda.cartridges.hibernate.metafacades.HibernateEntity#getHibernateVersionPropertySqlName() */ @Override protected String handleGetHibernateVersionPropertySqlName() { return EntityMetafacadeUtils.toSqlName(this.getHibernateVersionProperty(), this.getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR)); }
/** * @see org.andromda.metafacades.uml.EntityAssociationEnd#getForeignKeyConstraintName() */ @Override protected String handleGetForeignKeyConstraintName() { return EntityMetafacadeUtils.getForeignKeyConstraintName( (EntityAssociationEnd)THIS(), ObjectUtils.toString(this.getConfiguredProperty(UMLMetafacadeProperties.CONSTRAINT_SUFFIX)).trim(), ObjectUtils.toString(this.getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR)).trim(), ObjectUtils.toString(getConfiguredProperty(UMLMetafacadeProperties.MAX_SQL_NAME_LENGTH)).trim()); }
/** * @see org.andromda.core.metafacade.ModelAccessFacade#setModel(Object) */ public void setModel(final Object model) { ExceptionUtils.checkNull("model", model); ExceptionUtils.checkAssignable( UmlPackage.class, "modelElement", model.getClass()); this.model = (UmlPackage)model; // TODO: - clears out the foreign key cache (probably not // the cleanest way, but the easiest at this point). EntityMetafacadeUtils.clearForeignKeyConstraintNameCache(); }
/** * Retrieves a unique foreign key constraint name given the proposedName. Compares the proposedName * against any foreign key names already stored in an internal collection. * * @param proposedName the proposed foreign key name. * @return the unique foreign key name. */ private static String getUniqueForeignKeyConstraintName(String proposedName) { final char[] characters = proposedName.toCharArray(); int numericValue = 0; for (int ctr = 0; ctr < characters.length; ctr++) { numericValue = numericValue + Character.getNumericValue(characters[0]); } return getUniqueForeignKeyConstraintName(proposedName, new Random(numericValue)); }
buffer = new StringBuilder(toSqlName( element.getName(), separator)); buffer = new StringBuilder( EntityMetafacadeUtils.ensureMaximumNameLength( buffer.toString(), Short.valueOf(maxLength)));
final Collection<EntityAttribute> identifiers = EntityMetafacadeUtils.getIdentifiers(entity, follow); if (classifier instanceof Entity) Collection<EntityAttribute> entityIdentifiers = getIdentifierAttributes((Entity)classifier, true); identifierAttributes.addAll(entityIdentifiers); identifierAttributes.addAll(getIdentifiers((Entity)entity.getGeneralization(), follow));
buffer = new StringBuilder(EntityMetafacadeUtils.ensureMaximumNameLength(constraintName, Short.valueOf(maxLength))); buffer.append(suffix); constraintName = EntityMetafacadeUtils.getUniqueForeignKeyConstraintName(buffer.toString());
if (StringUtils.isNotBlank(columnLength)) value = EntityMetafacadeUtils.constructSqlTypeName( value, columnLength);
/** * @see EJB3AssociationEndFacadeLogic#handleGetCollectionIndexName() */ @Override protected String handleGetCollectionIndexName() { Object value = this.findTaggedValue(EJB3Profile.TAGGEDVALUE_ASSOCIATION_INDEX); if ((value == null) && this.isConfiguredProperty(COLLECTION_INDEX_NAME)) { value = this.getConfiguredProperty(COLLECTION_INDEX_NAME); if (StringUtils.isBlank(ObjectUtils.toString(value))) { value = null; } } if (value != null) { return ObjectUtils.toString(value); } final String otherEntityName = ((EJB3EntityFacade)this.getOtherEnd().getType()).getEntityName(); final Object separator = this.getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR); return EntityMetafacadeUtils.toSqlName( otherEntityName, separator) + separator + EntityMetafacadeUtils.toSqlName( this.getName(), separator) + separator + "IDX"; }
/** * @see org.andromda.metafacades.uml.EntityAssociationEnd#getForeignKeyConstraintName() */ @Override protected String handleGetForeignKeyConstraintName() { return EntityMetafacadeUtils.getForeignKeyConstraintName( (EntityAssociationEnd)THIS(), ObjectUtils.toString(this.getConfiguredProperty(UMLMetafacadeProperties.CONSTRAINT_SUFFIX)).trim(), ObjectUtils.toString(this.getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR)).trim(), ObjectUtils.toString(getConfiguredProperty(UMLMetafacadeProperties.MAX_SQL_NAME_LENGTH)).trim()); }
EntityMetafacadeUtils.clearForeignKeyConstraintNameCache();
/** * Retrieves a unique foreign key constraint name given the proposedName. Compares the proposedName * against any foreign key names already stored in an internal collection. * * @param proposedName the proposed foreign key name. * @return the unique foreign key name. */ private static String getUniqueForeignKeyConstraintName(String proposedName) { final char[] characters = proposedName.toCharArray(); int numericValue = 0; for (int ctr = 0; ctr < characters.length; ctr++) { numericValue = numericValue + Character.getNumericValue(characters[0]); } return getUniqueForeignKeyConstraintName(proposedName, new Random(numericValue)); }
/** * Gets the SQL name. (i.e. column name, table name, etc.). If it can't find * the corresponding tagged value with the specified <code>name</code>, * then it uses the element name by default and just returns that. * * @param element from which to retrieve the SQL name. * @param name the name of the tagged value. * @param nameMaxLength if this is not null, then the name returned will be * trimmed to this length (if it happens to be longer). * @param separator character used to separate words * @return the SQL name as a String. */ public static String getSqlNameFromTaggedValue( ModelElementFacade element, String name, Short nameMaxLength, Object separator) { return getSqlNameFromTaggedValue( null, element, name, nameMaxLength, null, separator); }