package net.sourceforge.fenixedu.dataTransferObject.inquiries; import java.util.ArrayList; import net.sourceforge.fenixedu.dataTransferObject.InfoExecutionDegree; import net.sourceforge.fenixedu.util.NumberUtils; /** * @author José Pedro Pereira * */ public class InfoInquiriesReport3 extends ArrayList { public static final int PERCENTS_FLOATING_DECIMAL_PLACES = 2; private InfoExecutionDegree executionDegree; private Integer totalNumberInquiries = null; private Integer numberNotStartedInquiries = null; private Integer numberNotFinishedInquiries = null; private Integer numberFinishedInquiries = null; private Integer numberReportedProblems = null; private Integer numberEligible = null; private Integer numberNotWillAnswer = null; private Integer numberMayBeSanctioned = null; public InfoInquiriesReport3() { } /** * @return Returns the executionDegree. */ public InfoExecutionDegree getExecutionDegree() { return executionDegree; } /** * @param executionDegree * The executionDegree to set. */ public void setExecutionDegree(InfoExecutionDegree executionDegree) { this.executionDegree = executionDegree; } public Integer getNumberReportedProblems() { if (numberReportedProblems == null) { int total = 0; // iterate over the list and calculate the value now! for (InfoInquiriesReportPerCurricularYear3 report : this) total += report.getNumberReportedProblems(); numberReportedProblems = total; } return numberReportedProblems; } public Integer getNumberEligible() { if (numberEligible == null) { int total = 0; // iterate over the list and calculate the value now! for (InfoInquiriesReportPerCurricularYear3 report : this) total += report.getNumberEligible(); numberEligible = total; } return numberEligible; } public Integer getNumberFinishedInquiries() { if (numberFinishedInquiries == null) { int total = 0; // iterate over the list and calculate the value now! for (InfoInquiriesReportPerCurricularYear3 report : this) total += report.getNumberFinishedInquiries(); numberFinishedInquiries = total; } return numberFinishedInquiries; } public Integer getNumberNotFinishedInquiries() { if (numberNotFinishedInquiries == null) { int total = 0; // iterate over the list and calculate the value now! for (InfoInquiriesReportPerCurricularYear3 report : this) total += report.getNumberNotFinishedInquiries(); numberNotFinishedInquiries = total; } return numberNotFinishedInquiries; } public Integer getNumberNotStartedInquiries() { if (numberNotStartedInquiries == null) { int total = 0; // iterate over the list and calculate the value now! for (InfoInquiriesReportPerCurricularYear3 report : this) total += report.getNumberNotStartedInquiries(); numberNotStartedInquiries = total; } return numberNotStartedInquiries; } public Integer getNumberNotWillAnswer() { if (numberNotWillAnswer == null) { int total = 0; // iterate over the list and calculate the value now! for (InfoInquiriesReportPerCurricularYear3 report : this) total += report.getNumberNotWillAnswer(); numberNotWillAnswer = total; } return numberNotWillAnswer; } public Integer getNumberMayBeSanctioned() { if (numberMayBeSanctioned == null) { int total = 0; // iterate over the list and calculate the value now! for (InfoInquiriesReportPerCurricularYear3 report : this) total += report.getNumberMayBeSanctioned(); numberMayBeSanctioned = total; } return numberMayBeSanctioned; } public Integer getTotalNumberInquiries() { if (totalNumberInquiries == null) { int total = 0; // iterate over the list and calculate the value now! for (InfoInquiriesReportPerCurricularYear3 report : this) total += report.getTotalNumberInquiries(); totalNumberInquiries = total; } return totalNumberInquiries; } public Double getPercentNotStartedInquiries() { double percent = (double) getNumberNotStartedInquiries() / (double) getTotalNumberInquiries(); percent *= 100.; if (Double.isNaN(percent)) return new Double(percent); return NumberUtils.formatNumber(percent, PERCENTS_FLOATING_DECIMAL_PLACES); } public Double getPercentNotFinishedInquiries() { double percent = (double) getNumberNotFinishedInquiries() / (double) getTotalNumberInquiries(); percent *= 100.; if (Double.isNaN(percent)) return new Double(percent); return NumberUtils.formatNumber(percent, PERCENTS_FLOATING_DECIMAL_PLACES); } public Double getPercentFinishedInquiries() { double percent = (double) getNumberFinishedInquiries() / (double) getTotalNumberInquiries(); percent *= 100.; if (Double.isNaN(percent)) return new Double(percent); return NumberUtils.formatNumber(percent, PERCENTS_FLOATING_DECIMAL_PLACES); } public Double getPercentReportedProblems() { double percent = (double) getNumberReportedProblems() / (double) (getNumberFinishedInquiries() + getNumberNotFinishedInquiries()); percent *= 100.; if (Double.isNaN(percent)) return new Double(percent); return NumberUtils.formatNumber(percent, PERCENTS_FLOATING_DECIMAL_PLACES); } public Double getPercentEligible() { double percent = (double) getNumberEligible() / (double) (getNumberFinishedInquiries()); percent *= 100.; if (Double.isNaN(percent)) return new Double(percent); return NumberUtils.formatNumber(percent, PERCENTS_FLOATING_DECIMAL_PLACES); } public Double getPercentMayBeSanctioned() { double percent = (double) getNumberMayBeSanctioned() / (double) getTotalNumberInquiries(); percent *= 100.; if (Double.isNaN(percent)) return new Double(percent); return NumberUtils.formatNumber(percent, InfoInquiriesReport3.PERCENTS_FLOATING_DECIMAL_PLACES); } public Double getPercentNotWillAnswer() { double percent = (double) getNumberNotWillAnswer() / (double) getNumberFinishedInquiries(); percent *= 100.; if (Double.isNaN(percent)) return new Double(percent); return NumberUtils.formatNumber(percent, InfoInquiriesReport3.PERCENTS_FLOATING_DECIMAL_PLACES); } public Double getPercentFinishedOrOngoing() { double percent = (double) (getNumberFinishedInquiries() + getNumberNotFinishedInquiries()) / (double) getTotalNumberInquiries(); percent *= 100; if (Double.isNaN(percent)) return new Double(percent); return NumberUtils.formatNumber(percent, PERCENTS_FLOATING_DECIMAL_PLACES); } public InfoInquiriesReportPerCurricularYear3 getOrCreateReportPerCurricularYear(Integer year) { if (this.find(year) == null) this.add(new InfoInquiriesReportPerCurricularYear3(year)); return this.find(year); } private InfoInquiriesReportPerCurricularYear3 find(Integer year) { for (InfoInquiriesReportPerCurricularYear3 element : this) { if (element.getCurricularYear().equals(year)) return element; } return null; } }