summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/models
diff options
context:
space:
mode:
authorPaul Martin <paul@paulsputer.com>2014-09-29 22:10:20 +0100
committerPaul Martin <paul@paulsputer.com>2014-10-20 22:54:54 +0100
commitf9c78c0ccc709509cdf7f83c45c898883d329db2 (patch)
tree50c89c4cf7756d9a80948c70b7eba8f14027d198 /src/main/java/com/gitblit/models
parent5be2d394c28f12269ba1aa8e2bd4f9cbd5db9540 (diff)
downloadgitblit-f9c78c0ccc709509cdf7f83c45c898883d329db2.tar.gz
gitblit-f9c78c0ccc709509cdf7f83c45c898883d329db2.zip
Tickets - Priority, Severity options
+ Severity indicated via new character indicator and color of ticket icon on ticket list + Priority indicated via new priority icon and color on ticket list + Indexed as integers to provide sorting and maintain language neutral index + Colours and indicator text controlled through CSS classes priority-<x> & severity-<x> + UITicketTest created to generate tickets of all types to ease debugging
Diffstat (limited to 'src/main/java/com/gitblit/models')
-rw-r--r--src/main/java/com/gitblit/models/TicketModel.java120
1 files changed, 119 insertions, 1 deletions
diff --git a/src/main/java/com/gitblit/models/TicketModel.java b/src/main/java/com/gitblit/models/TicketModel.java
index 9bdb2606..fd0b09eb 100644
--- a/src/main/java/com/gitblit/models/TicketModel.java
+++ b/src/main/java/com/gitblit/models/TicketModel.java
@@ -91,6 +91,10 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
public Integer deletions;
+ public Priority priority;
+
+ public Severity severity;
+
/**
* Builds an effective ticket from the collection of changes. A change may
* Add or Subtract information from a ticket, but the collection of changes
@@ -141,6 +145,8 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
changes = new ArrayList<Change>();
status = Status.New;
type = Type.defaultType;
+ priority = Priority.defaultPriority;
+ severity = Severity.defaultSeverity;
}
public boolean isOpen() {
@@ -517,6 +523,12 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
case mergeSha:
mergeSha = toString(value);
break;
+ case priority:
+ priority = TicketModel.Priority.fromObject(value, priority);
+ break;
+ case severity:
+ severity = TicketModel.Severity.fromObject(value, severity);
+ break;
default:
// unknown
break;
@@ -1183,7 +1195,7 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
public static enum Field {
title, body, responsible, type, status, milestone, mergeSha, mergeTo,
- topic, labels, watchers, reviewers, voters, mentions;
+ topic, labels, watchers, reviewers, voters, mentions, priority, severity;
}
public static enum Type {
@@ -1310,4 +1322,110 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
return null;
}
}
+
+ public static enum Priority {
+ Low(-1), Normal(0), High(1), Urgent(2);
+
+ public static Priority defaultPriority = Normal;
+
+ final int value;
+
+ Priority(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public static Priority [] choices() {
+ return new Priority [] { Urgent, High, Normal, Low };
+ }
+
+ @Override
+ public String toString() {
+ return name().toLowerCase().replace('_', ' ');
+ }
+
+ public static Priority fromObject(Object o, Priority defaultPriority) {
+ if (o instanceof Priority) {
+ // cast and return
+ return (Priority) o;
+ } else if (o instanceof String) {
+ // find by name
+ for (Priority priority : values()) {
+ String str = o.toString();
+ if (priority.name().equalsIgnoreCase(str)
+ || priority.toString().equalsIgnoreCase(str)) {
+ return priority;
+ }
+ }
+ } else if (o instanceof Number) {
+
+ switch (((Number) o).intValue()) {
+ case -1: return Priority.Low;
+ case 0: return Priority.Normal;
+ case 1: return Priority.High;
+ case 2: return Priority.Urgent;
+ default: return Priority.Normal;
+ }
+ }
+
+ return defaultPriority;
+ }
+ }
+
+ public static enum Severity {
+ Unrated(-1), Negligible(1), Minor(2), Serious(3), Critical(4), Catastrophic(5);
+
+ public static Severity defaultSeverity = Unrated;
+
+ final int value;
+
+ Severity(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public static Severity [] choices() {
+ return new Severity [] { Unrated, Negligible, Minor, Serious, Critical, Catastrophic };
+ }
+
+ @Override
+ public String toString() {
+ return name().toLowerCase().replace('_', ' ');
+ }
+
+ public static Severity fromObject(Object o, Severity defaultSeverity) {
+ if (o instanceof Severity) {
+ // cast and return
+ return (Severity) o;
+ } else if (o instanceof String) {
+ // find by name
+ for (Severity severity : values()) {
+ String str = o.toString();
+ if (severity.name().equalsIgnoreCase(str)
+ || severity.toString().equalsIgnoreCase(str)) {
+ return severity;
+ }
+ }
+ } else if (o instanceof Number) {
+
+ switch (((Number) o).intValue()) {
+ case -1: return Severity.Unrated;
+ case 1: return Severity.Negligible;
+ case 2: return Severity.Minor;
+ case 3: return Severity.Serious;
+ case 4: return Severity.Critical;
+ case 5: return Severity.Catastrophic;
+ default: return Severity.Unrated;
+ }
+ }
+
+ return defaultSeverity;
+ }
+ }
}