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 String DEFAULT_PACKAGE
          Le package par défaut si aucun n'est spécifié
static String PERSISTENCE_TYPE_DEFAULT
          Type de persistence par défaut (si aucun précisé)
static String PERSISTENCE_TYPE_HIBERNATE
          Type de persistence Hibernate
static String PERSISTENCE_TYPE_LDAP
          Type de persistence LDAP
static String PROPERTY_DEFAULT_PACKAGE
          Propriété des générateurs indiquant le package par défaut
static String STEREOTYPE_ARRAY
          Stéréotype pour les attributs considérés comme des tableaux
static String STEREOTYPE_BEAN
          Stéréotype pour les objets devant être générées sous forme de bean
static String STEREOTYPE_DAO
          Stéréotype pour les interfaces devant être générées sous forme de DAO
static String STEREOTYPE_DTO
          Stéréotype pour les objets devant être générées sous forme de DTO
static String STEREOTYPE_ENTITY
          Stéréotype pour les objets devant être générées sous forme d'entités
static String STEREOTYPE_FACADE
          Stéréotype pour les interfaces devant être générées sous forme de facades
static String STEREOTYPE_INDEXED
          Stéréotype pour les attributs à indexer en base
static String STEREOTYPE_PRIMARYKAY
          Stéréotype pour les attributs étant des clés primaires
static String STEREOTYPE_SERVICE
          Stéréotype pour les interfaces devant être générées sous forme de services
static String STEREOTYPE_UNIQUE
          Stéréotype pour les collections avec unicité
static String TAG_ACCESS
          Tag pour specfier le type d'acces a un champ
static String TAG_ANNOTATION
          Tag pour ajouter une annotation à un champ
static String TAG_COPYRIGHT
          Tag pour ajouter specifier le copyright d'un fichier
static String TAG_DB_NAME
          Tag pour le nom du champ / entité en BD
static String TAG_EMBED_XML
          Tag pour spécifier la caractère embed-xml d'une association
static String TAG_FETCH
          Tag pour spécifier la caractère fetch d'une association multiple
static String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER
          Tag pour specfier si on doit générer la methode getOperator dans les daohelpers )
static String TAG_I18N_PREFIX
          Tag pour specfier si on doit générer i18n
static String TAG_LAZY
          Tag pour spécifier la caractère lazy d'une association multiple
static String TAG_LENGTH
          Tag pour la taille du champ en BD
static String TAG_NATURAL_ID
          Tag pour ajouter un attribut dans une clef métier
static String TAG_NATURAL_ID_MUTABLE
          Tag pour specifier si une clef metier est mutable
static String TAG_NOT_GENERATE_TO_STRING
          Tag pour specifier de ne pas generer la methode toString
static String TAG_NOT_NULL
          Tag pour spécifier la caractère not-null d'un attribut
static String TAG_ORDER_BY
          Tag pour spécifier la caractère order-by d'une association multiple
static String TAG_PERSISTENCE_TYPE
          Tag pour le type de persistence
static String TAG_PROXY_INTERFACE
          Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut.
static String TAG_SCHEMA_NAME
          Tag pour le nom du schema en BD
static String TAG_SECURITY_CREATE
          Tag pour spécifier le permissions à la création
static String TAG_SECURITY_DELETE
          Tag pour spécifier le permissions à la suppression
static String TAG_SECURITY_LOAD
          Tag pour spécifier le permissions au chargement
static String TAG_SECURITY_UPDATE
          Tag pour spécifier le permissions à la mise à jour
static String TAG_SORT_ATTRIBUTE
          Tag pour specifier de trier les attributs par nom lors de la generation
 
Constructor Summary
TopiaGeneratorUtil()
           
 
Method Summary
protected static List<String> cleanImports(String packageName, Set<String> fqns)
          Clean a set of fqns, transform it into a List and sort it.
static String convertVariableNameToConstantName(String variableName)
          Convertit un nom de variable en nom de constante.
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 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 List<org.nuiton.eugene.models.object.ObjectModelClass> getClassesByStereotype(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 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 String getDBName(org.nuiton.eugene.models.object.ObjectModelElement element)
          Renvoie le nom BD de l'élement passé en paramètre.
static String getDefaultPackage(org.nuiton.eugene.AbstractGenerator<?> generator)
          Renvoie le package par défaut pour le générateur donné
static String getDOType(org.nuiton.eugene.models.object.ObjectModelElement elem, org.nuiton.eugene.models.object.ObjectModel model)
           
static String getDOType(String type, org.nuiton.eugene.models.object.ObjectModel model)
           
static
<Type extends org.nuiton.eugene.models.object.ObjectModelElement>
Collection<Type>
getElementsWithStereotype(Collection<Type> elements, String... stereotypes)
           
static 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 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, Set<String> fqns)
          Obtain the list of fqn of object involed in the given class.
static List<String> getImports(org.nuiton.eugene.models.object.ObjectModelClass aClass, 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, Set<String> fqns)
          Obtain the list of fqn of object involed in the given interface.
static List<String> getImports(org.nuiton.eugene.models.object.ObjectModelInterface anInterface, 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, Set<String> fqns)
          Obtain the fqn's list of all involed type in a givne operation.
static 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 List<String> getNaturalId(org.nuiton.eugene.models.object.ObjectModelClass clazz)
          Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
static String getNMultiplicityHibernateType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
          Renvoie le type d'interface à utiliser en fonction de l'attribut
static String getNMultiplicityInterfaceType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
          Renvoie le type d'interface à utiliser en fonction de l'attribut
static String getNMultiplicityObjectType(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
          Renvoie le type d'objet (instance) à utiliser en fonction de l'attribut
static String getPersistenceType(org.nuiton.eugene.models.object.ObjectModelElement element)
          Renvoie le type de persistence pour l'élément donné.
static String getPrimaryKeyAttributesListDeclaration(org.nuiton.eugene.models.object.ObjectModelClass clazz, boolean includeName)
           
static String getReverseDBName(org.nuiton.eugene.models.object.ObjectModelAttribute attr)
           
static 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 String getSimpleName(String fqn)
           
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, 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 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
capitalize, computeSerialVersionUID, findTagValue, getAttributeType, getAttributeType, getCastValue, getClassAttributesListDeclaration, getClassifiers, getClassNameFromQualifiedName, getFilenameFromQualifiedName, getFormatingExpression, getHashCodeExpression, getInitValue, getInitValue, getMethodParameterDeclaration, getMethodParameterListName, getOperationParametersListDeclaration, getOperationParametersListName, getParentPackageName, getParsingExpression, getTypesList, hasDocumentation, hasStereotype, isComposition, isFirstAttribute, isNMultiplicity, isNMultiplicity, isOneMultiplicity, isPrimitiveAttributeType, notEmpty, 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 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 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 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 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 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 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 String STEREOTYPE_INDEXED
Stéréotype pour les attributs à indexer en base

See Also:
Constant Field Values

STEREOTYPE_UNIQUE

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

See Also:
Constant Field Values

STEREOTYPE_PRIMARYKAY

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

See Also:
Constant Field Values

STEREOTYPE_ARRAY

public static final 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 String TAG_PERSISTENCE_TYPE
Tag pour le type de persistence

See Also:
Constant Field Values

TAG_DB_NAME

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

See Also:
Constant Field Values

TAG_SCHEMA_NAME

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

See Also:
Constant Field Values

TAG_LENGTH

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

See Also:
Constant Field Values

TAG_ANNOTATION

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

See Also:
Constant Field Values

TAG_COPYRIGHT

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

See Also:
Constant Field Values

TAG_ACCESS

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

See Also:
Constant Field Values

TAG_I18N_PREFIX

public static final 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 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 String TAG_NATURAL_ID_MUTABLE
Tag pour specifier si une clef metier est mutable

See Also:
Constant Field Values

TAG_LAZY

public static final String TAG_LAZY
Tag pour spécifier la caractère lazy d'une association multiple

See Also:
Constant Field Values

TAG_FETCH

public static final 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 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 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 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 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 String TAG_SECURITY_CREATE
Tag pour spécifier le permissions à la création

See Also:
Constant Field Values

TAG_SECURITY_LOAD

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

See Also:
Constant Field Values

TAG_SECURITY_UPDATE

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

See Also:
Constant Field Values

TAG_SECURITY_DELETE

public static final 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 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 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 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 String PERSISTENCE_TYPE_HIBERNATE
Type de persistence Hibernate

See Also:
Constant Field Values

PERSISTENCE_TYPE_LDAP

public static final String PERSISTENCE_TYPE_LDAP
Type de persistence LDAP

See Also:
Constant Field Values

PERSISTENCE_TYPE_DEFAULT

public static final 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 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 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 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é

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 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 String getReverseDBName(org.nuiton.eugene.models.object.ObjectModelAttribute attr)

getDBName

public static 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 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 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 List<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 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

getElementsWithStereotype

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

hasStereotypes

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

getPrimaryKeyAttributesListDeclaration

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

isAssociationClassDoublon

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

getAssocAttrName

public static 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 String getDOType(org.nuiton.eugene.models.object.ObjectModelElement elem,
                               org.nuiton.eugene.models.object.ObjectModel model)

getDOType

public static String getDOType(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 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 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 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 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 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 List<org.nuiton.eugene.models.object.ObjectModelClass> getClassesByStereotype(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 List<String> getImports(org.nuiton.eugene.models.object.ObjectModelClass aClass,
                                          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 List<String> getImports(org.nuiton.eugene.models.object.ObjectModelInterface anInterface,
                                          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 String getSimpleName(String fqn)

    getImports

    protected static void getImports(org.nuiton.eugene.models.object.ObjectModelClass aClass,
                                     Set<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,
                                     Set<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,
                                     Set<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 List<String> cleanImports(String packageName,
                                               Set<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 String convertVariableNameToConstantName(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-2010 CodeLutin. All Rights Reserved.