org.nuiton.topia.persistence
Class TopiaDAOLegacy<E extends TopiaEntity>

java.lang.Object
  extended by org.nuiton.topia.persistence.TopiaDAOImpl<E>
      extended by org.nuiton.topia.persistence.TopiaDAOLegacy<E>
Type Parameters:
E - le type de l'entite
All Implemented Interfaces:
TopiaDAO<E>

public class TopiaDAOLegacy<E extends TopiaEntity>
extends TopiaDAOImpl<E>

Cette classe permet d'avoir un ensemble de méthode implantée de façon standard et plus spécifiquement pour Hibernate. Certains accès à Hibernate sont tout de même fait ici, car on a pris le choix de se baser entièrement sur hibernate pour la persistence, et il est ainsi possible d'accèder au meta information hibernate sur les classes lorque l'on en a besoin.

Author:
poussin

Field Summary
protected  TopiaContextImplementor context
           
protected  Class<E> entityClass
           
 
Constructor Summary
TopiaDAOLegacy()
           
 
Method Summary
 void addTopiaEntityListener(TopiaEntityListener listener)
           
 void addTopiaEntityVetoable(TopiaEntityVetoable vetoable)
           
 void commitTransaction()
          Callback method when context was commit.
 E create(Map<String,Object> properties)
          Cette methode appelle fireVetoableCreate et fireOnCreated Si vous la surchargé, faites attention a appeler le super ou a appeler vous aussi ces deux methodes.
 E create(Object... properties)
          Construit une nouvelle instance de l'objet géré par ce DAO
 void delete(E e)
          Permet de supprimer une entite.
 List<E> findAll()
           
 List<E> findAllByProperties(Map<String,Object> properties)
           
 List<E> findAllByProperties(String propertyName, Object value, Object... others)
           
 List<E> findAllByProperty(String propertyName, Object value)
           
 List<E> findAllContainsProperties(Map<String,Collection<?>> properties)
          Find all entities with a specific rule : When the entity have a Collection type property, you want to find all entites where some values are contained in the collection type property.
 List<E> findAllContainsProperties(String propertyName, Collection values, Object... others)
          Cherche et renvoie toutes les entités trouvées dont la propriété propertyName contient values, ainsi de suite avec others.
 List<String> findAllIds()
          Recuperation de tous les ids en base pour le type d'entite du dao.
 List<E> findAllWithOrder(String... propertyNames)
           
 E findByPrimaryKey(Map<String,Object> keys)
          Recherche la classe en utilisant la cle naturelle, chaque champs de la cle naturelle est une entre de la map passe en argument.
 E findByPrimaryKey(Object... k)
          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
 E findByProperties(Map<String,Object> properties)
           
 E findByProperties(String propertyName, Object value, Object... others)
           
 E findByProperty(String propertyName, Object value)
           
 E findByTopiaId(String k)
          Find an entity corresponding to the id.
 E findContainsProperties(Map<String,Collection<?>> properties)
          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.
 E findContainsProperties(String propertyName, Collection values, Object... others)
          Cherche et renvoie la première entité trouvée dont la propriété propertyName contient values, ainsi de suite avec others.
 TopiaContextImplementor getContext()
          Return context used by this DAO.
 Class<E> getEntityClass()
          Return class of entity managed by this DAO.
protected  Serializable getId(E e)
          Retourne l'id de l'entity
protected  Serializable getId(Map map)
          Retourne l'id de l'entity representer comme une map
 List<Permission> getRequestPermission(String topiaId, int actions)
          Retourne les permissions a verifier pour l'acces a l'entite pour le service Taas.
 void init(TopiaContextImplementor context, Class<E> entityClass)
          When TopiaContextImpl create the TopiaDAOHibernate, it must call this method just after
protected  E instanciateNew()
           
 void removeTopiaEntityListener(TopiaEntityListener listener)
           
 void removeTopiaEntityVetoable(TopiaEntityVetoable vetoable)
           
 void rollbackTransaction()
          Callback method when context was rollback.
 long size()
          Count number of existing entities using TopiaQuery.executeCount(org.nuiton.topia.TopiaContext) FIXME-FD20091224 change type to int like in 2.2.2 version
 E update(E e)
          Permet d'ajouter ou de mettre a jour un objet.
 
Methods inherited from class org.nuiton.topia.persistence.TopiaDAOImpl
count, countByQuery, create, createQuery, createQuery, existByProperties, existByQuery, existByTopiaId, findAllByQuery, findAllMappedByQuery, findAllMappedByQuery, findAllUsages, findByQuery, findUsages, newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityClass

protected Class<E extends TopiaEntity> entityClass

context

protected TopiaContextImplementor context
Constructor Detail

TopiaDAOLegacy

public TopiaDAOLegacy()
Method Detail

getEntityClass

public Class<E> getEntityClass()
Description copied from interface: TopiaDAO
Return class of entity managed by this DAO.

Specified by:
getEntityClass in interface TopiaDAO<E extends TopiaEntity>
Overrides:
getEntityClass in class TopiaDAOImpl<E extends TopiaEntity>
Returns:
entity managed by this DAO

getId

protected Serializable getId(E e)
                      throws TopiaException
Retourne l'id de l'entity

Overrides:
getId in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
e - l'entity
Returns:
l'id de l'entity ou null si pas trouvé
Throws:
TopiaException - Si une erreur survient durant la recherche

getId

protected Serializable getId(Map map)
                      throws TopiaException
Retourne l'id de l'entity representer comme une map

Overrides:
getId in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
map - l'entity en representation map
Returns:
l'id de l'entity ou null si pas trouvé
Throws:
TopiaException - Si une erreur survient durant la recherche

init

public void init(TopiaContextImplementor context,
                 Class<E> entityClass)
          throws TopiaException
When TopiaContextImpl create the TopiaDAOHibernate, it must call this method just after

Specified by:
init in interface TopiaDAO<E extends TopiaEntity>
Overrides:
init in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
entityClass -
context - context
Throws:
TopiaException - if any pb while init

getContext

public TopiaContextImplementor getContext()
Description copied from interface: TopiaDAO
Return context used by this DAO.

Specified by:
getContext in interface TopiaDAO<E extends TopiaEntity>
Overrides:
getContext in class TopiaDAOImpl<E extends TopiaEntity>
Returns:
Returns the context.

instanciateNew

protected E instanciateNew()
                                        throws TopiaException
Throws:
TopiaException

commitTransaction

public void commitTransaction()
                       throws TopiaException
Callback method when context was commit. By default, the method does nothing

Specified by:
commitTransaction in interface TopiaDAO<E extends TopiaEntity>
Overrides:
commitTransaction in class TopiaDAOImpl<E extends TopiaEntity>
Throws:
TopiaException

rollbackTransaction

public void rollbackTransaction()
                         throws TopiaException
Callback method when context was rollback. By default, the method does nothing

Specified by:
rollbackTransaction in interface TopiaDAO<E extends TopiaEntity>
Overrides:
rollbackTransaction in class TopiaDAOImpl<E extends TopiaEntity>
Throws:
TopiaException

create

public E create(Object... properties)
                             throws TopiaException
Description copied from interface: TopiaDAO
Construit une nouvelle instance de l'objet géré par ce DAO

Specified by:
create in interface TopiaDAO<E extends TopiaEntity>
Overrides:
create in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
properties - la liste des propriétés que doit avoir l'objet créé les arguments vont par paire (propertyName, value)
Returns:
un nouvel objet
Throws:
TopiaException - si un problème est rencontré durant l'instanciation

findByPrimaryKey

public E findByPrimaryKey(Map<String,Object> keys)
                                       throws TopiaException
Description copied from interface: TopiaDAO
Recherche la classe en utilisant la cle naturelle, chaque champs de la cle naturelle est une entre de la map passe en argument.

Specified by:
findByPrimaryKey in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findByPrimaryKey in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
keys - la liste des champs de la cle naturelle avec leur valeur
Returns:
l'entite trouvé
Throws:
TopiaException - if any pb while getting datas

findByPrimaryKey

public E findByPrimaryKey(Object... k)
                                       throws TopiaException
Description copied from interface: TopiaDAO
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

Specified by:
findByPrimaryKey in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findByPrimaryKey in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
k - l'objet cle naturelle de la classe
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findByProperties

public E findByProperties(String propertyName,
                          Object value,
                          Object... others)
                                       throws TopiaException
Specified by:
findByProperties in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findByProperties in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
propertyName - le nom de la propriété
value - la valeur à tester
others - les autres proprietes doivent aller par 2 propertyName, value
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findAllByProperties

public List<E> findAllByProperties(String propertyName,
                                   Object value,
                                   Object... others)
                                                throws TopiaException
Specified by:
findAllByProperties in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findAllByProperties in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
propertyName - le nom de la propriété
value - la valeur à tester
others - les autres proprietes doivent aller par 2 propertyName, value
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findContainsProperties

public E findContainsProperties(Map<String,Collection<?>> properties)
                                             throws TopiaException
Description copied from interface: TopiaDAO
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.

Specified by:
findContainsProperties in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findContainsProperties in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
properties - les proprietes a utiliser
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findContainsProperties

public E findContainsProperties(String propertyName,
                                Collection values,
                                Object... others)
                                             throws TopiaException
Description copied from interface: TopiaDAO
Cherche et renvoie la première entité trouvée dont la propriété propertyName contient values, ainsi de suite avec others.

Specified by:
findContainsProperties in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findContainsProperties in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
propertyName - le nom de la propriété
values - les premières valeurs à tester
others - les secondes valeurs ) tester
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findAllContainsProperties

public List<E> findAllContainsProperties(Map<String,Collection<?>> properties)
                                                      throws TopiaException
Find all entities with a specific rule : When the entity have a Collection type property, you want to find all entites where some values are contained in the collection type property. Example entity parameter : private Collection historicalDates; You want some dates to be contained in historicalDates. Collection myDates... myDates.add(date1) ... Map properties = new HashMap(); properties.put("historicalDates",myDates); findAllContainsProperties(properties);

Specified by:
findAllContainsProperties in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findAllContainsProperties in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
properties -
Returns:
the list of entities corresponding to the request
Throws:
TopiaException - if any pb

findAllContainsProperties

public List<E> findAllContainsProperties(String propertyName,
                                         Collection values,
                                         Object... others)
                                                      throws TopiaException
Description copied from interface: TopiaDAO
Cherche et renvoie toutes les entités trouvées dont la propriété propertyName contient values, ainsi de suite avec others.

Specified by:
findAllContainsProperties in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findAllContainsProperties in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
propertyName - the name of the property
values - les premières valeurs à tester
others - les secondes valeurs à tester
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findAllByProperty

public List<E> findAllByProperty(String propertyName,
                                 Object value)
                                              throws TopiaException
Specified by:
findAllByProperty in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findAllByProperty in class TopiaDAOImpl<E extends TopiaEntity>
Throws:
TopiaException

findByProperty

public E findByProperty(String propertyName,
                        Object value)
                                     throws TopiaException
Specified by:
findByProperty in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findByProperty in class TopiaDAOImpl<E extends TopiaEntity>
Throws:
TopiaException

addTopiaEntityListener

public void addTopiaEntityListener(TopiaEntityListener listener)
Specified by:
addTopiaEntityListener in interface TopiaDAO<E extends TopiaEntity>
Overrides:
addTopiaEntityListener in class TopiaDAOImpl<E extends TopiaEntity>

addTopiaEntityVetoable

public void addTopiaEntityVetoable(TopiaEntityVetoable vetoable)
Specified by:
addTopiaEntityVetoable in interface TopiaDAO<E extends TopiaEntity>
Overrides:
addTopiaEntityVetoable in class TopiaDAOImpl<E extends TopiaEntity>

removeTopiaEntityListener

public void removeTopiaEntityListener(TopiaEntityListener listener)
Specified by:
removeTopiaEntityListener in interface TopiaDAO<E extends TopiaEntity>
Overrides:
removeTopiaEntityListener in class TopiaDAOImpl<E extends TopiaEntity>

removeTopiaEntityVetoable

public void removeTopiaEntityVetoable(TopiaEntityVetoable vetoable)
Specified by:
removeTopiaEntityVetoable in interface TopiaDAO<E extends TopiaEntity>
Overrides:
removeTopiaEntityVetoable in class TopiaDAOImpl<E extends TopiaEntity>

create

public E create(Map<String,Object> properties)
                             throws TopiaException
Cette methode appelle fireVetoableCreate et fireOnCreated Si vous la surchargé, faites attention a appeler le super ou a appeler vous aussi ces deux methodes.

Specified by:
create in interface TopiaDAO<E extends TopiaEntity>
Overrides:
create in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
properties - la liste des propriétés que doit avoir l'objet créé
Returns:
un nouvel objet
Throws:
TopiaException - si un problème est rencontré durant l'instanciation

update

public E update(E e)
                             throws TopiaException
Description copied from interface: TopiaDAO
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.

Specified by:
update in interface TopiaDAO<E extends TopiaEntity>
Overrides:
update in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
e - l'entite a ajouter ou mettre a jour
Returns:
l'entity passé en paramètre.
Throws:
TopiaException - if any pb while updating datas

delete

public void delete(E e)
            throws TopiaException
Description copied from interface: TopiaDAO
Permet de supprimer une entite.

Specified by:
delete in interface TopiaDAO<E extends TopiaEntity>
Overrides:
delete in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
e - l'entite a supprimer
Throws:
TopiaException - if any pb while deleting datas

findByTopiaId

public E findByTopiaId(String k)
                                    throws TopiaException
Description copied from interface: TopiaDAO
Find an entity corresponding to the id. If the id is null, nothing will be search.

Specified by:
findByTopiaId in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findByTopiaId in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
k - topiaId of the entity to found
Returns:
the entity found or null if not
Throws:
TopiaException - for Topia errors on query

findAll

public List<E> findAll()
                                    throws TopiaException
Specified by:
findAll in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findAll in class TopiaDAOImpl<E extends TopiaEntity>
Throws:
TopiaException

findAllIds

public List<String> findAllIds()
                        throws TopiaException
Description copied from interface: TopiaDAO
Recuperation de tous les ids en base pour le type d'entite du dao.

Specified by:
findAllIds in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findAllIds in class TopiaDAOImpl<E extends TopiaEntity>
Returns:
la liste de tous les ids
Throws:
TopiaException - si pb en base

findAllWithOrder

public List<E> findAllWithOrder(String... propertyNames)
                                             throws TopiaException
Specified by:
findAllWithOrder in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findAllWithOrder in class TopiaDAOImpl<E extends TopiaEntity>
Throws:
TopiaException

size

public long size()
          throws TopiaException
Count number of existing entities using TopiaQuery.executeCount(org.nuiton.topia.TopiaContext) FIXME-FD20091224 change type to int like in 2.2.2 version

Specified by:
size in interface TopiaDAO<E extends TopiaEntity>
Overrides:
size in class TopiaDAOImpl<E extends TopiaEntity>
Returns:
a long for the number of entities in database
Throws:
TopiaException - if any pb while getting datas

findByProperties

public E findByProperties(Map<String,Object> properties)
                                       throws TopiaException
Specified by:
findByProperties in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findByProperties in class TopiaDAOImpl<E extends TopiaEntity>
Throws:
TopiaException

findAllByProperties

public List<E> findAllByProperties(Map<String,Object> properties)
                                                throws TopiaException
Specified by:
findAllByProperties in interface TopiaDAO<E extends TopiaEntity>
Overrides:
findAllByProperties in class TopiaDAOImpl<E extends TopiaEntity>
Throws:
TopiaException

getRequestPermission

public List<Permission> getRequestPermission(String topiaId,
                                             int actions)
                                      throws TopiaException
Description copied from interface: TopiaDAO
Retourne les permissions a verifier pour l'acces a l'entite pour le service Taas.

Specified by:
getRequestPermission in interface TopiaDAO<E extends TopiaEntity>
Overrides:
getRequestPermission in class TopiaDAOImpl<E extends TopiaEntity>
Parameters:
topiaId - topiaId d'une entite
actions - encoded actions
Returns:
la liste des permissions
Throws:
TopiaException - if any pb while getting datas


Copyright © 2004-2010 CodeLutin. All Rights Reserved.