org.nuiton.topia.generator
Class TopiaGeneratorUtil

java.lang.Object
  extended by org.nuiton.eugene.GeneratorUtil
      extended by org.nuiton.topia.generator.TopiaGeneratorUtil

public class TopiaGeneratorUtil
extends org.nuiton.eugene.GeneratorUtil

Classe regroupant divers méthodes utiles pour la génération des entités


Field Summary
static java.lang.String DEFAULT_PACKAGE
          Le package par défaut si aucun n'est spécifié
static java.lang.String PERSISTENCE_TYPE_DEFAULT
          Type de persistence par défaut (si aucun précisé)
static java.lang.String PERSISTENCE_TYPE_HIBERNATE
          Type de persistence Hibernate
static java.lang.String PERSISTENCE_TYPE_LDAP
          Type de persistence LDAP
static java.lang.String PROPERTY_DEFAULT_PACKAGE
          Propriété des générateurs indiquant le package par défaut
static java.lang.String STEREOTYPE_ARRAY
          Stéréotype pour les attributs considérés comme des tableaux
static java.lang.String STEREOTYPE_BEAN
          Stéréotype pour les objets devant être générées sous forme de bean
static java.lang.String STEREOTYPE_DAO
          Stéréotype pour les interfaces devant être générées sous forme de DAO
static java.lang.String STEREOTYPE_DTO
          Stéréotype pour les objets devant être générées sous forme de DTO
static java.lang.String STEREOTYPE_ENTITY
          Stéréotype pour les objets devant être générées sous forme d'entités
static java.lang.String STEREOTYPE_FACADE
          Stéréotype pour les interfaces devant être générées sous forme de facades
static java.lang.String STEREOTYPE_INDEXED
          Stéréotype pour les attributs à indexer en base
static java.lang.String STEREOTYPE_PRIMARYKAY
          Stéréotype pour les attributs étant des clés primaires
static java.lang.String STEREOTYPE_SERVICE
          Stéréotype pour les interfaces devant être générées sous forme de services
static java.lang.String STEREOTYPE_UNIQUE
          Stéréotype pour les collections avec unicité
static java.lang.String TAG_ACCESS
          Tag pour specfier le type d'acces a un champ
static java.lang.String TAG_ANNOTATION
          Tag pour ajouter une annotation à un champ
static java.lang.String TAG_COPYRIGHT
          Tag pour ajouter specifier le copyright d'un fichier
static java.lang.String TAG_DB_NAME
          Tag pour le nom du champ / entité en BD
static java.lang.String TAG_EMBED_XML
          Tag pour spécifier la caractère embed-xml d'une association
static java.lang.String TAG_FETCH
          Tag pour spécifier la caractère fetch d'une association multiple
static java.lang.String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER
          Tag pour specfier si on doit générer la methode getOperator dans les daohelpers )
static java.lang.String TAG_I18N_PREFIX
          Tag pour specfier si on doit générer i18n
static java.lang.String TAG_LAZY
          Tag pour spécifier la caractèrelazy d'une association multiple
static java.lang.String TAG_LENGTH
          Tag pour la taille du champ en BD
static java.lang.String TAG_NATURAL_ID
          Tag pour ajouter un attribut dans une clef métier
static java.lang.String TAG_NATURAL_ID_MUTABLE
          Tag pour specifier si une clef metier est mutable
static java.lang.String TAG_NOT_GENERATE_TO_STRING
          Tag pour specifier de ne pas generer la methode toString
static java.lang.String TAG_NOT_NULL
          Tag pour spécifier la caractère not-null d'un attribut
static java.lang.String TAG_ORDER_BY
          Tag pour spécifier la caractère order-by d'une association multiple
static java.lang.String TAG_PERSISTENCE_TYPE
          Tag pour le type de persistence
static java.lang.String TAG_PROXY_INTERFACE
          Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut.
static java.lang.String TAG_SCHEMA_NAME
          Tag pour le nom du schema en BD
static java.lang.String TAG_SECURITY_CREATE
          Tag pour spécifier le permissions à la création
static java.lang.String TAG_SECURITY_DELETE
          Tag pour spécifier le permissions à la suppression
static java.lang.String TAG_SECURITY_LOAD
          Tag pour spécifier le permissions au chargement
static java.lang.String TAG_SECURITY_UPDATE
          Tag pour spécifier le permissions à la mise à jour
static java.lang.String TAG_SORT_ATTRIBUTE
          Tag pour specifier de trier les attributs par nom lors de la generation
 
Constructor Summary
TopiaGeneratorUtil()
           
 
Method Summary
static java.lang.String capitalize(java.lang.String s)
           
protected static java.util.List<java.lang.String> cleanImports(java.lang.String packageName, java.util.Set<java.lang.String> fqns)
          Clean a set of fqns, transform it into a List and sort it.
static java.lang.String convertVariableNameToConstantName(java.lang.String variableName)
          Convertit un nom de variable en nom de constante.
static java.lang.String findTagValue(java.lang.String tagName, org.nuiton.eugene.models.object.ObjectModelElement element, org.nuiton.eugene.models.Model model)
          Deprecated.  
static boolean generateToString(org.nuiton.eugene.models.object.ObjectModelClass clazz, org.nuiton.eugene.models.object.ObjectModel model)
          Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
static java.lang.String getAssocAttrName(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
          Renvoie le nom de l'attribut de classe d'association en fonction des cas: Si l'attribut porte le même nom que le type (extrémité inverse de l'association), on lui ajoute le nom de la classe d'association
static java.util.List<org.nuiton.eugene.models.object.ObjectModelClass> getClassesByStereotype(java.lang.String stereotype, org.nuiton.eugene.models.object.ObjectModel model, boolean sort)
          Obtain the list of classes for a given stereotype with the possibility to sort the result.
static java.lang.String getCopyright(org.nuiton.eugene.models.Model model)
          Cherches et renvoie le copyright a utiliser sur le model.
static org.nuiton.eugene.models.object.ObjectModelInterface getDAOInterface(org.nuiton.eugene.models.object.ObjectModelClass clazz, org.nuiton.eugene.models.object.ObjectModel model)
          Renvoie l'interface DAO associée à la classe passée en paramètre
static java.lang.String getDBName(org.nuiton.eugene.models.object.ObjectModelElement element)
          Renvoie le nom BD de l'élement passé en paramètre.
static java.lang.String getDefaultPackage(org.nuiton.eugene.AbstractGenerator<?> generator)
          Renvoie le package par défaut pour le générateur donné
static java.lang.String getDOType(org.nuiton.eugene.models.object.ObjectModelElement elem, org.nuiton.eugene.models.object.ObjectModel model)
           
static java.lang.String getDOType(java.lang.String type, org.nuiton.eugene.models.object.ObjectModel model)
           
static
<Type extends org.nuiton.eugene.models.object.ObjectModelElement>
java.util.Collection<Type>
getElementsWithStereotype(java.util.Collection<Type> elements, java.lang.String... stereotypes)
           
static java.util.List<org.nuiton.eugene.models.object.ObjectModelClass> getEntityClasses(org.nuiton.eugene.models.object.ObjectModel model, boolean sort)
          Obtain the list of entities classes with the possibility to sort the result.
static java.lang.String getI18nPrefix(org.nuiton.eugene.models.object.ObjectModelElement element, org.nuiton.eugene.models.object.ObjectModel model)
          Cherche et renvoie le prefixe i18n à utiliser sur cet element, sinon sur le model.
protected static void getImports(org.nuiton.eugene.models.object.ObjectModelClass aClass, java.util.Set<java.lang.String> fqns)
          Obtain the list of fqn of object involed in the given class.
static java.util.List<java.lang.String> getImports(org.nuiton.eugene.models.object.ObjectModelClass aClass, java.lang.String... incomingFqns)
          Obtain the list of fqn of object involed in the given class.
protected static void getImports(org.nuiton.eugene.models.object.ObjectModelInterface anInterface, java.util.Set<java.lang.String> fqns)
          Obtain the list of fqn of object involed in the given interface.
static java.util.List<java.lang.String> getImports(org.nuiton.eugene.models.object.ObjectModelInterface anInterface, java.lang.String... incomingFqns)
          Obtain the list of fqn of object involed in the given interface.
protected static void getImports(org.nuiton.eugene.models.object.ObjectModelOperation operation, java.util.Set<java.lang.String> fqns)
          Obtain the fqn's list of all involed type in a givne operation.
static java.lang.String getManyToManyTableName(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
          Renvoie le nom unique de table pour une relation ManyToMany en fonction de l'attribut attr

Plusieurs cas de figure:

static java.util.List<java.lang.String> getNaturalId(org.nuiton.eugene.models.object.ObjectModelClass clazz)
          Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
static java.lang.String getNMultiplicityHibernateType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
          Renvoie le type d'interface à utiliser en fonction de l'attribut
static java.lang.String getNMultiplicityInterfaceType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
          Renvoie le type d'interface à utiliser en fonction de l'attribut
static java.lang.String getNMultiplicityObjectType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
          Renvoie le type d'objet (instance) à utiliser en fonction de l'attribut
static java.lang.String getPersistenceType(org.nuiton.eugene.models.object.ObjectModelElement element)
          Renvoie le type de persistence pour l'élément donné.
static java.lang.String getPrimaryKeyAttributesListDeclaration(org.nuiton.eugene.models.object.ObjectModelClass clazz, boolean includeName)
           
static java.lang.String getReverseDBName(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
           
static java.lang.String getSchemaName(org.nuiton.eugene.models.object.ObjectModelElement element, org.nuiton.eugene.models.object.ObjectModel model)
          Cherche et renvoie le schema a utiliser sur cet element, sinon sur le model.
static java.lang.String getSimpleName(java.lang.String fqn)
           
static boolean hasDocumentation(org.nuiton.eugene.models.object.ObjectModelElement element)
          Deprecated.  
static boolean hasNothingOrAbstractMethods(org.nuiton.eugene.models.object.ObjectModelClass clazz)
          Indique si la classe specifiee n'a aucune ou que des methodes abstraites
static boolean hasStereotypes(org.nuiton.eugene.models.object.ObjectModelElement element, java.lang.String... stereotypes)
           
static boolean hasUnidirectionalRelationOnAbstractType(org.nuiton.eugene.models.object.ObjectModelAttribute attr, org.nuiton.eugene.models.object.ObjectModel model)
           Cette méthode permet de détecter si - l'attribut représente une relation 1-n - cette relation est unidirectionnelle - le type de l'attribut représente un entité - cette entité a des sous-classes dans le modèle

Ce cas correspond à une incompatibilité d'Hibernate qui nous oblige a adopter un comportement particulier.

static boolean isAssociationClassDoublon(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
           
static boolean isBooleanType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
           
static boolean isDateType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
           
static boolean isNaturalId(org.nuiton.eugene.models.object.ObjectModelAttribute attribute)
          Detecte si un attribut fait partie d'une clef metier.
static boolean isNaturalIdMutable(org.nuiton.eugene.models.object.ObjectModelClass clazz)
          Detecte si la clef metier d'une classe est mutable ou pas.
static boolean isNumericType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
           
static boolean isPrimitiveType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
           
static boolean isTextType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
           
static boolean notEmpty(java.lang.String s)
          Deprecated.  
static boolean shouldBeAbstract(org.nuiton.eugene.models.object.ObjectModelClass clazz)
          Indique si la classe specifiee devrait etre abstraite
static boolean shouldgenerateOperatorForDAOHelper(org.nuiton.eugene.models.object.ObjectModelElement element, org.nuiton.eugene.models.object.ObjectModel model)
          Cherche et renvoie le prefixe i18n à utiliser sur cet element, sinon sur le model.
static boolean sortAttribute(org.nuiton.eugene.models.object.ObjectModelClass clazz, org.nuiton.eugene.models.object.ObjectModel model)
          Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
 
Methods inherited from class org.nuiton.eugene.GeneratorUtil
computeSerialVersionUID, getAttributeType, getAttributeType, getCastValue, getClassAttributesListDeclaration, getClassifiers, getClassNameFromQualifiedName, getFilenameFromQualifiedName, getFormatingExpression, getHashCodeExpression, getInitValue, getInitValue, getMethodParameterDeclaration, getMethodParameterListName, getOperationParametersListDeclaration, getOperationParametersListName, getParentPackageName, getParsingExpression, getTypesList, hasStereotype, isComposition, isFirstAttribute, isNMultiplicity, isNMultiplicity, isOneMultiplicity, isPrimitiveAttributeType, toLowerCaseFirstLetter, toUpperCaseFirstLetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STEREOTYPE_FACADE

public static final java.lang.String STEREOTYPE_FACADE
Stéréotype pour les interfaces devant être générées sous forme de facades

See Also:
Constant Field Values

STEREOTYPE_ENTITY

public static final java.lang.String STEREOTYPE_ENTITY
Stéréotype pour les objets devant être générées sous forme d'entités

See Also:
Constant Field Values

STEREOTYPE_DTO

public static final java.lang.String STEREOTYPE_DTO
Stéréotype pour les objets devant être générées sous forme de DTO

See Also:
Constant Field Values

STEREOTYPE_BEAN

public static final java.lang.String STEREOTYPE_BEAN
Stéréotype pour les objets devant être générées sous forme de bean

See Also:
Constant Field Values

STEREOTYPE_SERVICE

public static final java.lang.String STEREOTYPE_SERVICE
Stéréotype pour les interfaces devant être générées sous forme de services

See Also:
Constant Field Values

STEREOTYPE_DAO

public static final java.lang.String STEREOTYPE_DAO
Stéréotype pour les interfaces devant être générées sous forme de DAO

See Also:
Constant Field Values

STEREOTYPE_INDEXED

public static final java.lang.String STEREOTYPE_INDEXED
Stéréotype pour les attributs à indexer en base

See Also:
Constant Field Values

STEREOTYPE_UNIQUE

public static final java.lang.String STEREOTYPE_UNIQUE
Stéréotype pour les collections avec unicité

See Also:
Constant Field Values

STEREOTYPE_PRIMARYKAY

public static final java.lang.String STEREOTYPE_PRIMARYKAY
Stéréotype pour les attributs étant des clés primaires

See Also:
Constant Field Values

STEREOTYPE_ARRAY

public static final java.lang.String STEREOTYPE_ARRAY
Stéréotype pour les attributs considérés comme des tableaux

See Also:
Constant Field Values

TAG_PERSISTENCE_TYPE

public static final java.lang.String TAG_PERSISTENCE_TYPE
Tag pour le type de persistence

See Also:
Constant Field Values

TAG_DB_NAME

public static final java.lang.String TAG_DB_NAME
Tag pour le nom du champ / entité en BD

See Also:
Constant Field Values

TAG_SCHEMA_NAME

public static final java.lang.String TAG_SCHEMA_NAME
Tag pour le nom du schema en BD

See Also:
Constant Field Values

TAG_LENGTH

public static final java.lang.String TAG_LENGTH
Tag pour la taille du champ en BD

See Also:
Constant Field Values

TAG_ANNOTATION

public static final java.lang.String TAG_ANNOTATION
Tag pour ajouter une annotation à un champ

See Also:
Constant Field Values

TAG_COPYRIGHT

public static final java.lang.String TAG_COPYRIGHT
Tag pour ajouter specifier le copyright d'un fichier

See Also:
Constant Field Values

TAG_ACCESS

public static final java.lang.String TAG_ACCESS
Tag pour specfier le type d'acces a un champ

See Also:
Constant Field Values

TAG_I18N_PREFIX

public static final java.lang.String TAG_I18N_PREFIX
Tag pour specfier si on doit générer i18n

See Also:
Constant Field Values

TAG_NATURAL_ID

public static final java.lang.String TAG_NATURAL_ID
Tag pour ajouter un attribut dans une clef métier

See Also:
Constant Field Values

TAG_NATURAL_ID_MUTABLE

public static final java.lang.String TAG_NATURAL_ID_MUTABLE
Tag pour specifier si une clef metier est mutable

See Also:
Constant Field Values

TAG_LAZY

public static final java.lang.String TAG_LAZY
Tag pour spécifier la caractèrelazy d'une association multiple

See Also:
Constant Field Values

TAG_FETCH

public static final java.lang.String TAG_FETCH
Tag pour spécifier la caractère fetch d'une association multiple

See Also:
Constant Field Values

TAG_ORDER_BY

public static final java.lang.String TAG_ORDER_BY
Tag pour spécifier la caractère order-by d'une association multiple

See Also:
Constant Field Values

TAG_NOT_NULL

public static final java.lang.String TAG_NOT_NULL
Tag pour spécifier la caractère not-null d'un attribut

See Also:
Constant Field Values

TAG_EMBED_XML

public static final java.lang.String TAG_EMBED_XML
Tag pour spécifier la caractère embed-xml d'une association

See Also:
Constant Field Values

TAG_PROXY_INTERFACE

public static final java.lang.String TAG_PROXY_INTERFACE
Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut. Par defaut : null > generere le proxy sur l'interface de l'implementation Autre valeur : "none" > laisse la configuration par defaut d'hibernate

See Also:
Constant Field Values

TAG_SECURITY_CREATE

public static final java.lang.String TAG_SECURITY_CREATE
Tag pour spécifier le permissions à la création

See Also:
Constant Field Values

TAG_SECURITY_LOAD

public static final java.lang.String TAG_SECURITY_LOAD
Tag pour spécifier le permissions au chargement

See Also:
Constant Field Values

TAG_SECURITY_UPDATE

public static final java.lang.String TAG_SECURITY_UPDATE
Tag pour spécifier le permissions à la mise à jour

See Also:
Constant Field Values

TAG_SECURITY_DELETE

public static final java.lang.String TAG_SECURITY_DELETE
Tag pour spécifier le permissions à la suppression

See Also:
Constant Field Values

TAG_NOT_GENERATE_TO_STRING

public static final java.lang.String TAG_NOT_GENERATE_TO_STRING
Tag pour specifier de ne pas generer la methode toString

See Also:
Constant Field Values

TAG_SORT_ATTRIBUTE

public static final java.lang.String TAG_SORT_ATTRIBUTE
Tag pour specifier de trier les attributs par nom lors de la generation

See Also:
Constant Field Values

TAG_GENERATE_OPERATOR_FOR_DAO_HELPER

public static final java.lang.String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER
Tag pour specfier si on doit générer la methode getOperator dans les daohelpers )

See Also:
Constant Field Values

PERSISTENCE_TYPE_HIBERNATE

public static final java.lang.String PERSISTENCE_TYPE_HIBERNATE
Type de persistence Hibernate

See Also:
Constant Field Values

PERSISTENCE_TYPE_LDAP

public static final java.lang.String PERSISTENCE_TYPE_LDAP
Type de persistence LDAP

See Also:
Constant Field Values

PERSISTENCE_TYPE_DEFAULT

public static final java.lang.String PERSISTENCE_TYPE_DEFAULT
Type de persistence par défaut (si aucun précisé)

See Also:
Constant Field Values

PROPERTY_DEFAULT_PACKAGE

public static final java.lang.String PROPERTY_DEFAULT_PACKAGE
Propriété des générateurs indiquant le package par défaut

See Also:
Constant Field Values

DEFAULT_PACKAGE

public static final java.lang.String DEFAULT_PACKAGE
Le package par défaut si aucun n'est spécifié

See Also:
Constant Field Values
Constructor Detail

TopiaGeneratorUtil

public TopiaGeneratorUtil()
Method Detail

getDefaultPackage

public static java.lang.String getDefaultPackage(org.nuiton.eugene.AbstractGenerator<?> generator)
Renvoie le package par défaut pour le générateur donné

Parameters:
generator - le générateur donné
Returns:
le package par défaut du générator donné

hasDocumentation

@Deprecated
public static boolean hasDocumentation(org.nuiton.eugene.models.object.ObjectModelElement element)
Deprecated. 

See Also:
GeneratorUtil.hasDocumentation(org.nuiton.eugene.models.object.ObjectModelElement)

notEmpty

@Deprecated
public static boolean notEmpty(java.lang.String s)
Deprecated. 

See Also:
GeneratorUtil.notEmpty(java.lang.String)

getDAOInterface

public static org.nuiton.eugene.models.object.ObjectModelInterface getDAOInterface(org.nuiton.eugene.models.object.ObjectModelClass clazz,
                                                                                   org.nuiton.eugene.models.object.ObjectModel model)
Renvoie l'interface DAO associée à la classe passée en paramètre

Parameters:
clazz - la classe à tester
model - le modele utilisé
Returns:
l'interface trouvée ou null sinon

getPersistenceType

public static java.lang.String getPersistenceType(org.nuiton.eugene.models.object.ObjectModelElement element)
Renvoie le type de persistence pour l'élément donné. Si aucun n'est trouvé, le type par défaut est utilisé

Parameters:
element - l'élément à tester
Returns:
le type de persitence pour l'élément donné.

getReverseDBName

public static java.lang.String getReverseDBName(org.nuiton.eugene.models.object.ObjectModelAttribute attr)

getDBName

public static java.lang.String getDBName(org.nuiton.eugene.models.object.ObjectModelElement element)
Renvoie le nom BD de l'élement passé en paramètre. Elle se base sur le tag associé si il existe, sinon sur le nom de l'élément

Parameters:
element - l'élément à tester
Returns:
le nom de table

getSchemaName

public static java.lang.String getSchemaName(org.nuiton.eugene.models.object.ObjectModelElement element,
                                             org.nuiton.eugene.models.object.ObjectModel model)
Cherche et renvoie le schema a utiliser sur cet element, sinon sur le model.

Parameters:
element - l'élément à tester
model - le modele utilisé
Returns:
le nom du schema ou null

getI18nPrefix

public static java.lang.String getI18nPrefix(org.nuiton.eugene.models.object.ObjectModelElement element,
                                             org.nuiton.eugene.models.object.ObjectModel model)
Cherche et renvoie le prefixe i18n à utiliser sur cet element, sinon sur le model.

Parameters:
element - l'élément à tester
model - le modele utilisé
Returns:
le prefix i18n ou null si non spécifié

shouldgenerateOperatorForDAOHelper

public static boolean shouldgenerateOperatorForDAOHelper(org.nuiton.eugene.models.object.ObjectModelElement element,
                                                         org.nuiton.eugene.models.object.ObjectModel model)
Cherche et renvoie le prefixe i18n à utiliser sur cet element, sinon sur le model.

Parameters:
element - l'élément à tester
model - le modele utilisé
Returns:
le prefix i18n ou null si non spécifié

getNaturalId

public static java.util.List<java.lang.String> getNaturalId(org.nuiton.eugene.models.object.ObjectModelClass clazz)
Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.

Parameters:
clazz - la classe à tester
Returns:
la liste des attributs de la clef métier ou null si pas de clef métier.

generateToString

public static boolean generateToString(org.nuiton.eugene.models.object.ObjectModelClass clazz,
                                       org.nuiton.eugene.models.object.ObjectModel model)
Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.

Parameters:
clazz - la classe à tester
model - le modele
Returns:
la liste des attributs de la clef métier ou null si pas de clef métier.

sortAttribute

public static boolean sortAttribute(org.nuiton.eugene.models.object.ObjectModelClass clazz,
                                    org.nuiton.eugene.models.object.ObjectModel model)
Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.

Parameters:
clazz - la classe à tester
model - le modele
Returns:
la liste des attributs de la clef métier ou null si pas de clef métier.

isNaturalId

public static boolean isNaturalId(org.nuiton.eugene.models.object.ObjectModelAttribute attribute)
Detecte si un attribut fait partie d'une clef metier.

Parameters:
attribute - l'attribut à tester
Returns:
true si l'attribut fait partie d'une clef metier, false sinon.

getCopyright

public static java.lang.String getCopyright(org.nuiton.eugene.models.Model model)
Cherches et renvoie le copyright a utiliser sur le model.

Parameters:
model - le modele utilisé
Returns:
le texte du copyright ou null

findTagValue

@Deprecated
public static java.lang.String findTagValue(java.lang.String tagName,
                                                       org.nuiton.eugene.models.object.ObjectModelElement element,
                                                       org.nuiton.eugene.models.Model model)
Deprecated. 

See Also:
GeneratorUtil.findTagValue(java.lang.String, org.nuiton.eugene.models.object.ObjectModelElement, org.nuiton.eugene.models.Model)

getElementsWithStereotype

public static <Type extends org.nuiton.eugene.models.object.ObjectModelElement> java.util.Collection<Type> getElementsWithStereotype(java.util.Collection<Type> elements,
                                                                                                                                     java.lang.String... stereotypes)

hasStereotypes

public static boolean hasStereotypes(org.nuiton.eugene.models.object.ObjectModelElement element,
                                     java.lang.String... stereotypes)

getPrimaryKeyAttributesListDeclaration

public static java.lang.String getPrimaryKeyAttributesListDeclaration(org.nuiton.eugene.models.object.ObjectModelClass clazz,
                                                                      boolean includeName)

capitalize

public static java.lang.String capitalize(java.lang.String s)

isAssociationClassDoublon

public static boolean isAssociationClassDoublon(org.nuiton.eugene.models.object.ObjectModelAttribute attr)

getAssocAttrName

public static java.lang.String getAssocAttrName(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
Renvoie le nom de l'attribut de classe d'association en fonction des cas: Si l'attribut porte le même nom que le type (extrémité inverse de l'association), on lui ajoute le nom de la classe d'association

Parameters:
attr - l'attribut a traiter
Returns:
le nom de l'attribut de classe d'association

getDOType

public static java.lang.String getDOType(org.nuiton.eugene.models.object.ObjectModelElement elem,
                                         org.nuiton.eugene.models.object.ObjectModel model)

getDOType

public static java.lang.String getDOType(java.lang.String type,
                                         org.nuiton.eugene.models.object.ObjectModel model)

isNumericType

public static boolean isNumericType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)

isTextType

public static boolean isTextType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)

isDateType

public static boolean isDateType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)

isBooleanType

public static boolean isBooleanType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)

isPrimitiveType

public static boolean isPrimitiveType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)

hasNothingOrAbstractMethods

public static boolean hasNothingOrAbstractMethods(org.nuiton.eugene.models.object.ObjectModelClass clazz)
Indique si la classe specifiee n'a aucune ou que des methodes abstraites

Parameters:
clazz - l'instance de ObjectModelClass
Returns:
true si la classe n'a que des operations abstraite ou aucune operation

shouldBeAbstract

public static boolean shouldBeAbstract(org.nuiton.eugene.models.object.ObjectModelClass clazz)
Indique si la classe specifiee devrait etre abstraite

Parameters:
clazz - l'instance de ObjectModelClass
Returns:
true dans ce cas, false sinon

hasUnidirectionalRelationOnAbstractType

public static boolean hasUnidirectionalRelationOnAbstractType(org.nuiton.eugene.models.object.ObjectModelAttribute attr,
                                                              org.nuiton.eugene.models.object.ObjectModel model)

Cette méthode permet de détecter si - l'attribut représente une relation 1-n - cette relation est unidirectionnelle - le type de l'attribut représente un entité - cette entité a des sous-classes dans le modèle

Ce cas correspond à une incompatibilité d'Hibernate qui nous oblige a adopter un comportement particulier.

Parameters:
attr - l'attribut a tester
model - le model
Returns:
true si et seulement si il s'agit bien de ce type de relation

getManyToManyTableName

public static java.lang.String getManyToManyTableName(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
Renvoie le nom unique de table pour une relation ManyToMany en fonction de l'attribut attr

Plusieurs cas de figure:

  • Parameters:
    attr - l'attribut servant de base au calcul du nom
    Returns:
    le nom de la table

  • getNMultiplicityInterfaceType

    public static java.lang.String getNMultiplicityInterfaceType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
    Renvoie le type d'interface à utiliser en fonction de l'attribut

    Parameters:
    attr - l'attribut a traiter
    Returns:
    String

    getNMultiplicityObjectType

    public static java.lang.String getNMultiplicityObjectType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
    Renvoie le type d'objet (instance) à utiliser en fonction de l'attribut

    Parameters:
    attr - l'attribut a traiter
    Returns:
    String

    getNMultiplicityHibernateType

    public static java.lang.String getNMultiplicityHibernateType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
    Renvoie le type d'interface à utiliser en fonction de l'attribut

    Parameters:
    attr - l'attribut a traiter
    Returns:
    String

    getEntityClasses

    public static java.util.List<org.nuiton.eugene.models.object.ObjectModelClass> getEntityClasses(org.nuiton.eugene.models.object.ObjectModel model,
                                                                                                    boolean sort)
    Obtain the list of entities classes with the possibility to sort the result.

    Parameters:
    model - the current model to scan
    sort - flag to allow sort the result
    Returns:
    the list of filtred classes by their stereotype

    getClassesByStereotype

    public static java.util.List<org.nuiton.eugene.models.object.ObjectModelClass> getClassesByStereotype(java.lang.String stereotype,
                                                                                                          org.nuiton.eugene.models.object.ObjectModel model,
                                                                                                          boolean sort)
    Obtain the list of classes for a given stereotype with the possibility to sort the result.

    Parameters:
    stereotype - filter stereotype
    model - the current model to scan
    sort - flag to allow sort the result
    Returns:
    the list of filtred classes by their stereotype

    isNaturalIdMutable

    public static boolean isNaturalIdMutable(org.nuiton.eugene.models.object.ObjectModelClass clazz)
    Detecte si la clef metier d'une classe est mutable ou pas.

    On respecte la valeur par defaut d'hibernate, à savoir que par default une clef metier est non mutable.

    Parameters:
    clazz - la classe a tester
    Returns:
    true si le tag value a ete positionne sur la classe via le tag TAG_NATURAL_ID_MUTABLE, , false sinon.

    getImports

    public static java.util.List<java.lang.String> getImports(org.nuiton.eugene.models.object.ObjectModelClass aClass,
                                                              java.lang.String... incomingFqns)
    Obtain the list of fqn of object involed in the given class.

    Parameters:
    aClass - the clazz to inspect
    incomingFqns - incoming fqns
    Returns:
    the list of fqn of attributes

    getImports

    public static java.util.List<java.lang.String> getImports(org.nuiton.eugene.models.object.ObjectModelInterface anInterface,
                                                              java.lang.String... incomingFqns)
    Obtain the list of fqn of object involed in the given interface.

    Parameters:
    anInterface - the interface to inspect
    incomingFqns - incoming fqns
    Returns:
    the list of fqn of attributes

    getSimpleName

    public static java.lang.String getSimpleName(java.lang.String fqn)

    getImports

    protected static void getImports(org.nuiton.eugene.models.object.ObjectModelClass aClass,
                                     java.util.Set<java.lang.String> fqns)
    Obtain the list of fqn of object involed in the given class.

    Parameters:
    aClass - the class to inspect
    fqns - where to store found fqns

    getImports

    protected static void getImports(org.nuiton.eugene.models.object.ObjectModelInterface anInterface,
                                     java.util.Set<java.lang.String> fqns)
    Obtain the list of fqn of object involed in the given interface.

    Parameters:
    anInterface - the interface to inspect
    fqns - where to store found fqns

    getImports

    protected static void getImports(org.nuiton.eugene.models.object.ObjectModelOperation operation,
                                     java.util.Set<java.lang.String> fqns)
    Obtain the fqn's list of all involed type in a givne operation.

    Parameters:
    operation - operation to inspect
    fqns - where to store found fqns

    cleanImports

    protected static java.util.List<java.lang.String> cleanImports(java.lang.String packageName,
                                                                   java.util.Set<java.lang.String> fqns)
    Clean a set of fqns, transform it into a List and sort it.

    Parameters:
    packageName - the current package name
    fqns - the dirty set of fqns
    Returns:
    the sorted cleaned list of fqns.

    convertVariableNameToConstantName

    public static java.lang.String convertVariableNameToConstantName(java.lang.String variableName)
    Convertit un nom de variable en nom de constante.

    Parameters:
    variableName - le nom de variable a convertir
    Returns:
    le nom de la constante à partir du nom de la variable


    Copyright © 2004-2009 CodeLutin. All Rights Reserved.