18 package org.turro.hr.humanres;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.Date;
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.HumanResource;
31 import org.turro.erp.entity.OwnedAptitude;
32 import org.turro.util.PhraseBuilder;
41 private boolean canChange;
45 this.humanResource = humanResource;
46 this.canChange = canChange;
47 this.aptitudeDegree = aptitudeDegree;
55 return aptitudeDegree;
59 PhraseBuilder pb =
new PhraseBuilder();
60 if(humanResource !=
null) {
61 pb.addWord(humanResource.
getName());
63 pb.addPendingSeparator(
" -");
64 if(aptitudeDegree !=
null) {
71 PhraseBuilder pb =
new PhraseBuilder();
72 if(humanResource !=
null) {
74 pb.addWord(
"Variable");
76 pb.addWord(humanResource.
getName());
79 pb.addPendingSeparator(
" -");
80 if(aptitudeDegree !=
null) {
103 public static Collection<HumanResourceAptitude>
load(Date date, String value, Collection<AptitudeDegree> required,
boolean onlyActive,
int nRows) {
104 ArrayList<HumanResourceAptitude> result =
new ArrayList<HumanResourceAptitude>();
110 Query q = em.createQuery(
111 "select res from HumanResource res " +
112 "where res.active = :active " +
117 q.setMaxResults(nRows);
119 List<HumanResource> l = q.getResultList();
122 if(required.isEmpty() || off.getAptitudeDegree().isIn(required)) {
134 String s[] = text.split(
" - ");
136 String name = s.length == 3 ? s[0] +
" - " + s[1] : s[0];
137 String aptitude = s.length == 3 ? s[2] : s[1];
140 Query q = em.createQuery(
141 " select res from HumanResource res " +
142 " where res.name = :name");
143 q.setParameter(
"name", name);
147 if(off.getAptitudeDegree().getFullName().equals(aptitude)) {
151 }
catch(Exception ex) {
static WhereClause getWhereClause(String[] fields, String value)
void setNamedParameters(Query q)
void addNamedValue(String name, Object value)
Collection< OwnedAptitude > getActiveAptitudes(Date date)
static Collection< HumanResourceAptitude > load(Date date, String value, Collection< AptitudeDegree > required, boolean onlyActive, int nRows)
HumanResourceAptitude(HumanResource humanResource, boolean canChange, AptitudeDegree aptitudeDegree)
HumanResource getHumanResource()
AptitudeDegree getAptitudeDegree()
EntityManager getEntityManager()