BrightSide Workbench Full Report + Source Code
elephant-dossier/src/main/java/org/turro/dossier/workload/WorkloadSet.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 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.workload;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.EnumSet;
24 import java.util.Iterator;
25 import java.util.TreeSet;
26 import org.turro.dossier.entity.Issue;
27 import org.turro.dossier.entity.Worksheet;
28 import org.turro.dossier.issue.IssueWrapper;
29 import org.turro.dossier.zul.issue.IssueStage;
30 
35 public class WorkloadSet extends TreeSet<WorkloadItem> {
36 
37  public static IssueStage getStage(WorkloadItem item) {
38 
39  Worksheet worksheet = item.getWorksheet();
40  if(worksheet != null) {
42  }
43 
44  IssueWrapper wissue = item.getWrapper();
45  if(wissue.isUnrelated()) {
47  }
48 
49  if(wissue.hasPassedNow()) {
51  }
52 
53  if(!wissue.hasPassedStartDate() || !wissue.canStartBySources()) {
55  }
56 
57  int stage = wissue.getRelevanceOrderByContact();
58 
59  switch(stage) {
60  case 1: return IssueStage.ISSUE_STAGE_TO_DO;
61  case 2: return IssueStage.ISSUE_STAGE_REUNION;
62  case 5: return IssueStage.ISSUE_STAGE_FROZEN;
63  }
64 
66  }
67 
68  public static int getKanbanColumn(WorkloadItem item) {
69  return item.getWrapper().getKanbanColumn();
70  }
71 
72  public boolean inWorksheet(Long id) {
73  for(final WorkloadItem item : this) {
74  if(item.getWorksheet() == null) break;
75  if(id.equals(item.getIssue().getId())) {
76  return true;
77  }
78  }
79  return false;
80  }
81 
82  public void keep(EnumSet<IssueStage> set) {
83  Iterator<WorkloadItem> it = iterator();
84  while(it.hasNext()) {
85  if(!set.contains(getStage(it.next()))) {
86  it.remove();
87  }
88  }
89  }
90 
91  public Collection<Issue> getIssues() {
92  ArrayList<Issue> issues = new ArrayList<>();
93  for(final WorkloadItem item : this) {
94  issues.add(item.getIssue());
95  }
96  return issues;
97  }
98 
99 }