BrightSide Workbench Full Report + Source Code
bserp-core/src/main/java/org/turro/erp/entity/Project.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.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.FetchType;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.ManyToOne;
29 import javax.persistence.OneToMany;
30 import org.turro.contacts.util.ContactGroup;
31 
36 @Entity
37 public class Project implements java.io.Serializable {
38 
39  @Id
40  @GeneratedValue(strategy=GenerationType.IDENTITY)
41  @Column(name="IDENTIFIER")
42  private long id;
43 
44  @Column(name="PROJECT_NAME", nullable = false)
45  private String name;
46 
47  @Column(name="PROJECT_OWNER")
48  private String owner;
49 
50  @ManyToOne
51  private org.turro.erp.entity.Project parent;
52 
53  @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
54  private Set<Project> subprojects = new HashSet<Project>();
55 
56  public long getId() {
57  return id;
58  }
59 
60  public void setId(long id) {
61  this.id = id;
62  }
63 
64  public String getName() {
65  return name;
66  }
67 
68  public void setName(String name) {
69  this.name = name;
70  }
71 
72  public String getOwner() {
73  return owner;
74  }
75 
76  public void setOwner(String owner) {
77  this.owner = owner;
78  }
79 
80  public Project getParent() {
81  return parent;
82  }
83 
84  public void setParent(Project parent) {
85  this.parent = parent;
86  }
87 
88  public Set<Project> getSubprojects() {
89  return subprojects;
90  }
91 
92  public void setSubprojects(Set<Project> subprojects) {
93  this.subprojects = subprojects;
94  }
95 
99  return new ContactGroup(null).setRealValue(owner);
100  }
101 
102  public void setContactGroup(ContactGroup contactGroup) {
103  if(contactGroup != null) {
104  owner = contactGroup.getRealValue();
105  }
106  }
107 
108 }
ContactGroup setRealValue(String value)