@SuppressWarnings("unused") public ListBoxModel doFillAssessmentTypeIdItems(@QueryParameter(RELEASE_ID) int releaseId) { ListBoxModel listBox = new ListBoxModel(); api.authenticate(); assessments = FilterNegativeEntitlements(api.getReleaseController().getAssessmentTypeIds(releaseId)); for (ReleaseAssessmentTypeDTO assessmentType : assessments) { final String value = String.valueOf(assessmentType.getAssessmentTypeId()); String infoText; if (assessmentType.getFrequencyTypeId() == EntitlementFrequencyType.Subscription.getValue()) { infoText = "Subscription"; } else { infoText = String.format("Single Scan: %s Unit(s) left", assessmentType.getUnitsAvailable()); } final String name = String.format("%s (%s)", assessmentType.getName(), infoText); listBox.add(new ListBoxModel.Option(name, value, false)); } return listBox; }
@SuppressWarnings("unused") public ListBoxModel doFillEntitlementIdItems( @QueryParameter(ASSESSMENT_TYPE_ID) final String assessmentTypeId) { // Get entitlements on load ListBoxModel listBox = new ListBoxModel(); Set<ReleaseAssessmentTypeDTO> applicableAssessments = new HashSet<>(); for (ReleaseAssessmentTypeDTO assessment : assessments) { if (assessment.getAssessmentTypeId() == Integer.parseInt(assessmentTypeId) && Integer.parseInt(assessmentTypeId) > 0) applicableAssessments.add(assessment); } for (ReleaseAssessmentTypeDTO entitlement : applicableAssessments) { String val = String.valueOf(entitlement.getEntitlementId()); boolean addIt = true; for (ListBoxModel.Option option : listBox) { addIt = !option.value.equals(val); } if (addIt) listBox.add(new ListBoxModel.Option(val, val, false)); } return listBox; }