BrightSide Workbench Full Report + Source Code
IssueStatus.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.ArrayList;
21 import java.util.List;
22 import org.turro.i18n.I_;
23 import org.zkoss.lang.Objects;
24 
29 public enum IssueStatus {
30 
31  STATUS_NEW(false, false, true, false),
32  STATUS_INCOMPLETE(true, false, true, false),
33  STATUS_STARTED(true, true, false, false),
34  STATUS_REOPENED(true, true, false, false),
35  STATUS_REUNION(true, false, true, false),
36  STATUS_FROZEN(true, false, true, false),
37  STATUS_RESOLVED(true, false, false, true),
38  STATUS_VERIFIED(true, false, false, true),
39  STATUS_CLOSED(true, false, false, true);
40 
41  private final boolean seen, working, standBy, finished;
42 
43  private IssueStatus(boolean seen, boolean working, boolean standBy, boolean finished) {
44  this.seen = seen;
45  this.working = working;
46  this.standBy = standBy;
47  this.finished = finished;
48  }
49 
50  public boolean isFinished() {
51  return finished;
52  }
53 
54  public boolean isSeen() {
55  return seen;
56  }
57 
58  public boolean isStandBy() {
59  return standBy;
60  }
61 
62  public boolean isWorking() {
63  return working;
64  }
65 
66  public String color(IssueResolution resolution) {
67  return switch (this) {
68  case STATUS_NEW -> "olive";
69  case STATUS_INCOMPLETE -> "orange";
70  case STATUS_STARTED -> "yellow";
71  case STATUS_REOPENED -> "yellow";
72  case STATUS_REUNION -> "brown";
73  case STATUS_FROZEN -> "grey";
74  case STATUS_RESOLVED, STATUS_VERIFIED, STATUS_CLOSED -> switch(resolution) {
75  case RESOLUTION_NONE -> "olive";
76  case RESOLUTION_FIXED -> "green";
77  case RESOLUTION_WORKSFORME -> "yellow";
78  case RESOLUTION_DUPLICATED, RESOLUTION_MOVED -> "teal";
79  case RESOLUTION_WONTFIX, RESOLUTION_INVALID -> "red";
80  default -> "";
81  };
82  default -> "";
83  };
84  }
85 
86  public String label(IssueResolution resolution) {
87  return I_.byKey(this.toString()) + (!this.isFinished() ? "" :
88  (" - " + I_.byKey(resolution.toString())));
89  }
90 
91  /* Helpers */
92 
93  public static List<IssueStatus> selectBy(Boolean seen, Boolean working, Boolean standBy, Boolean finished) {
94  List<IssueStatus> list= new ArrayList<>();
95  for(IssueStatus status : IssueStatus.values()) {
96  if((seen == null || Objects.equals(status.isSeen(), seen)) &&
97  (working == null || Objects.equals(status.isWorking(), working)) &&
98  (standBy == null || Objects.equals(status.isStandBy(), standBy)) &&
99  (finished == null || Objects.equals(status.isFinished(), finished))) {
100  list.add(status);
101  }
102  }
103  return list;
104  }
105 
106 }
static String byKey(String key)
Definition: I_.java:83
String label(IssueResolution resolution)
String color(IssueResolution resolution)
static List< IssueStatus > selectBy(Boolean seen, Boolean working, Boolean standBy, Boolean finished)