BrightSide Workbench Full Report + Source Code
org.turro.erp.resource.ResourceAptitude Class Reference

Public Member Functions

 ResourceAptitude (Resource resource, AptitudeDegree aptitudeDegree)
 
Resource getResource ()
 
AptitudeDegree getAptitudeDegree ()
 
String getName ()
 
String toString ()
 
double getCost ()
 
double getPrice ()
 
double getMarketPrice ()
 

Static Public Member Functions

static Collection< ResourceAptitudeload (String value, boolean onlyActive, int nRows)
 
static ResourceAptitude get (String text)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 37 of file ResourceAptitude.java.

Constructor & Destructor Documentation

◆ ResourceAptitude()

org.turro.erp.resource.ResourceAptitude.ResourceAptitude ( Resource  resource,
AptitudeDegree  aptitudeDegree 
)

Definition at line 42 of file ResourceAptitude.java.

42  {
43  this.resource = resource;
44  this.aptitudeDegree = aptitudeDegree;
45  }
Here is the caller graph for this function:

Member Function Documentation

◆ get()

static ResourceAptitude org.turro.erp.resource.ResourceAptitude.get ( String  text)
static

Definition at line 112 of file ResourceAptitude.java.

112  {
113  String s[] = text.split(" - ");
114  if(s.length > 1) {
115  String name = s.length == 3 ? s[0] + " - " + s[1] : s[0];
116  String aptitude = s.length == 3 ? s[2] : s[1];
117  EntityManager em = new ErpPU().getEntityManager();
118  try {
119  Query q = em.createQuery(
120  " select res from Resource res " +
121  " where res.name = :name");
122  q.setParameter("name", name);
123  q.setMaxResults(1);
124  Resource hr = (Resource) q.getSingleResult();
125  for(AptitudeDegree ad : hr.getAptitudeDegrees()) {
126  if(ad.getFullName().equals(aptitude)) {
127  return new ResourceAptitude(hr, ad);
128  }
129  }
130  } catch(Exception ex) {
131  return null;
132  } finally {
133  em.close();
134  }
135  }
136  return null;
137  }
ResourceAptitude(Resource resource, AptitudeDegree aptitudeDegree)
Here is the call graph for this function:

◆ getAptitudeDegree()

AptitudeDegree org.turro.erp.resource.ResourceAptitude.getAptitudeDegree ( )

Definition at line 51 of file ResourceAptitude.java.

51  {
52  return aptitudeDegree;
53  }
Here is the caller graph for this function:

◆ getCost()

double org.turro.erp.resource.ResourceAptitude.getCost ( )

Definition at line 72 of file ResourceAptitude.java.

72  {
73  return resource.getCostHour() + aptitudeDegree.getCost();
74  }
Here is the call graph for this function:

◆ getMarketPrice()

double org.turro.erp.resource.ResourceAptitude.getMarketPrice ( )

Definition at line 80 of file ResourceAptitude.java.

80  {
81  return resource.getMarketPrice() + aptitudeDegree.getMarketPrice();
82  }
Here is the call graph for this function:

◆ getName()

String org.turro.erp.resource.ResourceAptitude.getName ( )

Definition at line 55 of file ResourceAptitude.java.

55  {
56  PhraseBuilder pb = new PhraseBuilder();
57  if(resource != null) {
58  pb.addWord(resource.getName());
59  }
60  pb.addPendingSeparator(" -");
61  if(aptitudeDegree != null) {
62  pb.addWord(aptitudeDegree.getFullName());
63  }
64  return pb.toString();
65  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPrice()

double org.turro.erp.resource.ResourceAptitude.getPrice ( )

Definition at line 76 of file ResourceAptitude.java.

76  {
77  return resource.getPriceHour() + aptitudeDegree.getPrice();
78  }
Here is the call graph for this function:

◆ getResource()

Resource org.turro.erp.resource.ResourceAptitude.getResource ( )

Definition at line 47 of file ResourceAptitude.java.

47  {
48  return resource;
49  }
Here is the caller graph for this function:

◆ load()

static Collection<ResourceAptitude> org.turro.erp.resource.ResourceAptitude.load ( String  value,
boolean  onlyActive,
int  nRows 
)
static

Definition at line 84 of file ResourceAptitude.java.

84  {
85  ArrayList<ResourceAptitude> result = new ArrayList<ResourceAptitude>();
86  EntityManager em = new ErpPU().getEntityManager();
87  try {
88  WhereClause wc = SQLHelper.getWhereClause(new String[]{
89  "res.name"
90  }, value);
91  Query q = em.createQuery(
92  "select res from Resource res " +
93  "where res.active = :active " +
94  wc.getClause() +
95  " order by res.name"
96  );
97  wc.addNamedValue("active", onlyActive);
98  q.setMaxResults(nRows);
99  wc.setNamedParameters(q);
100  List<Resource> l = q.getResultList();
101  for(Resource hr : l) {
102  for(AptitudeDegree ad : hr.getAptitudeDegrees()) {
103  result.add(new ResourceAptitude(hr, ad));
104  }
105  }
106  } finally {
107  em.close();
108  }
109  return result;
110  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

String org.turro.erp.resource.ResourceAptitude.toString ( )

Definition at line 68 of file ResourceAptitude.java.

68  {
69  return getName();
70  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: