private List<ReleaseAssessmentTypeDTO> FilterNegativeEntitlements( List<ReleaseAssessmentTypeDTO> assessments) { List<ReleaseAssessmentTypeDTO> filtered = new LinkedList<>(); for (ReleaseAssessmentTypeDTO assessment : assessments) { if (assessment.getEntitlementId() > 0) filtered.add(assessment); } return filtered; }
// Fields in config.jelly must match the parameter names in the "DataBoundConstructor" // Entry point when building @DataBoundConstructor public FodUploaderPlugin( String applicationId, String releaseId, String assessmentTypeId, String technologyStack, String languageLevel, boolean runOpenSourceAnalysis, boolean isExpressScan, boolean isExpressAudit, int pollingInterval, boolean doPrettyLogOutput, boolean includeAllFiles, boolean excludeThirdParty, boolean isRemediationScan, int entitlementId) { int frequencyType = 0; for (ReleaseAssessmentTypeDTO assessment : getDescriptor().assessments) { if (assessment.getEntitlementId() == entitlementId) { frequencyType = assessment.getFrequencyTypeId(); } } // load job model jobModel = new JobConfigModel( applicationId, releaseId, assessmentTypeId, technologyStack, languageLevel, runOpenSourceAnalysis, isExpressScan, isExpressAudit, pollingInterval, doPrettyLogOutput, includeAllFiles, excludeThirdParty, isRemediationScan, entitlementId, frequencyType); }
@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; }