org.andromda.metafacades.uml
Class EntityMetafacadeUtils

java.lang.Object
  extended by org.andromda.metafacades.uml.EntityMetafacadeUtils

public class EntityMetafacadeUtils
extends java.lang.Object

Utilities for dealing with entity metafacades

Author:
Chad Brandon

Constructor Summary
EntityMetafacadeUtils()
           
 
Method Summary
static void clearForeignKeyConstraintNameCache()
          Clears out the foreign key cache.
static java.lang.String constructSqlTypeName(java.lang.String typeName, java.lang.String columnLength)
          Constructs a sql type name from the given mappedName and columnLength.
static java.lang.String ensureMaximumNameLength(java.lang.String name, java.lang.Short nameMaxLength)
          

Trims the passed in value to the maximum name length.

static java.lang.String getForeignKeyConstraintName(EntityAssociationEnd associationEnd, java.lang.String suffix, java.lang.String sqlNameSeperator, java.lang.String maxLengthProperty)
          Constructs and returns the foreign key constraint name for the given associationEnd, suffix, sqlNameSeperator and maxLengthProperty.
static java.util.Collection getIdentifiers(Entity entity, boolean follow)
          Gets all identifiers for an entity.
static java.lang.String getSqlNameFromTaggedValue(ModelElementFacade element, java.lang.String name, java.lang.Short nameMaxLength, java.lang.Object separator)
          Gets the SQL name.
static java.lang.String getSqlNameFromTaggedValue(ModelElementFacade element, java.lang.String name, java.lang.Short nameMaxLength, java.lang.String suffix, java.lang.Object separator)
          Gets the SQL name.
static java.lang.String getSqlNameFromTaggedValue(java.lang.String prefix, ModelElementFacade element, java.lang.String name, java.lang.Short nameMaxLength, java.lang.Object separator)
          Gets the SQL name.
static java.lang.String getSqlNameFromTaggedValue(java.lang.String prefix, ModelElementFacade element, java.lang.String name, java.lang.Short nameMaxLength, java.lang.String suffix, java.lang.Object separator)
          Gets the SQL name.
static java.lang.String toSqlName(java.lang.String modelElementName, java.lang.Object separator)
          

Converts a string following the Java naming conventions to a database attribute name.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityMetafacadeUtils

public EntityMetafacadeUtils()
Method Detail

toSqlName

public static java.lang.String toSqlName(java.lang.String modelElementName,
                                         java.lang.Object separator)

Converts a string following the Java naming conventions to a database attribute name. For example convert customerName to CUSTOMER_NAME.

Parameters:
modelElementName - the string to convert
separator - character used to separate words
Returns:
string converted to database attribute format

getSqlNameFromTaggedValue

public static java.lang.String getSqlNameFromTaggedValue(java.lang.String prefix,
                                                         ModelElementFacade element,
                                                         java.lang.String name,
                                                         java.lang.Short nameMaxLength,
                                                         java.lang.Object separator)
Gets the SQL name. (i.e. column name, table name, etc.). If it can't find the corresponding tagged value with the specified name, then it uses the element name by default and just returns that.

Parameters:
prefix - the optional prefix to add to the sql name (i.e. table name prefix, etc.).
element - from which to retrieve the SQL name.
name - the name of the tagged value.
nameMaxLength - if this is not null, then the name returned will be trimmed to this length (if it happens to be longer).
separator - character used to separate words
Returns:
the SQL name as a String.

getSqlNameFromTaggedValue

public static java.lang.String getSqlNameFromTaggedValue(ModelElementFacade element,
                                                         java.lang.String name,
                                                         java.lang.Short nameMaxLength,
                                                         java.lang.String suffix,
                                                         java.lang.Object separator)
Gets the SQL name. (i.e. column name, table name, etc.). If it can't find the corresponding tagged value with the specified name, then it uses the element name by default and just returns that.

Parameters:
element - from which to retrieve the SQL name.
name - the name of the tagged value.
nameMaxLength - if this is not null, then the name returned will be trimmed to this length (if it happens to be longer).
suffix - the optional suffix to add to the sql name (i.e. foreign key suffix, etc.)
separator - character used to separate words
Returns:
the SQL name as a String.

getSqlNameFromTaggedValue

public static java.lang.String getSqlNameFromTaggedValue(ModelElementFacade element,
                                                         java.lang.String name,
                                                         java.lang.Short nameMaxLength,
                                                         java.lang.Object separator)
Gets the SQL name. (i.e. column name, table name, etc.). If it can't find the corresponding tagged value with the specified name, then it uses the element name by default and just returns that.

Parameters:
element - from which to retrieve the SQL name.
name - the name of the tagged value.
nameMaxLength - if this is not null, then the name returned will be trimmed to this length (if it happens to be longer).
separator - character used to separate words
Returns:
the SQL name as a String.

getSqlNameFromTaggedValue

public static java.lang.String getSqlNameFromTaggedValue(java.lang.String prefix,
                                                         ModelElementFacade element,
                                                         java.lang.String name,
                                                         java.lang.Short nameMaxLength,
                                                         java.lang.String suffix,
                                                         java.lang.Object separator)
Gets the SQL name. (i.e. column name, table name, etc.). If it can't find the corresponding tagged value with the specified name, then it uses the element name by default and just returns that.

Parameters:
prefix - the optional prefix to add to the sql name (i.e. table name prefix, etc.).
element - from which to retrieve the SQL name.
name - the name of the tagged value.
nameMaxLength - if this is not null, then the name returned will be trimmed to this length (if it happens to be longer).
suffix - the optional suffix to add to the sql name (i.e. foreign key suffix, etc.)
separator - character used to separate words
Returns:
the SQL name as a String.

ensureMaximumNameLength

public static java.lang.String ensureMaximumNameLength(java.lang.String name,
                                                       java.lang.Short nameMaxLength)

Trims the passed in value to the maximum name length.

If no maximum length has been set then this method does nothing.

Parameters:
name - the name length to check and trim if necessary
nameMaxLength - if this is not null, then the name returned will be trimmed to this length (if it happens to be longer).
Returns:
String the string to be used as SQL type

getIdentifiers

public static java.util.Collection getIdentifiers(Entity entity,
                                                  boolean follow)
Gets all identifiers for an entity. If 'follow' is true, and if no identifiers can be found on the entity, a search up the inheritance chain will be performed, and the identifiers from the first super class having them will be used. If no identifiers exist, a default identifier will be created if the allowDefaultIdentifiers property is set to true.

Parameters:
entity - the entity for which to retrieve the identifiers
follow - a flag indicating whether or not the inheritance hiearchy should be followed
Returns:
the collection of identifiers.

constructSqlTypeName

public static java.lang.String constructSqlTypeName(java.lang.String typeName,
                                                    java.lang.String columnLength)
Constructs a sql type name from the given mappedName and columnLength.

Parameters:
typeName - the actual type name (usually retrieved from a mappings file, ie NUMBER(19).
columnLength - the length of the column.
Returns:
the new name co

getForeignKeyConstraintName

public static java.lang.String getForeignKeyConstraintName(EntityAssociationEnd associationEnd,
                                                           java.lang.String suffix,
                                                           java.lang.String sqlNameSeperator,
                                                           java.lang.String maxLengthProperty)
Constructs and returns the foreign key constraint name for the given associationEnd, suffix, sqlNameSeperator and maxLengthProperty.

Parameters:
associationEnd - the association end for which to construct the constraint name.
suffix - the suffix appeneded to the constraint name (if not limited by length).
sqlNameSeperator - the SQL name seperator to use (i.e. '_').
maxLengthProperty - the numeric value stored as a string indicating the max length the constraint may be.
Returns:
the constructed foreign key constraint name.

clearForeignKeyConstraintNameCache

public static void clearForeignKeyConstraintNameCache()
Clears out the foreign key cache.



Copyright © 2003-2008 AndroMDA.org. All Rights Reserved.