BrightSide Workbench Full Report + Source Code
Department.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.financials.entity;
19 
20 import java.util.HashSet;
21 import java.util.Set;
22 import javax.persistence.*;
23 import org.turro.string.Strings;
24 import org.turro.financials.model.business.IValuation;
25 import org.turro.jpa.entity.IDaoEntity;
26 
31 @Entity
32 public class Department implements java.io.Serializable, IDaoEntity, IValuation {
33 
34  @Id
35  @GeneratedValue(strategy=GenerationType.IDENTITY)
36  @Column(name="IDENTIFIER")
37  private long id;
38 
39  private double structureMargin, profitMargin;
40 
41  private boolean alwaysApply;
42 
43  @Column(name="DEPARTMENT_NAME")
44  private String name;
45 
46  @ManyToOne
47  private Headquarters headquarters;
48 
49  @OneToMany(mappedBy = "department", fetch = FetchType.EAGER)
50  @OrderBy(value="name ASC")
51  private Set<Contract> stores = new HashSet<Contract>();
52 
53  @Override
54  public double getStructureMargin() {
55  return structureMargin;
56  }
57 
58  public void setStructureMargin(double structureMargin) {
59  this.structureMargin = structureMargin;
60  }
61 
63  return headquarters;
64  }
65 
66  public void setHeadquarters(Headquarters headquarters) {
67  this.headquarters = headquarters;
68  }
69 
70  @Override
71  public long getId() {
72  return id;
73  }
74 
75  public void setId(long id) {
76  this.id = id;
77  }
78 
79  @Override
80  public String getName() {
81  return name;
82  }
83 
84  public void setName(String name) {
85  this.name = name;
86  }
87 
88  @Override
89  public double getProfitMargin() {
90  return profitMargin;
91  }
92 
93  public void setProfitMargin(double profitMargin) {
94  this.profitMargin = profitMargin;
95  }
96 
97  @Override
98  public boolean isAlwaysApply() {
99  return alwaysApply;
100  }
101 
102  public void setAlwaysApply(boolean alwaysApply) {
103  this.alwaysApply = alwaysApply;
104  }
105 
106  public Set<Contract> getStores() {
107  return stores;
108  }
109 
110  public void setStores(Set<Contract> stores) {
111  this.stores = stores;
112  }
113 
114  /* IDaoEntity */
115 
116  @Override
117  public Object entityId() {
118  return id;
119  }
120 
121  @Override
122  public boolean isEmpty() {
123  return Strings.isBlank(name);
124  }
125 
126  /* Helpers */
127 
128  public String getFullName() {
129  return headquarters.getName() + " | " +
130  getName();
131  }
132 
133 }
void setAlwaysApply(boolean alwaysApply)
void setProfitMargin(double profitMargin)
Definition: Department.java:93
void setHeadquarters(Headquarters headquarters)
Definition: Department.java:66
void setStores(Set< Contract > stores)
void setStructureMargin(double structureMargin)
Definition: Department.java:58