BrightSide Workbench Full Report + Source Code
IssueVertex.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 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 
19 package org.turro.dossier.graph;
20 
21 import java.util.HashSet;
22 import java.util.Objects;
23 import java.util.Set;
24 import java.util.stream.Collectors;
25 import org.turro.dossier.db.DossierPU;
26 import org.turro.dossier.task.Tasks;
27 
32 public class IssueVertex {
33 
34  private final IssueGraph graph;
35  private final Set<IssueItem> tasks;
36  private final IssueItem item;
37 
38  public IssueVertex(IssueGraph graph, IssueItem item) {
39  this.graph = graph;
40  this.tasks = new HashSet<>();
41  this.item = item;
42  }
43 
44  public Set<IssueItem> getTasks() {
45  return tasks;
46  }
47 
48  public IssueItem getItem() {
49  return item;
50  }
51 
52  public String getName() {
53  return item.getIssue().getDescription();
54  }
55 
56  public boolean isMilestone() {
57  return item.getIssue().isMilestone();
58  }
59 
60  public boolean isAchieved() {
61  return item.getIssue().getStatus().isFinished();
62  }
63 
64  public boolean isLeaf() {
65  return graph.outgoingEdgesOf(this).isEmpty();
66  }
67 
68  public boolean hasDates() {
69  return item.getIssue().getStartDate() != null &&
70  item.getIssue().getDelivery() != null;
71  }
72 
73  public Set<IssueVertex> getIncoming() {
74  return graph.incomingEdgesOf(this).stream().map(e -> e.getSource()).collect(Collectors.toSet());
75  }
76 
77  public Set<IssueVertex> getOutgoing() {
78  return graph.outgoingEdgesOf(this).stream().map(e -> e.getTarget()).collect(Collectors.toSet());
79  }
80 
81  public String getEntityPath() {
82  return DossierPU.getObjectPath(item.getIssue());
83  }
84 
85  /* Done */
86 
87  private double pcdone = - 1;
88 
89  public double percentDone() {
90  if(pcdone == -1) {
91  pcdone = Tasks.from(item.getIssue(), false, false).getPercentTasksDone();
92  }
93  return pcdone;
94  }
95 
96  /* Utils */
97 
98  @Override
99  public int hashCode() {
100  int hash = 3;
101  hash = 67 * hash + Objects.hashCode(this.item);
102  return hash;
103  }
104 
105  @Override
106  public boolean equals(Object obj) {
107  if (this == obj) {
108  return true;
109  }
110  if (obj == null) {
111  return false;
112  }
113  if (getClass() != obj.getClass()) {
114  return false;
115  }
116  final IssueVertex other = (IssueVertex) obj;
117  return Objects.equals(this.item, other.item);
118  }
119 
120 }
static String getObjectPath(Object object)
Definition: DossierPU.java:66
Set< IssueVertex > getOutgoing()
Set< IssueVertex > getIncoming()
IssueVertex(IssueGraph graph, IssueItem item)
static Tasks from(Dossier dossier, boolean onlyOpen, boolean sameDossier)