src/main/java/de/uapcore/lightpit/entities/IssueSummary.java

Fri, 09 Oct 2020 11:43:15 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 09 Oct 2020 11:43:15 +0200
changeset 116
d24354f21df5
parent 86
0a658e53177c
child 126
4148e6de0f21
permissions
-rw-r--r--

zero issues in a version should be displayed as DONE and not TODO

package de.uapcore.lightpit.entities;

public class IssueSummary {
    private int open = 0;
    private int active = 0;
    private int done = 0;

    public int getOpen() {
        return open;
    }

    public void setOpen(int open) {
        this.open = open;
    }

    public int getActive() {
        return active;
    }

    public void setActive(int active) {
        this.active = active;
    }

    public int getDone() {
        return done;
    }

    public void setDone(int done) {
        this.done = done;
    }

    public int getTotal() {
        return open+active+done;
    }

    public int getOpenPercent() {
        return 100-getActivePercent()-getDonePercent();
    }

    public int getActivePercent() {
        int total = getTotal();
        return total > 0 ? 100*active/total : 0;
    }

    public int getDonePercent() {
        int total = getTotal();
        return total > 0 ? 100*done/total : 100;
    }

    /**
     * Adds the specified issue to the summary by increming the respective counter.
     * @param issue the issue
     */
    public void add(Issue issue) {
        switch (issue.getStatus().getPhase()) {
            case 0:
                open++;
                break;
            case 1:
                active++;
                break;
            case 2:
                done++;
                break;
        }
    }
}

mercurial