BrightSide Workbench Full Report + Source Code
Resource.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.erp.entity;
19 
20 import java.util.HashSet;
21 import java.util.Set;
22 import javax.persistence.*;
23 import org.turro.financials.db.FinancialsPU;
24 import org.turro.financials.entity.Contract;
25 
30 @Entity
31 public class Resource implements java.io.Serializable {
32 
33  @Id
34  @GeneratedValue(strategy=GenerationType.IDENTITY)
35  @Column(name="IDENTIFIER")
36  private long id;
37 
38  @Column(name="RESOURCE_NAME", unique = true, nullable = false)
39  private String name;
40 
41  private long idContract;
42 
43  private double costHour, priceHour, marketPrice;
44 
45  private boolean active;
46 
47  @ManyToMany(fetch = FetchType.EAGER)
48  private Set<AptitudeDegree> aptitudeDegrees = new HashSet<AptitudeDegree>();
49 
50  public boolean isActive() {
51  return active;
52  }
53 
54  public void setActive(boolean active) {
55  this.active = active;
56  }
57 
58  public double getCostHour() {
59  return costHour;
60  }
61 
62  public void setCostHour(double costHour) {
63  this.costHour = costHour;
64  }
65 
66  public long getId() {
67  return id;
68  }
69 
70  public void setId(long id) {
71  this.id = id;
72  }
73 
74  public long getIdContract() {
75  return idContract;
76  }
77 
78  public void setIdContract(long idContract) {
79  this.idContract = idContract;
80  }
81 
82  public double getMarketPrice() {
83  return marketPrice;
84  }
85 
86  public void setMarketPrice(double marketPrice) {
87  this.marketPrice = marketPrice;
88  }
89 
90  public String getName() {
91  return name;
92  }
93 
94  public void setName(String name) {
95  this.name = name;
96  }
97 
98  public Set<AptitudeDegree> getAptitudeDegrees() {
99  return aptitudeDegrees;
100  }
101 
102  public void setAptitudeDegrees(Set<AptitudeDegree> aptitudeDegrees) {
103  this.aptitudeDegrees = aptitudeDegrees;
104  }
105 
106  public double getPriceHour() {
107  return priceHour;
108  }
109 
110  public void setPriceHour(double priceHour) {
111  this.priceHour = priceHour;
112  }
113 
117  return new FinancialsPU().find(Contract.class, idContract);
118  }
119 
120  public void setContract(Contract contract) {
121  idContract = contract != null ? contract.getId() : 0L;
122  }
123 
124  public void prepareForSaving() {
125  Contract c = getContract();
126  String s = c == null ? null : c.getIContractor().getName();
127  name = (s == null || name.endsWith(s)) ? name : name + " - " + s;
128  }
129 
130  public boolean isInternal() {
131  return idContract == 0;
132  }
133 
134 }
void setName(String name)
Definition: Resource.java:94
void setContract(Contract contract)
Definition: Resource.java:120
void setMarketPrice(double marketPrice)
Definition: Resource.java:86
void setActive(boolean active)
Definition: Resource.java:54
void setCostHour(double costHour)
Definition: Resource.java:62
void setIdContract(long idContract)
Definition: Resource.java:78
Set< AptitudeDegree > getAptitudeDegrees()
Definition: Resource.java:98
void setPriceHour(double priceHour)
Definition: Resource.java:110
void setAptitudeDegrees(Set< AptitudeDegree > aptitudeDegrees)
Definition: Resource.java:102