Index: topia/src/java/org/codelutin/topia/Util.java diff -u topia/src/java/org/codelutin/topia/Util.java:1.7 topia/src/java/org/codelutin/topia/Util.java:1.8 --- topia/src/java/org/codelutin/topia/Util.java:1.7 Fri Jun 18 18:29:19 2004 +++ topia/src/java/org/codelutin/topia/Util.java Mon Jun 21 09:51:17 2004 @@ -23,185 +23,17 @@ * * @author Cédric Pineau * Copyright Code Lutin -* @version $Revision: 1.7 $ +* @version $Revision: 1.8 $ * -* Last update : $Date: 2004/06/18 18:29:19 $ +* Last update : $Date: 2004/06/21 09:51:17 $ * by : $Author: bpoussin $ */ package org.codelutin.topia; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -import org.codelutin.generator.models.object.ObjectModelParameter; -import org.codelutin.generator.models.object.ObjectModelAttribute; -import org.codelutin.generator.models.object.ObjectModelClass; -import org.codelutin.generator.models.object.ObjectModelClassifier; -import org.codelutin.generator.models.object.ObjectModelOperation; - /** - * @author cedric - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * Classe contenant des methodes utiles pour le framework. */ -public class Util extends org.codelutin.generator.Util { - - /** - * Returns all attributes that are part of the primary key for this class. - * @see ObjectModelAttribute - * - * @return a Collection containing all ObjectModelAttribute for this class. - */ - public static Collection getPrimaryKeyAttributes(ObjectModelClass clazz) { - ArrayList primaryKeyAttributes = new ArrayList(); - for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { - ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); - if (isPrimaryKey(attribute)) { - primaryKeyAttributes.add(attribute); - } - } - return primaryKeyAttributes; - } - - /** - * Returns whether this classifier is an entity or not. - * - * @return a boolean indicating whether this classifier is an entity or not. - */ - public static boolean isEntity(ObjectModelClassifier classifier) { - return classifier.hasStereotype("entity"); - } - - /** - * Returns whether this classifier is a service or not. - * - * @return a boolean indicating whether this classifier is a service or not. - */ - public static boolean isService(ObjectModelClassifier classifier) { - return classifier.hasStereotype("service"); - } - - /** - * Returns whether this classifier is a controller or not. - * - * @return a boolean indicating whether this classifier is a controller or not. - */ - public static boolean isController(ObjectModelClassifier classifier) { - return classifier.hasStereotype("controller"); - } - - /** - * Returns whether this classifier is a utility or not. - * - * @return a boolean indicating whether this classifier is a utility or not. - */ - public static boolean isUtility(ObjectModelClassifier classifier) { - return classifier.hasStereotype("utility"); - } - - /** - * Returns the needed transaction level of this operation. - * Possible values includes required, requiresNew, mandatory, supports, notSupported and never. - * - * @return the the needed transaction level of this operation. - */ - public static String getTransactionLevel(ObjectModelOperation operation) { - return operation.getTagValue("transactionLevel"); - } - - public static boolean isReadOnly(ObjectModelAttribute attribute) { - String value = attribute.getTagValue("readOnly"); - return "true".equals(value); - } - - public static boolean isPrimaryKey(ObjectModelAttribute attribute) { - String value = attribute.getTagValue("primaryKey"); - return "true".equals(value); - } - - public static boolean isMandatory(ObjectModelAttribute attribute) { - String value = attribute.getTagValue("mandatory"); - return "true".equals(value); - } - - /** - * Returns whether this attribute is derived (calculated) or not. - * - * @return a boolean indicating whether this attribute is derived or not. - */ - public static boolean isDerived(ObjectModelAttribute attribute) { - String value = attribute.getTagValue("derived"); - return "true".equals(value); - } - - public static boolean isDerived(ObjectModelClass clazz){ - for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { - ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); - if (isDerived(attribute)) { - return true; - } - } - return false; - } - - /** - * Returns the creation pattern for this auto valued attribute. - * - * @return the creation pattern for this auto valued attribute. - */ - public static String getDefaultValue(ObjectModelAttribute attribute) { - return attribute.getTagValue("defaultValue"); - } - - /** - * Returns the rendering pattern for this attribute. - * - * @return the rendering pattern for this attribute. - */ - public static String getMask(ObjectModelAttribute attribute) { - return attribute.getTagValue("mask"); - } - - /** - * Returns the enumeration name of values for this attribute. - * - * @return the the enumeration name of values for this attribute. - */ - public static String getEnumName(ObjectModelAttribute attribute) { - return attribute.getTagValue("enumName"); - } - /** - * Returns whether this attribute is to be internationalized or not. - * - * @return a boolean indicating whether this attribute is to be internationalized or not. - */ - public static boolean isI18n(ObjectModelAttribute attribute) { - String value = attribute.getTagValue("i18n"); - return "true".equals(value); - } - - /** - * Returns whether this attribute is to be versioned or not. - * - * @return a boolean indicating whether this attribute is to be versioned or not. - */ - public static boolean isVersioned(ObjectModelAttribute attribute) { - String value = attribute.getTagValue("versioned"); - return "true".equals(value); - } - - public static String getAttributeTypeForDO(ObjectModelParameter attribute) { - String result; - if (attribute instanceof ObjectModelAttribute - && isNMultiplicity((ObjectModelAttribute)attribute)){ - result = "java.util.List"; - }else{ - result = attribute.getType(); - } - return result; - } +public class Util { /** * Returns a TopiaEntityTO from a TopiaEntityTO or a TopiaEntityTOProxy.