1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/main/java/de/uapcore/lightpit/entities/IssueSummary.java Mon Jun 01 14:46:58 2020 +0200 1.3 @@ -0,0 +1,67 @@ 1.4 +package de.uapcore.lightpit.entities; 1.5 + 1.6 +public class IssueSummary { 1.7 + private int open = 0; 1.8 + private int active = 0; 1.9 + private int done = 0; 1.10 + 1.11 + public int getOpen() { 1.12 + return open; 1.13 + } 1.14 + 1.15 + public void setOpen(int open) { 1.16 + this.open = open; 1.17 + } 1.18 + 1.19 + public int getActive() { 1.20 + return active; 1.21 + } 1.22 + 1.23 + public void setActive(int active) { 1.24 + this.active = active; 1.25 + } 1.26 + 1.27 + public int getDone() { 1.28 + return done; 1.29 + } 1.30 + 1.31 + public void setDone(int done) { 1.32 + this.done = done; 1.33 + } 1.34 + 1.35 + public int getTotal() { 1.36 + return open+active+done; 1.37 + } 1.38 + 1.39 + public int getOpenPercent() { 1.40 + return 100-getActivePercent()-getDonePercent(); 1.41 + } 1.42 + 1.43 + public int getActivePercent() { 1.44 + int total = getTotal(); 1.45 + return total > 0 ? 100*active/total : 0; 1.46 + } 1.47 + 1.48 + public int getDonePercent() { 1.49 + int total = getTotal(); 1.50 + return total > 0 ? 100*done/total : 0; 1.51 + } 1.52 + 1.53 + /** 1.54 + * Adds the specified issue to the summary by increming the respective counter. 1.55 + * @param issue the issue 1.56 + */ 1.57 + public void add(Issue issue) { 1.58 + switch (issue.getStatus().getPhase()) { 1.59 + case 0: 1.60 + open++; 1.61 + break; 1.62 + case 1: 1.63 + active++; 1.64 + break; 1.65 + case 2: 1.66 + done++; 1.67 + break; 1.68 + } 1.69 + } 1.70 +}