Index: topia/src/java/org/codelutin/topia/generators/Util.java diff -u topia/src/java/org/codelutin/topia/generators/Util.java:1.8 topia/src/java/org/codelutin/topia/generators/Util.java:1.9 --- topia/src/java/org/codelutin/topia/generators/Util.java:1.8 Thu Jul 21 12:54:50 2005 +++ topia/src/java/org/codelutin/topia/generators/Util.java Tue Jul 26 13:51:58 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ * - * Mise a jour: $Date: 2005/07/21 12:54:50 $ + * Mise a jour: $Date: 2005/07/26 13:51:58 $ * par : $Author: thimel $ */ @@ -286,6 +286,8 @@ * @return a boolean indicationg if the given attribute is an Entity */ public static boolean isAttributeEntity(ObjectModelAttribute attribute) { + if (attribute == null) + return false; if (!(attribute.getClassifier() instanceof ObjectModelClassifier)) return false; return isEntity((ObjectModelClassifier)attribute.getClassifier()); @@ -371,6 +373,33 @@ return output; } - + /** + * Renvoie le nom de la classe d'association concernant l'attribut donné + * @param attr l'attribut dont on souhaite connaitre la class d'association associée + * @return Une String représentant la class d'association + */ + public static String getAssociationClassName(ObjectModelAttribute attr) { + if (attr.hasAssociationClass()) { + return attr.getAssociationClass().getQualifiedName(); + } + String packageName; + String output; + String local = attr.getName(); + String reverse = null; + if (attr.getReverseAttribute() != null) { + reverse = attr.getReverseAttribute().getName(); + if (local.compareTo(reverse) < 0) { + packageName = attr.getClassifier().getPackageName(); + output = capitalize(local) + capitalize(reverse); + } else { + packageName = attr.getReverseAttribute().getClassifier().getPackageName(); + output = capitalize(reverse) + capitalize(local); + } + } else { + packageName = attr.getClassifier().getPackageName(); + output = capitalize(local); + } + return packageName + "._associations_.Assoc" + output; + } } // Util