1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
public List<Collaborateur> findAll(String init, String identite, String firstName, String lastName, List<Integer> societeUids, List<Integer> exploitUids, List<Integer> sectionUids, String status)
{
LogUtil.log("finding all Collaborateur instances", Level.INFO, null);
try
{
StringBuilder sb = new StringBuilder(80);
sb.append("select c from Collaborateur c where 1=1");
if ( Converters.isParameterSet(init) )
{
init = Converters.filterValue(init);
if ( init.indexOf("%") != -1 ) sb.append(" and upper(c.init) like :init");
else sb.append(" and upper(c.init) = :init");
}
if ( Converters.isParameterSet(identite) )
{
identite = Converters.filterValue(identite);
if ( identite.indexOf("%") != -1 ) sb.append(" and upper(c.identite) like :identite");
else sb.append(" and upper(c.identite) = :identite");
}
if ( Converters.isParameterSet(firstName) )
{
firstName = Converters.filterValue(firstName);
if ( firstName.indexOf("%") != -1 ) sb.append(" and upper(c.prenom) like :firstName");
else sb.append(" and upper(c.prenom) = :firstName");
}
if ( Converters.isParameterSet(lastName) )
{
lastName = Converters.filterValue(lastName);
if ( lastName.indexOf("%") != -1 ) sb.append(" and upper(c.nom) like :lastName");
else sb.append(" and upper(c.nom) = :lastName");
}
if ( Converters.isParameterSet(societeUids) )
{
sb.append(" and societe.uid in (:societeUids)") ;
}
if ( Converters.isParameterSet(exploitUids) )
{
sb.append(" and exploit.uid in (:exploitUids)") ;
}
if ( Converters.isParameterSet(sectionUids) )
{
sb.append(" and section.uid in (:sectionUids)") ;
}
if ( Converters.isParameterSet(status) )
{
if ( status.equalsIgnoreCase("A") ) sb.append(" and (sortie is null or sortie > :now)") ;
if ( status.equalsIgnoreCase("I") ) sb.append(" and sortie is not null and sortie < :now") ;
}
sb.append(" order by c.nom, c.prenom, c.init");
Query query = getEntityManager().createQuery(sb.toString());
if ( sb.indexOf(":init") != -1 ) query.setParameter("init", init.toUpperCase());
if ( sb.indexOf(":identite") != -1 ) query.setParameter("identite", identite.toUpperCase());
if ( sb.indexOf(":firstName") != -1 ) query.setParameter("firstName", firstName.toUpperCase());
if ( sb.indexOf(":lastName") != -1 ) query.setParameter("lastName", lastName.toUpperCase());
if ( sb.indexOf(":societeUids") != -1 ) query.setParameter("societeUids", societeUids);
if ( sb.indexOf(":exploitUids") != -1 ) query.setParameter("exploitUids", exploitUids);
if ( sb.indexOf(":sectionUids") != -1 ) query.setParameter("sectionUids", sectionUids);
if ( sb.indexOf(":now") != -1 ) query.setParameter("now", new Date());
return query.getResultList();
}
catch (RuntimeException re)
{
LogUtil.log("find all failed", Level.SEVERE, re);
throw re;
}
} |
Partager