BrightSide Workbench Full Report + Source Code
Aptitude.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.ArrayList;
21 import java.util.Iterator;
22 import java.util.List;
23 import javax.persistence.*;
24 import org.turro.string.Strings;
25 
30 @Entity
31 public class Aptitude implements java.io.Serializable {
32 
33  @Id
34  @GeneratedValue(strategy=GenerationType.IDENTITY)
35  @Column(name="IDENTIFIER")
36  private long id;
37 
38  private String name;
39 
40  @OneToMany(mappedBy="aptitude", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval=true)
41  @OrderBy(value="ordering")
42  private List<AptitudeDegree> aptitudeDegrees = new ArrayList<AptitudeDegree>();
43 
44  public long getId() {
45  return id;
46  }
47 
48  public void setId(long id) {
49  this.id = id;
50  }
51 
52  public String getName() {
53  return name;
54  }
55 
56  public void setName(String name) {
57  this.name = name;
58  }
59 
60  public List<AptitudeDegree> getAptitudeDegrees() {
61  return aptitudeDegrees;
62  }
63 
64  public void setAptitudeDegrees(List<AptitudeDegree> aptitudeDegrees) {
65  this.aptitudeDegrees = aptitudeDegrees;
66  }
67 
68  /* Helpers */
69 
70  public boolean isEmpty() {
72  return Strings.isBlank(name);
73  }
74 
75  public void clearEmptyLines() {
76  Iterator<AptitudeDegree> itp = aptitudeDegrees.iterator();
77  while(itp.hasNext()) {
78  AptitudeDegree p = itp.next();
79  if(p.isEmpty()) {
80  p.setAptitude(null);
81  itp.remove();
82  }
83  }
84  }
85 
86  public void prepareForSaving() {
88  }
89 
90 }
void setAptitude(Aptitude aptitude)
void setName(String name)
Definition: Aptitude.java:56
List< AptitudeDegree > getAptitudeDegrees()
Definition: Aptitude.java:60
void setAptitudeDegrees(List< AptitudeDegree > aptitudeDegrees)
Definition: Aptitude.java:64