18 package org.turro.erp.entity;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.List;
24 import javax.persistence.*;
25 import org.amic.util.date.CheckDate;
26 import org.turro.financials.db.FinancialsPU;
27 import org.turro.financials.entity.Contract;
28 import org.turro.financials.entity.ContractParticipant;
29 import org.turro.hr.aptitude.AptituteDegreeAdapter;
30 import org.turro.hr.humanres.HumanResourceAptitude;
31 import org.turro.jpa.Dao;
32 import org.turro.jpa.entity.CachedEntity;
33 import org.turro.plugin.contacts.IContact;
43 @GeneratedValue(strategy=GenerationType.IDENTITY)
44 @Column(name=
"IDENTIFIER")
47 @Column(name=
"RESOURCE_NAME", unique =
true, nullable =
false)
50 private long idContract, idOperator;
52 private boolean active;
54 private double costHour, priceHour, marketPrice;
56 @OneToMany(mappedBy =
"humanResource", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval=
true)
57 @OrderBy(
"defaultDegree DESC, initialDate")
58 private List<OwnedAptitude> ownedAptitudes =
new ArrayList<OwnedAptitude>();
81 this.idContract = idContract;
89 this.idOperator = idOperator;
97 this.marketPrice = marketPrice;
113 this.costHour = costHour;
117 return ownedAptitudes;
121 this.ownedAptitudes = ownedAptitudes;
129 this.priceHour = priceHour;
134 private transient CachedEntity<Contract, Long> contract =
135 new CachedEntity<Contract, Long>() {
137 protected Dao createDao() {
143 return contract.getEntity(idContract);
147 idContract = this.contract.setEntity(contract);
150 private transient CachedEntity<ContractParticipant, Long>
operator =
151 new CachedEntity<ContractParticipant, Long>() {
153 protected Dao createDao() {
159 return operator.getEntity(idOperator);
163 idOperator = this.
operator.setEntity(
operator);
171 return contact !=
null &&
185 name = cp.
getName() +
" - " + name;
190 CheckDate cd =
new CheckDate(date);
191 ArrayList<OwnedAptitude> soo =
new ArrayList<OwnedAptitude>();
193 if(cd.isDateActive(oo.getInitialDate(), oo.getFinalDate())) {
212 if(oo.isDefaultDegree())
break;
boolean isIn(Collection< AptitudeDegree > aptitudeDegrees)
void setContract(Contract contract)
boolean fits(AptitudeDegree required, Date now)
void setOperator(ContractParticipant operator)
void setIdOperator(long idOperator)
boolean fits(IContact contact)
void setActive(boolean active)
Collection< OwnedAptitude > getActiveAptitudes(Date date)
void setPriceHour(double priceHour)
ContractParticipant getOperator()
List< OwnedAptitude > getOwnedAptitudes()
void setCostHour(double costHour)
void setOwnedAptitudes(List< OwnedAptitude > ownedAptitudes)
void setIdContract(long idContract)
void setMarketPrice(double marketPrice)
void setName(String name)
HumanResourceAptitude getDefaultHumanResourceAptitude(Date date)
ContractDefinition getContractDefinition()
IContact getIContractor()