public class EntityMetafacadeUtils extends Object
Constructor and Description |
---|
EntityMetafacadeUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
clearForeignKeyConstraintNameCache()
Clears out the foreign key cache.
|
static String |
constructSqlTypeName(String typeName,
String columnLength)
Constructs a sql type name from the given
mappedName and
columnLength . |
static String |
ensureMaximumNameLength(String name,
Short nameMaxLength,
String method)
Trims the passed in value to the maximum name length.
|
static String |
getForeignKeyConstraintName(EntityAssociationEnd associationEnd,
String suffix,
String sqlNameSeparator,
String maxLengthProperty,
String shortenSqlNamesMethod)
Constructs and returns the foreign key constraint name for the given
associationEnd , suffix , sqlNameSeparator
and maxLengthProperty . |
static Collection<ModelElementFacade> |
getIdentifierAttributes(Entity entity,
boolean follow)
Gets all identifier attributes for an entity.
|
static Collection<ModelElementFacade> |
getIdentifiers(Entity entity,
boolean follow)
Gets all identifiers for an entity.
|
static int |
getPriority(Entity entity)
Gets the execution priority of a specific entity, based on dependency/owning relationships,
so that TestNG unit tests can be put in the proper order across all entities and CRUD methods
|
static String |
getSqlNameFromTaggedValue(ModelElementFacade element,
String name,
Short nameMaxLength,
Object separator,
Object shortenSqlNamesMethod)
Gets the SQL name.
|
static String |
getSqlNameFromTaggedValue(ModelElementFacade element,
String name,
Short nameMaxLength,
String suffix,
Object separator,
Object shortenSqlNamesMethod)
Gets the SQL name.
|
static String |
getSqlNameFromTaggedValue(String prefix,
ModelElementFacade element,
String name,
Short nameMaxLength,
Object separator,
Object shortenSqlNamesMethod)
Gets the SQL name.
|
static String |
getSqlNameFromTaggedValue(String prefix,
ModelElementFacade element,
String name,
Short nameMaxLength,
String suffix,
Object separator,
Object shortenSqlNamesMethod)
Gets the SQL name.
|
static PackageFacade |
getTopLevelPackage(LinkedHashSet<ClassifierFacade> classifiers,
boolean entityOnly)
Finds the top level package in the model containing any classes or entity classes.
|
static List<Entity> |
sortEntities(Collection<Entity> entities,
boolean ascending)
Puts non-abstract entities in order based on associations.
|
static String |
toSqlName(String modelElementName,
Object separator)
Converts a string following the Java naming conventions to a
database attribute name.
|
public EntityMetafacadeUtils()
public static String toSqlName(String modelElementName, Object separator)
modelElementName
- the string to convertseparator
- character used to separate wordspublic static String getSqlNameFromTaggedValue(String prefix, ModelElementFacade element, String name, Short nameMaxLength, Object separator, Object shortenSqlNamesMethod)
name
,
then it uses the element name by default and just returns that.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 wordsshortenSqlNamesMethod
- Method of shortening SQL Names, i.e. removeVowelspublic static String getSqlNameFromTaggedValue(ModelElementFacade element, String name, Short nameMaxLength, String suffix, Object separator, Object shortenSqlNamesMethod)
name
,
then it uses the element name by default and just returns that.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 wordsshortenSqlNamesMethod
- Method of shortening SQL Names, i.e. removeVowelspublic static String getSqlNameFromTaggedValue(ModelElementFacade element, String name, Short nameMaxLength, Object separator, Object shortenSqlNamesMethod)
name
,
then it uses the element name by default and just returns that.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 wordsshortenSqlNamesMethod
- Method of shortening SQL Names, i.e. removeVowelspublic static String getSqlNameFromTaggedValue(String prefix, ModelElementFacade element, String name, Short nameMaxLength, String suffix, Object separator, Object shortenSqlNamesMethod)
name
,
then it uses the element name by default and just returns that.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 wordsshortenSqlNamesMethod
- Method of shortening SQL Names, i.e. removeVowelspublic static List<Entity> sortEntities(Collection<Entity> entities, boolean ascending)
entities
- the entity list to be sorted.ascending
- true for entities with no associations first.public static int getPriority(Entity entity)
entity
- the entity to be prioritized.public static String ensureMaximumNameLength(String name, Short nameMaxLength, String method)
name
- the name length to check and trim if necessarynameMaxLength
- if this is not null, then the name returned will be
trimmed to this length (if it happens to be longer).method
- Method of shortening SQL Names, i.e. removeVowelspublic static Collection<ModelElementFacade> getIdentifiers(Entity entity, boolean follow)
entity
- the entity for which to retrieve the identifiersfollow
- a flag indicating whether or not the inheritance hierarchy
should be followedpublic static Collection<ModelElementFacade> getIdentifierAttributes(Entity entity, boolean follow)
entity
- the entity for which to retrieve the identifiersfollow
- a flag indicating whether or not the inheritance hierarchy
should be followedpublic static String constructSqlTypeName(String typeName, String columnLength)
mappedName
and
columnLength
.typeName
- the actual type name (usually retrieved from a mappings
file, i.e. NUMBER(19).columnLength
- the length of the column.public static String getForeignKeyConstraintName(EntityAssociationEnd associationEnd, String suffix, String sqlNameSeparator, String maxLengthProperty, String shortenSqlNamesMethod)
associationEnd
, suffix
, sqlNameSeparator
and maxLengthProperty
.associationEnd
- the association end for which to construct the constraint name.suffix
- the suffix appended to the constraint name (if not limited by length).sqlNameSeparator
- the SQL name separator to use (i.e. '_').maxLengthProperty
- the numeric value stored as a string indicating the max length the constraint may be.shortenSqlNamesMethod
- Method of shortening SQL Names, i.e. removeVowelspublic static void clearForeignKeyConstraintNameCache()
public static PackageFacade getTopLevelPackage(LinkedHashSet<ClassifierFacade> classifiers, boolean entityOnly)
classifiers
- Entities in the current modelentityOnly
- true to find the top package containing entitiesCopyright © 2003–2014 AndroMDA.org. All rights reserved.