BrightSide Workbench Full Report + Source Code
IssuePredecessor.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.dossier.entity;
19 
20 import java.util.Date;
21 import java.util.Objects;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.ManyToOne;
28 import javax.persistence.Temporal;
29 import javax.persistence.TemporalType;
30 import org.turro.i18n.I_;
31 
36 @Entity
37 public class IssuePredecessor implements java.io.Serializable {
38 
39  @Id
40  @GeneratedValue(strategy=GenerationType.IDENTITY)
41  @Column(name="IDENTIFIER")
42  private Long id;
43 
44  private IssuePredecessorType type;
45 
46  @Temporal(value = TemporalType.TIMESTAMP)
47  private java.util.Date creation;
48 
49  @ManyToOne
50  private Issue source;
51 
52  @ManyToOne
53  private Issue target;
54 
55  public Long getId() {
56  return id;
57  }
58 
59  public void setId(Long id) {
60  this.id = id;
61  }
62 
63  public Date getCreation() {
64  return creation;
65  }
66 
67  public void setCreation(Date creation) {
68  this.creation = creation;
69  }
70 
71  public Issue getSource() {
72  return source;
73  }
74 
75  public void setSource(Issue source) {
76  this.source = source;
77  }
78 
79  public Issue getTarget() {
80  return target;
81  }
82 
83  public void setTarget(Issue target) {
84  this.target = target;
85  }
86 
88  return type;
89  }
90 
91  public void setType(IssuePredecessorType type) {
92  this.type = type;
93  }
94 
95  public String getFullDescription() {
96  return "#" + target.getId() + " " + target.getDescription() + " " +
97  I_.byKey(type.toString()) +
98  " #" + source.getId() + " " + source.getDescription();
99  }
100 
101  public Issue getCounterFor(Issue issue) {
102  if(Objects.equals(source.getId(), issue.getId())) {
103  return target;
104  } else if(Objects.equals(target.getId(), issue.getId())) {
105  return source;
106  }
107  return null;
108  }
109 
110  public String getDescriptionFor(Issue issue) {
111  if(Objects.equals(source.getId(), issue.getId())) {
112  if(type.equals(IssuePredecessorType.START_WHEN_ENDS)) {
113  return "starts when this issue is resolved";
114  } else if(type.equals(IssuePredecessorType.START_WHEN_STARTS)) {
115  return "and this issue start together";
116  }
117  } else if(Objects.equals(target.getId(), issue.getId())) {
118  if(type.equals(IssuePredecessorType.START_WHEN_ENDS)) {
119  return "must be resolved to start this issue";
120  } else if(type.equals(IssuePredecessorType.START_WHEN_STARTS)) {
121  return "and this issue start together";
122  }
123  }
124  return null;
125  }
126 
127 }
void setType(IssuePredecessorType type)
static String byKey(String key)
Definition: I_.java:83