r1938 - in trunk: topia-persistence/src/main/java/org/nuiton/topia/framework topia-persistence/src/main/java/org/nuiton/topia/generator topia-persistence/src/main/java/org/nuiton/topia/persistence topia-persistence/src/main/java/org/nuiton/topia/persistence/util topia-persistence/src/test/java/org/nuiton/topia/generator topia-persistence/src/test/java/org/nuiton/topia/persistence topia-persistence/src/test/java/org/nuiton/topia/persistence/util topia-persistence/src/test/java/org/nuiton/topi
Author: fdesbois Date: 2010-05-07 22:50:21 +0200 (Fri, 07 May 2010) New Revision: 1938 Url: http://nuiton.org/repositories/revision/topia/1938 Log: - Evo #578 : start put deprecated methods for entities and daos. - Add javadoc for TopiaEntity and TopiaDAO Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntity.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityAbstract.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityRef.java trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/ExportXMLVisitor.java trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTester.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/deletetest/DeleteEntityTest.java trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/ManualMigrationEngine.java trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachAssociation.java trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachLink.java trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/AbstractReplicationEngineTest.java trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/ReplicationEngineTest.java trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationOperationTest.java trunk/topia-service-security/src/main/java/org/nuiton/topia/security/TopiaSecurityServiceImpl.java trunk/topia-service-security/src/main/java/org/nuiton/topia/security/jaas/TopiaLoginModule.java trunk/topia-service-security/src/main/java/org/nuiton/topia/security/util/TopiaSecurityFactoryFilter.java trunk/topia-service-security/src/main/java/org/nuiton/topia/security/util/TopiaSecurityUtil.java trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/TaasService.java trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/event/TaasEntityVetoable.java trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/event/TaasEntityVetoableRequestPermission.java trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/jaas/TaasLoginModule.java trunk/topia-service-security/src/test/java/org/nuiton/topia/security/TopiaSecurityTest.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -710,6 +710,7 @@ try { for (TopiaDAO<? extends TopiaEntity> dao : daoCache.values()) { + // TODO-fdesbois-20100507 : need to be removed for 2.5 version dao.commitTransaction(); } Transaction tx = hibernate.getTransaction(); @@ -754,6 +755,7 @@ "rollback")); try { for (TopiaDAO<? extends TopiaEntity> dao : daoCache.values()) { + // TODO-fdesbois-20100507 : need to be removed for 2.5 version dao.rollbackTransaction(); } Transaction tx = hibernate.getTransaction(); @@ -922,8 +924,8 @@ /** * Execute HQL operation on data (Update, Delete) * - * @param hql - * @param args + * @param hql HQL query + * @param args arguments for query * @return The number of entities updated or deleted. * @throws TopiaException */ @@ -956,7 +958,7 @@ "topia.persistence.error.unsupported.operation.on.closed.context", "add")); - String id = e.getTopiaId(); + String id = e.getId(); Class<TopiaEntity> entityClass = TopiaId.getClassName(id); TopiaDAO<TopiaEntity> dao = getDAO(entityClass); dao.update(e); Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -1004,7 +1004,7 @@ TopiaContext transaction, Class<E> entityClass) throws TopiaException, ClassCastException { return executeToEntityMap(transaction, entityClass, - TopiaEntity.TOPIA_ID, String.class); + TopiaEntity.ID, String.class); } /** Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -68,7 +68,7 @@ * Logger */ private static final Log log = LogFactory.getLog(TopiaGeneratorUtil.class); - + /** * Stéréotype pour les interfaces devant être générées sous forme de facades */ @@ -404,31 +404,6 @@ * d'une classe. * * @param clazz la classe à tester - * @return la liste des attributs de la clef métier ou null si pas de clef - * métier. - * @deprecated since 2.3.0 use - * {@link #getNaturalIdAttributes(ObjectModelClass) } instead - * this usage is not allowed, prefer put tagvalue.naturalId on each - * entity attribute needed - */ - @Deprecated - public static List<String> getNaturalId(ObjectModelClass clazz) { - String value = clazz.getTagValue(TAG_NATURAL_ID); - if (value == null || value.trim().isEmpty()) { - return Collections.emptyList(); - } - List<String> result = new ArrayList<String>(); - for (String attribute : value.split(",")) { - result.add(attribute.trim()); - } - return result; - } - - /** - * Cherche et renvoie la liste des attributs constituant la clef metier - * d'une classe. - * - * @param clazz la classe à tester * @return la liste des attributs de la clef métier */ public static List<ObjectModelAttribute> getNaturalIdAttributes( @@ -802,12 +777,6 @@ result = revers + '_' + name; } } - // String result; - // if (!Util.isFirstAttribute(attr)) { - // result = attr.getDeclaringElement().getName() + "_" + attr.getReverseAttribute().getDeclaringElement().getName(); - // } else { - // result = attr.getReverseAttribute().getDeclaringElement().getName() + "_" + attr.getDeclaringElement().getName(); - // } return result.toLowerCase(); } @@ -971,29 +940,6 @@ } /** - * - * @param fqn fqn to parse - * @return the simple name of fqn - * @deprecated since 2.0.2 : already in GeneratorUtil - */ - @Deprecated - public static String getSimpleName(String fqn) { - return GeneratorUtil.getSimpleName(fqn); -// int lasIndex = fqn.lastIndexOf("."); -// if (lasIndex == 1) { -// // primitive type -// return fqn; -// } -// return fqn.substring(lasIndex + 1); - /*if (lasIndex == aClass.getPackageName().length()) { - // same package - return fqn.substring(lasIndex + 1); - } - - return fqn;*/ - } - - /** * Obtain the list of fqn of object involed in the given class. * * @param aClass the class to inspect @@ -1116,39 +1062,6 @@ return result; } - /** - * Convertit un nom de variable en nom de constante. - * - * @param variableName le nom de variable a convertir - * @return le nom de la constante à partir du nom de la variable - * @deprecated since 2.3, prefer use the - * {@link org.nuiton.eugene.java.ConstantsManagerExtension}. Will be removed - * in version 3. - */ - @Deprecated - public static String convertVariableNameToConstantName(String variableName) { - //TODO Faire des tests pour savoir si variableName est non null et valide - //TODO Ameliorer l'algo pour tenir compte des caractères non alpha - //TODO pour le moment cela convient, donc... - StringBuilder buffer = new StringBuilder(); - boolean lastCarIsUp = false; - for (int i = 0, j = variableName.length(); i < j; i++) { - char c = variableName.charAt(i); - boolean carIsUp = Character.isUpperCase(c); - if (i > 0 && !lastCarIsUp && carIsUp) { - // ajout d'un _ - buffer.append('_'); - } - if (carIsUp) { - buffer.append(c); - } else { - buffer.append(Character.toUpperCase(c)); - } - lastCarIsUp = carIsUp; - } - return buffer.toString(); - } - public static Map<ObjectModelClass, Set<ObjectModelClass>> searchDirectUsages(ObjectModel model) { List<ObjectModelClass> allEntities; Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -31,10 +31,7 @@ * Created: 28 janv. 2009 18:10:34 * * @author poussin <poussin@codelutin.com> - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ + * @version $Id$ */ public interface EntityVisitor { @@ -97,7 +94,7 @@ /** * Reset all states of the visitor. * - * TODO called by who ? what is it for ? + * TODO-chatellier-20091221 : need explanations : called by who ? what is it for ? */ void clear(); } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -36,131 +36,155 @@ */ package org.nuiton.topia.persistence; -import java.security.Permission; -import java.util.Collection; -import java.util.List; -import java.util.Map; - import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.event.TopiaEntityListener; import org.nuiton.topia.event.TopiaEntityVetoable; import org.nuiton.topia.framework.TopiaContextImplementor; import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.generator.DAOAbstractTransformer; +import org.nuiton.topia.generator.DAOImplTransformer; +import org.nuiton.topia.generator.DAOTransformer; +import java.security.Permission; +import java.util.Collection; +import java.util.List; +import java.util.Map; + /** + * TopiaDAO is used to manipulate entities corresponding to {@code E} type : + * create, delete, update or find entities using properties of {@link + * TopiaQuery}. + * <p /> + * This interface is implemented by {@link TopiaDAOImpl} overriden by generation + * from {@link DAOTransformer} for specific entity interface, {@link + * DAOAbstractTransformer} for abstract implementation and {@link + * DAOImplTransformer} for final implementation class. + * + * * @author poussin <poussin@codelutin.com> - * - * @param <Entity> + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + * @param <E> the entity type linked with the dao */ -public interface TopiaDAO<Entity extends TopiaEntity> { +public interface TopiaDAO<E extends TopiaEntity> { /** * When TopiaContextImpl create the TopiaDAOHibernate, it must call this * method just after. - * - * @param context context + * + * @param context context * @param entityClass entity class - * @throws TopiaException if any pb while init + * @throws TopiaException if any pb while init */ - void init(TopiaContextImplementor context, Class<Entity> entityClass) + void init(TopiaContextImplementor context, Class<E> entityClass) throws TopiaException; /** * Create a new instance of managed entity. - * + * * @return new entity instance + * @throws TopiaException if any pb while creating the entitie * @since 2.3.1 - * @throws TopiaException if any pb while creating the entitie */ - Entity newInstance() throws TopiaException; + E newInstance() throws TopiaException; /** * Return class of entity managed by this DAO. - * + * * @return entity managed by this DAO */ - Class<Entity> getEntityClass(); + Class<E> getEntityClass(); /** * Return context used by this DAO. - * + * * @return Returns the context. */ TopiaContextImplementor getContext(); /** * Appelé lorsque le context a eu un commit de fait. - * - * TODO il faudrait peut-etre plutot faire un commit a deux phase - * car plusieurs type de persistence peuvent etre melangé, et il - * serait bien que si l'une echoué les autres echoue aussi. - * + * <p/> + * TODO il faudrait peut-etre plutot faire un commit a deux phase car + * plusieurs type de persistence peuvent etre melangé, et il serait bien que + * si l'une echoué les autres echoue aussi. + * * @throws TopiaException if any pb while commit + * @deprecated since 2.4 do nothing in dao implementation generated, not + * well placed */ + @Deprecated void commitTransaction() throws TopiaException; /** * Appelé lorsque le context a eu un rollback de fait. - * + * * @throws TopiaException if any pb while rollback + * @deprecated since 2.4 do nothing in dao implementation generated, not + * well placed */ + @Deprecated void rollbackTransaction() throws TopiaException; /** * Construit une nouvelle instance de l'objet géré par ce DAO - * @param properties la liste des propriétés que doit avoir l'objet créé - * les arguments vont par paire (propertyName, value) + * + * @param properties la liste des propriétés que doit avoir l'objet créé les + * arguments vont par paire (propertyName, value) * @return un nouvel objet - * @throws TopiaException si un problème est rencontré durant l'instanciation + * @throws TopiaException si un problème est rencontré durant + * l'instanciation * @throws IllegalArgumentException Si le nombre on le type des arguments - * n'est pas bon ou que le type ou le nom d'une propriété est fausse + * n'est pas bon ou que le type ou le nom + * d'une propriété est fausse */ - Entity create(Object... properties) throws TopiaException; + E create(Object... properties) throws TopiaException; /** * Construit une nouvelle instance de l'objet géré par ce DAO + * * @param properties la liste des propriétés que doit avoir l'objet créé * @return un nouvel objet - * @throws TopiaException si un problème est rencontré durant l'instanciation + * @throws TopiaException si un problème est rencontré durant + * l'instanciation * @throws IllegalArgumentException Si le nombre on le type des arguments - * n'est pas bon ou que le type ou le nom d'une propriété est fausse + * n'est pas bon ou que le type ou le nom + * d'une propriété est fausse */ - Entity create(Map<String, Object> properties) throws TopiaException; + E create(Map<String, Object> properties) throws TopiaException; /** * Permet de sauver un object instancié sans le DAO. - * + * * @param e l'entité instanciée à sauver * @return l'entité avec son topiaID valorisé * @throws TopiaException if any pb while creating datas - * * @since 2.3.1 */ - Entity create(Entity e) throws TopiaException; - + E create(E e) throws TopiaException; + /** - * Permet d'ajouter ou de mettre a jour un objet. Cela permet d'ajouter - * par exemple un objet provenant d'un autre context mais du meme type - * de DAO. + * Permet d'ajouter ou de mettre a jour un objet. Cela permet d'ajouter par + * exemple un objet provenant d'un autre context mais du meme type de DAO. * * @param e l'entite a ajouter ou mettre a jour * @return l'entity passé en paramètre. * @throws TopiaException if any pb while updating datas */ - Entity update(Entity e) throws TopiaException; + E update(E e) throws TopiaException; /** * Permet de supprimer une entite. - * + * * @param e l'entite a supprimer * @throws TopiaException if any pb while deleting datas */ - void delete(Entity e) throws TopiaException; + void delete(E e) throws TopiaException; - Entity findByTopiaId(String k) throws TopiaException; + E findByTopiaId(String k) throws TopiaException; - List<Entity> findAll() throws TopiaException; + List<E> findAll() throws TopiaException; /** * Recuperation de tous les ids en base pour le type d'entite du dao. @@ -170,20 +194,20 @@ */ List<String> findAllIds() throws TopiaException; - List<Entity> findAllWithOrder(String... propertyNames) + List<E> findAllWithOrder(String... propertyNames) throws TopiaException; /** * Compte le nombre d'entites en base - * + * * @return le nombre total d'entites existantes * @throws TopiaException if any pb while getting datas */ long size() throws TopiaException; /** - * Crée une requete basé sur l'entité lié au DAO. - * Résultat attendu : "FROM Entity" + * Crée une requete basé sur l'entité lié au DAO. Résultat attendu : "FROM + * E" * * @return une nouvelle TopiaQuery vide. (uniquement avec le From sur le * type d'entité) @@ -193,10 +217,11 @@ /** * Crée une requête basé sur l'entité lié au DAO et lui assigne un alias * valable dans la requête.. + * <p/> + * Résultat attendu : "FROM E AS entityAlias" * - * Résultat attendu : "FROM Entity AS entityAlias" - * - * @param entityAlias alias permettant de manipuler l'entité dans la requête + * @param entityAlias alias permettant de manipuler l'entité dans la + * requête * @return une nouvelle TopiaQuery */ TopiaQuery createQuery(String entityAlias); @@ -206,12 +231,12 @@ * entité correspondant à la requête. * * @param query la requête - * @return l'entité correspondant à la recherche ou null si aucune entité - * n'a été trouvée + * @return l'entité correspondant à la recherche ou null si aucune entité + * n'a été trouvée * @throws TopiaException if any pb while getting datas * @see TopiaQuery#executeToEntity(TopiaContext, Class) */ - Entity findByQuery(TopiaQuery query) throws TopiaException; + E findByQuery(TopiaQuery query) throws TopiaException; /** * Execute une requête basé sur l'entité du DAO. Permet de récupérer une @@ -222,178 +247,190 @@ * @throws TopiaException if any pb while getting datas * @see TopiaQuery#executeToEntityList(TopiaContext, Class) */ - List<Entity> findAllByQuery(TopiaQuery query) throws TopiaException; + List<E> findAllByQuery(TopiaQuery query) throws TopiaException; /** - * Execute une requête basé sur l'entité du DAO. Permet de récupérer une - * map d'entités correspondant à la requête. La clé de la map étant le - * topiaId de l'entité. + * Execute une requête basé sur l'entité du DAO. Permet de récupérer une map + * d'entités correspondant à la requête. La clé de la map étant le topiaId + * de l'entité. * * @param query la requête * @return la map d'entités correspondant à la recherche * @throws TopiaException if any pb while getting datas * @see TopiaQuery#executeToEntityMap(TopiaContext, Class) */ - Map<String, Entity> findAllMappedByQuery(TopiaQuery query) throws TopiaException; + Map<String, E> findAllMappedByQuery(TopiaQuery query) throws TopiaException; /** - * Execute une requête basé sur l'entité du DAO. Permet de récupérer une - * map d'entités correspondant à la requête. Le type et le nom de la - * propriété utilisé comme clé de la map doit être passé en argument. + * Execute une requête basé sur l'entité du DAO. Permet de récupérer une map + * d'entités correspondant à la requête. Le type et le nom de la propriété + * utilisé comme clé de la map doit être passé en argument. * - * @param <K> type de la clé de la map - * @param query la requête - * @param keyName nom de la propriété de l'entité utilisée comme clé + * @param <K> type de la clé de la map + * @param query la requête + * @param keyName nom de la propriété de l'entité utilisée comme clé * @param keyClass type de la propriété de l'entité utilisée comme clé * @return la map d'entités correspondant à la recherche * @throws TopiaException if any pb while getting datas * @see TopiaQuery#executeToEntityMap(TopiaContext, Class) */ - <K> Map<K, Entity> findAllMappedByQuery(TopiaQuery query, - String keyName, Class<K> keyClass) throws TopiaException; + <K> Map<K, E> findAllMappedByQuery(TopiaQuery query, + String keyName, Class<K> keyClass) throws TopiaException; /** * Recherche la classe en utilisant la cle naturelle, chaque champs de la * cle naturelle est une entre de la map passe en argument. - * + * * @param keys la liste des champs de la cle naturelle avec leur valeur * @return l'entite trouvé * @throws TopiaException if any pb while getting datas */ - Entity findByPrimaryKey(Map<String, Object> keys) throws TopiaException; + E findByPrimaryKey(Map<String, Object> keys) throws TopiaException; /** * Recherche la classe en utilisant la cle naturelle, si la cle naturelle * est composé de plusieurs champs alors les arguments passés doivent être * dans l'ordre de declaration dans le fichier de mapping - * + * * @param k l'objet cle naturelle de la classe * @return l'entité trouvé * @throws TopiaException if any pb while getting datas */ - Entity findByPrimaryKey(Object... k) throws TopiaException; + E findByPrimaryKey(Object... k) throws TopiaException; - Entity findByProperty(String propertyName, Object value) + E findByProperty(String propertyName, Object value) throws TopiaException; /** - * * @param propertyName le nom de la propriété - * @param value la valeur à tester - * @param others les autres proprietes doivent aller par 2 propertyName, - * value + * @param value la valeur à tester + * @param others les autres proprietes doivent aller par 2 + * propertyName, value * @return l'entité trouvé * @throws TopiaException if any pb while getting datas */ - Entity findByProperties(String propertyName, Object value, - Object... others) throws TopiaException; + E findByProperties(String propertyName, Object value, + Object... others) throws TopiaException; - Entity findByProperties(Map<String, Object> properties) throws TopiaException; + E findByProperties(Map<String, Object> properties) throws TopiaException; - List<Entity> findAllByProperty(String propertyName, Object value) + List<E> findAllByProperty(String propertyName, Object value) throws TopiaException; /** - * * @param propertyName le nom de la propriété - * @param value la valeur à tester - * @param others les autres proprietes doivent aller par 2 propertyName, - * value + * @param value la valeur à tester + * @param others les autres proprietes doivent aller par 2 + * propertyName, value * @return l'entité trouvé * @throws TopiaException if any pb while getting datas */ - List<Entity> findAllByProperties(String propertyName, Object value, - Object... others) throws TopiaException; + List<E> findAllByProperties(String propertyName, Object value, + Object... others) throws TopiaException; - List<Entity> findAllByProperties(Map<String, Object> properties) + List<E> findAllByProperties(Map<String, Object> properties) throws TopiaException; /* * Find Contains */ + /** * Cherche et renvoie la première entité trouvée dont les propriétés en clé * de Map contiennent toutes les valeurs de la Collection. - * + * * @param properties les proprietes a utiliser * @return l'entité trouvé * @throws TopiaException if any pb while getting datas + * @deprecated since 2.4 strange method, not very useful, use {@link + * TopiaQuery} instead */ - Entity findContainsProperties(Map<String, Collection<?>> properties) throws + @Deprecated + E findContainsProperties(Map<String, Collection<?>> properties) throws TopiaException; /** * Cherche et renvoie la première entité trouvée dont la propriété * propertyName contient values, ainsi de suite avec others. - * - * @param propertyName le nom de la propriété - * @param values les premières valeurs à tester - * @param others les secondes valeurs ) tester + * + * @param propertyName le nom de la propriété + * @param values les premières valeurs à tester + * @param others les secondes valeurs ) tester * @return l'entité trouvé * @throws TopiaException if any pb while getting datas + * @deprecated since 2.4 strange method, not very useful, use {@link + * TopiaQuery} instead */ - Entity findContainsProperties(String propertyName, Collection<?> values, - Object... others) throws TopiaException; + @Deprecated + E findContainsProperties(String propertyName, Collection<?> values, + Object... others) throws TopiaException; /** * Cherche et renvoie la première entité trouvée dont les propriétés en clé * de Map contiennent toutes les valeurs de la Collection. - * + * * @param properties les propriétés à tester * @return l'entité trouvé * @throws TopiaException if any pb while getting datas + * @deprecated since 2.4 strange method, not very useful, use {@link + * TopiaQuery} instead */ - List<Entity> findAllContainsProperties(Map<String, Collection<?>> properties) + @Deprecated + List<E> findAllContainsProperties(Map<String, Collection<?>> properties) throws TopiaException; /** * Cherche et renvoie toutes les entités trouvées dont la propriété * propertyName contient values, ainsi de suite avec others. - * + * * @param propertyName the name of the property - * @param values les premières valeurs à tester - * @param others les secondes valeurs à tester + * @param values les premières valeurs à tester + * @param others les secondes valeurs à tester * @return l'entité trouvé * @throws TopiaException if any pb while getting datas + * @deprecated since 2.4 strange method, not very useful, use {@link + * TopiaQuery} instead */ - List<Entity> findAllContainsProperties(String propertyName, - Collection<?> values, Object... others) throws TopiaException; + @Deprecated + List<E> findAllContainsProperties(String propertyName, + Collection<?> values, Object... others) + throws TopiaException; /** * Find usages of the given {@code entity} in the entities of the given * {@code type}. * - * @param type the type of entity to search + * @param type the type of entity to search * @param entity the entity - * @param <U> tthe type of entity to search + * @param <U> tthe type of entity to search * @return the list of entities of the given type which uses the given * entity * @throws TopiaException if any problem while getting data * @since 2.3.0 */ - <U extends TopiaEntity> List<U> findUsages(Class<U> type, Entity entity) + <U extends TopiaEntity> List<U> findUsages(Class<U> type, E entity) throws TopiaException; /** * Find all usages of the given {@code entity}. - * + * * @param entity the entity * @return the dictionnary of usages of the given entities (keys are entity - * usage container, values are the list of this type of entity to use the - * given entity). + * usage container, values are the list of this type of entity to + * use the given entity). * @throws TopiaException if any pb while getting data * @since 2.3.0 */ - Map<Class<? extends TopiaEntity>, List<? extends TopiaEntity>> findAllUsages(Entity entity) + Map<Class<? extends TopiaEntity>, List<? extends TopiaEntity>> findAllUsages(E entity) throws TopiaException; - + /** * Retourne les permissions a verifier pour l'acces a l'entite pour le * service Taas. - * + * * @param topiaId topiaId d'une entite - * @param actions encoded actions + * @param actions encoded actions * @return la liste des permissions * @throws TopiaException if any pb while getting datas */ @@ -401,11 +438,13 @@ throws TopiaException; /* Adders */ + void addTopiaEntityListener(TopiaEntityListener listener); void addTopiaEntityVetoable(TopiaEntityVetoable vetoable); /* Removers */ + void removeTopiaEntityListener(TopiaEntityListener listener); void removeTopiaEntityVetoable(TopiaEntityVetoable vetoable); Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -578,91 +578,6 @@ throw new UnsupportedOperationException(); } - //TODO-TC20100225 Says since when it is deprecated (via javadoc annotations - //TODO-TC20100225 + tells what to use instead) - @Deprecated - private Criterion computeCriterions(Object... values) { - if (values == null) { - return null; - } - Criterion criterion = null; - for (Object value : values) { - criterion = or(criterion, computeCriterion(value)); - } - return criterion; - } - - //TODO-TC20100225 Says since when it is deprecated (via javadoc annotations - //TODO-TC20100225 + tells what to use instead) - @Deprecated - private Criterion computeCriterion(Object value) { - Criterion criterion = null; - SearchFields fields = entityClass.getAnnotation(SearchFields.class); - String textValue = "%" + value + '%'; - //textFields - String[] textFields = fields.txtFields(); - for (String propName : textFields) { - criterion = or(criterion, Restrictions.like(propName, textValue)); - } - //numFields - boolean isNumber = value instanceof Number; - if (value instanceof String) { - try { - Double.parseDouble((String) value); - isNumber = true; - } catch (NumberFormatException nfe) { - isNumber = false; - } - - } - if (isNumber) { - String[] numFields = fields.numFields(); - for (String propName : numFields) { - criterion = or(criterion, Restrictions.sqlRestriction(propName - + " like '" + textValue + '\'')); - } - } - //boolFields - boolean isBoolean = value instanceof Boolean; - if (value instanceof String) { - isBoolean |= "true".equalsIgnoreCase((String) value) || "false" - .equalsIgnoreCase((String) value); - } - if (isBoolean) { - Boolean booleanValue; - if (value instanceof String) { - booleanValue = Boolean.valueOf((String) value); - } else { - booleanValue = (Boolean) value; - } - String[] boolFields = fields.numFields(); - for (String propName : boolFields) { - criterion = or(criterion, Restrictions.eq(propName, - booleanValue)); - } - } - //timeFields - String[] timeFields = fields.dateFields(); - for (String propName : timeFields) { - criterion = or(criterion, Restrictions.sqlRestriction(propName - + " like '" + textValue + '\'')); - } - return criterion; - } - - //TODO-TC20100225 Says since when it is deprecated (via javadoc annotations - //TODO-TC20100225 + tells what to use instead) - @Deprecated - private Criterion or(Criterion crit1, Criterion crit2) { - if (crit1 == null) { - return crit2; - } - if (crit2 == null) { - return crit1; - } - return Restrictions.or(crit1, crit2); - } - @Override public void addTopiaEntityListener(TopiaEntityListener listener) { getContext().addTopiaEntityListener(entityClass,listener); @@ -737,6 +652,7 @@ throw new IllegalArgumentException( "Can't put properties on new Object", eee); } + // TODO-fdesbois-20100507 : need to be removed for 2.5 version result.postCreate(); // on fait un save maintenant, car puisqu'on a creer l'entity au @@ -770,29 +686,18 @@ @Override public E findByTopiaId(String k) throws TopiaException { - return findByQuery(createQuery().add(TopiaEntity.TOPIA_ID, k)); + return findByQuery(createQuery().add(TopiaEntity.ID, k)); //return query(Restrictions.idEq(k)); } @Override public List<E> findAll() throws TopiaException { -// try { -// Criteria criteria = createCriteria(FlushMode.AUTO); -// List<E> result = (List<E>) criteria.list(); -// result = getContext().getFiresSupport().fireEntitiesLoad(context, -// result); -// return result; -// } catch (HibernateException eee) { -// throw new TopiaException(eee); -// } return findAllByQuery(createQuery()); } @Override public List<String> findAllIds() throws TopiaException { - //List<String> find = context.find("select src.topiaId from " + entityClass.getSimpleName() + "Impl src"); - //return find; - return createQuery().setSelect(TopiaEntity.TOPIA_ID).execute(); + return createQuery().setSelect(TopiaEntity.ID).execute(); } @Override Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntity.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntity.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntity.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -37,58 +37,167 @@ package org.nuiton.topia.persistence; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.generator.EntityAbstractTransformer; +import org.nuiton.topia.generator.EntityHibernateMappingGenerator; +import org.nuiton.topia.generator.EntityImplTransformer; +import org.nuiton.topia.generator.EntityInterfaceTransformer; +import org.nuiton.topia.generator.TopiaMetaTransformer; + import java.beans.PropertyChangeListener; import java.beans.VetoableChangeListener; import java.util.Date; import java.util.List; -import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.TopiaException; - /** - * TopiaEntity. - * - * Toutes les methodes set ne doivent être utilisé que par le framework. Elle - * sont publique car on ne peut pas faire autrement sur une interface. - * + * The TopiaEntity is the main interface for each entities generated with {@link + * TopiaMetaTransformer}. An entity is simply a persistent bean mapped with + * hibernate. The manipulation on entities (create, update, delete, find) is + * made by the dao associated. The corresponding dao interface is {@link + * TopiaDAO}. + * <p/> + * Setter methods have to be used only in internal. They are in the interface to + * make easier their usages in internal. + * * @author poussin <poussin@codelutin.com> + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + * @see EntityHibernateMappingGenerator + * @see EntityInterfaceTransformer + * @see EntityAbstractTransformer + * @see EntityImplTransformer */ @SearchFields public interface TopiaEntity { + /** @deprecated since 2.4 use {@link #ID} instead */ + @Deprecated String TOPIA_ID = "topiaId"; + + /** @deprecated since 2.4 use {@link #CREATE_DATE} instead */ + @Deprecated String TOPIA_CREATE_DATE = "topiaCreateDate"; + + /** @deprecated since 2.4 use {@link #VERSION} instead */ + @Deprecated String TOPIA_VERSION = "topiaVersion"; + /** Property name of the unique technical {@code id} of the entity */ + String ID = "topiaId"; + + /** Property name of the technical {@code createDate} of the entity */ + String CREATE_DATE = "topiaCreateDate"; + + /** Property name of the technical {@code version} of the entity */ + String ENTITY_VERSION = "topiaVersion"; + + /** @deprecated since 2.4 use {@link #getId()} instead */ + @Deprecated String getTopiaId(); + /** @deprecated since 2.4 use {@link #setId(String)} instead */ + @Deprecated void setTopiaId(String v); + /** @deprecated since 2.4 use {@link #getVersion()} instead */ + @Deprecated long getTopiaVersion(); + /** @deprecated since 2.4 use {@link #setVersion(long)} instead */ + @Deprecated void setTopiaVersion(long v); + /** @deprecated since 2.4 use {@link #getCreateDate()} */ + @Deprecated + Date getTopiaCreateDate(); + + /** @deprecated since 2.4 use {@link #setCreateDate(Date)} */ + @Deprecated + void setTopiaCreateDate(Date topiaCreatedate); + /** - * @return Returns the topiaCreateTime. + * Unique technical Id of the entity. This id contains the full qualified + * name of the entity interface. This id has also an index and his used to + * identify uniquely the entity in the database. + * + * @return the technical Id of the entity */ - Date getTopiaCreateDate(); + String getId(); /** - * @param topiaCreatedate the topiaCreateTime to set. + * Set the technical {@code id} of the entity. Careful, use this method only + * for copy. The technical id is generated by ToPIA when entity is created + * using {@link TopiaDAO#create(Object...)}. + * + * @param id technical id to set */ - void setTopiaCreateDate(Date topiaCreatedate); + void setId(String id); + /** + * Technical property to keep versionning of the entity. The version is + * incremented on each change of the entity. + * + * @return the current version of the entity + */ + long getEntityVersion(); + + /** + * Set the technical {@code version} of the entity. Careful, use this method + * only for copy. The version is automatically incremented on entity + * changes. + * + * @param version technical version to set + */ + void setEntityVersion(long version); + + /** + * Technical date creation of the entity. This date doesn't change through + * time and was initialized on entity creation when using {@link + * TopiaDAO#create(Object...)}. + * + * @return the creation date of the entity + */ + Date getCreateDate(); + + /** + * Set the technical creation {@code date} of the entity. Careful, use this + * method only for copy. This date is immutable and was created on entity + * creation. + * + * @param date technical create date to set + */ + void setCreateDate(Date date); + + @Deprecated TopiaContext getTopiaContext(); /** - * called just after object creation and initialisation - * each entity impl can overide it to do something after creation + * Called just after object creation and initialisation each entity impl can + * overide it to do something after creation + * * @throws TopiaException + * @deprecated since 2.4 : don't really know is concrete usage, the needed + * treatment can be directly done after creating the entity with + * {@link TopiaDAO#create(Object...)} */ + @Deprecated void postCreate() throws TopiaException; + /** + * @deprecated since 2.4 : context will no longer be keeped by the entity, + * so it will be impossible to do such operation. Use {@link + * TopiaDAO#update(TopiaEntity)} instead. + */ + @Deprecated void update() throws TopiaException; + /** + * @deprecated since 2.4 : context will no longer be keeped by the entity, + * so it will be impossible to do such operation. Use {@link + * TopiaDAO#delete(TopiaEntity)} instead. + */ + @Deprecated void delete() throws TopiaException; /** @@ -99,45 +208,45 @@ /** * @return all object that are aggregate with this instance, aggreate object - * are not removed automaticaly + * are not removed automaticaly * @throws TopiaException */ List<TopiaEntity> getAggregate() throws TopiaException; /** * Add listener for property writing. - * + * * @param propertyName * @param listener */ void addPropertyChangeListener(String propertyName, - PropertyChangeListener listener); + PropertyChangeListener listener); /** * Add listener for property writing. - * + * * @param listener */ void addPropertyChangeListener(PropertyChangeListener listener); void addVetoableChangeListener(String propertyName, - VetoableChangeListener vetoable); + VetoableChangeListener vetoable); void addVetoableChangeListener(VetoableChangeListener vetoable); void removePropertyChangeListener(String propertyName, - PropertyChangeListener listener); + PropertyChangeListener listener); void removePropertyChangeListener(PropertyChangeListener listener); void removeVetoableChangeListener(String propertyName, - VetoableChangeListener vetoable); + VetoableChangeListener vetoable); void removeVetoableChangeListener(VetoableChangeListener vetoable); /** * Add listener for property reading. - * + * * @param propertyName * @param listener */ @@ -146,32 +255,32 @@ /** * Add listener for property reading. - * + * * @param listener */ void addPropertyListener(PropertyChangeListener listener); void addVetoableListener(String propertyName, - VetoableChangeListener vetoable); + VetoableChangeListener vetoable); void addVetoableListener(VetoableChangeListener vetoable); void removePropertyListener(String propertyName, - PropertyChangeListener listener); + PropertyChangeListener listener); void removePropertyListener(PropertyChangeListener listener); void removeVetoableListener(String propertyName, - VetoableChangeListener vetoable); + VetoableChangeListener vetoable); void removeVetoableListener(VetoableChangeListener vetoable); /** - * Parcourt de l'entité via un visiteur. - * - * @param visitor visitor le visiteur utilise - * @throws TopiaException pour toute erreur pendant le parcours + * Route the entity using a {@code visitor}. + * + * @param visitor to used + * @throws TopiaException for all type of error */ void accept(EntityVisitor visitor) throws TopiaException; - + } //TopiaEntity Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityAbstract.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityAbstract.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityAbstract.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -82,6 +82,36 @@ new PropertyChangeSupport(this); @Override + public String getId() { + return getTopiaId(); + } + + @Override + public void setId(String id) { + setTopiaId(id); + } + + @Override + public long getEntityVersion() { + return getTopiaVersion(); + } + + @Override + public void setEntityVersion(long version) { + setTopiaVersion(version); + } + + @Override + public Date getCreateDate() { + return getTopiaCreateDate(); + } + + @Override + public void setCreateDate(Date date) { + setTopiaCreateDate(date); + } + + @Override public String getTopiaId() { return topiaId; } @@ -184,10 +214,10 @@ return false; } TopiaEntity other = (TopiaEntity) obj; - if (getTopiaId() == null || other.getTopiaId() == null) { + if (getTopiaId() == null || other.getId() == null) { return false; } - boolean result = getTopiaId().equals(other.getTopiaId()); + boolean result = getTopiaId().equals(other.getId()); return result; } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -69,7 +69,7 @@ * Le pattern d'une reference sur une association */ public static final String ASSOCIATION_PATTERN = - "%1$s[@" + TopiaEntity.TOPIA_ID + "=\"%2$s\"]"; + "%1$s[@" + TopiaEntity.ID + "=\"%2$s\"]"; /** * Bind les valeurs techniques depuis une entitée vers une autre. @@ -79,13 +79,13 @@ */ public static void bindTechnical(TopiaEntity from, TopiaEntity dst) { if (from == null) { - dst.setTopiaId(null); - dst.setTopiaVersion(0); - dst.setTopiaCreateDate(null); + dst.setId(null); + dst.setEntityVersion(0); + dst.setCreateDate(null); } else { - dst.setTopiaId(from.getTopiaId()); - dst.setTopiaVersion(from.getTopiaVersion()); - dst.setTopiaCreateDate(from.getTopiaCreateDate()); + dst.setId(from.getId()); + dst.setEntityVersion(from.getEntityVersion()); + dst.setCreateDate(from.getCreateDate()); } } @@ -126,7 +126,7 @@ Collection<E> entities, String topiaId) { if (entities != null) { for (E e : entities) { - if (topiaId.equals(e.getTopiaId())) { + if (topiaId.equals(e.getId())) { return e; } } @@ -149,7 +149,7 @@ if (bean == null) { throw new NullPointerException(paramName + " can not be null"); } - if (bean.getTopiaId() == null) { + if (bean.getId() == null) { // can not create bean here throw new IllegalStateException( "can not create " + bean.getClass() + " here..."); @@ -171,7 +171,7 @@ if (bean == null) { throw new NullPointerException(paramName + " can not be null"); } - if (bean.getTopiaId() != null) { + if (bean.getId() != null) { // can not create bean here throw new IllegalStateException( "can not update " + bean.getClass() + " here..."); @@ -297,13 +297,13 @@ @Override public int compare(TopiaEntity o1, TopiaEntity o2) { - if (o1.getTopiaId() == null) { + if (o1.getId() == null) { return -1; } - if (o2.getTopiaId() == null) { + if (o2.getId() == null) { return 1; } - return o1.getTopiaId().compareTo(o2.getTopiaId()); + return o1.getId().compareTo(o2.getId()); } }; } @@ -481,7 +481,7 @@ super.onStarting(e); Class<? extends TopiaEntity> entityClass = e.getClass(); if (log.isDebugEnabled()) { - log.debug(entityClass + " : " + e.getTopiaId()); + log.debug(entityClass + " : " + e.getId()); } detectedTypes.add(entityClass); return true; @@ -539,7 +539,7 @@ } if (log.isDebugEnabled()) { - log.debug(entityClass + " : " + e.getTopiaId()); + log.debug(entityClass + " : " + e.getId()); } List<TopiaEntity> refs = detectedRefs.get(entityClass); @@ -601,7 +601,7 @@ } if (log.isDebugEnabled()) { - log.debug(entityClass + " : " + e.getTopiaId()); + log.debug(entityClass + " : " + e.getId()); } List<String> refs = detectedRefs.get(entityClass); @@ -609,7 +609,7 @@ refs = new ArrayList<String>(); detectedRefs.put(entityClass, refs); } - refs.add(e.getTopiaId()); + refs.add(e.getId()); } @Override @@ -694,7 +694,7 @@ @Override protected boolean onStarting(TopiaEntity e) { - log.debug(e.getTopiaId()); + log.debug(e.getId()); if (root == null) { // start come in start method since // last clear method invocation @@ -735,7 +735,7 @@ if (visitor.getAlreadyExplored().contains(e1)) { boolean contains = visitor.getStack().contains(e1); if (log.isDebugEnabled()) { - log.debug("already enter " + e1.getTopiaId() + + log.debug("already enter " + e1.getId() + ", can reenter ? " + !contains); } if (!contains) { @@ -787,7 +787,7 @@ if (visitor.getAlreadyExplored().contains(e1)) { boolean contains = visitor.getStack().contains(e1); if (log.isDebugEnabled()) { - log.debug("already enter " + e1.getTopiaId() + + log.debug("already enter " + e1.getId() + ", can reenter ? " + !contains); } if (!contains) { @@ -840,7 +840,7 @@ } boolean accept(TopiaEntity e) { - return ids.contains(e.getTopiaId()); + return ids.contains(e.getId()); } void addPath(TopiaEntity e, String name, int index) { @@ -851,16 +851,16 @@ accessorExpression.append(name); if (index > -1) { String association = String.format( - ASSOCIATION_PATTERN, "", e.getTopiaId()); + ASSOCIATION_PATTERN, "", e.getId()); accessorExpression.append(association); } // if (index > -1) { // accessorExpression.append("[@topiaId=\""); -// accessorExpression.append(e.getTopiaId()); +// accessorExpression.append(e.getId()); // accessorExpression.append("\"]"); // } if (log.isTraceEnabled()) { - log.trace("add to stack : " + e.getTopiaId() + + log.trace("add to stack : " + e.getId() + ", new size : " + path.size() + ", path : " + accessorExpression.toString()); } @@ -879,7 +879,7 @@ } } if (log.isTraceEnabled()) { - log.trace("remove from stack : " + e.getTopiaId() + + log.trace("remove from stack : " + e.getId() + ", new size : " + path.size() + ", path : " + accessorExpression.toString()); } @@ -905,11 +905,11 @@ ); if (log.isDebugEnabled()) { - log.debug(expression + " (" + e.getTopiaId() + ") - " + - list.size() + " , root:" + root.getTopiaId()); + log.debug(expression + " (" + e.getId() + ") - " + + list.size() + " , root:" + root.getId()); } if (log.isTraceEnabled()) { - log.trace(e.getTopiaId() + " : new size " + list.size() + + log.trace(e.getId() + " : new size " + list.size() + ", path : " + expression); } } @@ -932,7 +932,7 @@ List<? extends TopiaEntity> entities) { List<String> ids = new ArrayList<String>(entities.size()); for (TopiaEntity entity : entities) { - ids.add(entity.getTopiaId()); + ids.add(entity.getId()); } return ids; } @@ -952,7 +952,7 @@ List<E> r = new ArrayList<E>(list == null ? 0 : list.size()); if (list != null) { for (E e : list) { - if (topiaIds.contains(e.getTopiaId())) { + if (topiaIds.contains(e.getId())) { r.add(e); } } @@ -982,7 +982,7 @@ for (E aReferentiel : referentiel) { TopiaEntity referentielEntity = aReferentiel; - String refId = referentielEntity.getTopiaId(); + String refId = referentielEntity.getId(); if (localeIdList.contains(refId)) { // id existant sur le storage locale @@ -991,13 +991,13 @@ // ordre, on parcourt donc la liste cible pour retrouver // l'entité cible for (TopiaEntity e : locale) { - if (e.getTopiaId().equals(refId)) { + if (e.getId().equals(refId)) { localeEntity = e; break; } } - boolean wasModified = referentielEntity.getTopiaVersion() > - localeEntity.getTopiaVersion(); + boolean wasModified = referentielEntity.getEntityVersion() > + localeEntity.getEntityVersion(); if (wasModified) { result.get(DiffState.MODIFIED).add(refId); Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityRef.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityRef.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityRef.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -99,6 +99,6 @@ @Override public int compareTo(TopiaEntityRef o) { - return ref.getTopiaId().compareTo(o.getRef().getTopiaId()); + return ref.getId().compareTo(o.getRef().getId()); } } Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -154,7 +154,7 @@ companyDAO = TopiaTestDAOHelper.getCompanyDAO(newContext); - company = companyDAO.findByTopiaId(company.getTopiaId()); + company = companyDAO.findByTopiaId(company.getId()); Assert.assertEquals(company.getName(),"Ma société"); Assert.assertEquals(company.getDepartment().size(),4); Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/ExportXMLVisitor.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/ExportXMLVisitor.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/ExportXMLVisitor.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -58,9 +58,9 @@ } buffer.append("<").append(e.getClass().getName()); - buffer.append(" topiaId=\"").append(e.getTopiaId()).append("\""); - buffer.append(" topiaCreateDate=\"").append(e.getTopiaCreateDate()).append("\""); - buffer.append(" topiaVersion=\"").append(e.getTopiaVersion()).append("\""); + buffer.append(" topiaId=\"").append(e.getId()).append("\""); + buffer.append(" topiaCreateDate=\"").append(e.getCreateDate()).append("\""); + buffer.append(" topiaVersion=\"").append(e.getEntityVersion()).append("\""); buffer.append(">\n"); } Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -164,7 +164,7 @@ actual = operationC.getChild(Company.DEPARTMENT, c, topiaId); assertNull(actual); - d.setTopiaId(topiaId); + d.setId(topiaId); actual = operationC.getChild(Company.DEPARTMENT, c, topiaId); assertNotNull(actual); assertEquals(d, actual); Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -87,7 +87,7 @@ BinderBuilder builder = new BinderBuilder(); builder.createBinderModel(Company.class, CompanyDTO.class); builder.addSimpleProperties(Company.NAME, Company.SIRET); - builder.addProperties(TopiaEntity.TOPIA_ID, "id"); + builder.addProperties(TopiaEntity.ID, "id"); BinderProvider.registerBinder(builder); Binder<Company, CompanyDTO> binder = Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTester.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTester.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTester.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -94,7 +94,7 @@ InstantiationException { Class<? extends TopiaEntity> impl = constant.getImplementation(); TopiaEntity topiaEntity = impl.newInstance(); - topiaEntity.setTopiaId(topiaId); + topiaEntity.setId(topiaId); return (T) topiaEntity; } @@ -111,7 +111,7 @@ * @return the reference of the association */ protected String getAssociationRef(String associationName, TopiaEntity e) { - return getAssociationRef(associationName, e.getTopiaId()); + return getAssociationRef(associationName, e.getId()); } /** @@ -276,7 +276,7 @@ TopiaEntity[] path = actual.getPath(); Assert.assertEquals(expected.length, path.length); for (int i = 0; i < expected.length; i++) { - Assert.assertEquals(expected[i].getTopiaId(), path[i].getTopiaId()); + Assert.assertEquals(expected[i].getId(), path[i].getId()); } } Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/deletetest/DeleteEntityTest.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/deletetest/DeleteEntityTest.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/deletetest/DeleteEntityTest.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -123,7 +123,7 @@ log.debug("CREATE PERSONNE : Bob Marley"); Personne personne = dao.create(Personne.NAME,"Bob Marley"); transaction.commitTransaction(); - String idPersonne = personne.getTopiaId(); + String idPersonne = personne.getId(); assertNotNull(idPersonne); log.debug("ENTITY PERSONNE SAVED !"); @@ -137,7 +137,7 @@ log.debug("CREATE PERSONNE : Ziggy Marley"); Personne personne2 = dao.create(Personne.NAME,"Ziggy Marley"); transaction.commitTransaction(); - String idPersonne2 = personne2.getTopiaId(); + String idPersonne2 = personne2.getId(); assertNotNull(idPersonne2); log.debug("ENTITY PERSONNE SAVED !"); @@ -175,7 +175,7 @@ log.debug("CREATE PERSONNE : Bob Marley"); Personne personne = dao.create(Personne.NAME,"Bob Marley"); transaction.commitTransaction(); - String idPersonne = personne.getTopiaId(); + String idPersonne = personne.getId(); assertNotNull(idPersonne); log.debug("ENTITY PERSONNE SAVED !"); @@ -184,7 +184,7 @@ log.debug("CREATE CONTACT : jaja@codelutin.com"); Contact2 contact = contactDAO.create(Contact2.CONTACT_VALUE,"jaja@codelutin.com"); transaction.commitTransaction(); - String idContact = contact.getTopiaId(); + String idContact = contact.getId(); assertNotNull(idContact); log.debug("ENTITY CONTACT SAVED !"); Modified: trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/ManualMigrationEngine.java =================================================================== --- trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/ManualMigrationEngine.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/ManualMigrationEngine.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -471,7 +471,7 @@ //FIXME on pourrait conserver l'information sur les date de mise a jour List<TMSVersion> toDelete = dao.findAll(); for (TMSVersion v : toDelete) { - v.delete(); + dao.delete(v); } log.info(_("topia.migration.saving.db.version", version)); Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachAssociation.java =================================================================== --- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachAssociation.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachAssociation.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -175,7 +175,7 @@ // l'entite repliquee a laquelle on veut attacher l'association - TopiaEntity dst = dstCtxt.findByTopiaId(src.getTopiaId()); + TopiaEntity dst = dstCtxt.findByTopiaId(src.getId()); // les association cibles connues pour l'entite sur la base destination Collection<?> dstTargetEntities = (Collection<?>) ownerOperator.get(name, dst); @@ -188,8 +188,8 @@ TopiaEntity assosiationSrc = (TopiaEntity) a; // on verifie que l'association doit etre rattachee - if (associationsId.contains(assosiationSrc.getTopiaId())) { - if (dstTargetAssociationsId.contains(assosiationSrc.getTopiaId())) { + if (associationsId.contains(assosiationSrc.getId())) { + if (dstTargetAssociationsId.contains(assosiationSrc.getId())) { // deja attache if (log.isDebugEnabled()) { log.debug("already attached association '" + name + "' : " + assosiationSrc); @@ -200,7 +200,7 @@ // la donnees doit etre attachee - TopiaEntity assosiationDst = dstCtxt.findByTopiaId(assosiationSrc.getTopiaId()); + TopiaEntity assosiationDst = dstCtxt.findByTopiaId(assosiationSrc.getId()); ownerOperator.addChild(name, dst, assosiationDst); if (log.isDebugEnabled()) { log.debug("will attach association '" + name + "' : " + assosiationDst); @@ -212,7 +212,7 @@ if (shouldUpdate) { if (log.isTraceEnabled()) { - log.trace("will update " + dst.getTopiaId()); + log.trace("will update " + dst.getId()); } //FIXME: on ne peut pas updater l'objet car l'objet peut rentre // en conflit dans la session hibernate Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachLink.java =================================================================== --- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachLink.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/AttachLink.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -163,7 +163,7 @@ // l'entite repliquee a laquelle on veut attacher l'association - TopiaEntity dst = dstCtxt.findByTopiaId(src.getTopiaId()); + TopiaEntity dst = dstCtxt.findByTopiaId(src.getId()); // les association cibles connues pour l'entite sur la base destination Collection<?> dstTargetEntities = (Collection<?>) ownerOperator.get(name, dst); @@ -176,8 +176,8 @@ TopiaEntity assosiationSrc = (TopiaEntity) a; // on verifie que l'association doit etre rattachee - if (associationIds.contains(assosiationSrc.getTopiaId())) { - if (dstTargetAssociationsId.contains(assosiationSrc.getTopiaId())) { + if (associationIds.contains(assosiationSrc.getId())) { + if (dstTargetAssociationsId.contains(assosiationSrc.getId())) { // deja attache if (log.isDebugEnabled()) { log.debug("already attached association '" + name + "' : " + assosiationSrc); @@ -188,7 +188,7 @@ // la donnees doit etre attachee - TopiaEntity assosiationDst = dstCtxt.findByTopiaId(assosiationSrc.getTopiaId()); + TopiaEntity assosiationDst = dstCtxt.findByTopiaId(assosiationSrc.getId()); ownerOperator.addChild(name, dst, assosiationDst); if (log.isDebugEnabled()) { log.debug("will attach association '" + name + "' : " + assosiationDst); @@ -200,7 +200,7 @@ if (shouldUpdate) { if (log.isTraceEnabled()) { - log.trace("will update " + dst.getTopiaId()); + log.trace("will update " + dst.getId()); } //FIXME: on ne peut pas updater l'objet car l'objet peut rentre // en conflit dans la session hibernate Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/AbstractReplicationEngineTest.java =================================================================== --- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/AbstractReplicationEngineTest.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/AbstractReplicationEngineTest.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -125,7 +125,7 @@ protected <E extends TopiaEntity> E update(E e) throws TopiaException { Class<E> k = (Class<E>) TopiaEntityHelper.getContractClass(getContracts(), e.getClass()); TopiaDAO<E> dao = ((TopiaContextImplementor) ctxt).getDAO(k); - return dao.findByTopiaId(e.getTopiaId()); + return dao.findByTopiaId(e.getId()); } /** @@ -195,7 +195,7 @@ Set<?> detectTypes; - detectTypes = service.detectTypes(getContracts(), entity.getTopiaId()); + detectTypes = service.detectTypes(getContracts(), entity.getId()); assertEquals("expected types : "+ Arrays.toString(expectedCouple) + " but was "+detectTypes, @@ -293,7 +293,7 @@ // // Iterator<List<ReplicationNode>> order = dependencies.iterator(); // if (entity != null) { -// getLog().info("for " + entity.getTopiaId()); +// getLog().info("for " + entity.getId()); // } // int index = 0; // for (TopiaEntityEnum[] expectedLevel : expected) { @@ -348,7 +348,7 @@ if (entity == null) { prepareModel(); } else { - prepareModel(entity.getTopiaId()); + prepareModel(entity.getId()); } // createModel(entity); // model.detectAssociations(); @@ -364,7 +364,7 @@ getLog().info("resume of operations for all "); } else { - getLog().info("resume of operations for entity " + entity.getTopiaId()); + getLog().info("resume of operations for entity " + entity.getId()); } for (ReplicationNode node : model.getOrder()) { @@ -400,7 +400,7 @@ dstCtxt = (TopiaContextImplementor) rootCtxt.beginTransaction(); for (TopiaEntity e : entity) { - TopiaEntity actual = dstCtxt.findByTopiaId(e.getTopiaId()); + TopiaEntity actual = dstCtxt.findByTopiaId(e.getId()); assertNotNull(actual); assertEquals(e, actual); } @@ -490,14 +490,14 @@ if (treated == null) { treated = new HashSet<String>(); } - if (treated.contains(actual.getTopiaId())) { + if (treated.contains(actual.getId())) { return; } if (getLog().isDebugEnabled()) { getLog().debug(expected); } - assertEquals(actual.getTopiaId(), expected.getTopiaId()); - treated.add(actual.getTopiaId()); + assertEquals(actual.getId(), expected.getId()); + treated.add(actual.getId()); if (getLog().isDebugEnabled()) { getLog().debug("expected : " + expected + " / actual " + actual); } @@ -565,8 +565,8 @@ protected void createUnsupportedBeforeOperation(TopiaEntityEnum contract, TopiaEntity entity, Class<? extends TopiaReplicationOperation> operationClass, Object... parameters) throws Exception { - getLog().info("entity " + entity.getTopiaId()); - prepareModel(entity.getTopiaId()); + getLog().info("entity " + entity.getId()); + prepareModel(entity.getId()); service.addBeforeOperation(model, contract, operationClass, parameters); // on ne doit pas avoir le droit de creer cette operation @@ -575,8 +575,8 @@ protected void createUnsupportedAfterOperation(TopiaEntityEnum contract, TopiaEntity entity, Class<? extends TopiaReplicationOperation> operationClass, Object... parameters) throws Exception { - getLog().info("entity " + entity.getTopiaId()); - prepareModel(entity.getTopiaId()); + getLog().info("entity " + entity.getId()); + prepareModel(entity.getId()); // model = service.createModel(getContracts()); // model.detectDirectDependencies(); service.addAfterOperation(model, contract, operationClass, parameters); @@ -606,7 +606,7 @@ } protected void createModel(TopiaEntity entity) throws TopiaException { - model = service.createModel(getContracts(), entity.getTopiaId()); + model = service.createModel(getContracts(), entity.getId()); } protected void prepareModel(String... ids) throws TopiaException { Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/ReplicationEngineTest.java =================================================================== --- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/ReplicationEngineTest.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/ReplicationEngineTest.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -253,7 +253,7 @@ TopiaContext dstRootCtxt = createDb2("testSimpleReplicateFailed"); - //model = service.prepare(contracts, pet.getTopiaId()); + //model = service.prepare(contracts, pet.getId()); TopiaContext srcCtxt = ctxt.beginTransaction(); dstCtxt = (TopiaContextImplementor) dstRootCtxt.beginTransaction(); @@ -288,7 +288,7 @@ TopiaContext dstRootCtxt = createDb2("testSimpleReplicateNotSure"); - //model = service.prepare(contracts, pet.getTopiaId()); + //model = service.prepare(contracts, pet.getId()); TopiaContext srcCtxt = ctxt; dstCtxt = (TopiaContextImplementor) dstRootCtxt.beginTransaction(); @@ -307,13 +307,13 @@ srcCtxt.replicateEntity(dstCtxt, person); dstCtxt.commitTransaction(); - ((Pet) dstCtxt.findByTopiaId(pet.getTopiaId())).setPerson((Person) dstCtxt.findByTopiaId(person.getTopiaId())); + ((Pet) dstCtxt.findByTopiaId(pet.getId())).setPerson((Person) dstCtxt.findByTopiaId(person.getId())); dstCtxt.commitTransaction(); srcCtxt.rollbackTransaction(); person = update(person); - assertEntityEquals(person, dstCtxt.findByTopiaId(person.getTopiaId()), null); + assertEntityEquals(person, dstCtxt.findByTopiaId(person.getId()), null); } finally { srcCtxt.rollbackTransaction(); //srcCtxt.closeContext(); @@ -341,7 +341,7 @@ TopiaContext dstRootCtxt = createDb2("testSimpleReplicateSure"); - //model = service.prepare(contracts, pet.getTopiaId()); + //model = service.prepare(contracts, pet.getId()); TopiaContext srcCtxt = ctxt; dstCtxt = (TopiaContextImplementor) dstRootCtxt.beginTransaction(); @@ -357,7 +357,7 @@ srcCtxt.rollbackTransaction(); dstCtxt.commitTransaction(); - //((Person) dstCtxt.findByTopiaId(person.getTopiaId())).addPet(((Pet) dstCtxt.findByTopiaId(pet.getTopiaId()))); + //((Person) dstCtxt.findByTopiaId(person.getId())).addPet(((Pet) dstCtxt.findByTopiaId(pet.getId()))); //dstCtxt.commitTransaction(); srcCtxt.rollbackTransaction(); @@ -370,7 +370,7 @@ person = update(person); - assertEntityEquals(person, dstCtxt.findByTopiaId(person.getTopiaId()), null); + assertEntityEquals(person, dstCtxt.findByTopiaId(person.getId()), null); } finally { dstCtxt.closeContext(); Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationOperationTest.java =================================================================== --- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationOperationTest.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationOperationTest.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -261,7 +261,7 @@ @Test(expected = IllegalArgumentException.class) public void testCreateOperation_wrongParameterNumber() throws Exception { - model = service.createModel(contracts, pet.getTopiaId()); + model = service.createModel(contracts, pet.getId()); service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOperation.class); } @@ -269,7 +269,7 @@ @Test(expected = IllegalArgumentException.class) public void testCreateOperation_wrongParameterNumber2() throws Exception { - model = service.createModel(contracts, pet.getTopiaId()); + model = service.createModel(contracts, pet.getId()); service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOperation.class, String.class, String.class); } @@ -277,7 +277,7 @@ @Test(expected = IllegalArgumentException.class) public void testCreateOperation_wrongParameterType() throws Exception { - model = service.createModel(contracts, pet.getTopiaId()); + model = service.createModel(contracts, pet.getId()); service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOperation.class, Integer.class); } @@ -285,7 +285,7 @@ @Test(expected = IllegalArgumentException.class) public void testCreateOperation_nullParameter() throws Exception { - model = service.createModel(contracts, pet.getTopiaId()); + model = service.createModel(contracts, pet.getId()); service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOperation.class, (Object) null); } @@ -293,7 +293,7 @@ @Test public void testCreateOperation() throws Exception { - model = service.createModel(contracts, pet.getTopiaId()); + model = service.createModel(contracts, pet.getId()); service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOperation.class, "before"); service.addAfterOperation(model, TopiaTestEntityEnum.Race, FakeOperation.class, "after"); } Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/security/TopiaSecurityServiceImpl.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/security/TopiaSecurityServiceImpl.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/security/TopiaSecurityServiceImpl.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -401,7 +401,8 @@ try { Class<?> klass = TopiaId.getClassName(topiaId); - if(TopiaSecurityUtil.isImplement(klass, NoSecurityLoad.class)) { + //if(TopiaSecurityUtil.isImplement(klass, NoSecurityLoad.class)) { + if (NoSecurityLoad.class.isAssignableFrom(klass)) { //LOAD actions &= UPDATE + DELETE + CREATE; } Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/security/jaas/TopiaLoginModule.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/security/jaas/TopiaLoginModule.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/security/jaas/TopiaLoginModule.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -135,7 +135,7 @@ // R�cup�ration des principals principals = new HashSet<Principal>(); - String topiaIdUser = user.getTopiaId(); + String topiaIdUser = user.getId(); principals.add(new TopiaPrincipal(topiaIdUser)); securityManager.putPermissionsCache(topiaIdUser); securityManager.removeEntitiesLoadingCache(topiaIdUser); @@ -149,11 +149,11 @@ if(groups != null) { for(TopiaGroup group : groups) { for (TopiaGroup superGroup : (List<TopiaGroup>)group.getAllSuperGroup()) { - String topiaIdGroup = superGroup.getTopiaId(); + String topiaIdGroup = superGroup.getId(); principals.add(new TopiaPrincipal(topiaIdGroup)); securityManager.putPermissionsCache(topiaIdGroup); } - String topiaIdGroup = group.getTopiaId(); + String topiaIdGroup = group.getId(); principals.add(new TopiaPrincipal(topiaIdGroup)); securityManager.putPermissionsCache(topiaIdGroup); } Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/security/util/TopiaSecurityFactoryFilter.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/security/util/TopiaSecurityFactoryFilter.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/security/util/TopiaSecurityFactoryFilter.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -66,7 +66,7 @@ */ public TopiaEntity filter(TopiaEntity entity, int actions) { try { - securityManager.checkPermission(entity.getTopiaId(), actions); + securityManager.checkPermission(entity.getId(), actions); } catch (SecurityException e) { if(log.isDebugEnabled()) { log.debug("Return Null because : " + e); @@ -87,7 +87,7 @@ for (Iterator<?> iterator = result.iterator(); iterator.hasNext();) { TopiaEntity entity = (TopiaEntity) iterator.next(); try { - securityManager.checkPermission(entity.getTopiaId(), actions); + securityManager.checkPermission(entity.getId(), actions); } catch (SecurityException e) { iterator.remove(); if(log.isDebugEnabled()) { Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/security/util/TopiaSecurityUtil.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/security/util/TopiaSecurityUtil.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/security/util/TopiaSecurityUtil.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -257,34 +257,4 @@ TopiaContext topiaContext = TopiaContextFactory.getContext(config); return topiaContext.beginTransaction(); } - - /** - * Détermine si la classe implémente une interface - * <p> - * interface A <---- class B <---- class C - * <p> - * interface D <---- class E - * <p> - * isImplement(C, A) = true - * <p> - * isImplement(E, A) = false - * - * @param klass la classe - * @param iface l'interface - * @return vrai si la classe implémente l'interface sinon faux - * @deprecated je pense que {@link Class#isAssignableFrom(Class)} doit faire l'affaire :) - */ - public static boolean isImplement(Class klass, Class iface) { - boolean result = false; - - Class<?>[] interfaces = klass.getInterfaces(); - result = ArrayUtils.contains(interfaces, iface); - - Class<?> superclass = klass.getSuperclass(); - if(!result && superclass != null) { - result |= isImplement(superclass, iface); - } - - return result; - } } //TopiaSecurityUtil Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/TaasService.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/TaasService.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/TaasService.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -256,7 +256,7 @@ for (Iterator<? extends TopiaEntity> iterator = entities.iterator(); iterator.hasNext();) { TopiaEntity entity = iterator.next(); try { - AccessController.checkPermission(new TaasPermission(entity.getTopiaId(), actions)); + AccessController.checkPermission(new TaasPermission(entity.getId(), actions)); } catch (SecurityException se) { if (log.isDebugEnabled()) { log.debug(getPrincipalNames(subj) + " does not have permissions to load: " + entity); @@ -279,9 +279,9 @@ Subject subj = findSubject(); if (subj != null) { try { - AccessController.checkPermission(new TaasPermission(entity.getTopiaId(), actions)); + AccessController.checkPermission(new TaasPermission(entity.getId(), actions)); } catch (SecurityException se) { - throw new SecurityException("Access denied to object \"" + entity.getTopiaId() + "\" for \"" + getPrincipalNames(subj) + "\""); + throw new SecurityException("Access denied to object \"" + entity.getId() + "\" for \"" + getPrincipalNames(subj) + "\""); } } else { throw new SecurityException("Use doAs() and login first"); @@ -321,9 +321,9 @@ if(permissions == null) { try { - AccessController.checkPermission(new TaasPermission(entity.getTopiaId(), actions)); + AccessController.checkPermission(new TaasPermission(entity.getId(), actions)); } catch (SecurityException se) { - throw new SecurityException("Access denied to object \"" + entity.getTopiaId() + "\" for \"" + getPrincipalNames(subj) + "\""); + throw new SecurityException("Access denied to object \"" + entity.getId() + "\" for \"" + getPrincipalNames(subj) + "\""); } } else { for (Permission permission : permissions) { @@ -331,7 +331,7 @@ AccessController.checkPermission(permission); break; } catch (SecurityException se) { - throw new SecurityException("Access denied to object \"" + entity.getTopiaId() + "\" for \"" + getPrincipalNames(subj) + "\""); + throw new SecurityException("Access denied to object \"" + entity.getId() + "\" for \"" + getPrincipalNames(subj) + "\""); } } } @@ -356,7 +356,7 @@ if(permissions == null) { try { - AccessController.checkPermission(new TaasPermission(entity.getTopiaId(), actions)); + AccessController.checkPermission(new TaasPermission(entity.getId(), actions)); } catch (SecurityException se) { iterator.remove(); } @@ -383,7 +383,7 @@ * @return permissions � v�rifier */ public List<Permission> getRequestPermission(TopiaEntity entity, int actions) { - String topiaId = entity.getTopiaId(); + String topiaId = entity.getId(); Class<? extends TopiaEntity> klass = null; try { Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/event/TaasEntityVetoable.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/event/TaasEntityVetoable.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/event/TaasEntityVetoable.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -59,7 +59,7 @@ */ public void create(TopiaEntityEvent event) { TopiaEntity entity = event.getEntity(); - String topiaId = entity.getTopiaId(); + String topiaId = entity.getId(); Class<? extends TopiaEntity> clazz; if (log.isDebugEnabled()) { @@ -73,7 +73,7 @@ */ public void delete(TopiaEntityEvent event) { TopiaEntity entity = event.getEntity(); - String topiaId = entity.getTopiaId(); + String topiaId = entity.getId(); if (log.isDebugEnabled()) { log.debug("[Security] delete entity : " + topiaId); @@ -87,7 +87,7 @@ */ public void load(TopiaEntityEvent event) { // TopiaEntity entity = event.getEntity(); -// String topiaId = entity.getTopiaId(); +// String topiaId = entity.getId(); // // if (log.isDebugEnabled()) { // log.debug("[Security] load entity : " + topiaId); @@ -100,7 +100,7 @@ */ public void update(TopiaEntityEvent event) { TopiaEntity entity = event.getEntity(); - String topiaId = entity.getTopiaId(); + String topiaId = entity.getId(); if (log.isDebugEnabled()) { log.debug("[Security] update entity : " + topiaId); Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/event/TaasEntityVetoableRequestPermission.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/event/TaasEntityVetoableRequestPermission.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/event/TaasEntityVetoableRequestPermission.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -56,7 +56,7 @@ */ public void create(TopiaEntityEvent event) { TopiaEntity entity = event.getEntity(); - String topiaId = entity.getTopiaId(); + String topiaId = entity.getId(); Class<? extends TopiaEntity> clazz; if (log.isDebugEnabled()) { @@ -70,7 +70,7 @@ */ public void delete(TopiaEntityEvent event) { TopiaEntity entity = event.getEntity(); - String topiaId = entity.getTopiaId(); + String topiaId = entity.getId(); if (log.isDebugEnabled()) { log.debug("[Security] delete entity : " + topiaId); @@ -84,7 +84,7 @@ */ public void load(TopiaEntityEvent event) { // TopiaEntity entity = event.getEntity(); -// String topiaId = entity.getTopiaId(); +// String topiaId = entity.getId(); // // if (log.isDebugEnabled()) { // log.debug("[Security] load entity : " + topiaId); @@ -97,7 +97,7 @@ */ public void update(TopiaEntityEvent event) { TopiaEntity entity = event.getEntity(); - String topiaId = entity.getTopiaId(); + String topiaId = entity.getId(); if (log.isDebugEnabled()) { log.debug("[Security] update entity : " + topiaId); Modified: trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/jaas/TaasLoginModule.java =================================================================== --- trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/jaas/TaasLoginModule.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/main/java/org/nuiton/topia/taas/jaas/TaasLoginModule.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -148,7 +148,7 @@ user.setLastConnectionDate(new Date()); int numberOfConnection = user.getNumberOfConnection(); user.setNumberOfConnection(numberOfConnection + 1); - user.update(); + userDAO.update(user); // Récupération des principals principals = new HashSet<TaasPrincipalWrapper>(); Modified: trunk/topia-service-security/src/test/java/org/nuiton/topia/security/TopiaSecurityTest.java =================================================================== --- trunk/topia-service-security/src/test/java/org/nuiton/topia/security/TopiaSecurityTest.java 2010-05-07 19:02:02 UTC (rev 1937) +++ trunk/topia-service-security/src/test/java/org/nuiton/topia/security/TopiaSecurityTest.java 2010-05-07 20:50:21 UTC (rev 1938) @@ -140,14 +140,14 @@ TopiaUser admin = topiaUserDAO.create(); admin.setLogin("admin"); admin.setPassword("azerty"); - admin.update(); + topiaUserDAO.update(admin); childContext.commitTransaction(); /* Création d'un utilisateur */ TopiaUser thimel = topiaUserDAO.create(); thimel.setLogin("thimel"); thimel.setPassword("zou;bi@da"); - thimel.update(); + topiaUserDAO.update(thimel); childContext.commitTransaction(); /* Création d'un groupe avec un utilisateur */ @@ -160,8 +160,8 @@ groupRuchaud.setTopiaUser(new ArrayList<TopiaUser>()); ruchaud.addTopiaGroup(groupRuchaud); - groupRuchaud.update(); - ruchaud.update(); + topiaGroupDAO.update(groupRuchaud); + topiaUserDAO.update(ruchaud); childContext.commitTransaction(); /* Création des personnes */ @@ -188,67 +188,67 @@ debux.setName("debux"); debux.setType("chat"); debux.setPerson(jacques); - debux.update(); + petDAO.update(debux); childContext.commitTransaction(); Pet pluto = petDAO.create(); pluto.setName("pluto"); pluto.setType("chien"); pluto.setPerson(jacques); - pluto.update(); + petDAO.update(pluto); childContext.commitTransaction(); Pet fliper = petDAO.create(); fliper.setName("fliper"); fliper.setType("dauphin"); fliper.setPerson(mylene); - fliper.update(); + petDAO.update(fliper); childContext.commitTransaction(); /* Création des autorisations Entity */ TopiaEntityAuthorization authorizationForAdmin = topiaEntityAuthorizationDAO.create(); authorizationForAdmin.setExpression("*"); authorizationForAdmin.setActions(15); - authorizationForAdmin.setPrincipals(admin.getTopiaId()); - authorizationForAdmin.update(); + authorizationForAdmin.setPrincipals(admin.getId()); + topiaEntityAuthorizationDAO.update(authorizationForAdmin); childContext.commitTransaction(); TopiaEntityAuthorization authorizationForRuchaud = topiaEntityAuthorizationDAO.create(); authorizationForRuchaud.setExpression(Person.class.getName() + "#*"); authorizationForRuchaud.setActions(LOAD); - authorizationForRuchaud.setPrincipals(groupRuchaud.getTopiaId()); - authorizationForRuchaud.update(); + authorizationForRuchaud.setPrincipals(groupRuchaud.getId()); + topiaEntityAuthorizationDAO.update(authorizationForRuchaud); childContext.commitTransaction(); TopiaEntityAuthorization authorizationForThimel = topiaEntityAuthorizationDAO.create(); - authorizationForThimel.setExpression(jacques.getTopiaId()); + authorizationForThimel.setExpression(jacques.getId()); authorizationForThimel.setActions(LOAD); - authorizationForThimel.setPrincipals(thimel.getTopiaId()); - authorizationForThimel.update(); + authorizationForThimel.setPrincipals(thimel.getId()); + topiaEntityAuthorizationDAO.update(authorizationForThimel); childContext.commitTransaction(); /* Création d'une autorisation Link */ TopiaExpressionLink link = linkDAO.create(); - link.setReplace(mylene.getTopiaId()); - link.setBy(jacques.getTopiaId()); - link.update(); + link.setReplace(mylene.getId()); + link.setBy(jacques.getId()); + linkDAO.update(link); childContext.commitTransaction(); /* Création d'une authorisation association */ TopiaAssociationAuthorization associationAuthorization = topiaAssociationAuthorizationDAO.create(); - associationAuthorization.setIdBeginAssociation(jacques.getTopiaId()); + associationAuthorization.setIdBeginAssociation(jacques.getId()); associationAuthorization.setNameAssociation("pet"); associationAuthorization.setActions(LOAD); - associationAuthorization.setPrincipals(ruchaud.getTopiaId()); - associationAuthorization.update(); + associationAuthorization.setPrincipals(ruchaud.getId()); + topiaAssociationAuthorizationDAO.update(associationAuthorization); childContext.commitTransaction(); associationAuthorization = topiaAssociationAuthorizationDAO.create(); - associationAuthorization.setIdBeginAssociation(mylene.getTopiaId()); + associationAuthorization.setIdBeginAssociation(mylene.getId()); associationAuthorization.setNameAssociation("pet"); associationAuthorization.setActions(UPDATE); - associationAuthorization.setPrincipals(ruchaud.getTopiaId()); - associationAuthorization.update(); + associationAuthorization.setPrincipals(ruchaud.getId()); + topiaAssociationAuthorizationDAO.update(associationAuthorization); childContext.commitTransaction(); childContext.closeContext();
participants (1)
-
fdesbois@users.nuiton.org