19 package org.turro.erp.resource;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.List;
24 import javax.persistence.EntityManager;
25 import javax.persistence.Query;
26 import org.turro.elephant.db.SQLHelper;
27 import org.turro.elephant.db.WhereClause;
28 import org.turro.erp.db.ErpPU;
29 import org.turro.erp.entity.AptitudeDegree;
30 import org.turro.erp.entity.Resource;
31 import org.turro.util.PhraseBuilder;
43 this.resource = resource;
44 this.aptitudeDegree = aptitudeDegree;
52 return aptitudeDegree;
56 PhraseBuilder pb =
new PhraseBuilder();
57 if(resource !=
null) {
60 pb.addPendingSeparator(
" -");
61 if(aptitudeDegree !=
null) {
84 public static Collection<ResourceAptitude>
load(String value,
boolean onlyActive,
int nRows) {
85 ArrayList<ResourceAptitude> result =
new ArrayList<ResourceAptitude>();
91 Query q = em.createQuery(
92 "select res from Resource res " +
93 "where res.active = :active " +
98 q.setMaxResults(nRows);
100 List<Resource> l = q.getResultList();
113 String s[] = text.split(
" - ");
115 String name = s.length == 3 ? s[0] +
" - " + s[1] : s[0];
116 String aptitude = s.length == 3 ? s[2] : s[1];
119 Query q = em.createQuery(
120 " select res from Resource res " +
121 " where res.name = :name");
122 q.setParameter(
"name", name);
126 if(ad.getFullName().equals(aptitude)) {
130 }
catch(Exception ex) {
static WhereClause getWhereClause(String[] fields, String value)
void setNamedParameters(Query q)
void addNamedValue(String name, Object value)
Set< AptitudeDegree > getAptitudeDegrees()
ResourceAptitude(Resource resource, AptitudeDegree aptitudeDegree)
static Collection< ResourceAptitude > load(String value, boolean onlyActive, int nRows)
AptitudeDegree getAptitudeDegree()
EntityManager getEntityManager()