List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty
public static boolean isEmpty(final Collection<?> coll)
From source file:org.kuali.coeus.propdev.impl.budget.ProposalDevelopmentBudgetVersionsAction.java
/** * This method opens a particular budget version. * // ww w .j av a2s.c om * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward openBudgetVersion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ProposalDevelopmentForm pdForm = (ProposalDevelopmentForm) form; BudgetRatesService budgetService = getBudgetRatesService(); if (StringUtils.equalsIgnoreCase("TRUE", (String) pdForm.getEditingMode().get("modifyProposalBudget"))) { save(mapping, form, request, response); } ProposalDevelopmentDocument pdDoc = pdForm.getProposalDevelopmentDocument(); Budget budgetToOpen = pdDoc.getBudgetDocumentVersion(getSelectedLine(request)); DocumentService documentService = getDocumentService(); String routeHeaderId = budgetToOpen.getBudgetId().toString(); BudgetParentDocument parentDocument = budgetToOpen.getBudgetParent().getDocument(); this.checkProjectStartEndDateWarning(budgetToOpen); Collection<BudgetRate> allPropRates = budgetService.getSavedBudgetRates(budgetToOpen); if (budgetService.checkActivityTypeChange(allPropRates, pdDoc.getDevelopmentProposal().getActivityTypeCode())) { return confirm( syncBudgetRateConfirmationQuestion(mapping, form, request, response, KeyConstants.QUESTION_SYNCH_BUDGET_RATE), CONFIRM_SYNCH_BUDGET_RATE, NO_SYNCH_BUDGET_RATE); } else if (CollectionUtils.isEmpty(allPropRates)) { //Throw Empty Rates message return confirm( syncBudgetRateConfirmationQuestion(mapping, form, request, response, KeyConstants.QUESTION_NO_RATES_ATTEMPT_SYNCH), CONFIRM_SYNCH_BUDGET_RATE, NO_SYNCH_BUDGET_RATE); } String forward = buildForwardUrl(routeHeaderId); if (pdForm.isAuditActivated()) { forward = StringUtils.replace(forward, "budgetParameters.do?", "budgetParameters.do?auditActivated=true&"); } return new ActionForward(forward, true); }
From source file:org.kuali.coeus.propdev.impl.copy.ProposalCopyServiceImpl.java
/** * This method copies all custom data from one document to another. * @param src//from w ww . j a v a 2s. co m * @param dest */ protected void copyCustomDataFromDocument(ProposalDevelopmentDocument src, ProposalDevelopmentDocument dest) { for (Map.Entry<String, CustomAttributeDocument> entry : src.getCustomAttributeDocuments().entrySet()) { // Find the attribute value CustomAttributeDocument customAttributeDocument = entry.getValue(); if (customAttributeDocument.isActive()) { Map<String, Object> primaryKeys = new HashMap<String, Object>(); primaryKeys.put(KRADPropertyConstants.DOCUMENT_NUMBER, src.getDocumentNumber()); primaryKeys.put(Constants.CUSTOM_ATTRIBUTE_ID, customAttributeDocument.getId()); List<CustomAttributeDocValue> customAttributeDocValues = (List<CustomAttributeDocValue>) getDataObjectService() .findMatching(CustomAttributeDocValue.class, QueryByCriteria.Builder.andAttributes(primaryKeys).build()) .getResults(); if (!CollectionUtils.isEmpty(customAttributeDocValues)) { CustomAttributeDocValue customAttributeDocValue = customAttributeDocValues.get(0); // Store a new CustomAttributeDocValue using the new document's document number CustomAttributeDocValue newDocValue = new CustomAttributeDocValue(); newDocValue.setDocumentNumber(dest.getDocumentNumber()); newDocValue.setId(customAttributeDocument.getId().longValue()); newDocValue.setValue(customAttributeDocValue.getValue()); dest.getCustomDataList().add(newDocValue); newDocValue.setValue(customAttributeDocValue == null ? customAttributeDocument.getCustomAttribute().getDefaultValue() : customAttributeDocValue.getValue()); } } } }
From source file:org.kuali.coeus.propdev.impl.core.PropDevLookupableHelperServiceImpl.java
/** * Retrieves all aggregator associated document numbers * with the personSearchString given (matches on lastName, principalName, and principalIds). * Aggregators retrieved have the AGGREGATOR_DOCUMENT_LEVEL role and proposal development namepace. */// w w w .j a v a 2s. c o m private List<String> getAggregatorDocumentNumbers(String personSearchString, Collection<String> principalIds) { if (StringUtils.isEmpty(personSearchString)) { return new ArrayList<>(); } if (CollectionUtils.isEmpty(principalIds)) { principalIds = getMatchingPrincipalIds(personSearchString); } Collection<DocumentAccess> accesses = getDataObjectService().findMatching(DocumentAccess.class, QueryByCriteria.Builder.fromPredicates(equal(ROLE_NAME, RoleConstants.AGGREGATOR_DOCUMENT_LEVEL), equal(NAMESPACE_CODE, Constants.MODULE_NAMESPACE_PROPOSAL_DEVELOPMENT), PredicateFactory.in(PRINCIPAL_ID, principalIds))) .getResults(); List<String> documentNumbers = new ArrayList<>(); for (DocumentAccess access : accesses) { documentNumbers.add(access.getDocumentNumber()); } return documentNumbers; }
From source file:org.kuali.coeus.propdev.impl.s2s.ProposalDevelopmentS2SController.java
@Transactional @RequestMapping(value = "/proposalDevelopment", params = { "methodToCall=refresh", "refreshCaller=S2sOpportunity-LookupView" }) public ModelAndView refresh(@ModelAttribute("KualiForm") ProposalDevelopmentDocumentForm form, BindingResult result, HttpServletRequest request, HttpServletResponse response) throws Exception { ProposalDevelopmentDocument document = form.getProposalDevelopmentDocument(); DevelopmentProposal proposal = document.getDevelopmentProposal(); if (form.getNewS2sOpportunity() != null && StringUtils.isNotEmpty(form.getNewS2sOpportunity().getOpportunityId())) { proposal.setS2sOpportunity(form.getNewS2sOpportunity()); proposal.getS2sOpportunity().setDevelopmentProposal(proposal); //Set default S2S Submission Type if (StringUtils.isBlank(form.getNewS2sOpportunity().getS2sSubmissionTypeCode())) { String defaultS2sSubmissionTypeCode = getParameterService().getParameterValueAsString( ProposalDevelopmentDocument.class, KeyConstants.S2S_SUBMISSIONTYPE_APPLICATION); proposal.getS2sOpportunity().setS2sSubmissionTypeCode(defaultS2sSubmissionTypeCode); getDataObjectService().wrap(proposal.getS2sOpportunity()).fetchRelationship("s2sSubmissionType"); }// w ww. j a va 2s . c om //Set Opportunity Title and Opportunity ID in the Sponsor & Program Information section proposal.setProgramAnnouncementTitle(form.getNewS2sOpportunity().getOpportunityTitle()); proposal.setCfdaNumber(form.getNewS2sOpportunity().getCfdaNumber()); proposal.setProgramAnnouncementNumber(form.getNewS2sOpportunity().getOpportunityId()); form.setNewS2sOpportunity(new S2sOpportunity()); } S2sOpportunity s2sOpportunity = proposal.getS2sOpportunity(); try { if (s2sOpportunity != null && s2sOpportunity.getSchemaUrl() != null) { List<String> missingMandatoryForms = s2sSubmissionService.setMandatoryForms(proposal, s2sOpportunity); if (!CollectionUtils.isEmpty(missingMandatoryForms)) { globalVariableService.getMessageMap().putError(Constants.NO_FIELD, KeyConstants.ERROR_IF_OPPORTUNITY_ID_IS_INVALID, s2sOpportunity.getOpportunityId(), StringUtils.join(missingMandatoryForms, ",")); proposal.setS2sOpportunity(new S2sOpportunity()); } } } catch (S2sCommunicationException ex) { if (ex.getErrorKey().equals(KeyConstants.ERROR_GRANTSGOV_NO_FORM_ELEMENT)) { ex.setMessage(s2sOpportunity.getOpportunityId()); } globalVariableService.getMessageMap().putError(Constants.NO_FIELD, ex.getErrorKey(), ex.getMessageWithParams()); proposal.setS2sOpportunity(new S2sOpportunity()); } super.save(form, result, request, response); return getRefreshControllerService().refresh(form); }
From source file:org.kuali.coeus.propdev.impl.s2s.S2sSubmissionServiceImpl.java
public List<String> setMandatoryForms(DevelopmentProposal proposal, S2sOpportunity s2sOpportunity) { List<String> missingMandatoryForms = new ArrayList<String>(); s2sOpportunity/*from ww w . j av a 2s. co m*/ .setS2sProvider(getDataObjectService().find(S2sProvider.class, s2sOpportunity.getProviderCode())); List<S2sOppForms> s2sOppForms = parseOpportunityForms(s2sOpportunity); if (s2sOppForms != null) { for (S2sOppForms s2sOppForm : s2sOppForms) { if (s2sOppForm.getMandatory() && !s2sOppForm.getAvailable()) { missingMandatoryForms.add(s2sOppForm.getFormName()); } } } if (CollectionUtils.isEmpty(missingMandatoryForms)) { Collections.sort(s2sOppForms, new Comparator<S2sOppForms>() { public int compare(S2sOppForms arg0, S2sOppForms arg1) { int result = arg0.getMandatory().compareTo(arg1.getMandatory()) * -1; if (result == 0) { result = arg0.getFormName().compareTo(arg1.getFormName()); } return result; } }); s2sOpportunity.setS2sOppForms(s2sOppForms); } return missingMandatoryForms; }
From source file:org.kuali.coeus.sys.framework.persistence.CompositeDescriptorCustomizer.java
@Override public final void customize(ClassDescriptor descriptor) throws Exception { final Collection<DescriptorCustomizer> customizers = getCustomizers(); if (CollectionUtils.isEmpty(customizers)) { throw new IllegalStateException("getCustomizers cannot return an empty Collection"); }//from ww w . ja v a2s . c o m for (DescriptorCustomizer customizer : customizers) { if (customizer == null) { throw new IllegalStateException("customizer is null"); } customizer.customize(descriptor); } }
From source file:org.kuali.kra.award.contacts.AwardCentralAdminContactsBean.java
/** * This method finds the count of AwardContacts in the "Unit Contacts" category * @return The count; may be 0/*from w ww . j av a 2 s. c o m*/ */ public int getCentralAdminContactsCount() { if (CollectionUtils.isEmpty(getCentralAdminContacts())) return 0; return getCentralAdminContacts().size(); }
From source file:org.kuali.kra.award.web.struts.action.AwardBudgetsAction.java
/** * This method opens a particular budget version. * //w w w .ja v a 2 s .co m * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ @SuppressWarnings(value = { "unchecked", "rawtypes" }) public ActionForward openBudgetVersion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { AwardForm awardForm = (AwardForm) form; BudgetService budgetService = KcServiceLocator.getService(BudgetService.class); BudgetRatesService budgetRatesService = KcServiceLocator.getService(BudgetRatesService.class); AwardBudgetService awardBudgetService = KcServiceLocator.getService(AwardBudgetService.class); if ("TRUE".equals(awardForm.getEditingMode().get("modifyAwardBudget"))) { save(mapping, form, request, response); } AwardDocument awardDocument = awardForm.getAwardDocument(); awardDocument.refreshBudgetDocumentVersions(); Budget budgetToOpen = awardDocument.getBudgetDocumentVersion(getSelectedLine(request)); Collection<BudgetRate> allBudgetRates = budgetService.getSavedProposalRates(budgetToOpen); Award newestAward = getAwardBudgetService() .getActiveOrNewestAward(awardDocument.getAward().getAwardNumber()); newestAward.refreshReferenceObject("awardFandaRate"); List<AwardFandaRate> fandaRates = newestAward.getAwardFandaRate(); List ebRates = new ArrayList(); if (newestAward.getSpecialEbRateOffCampus() != null) ebRates.add(newestAward.getSpecialEbRateOffCampus()); if (newestAward.getSpecialEbRateOnCampus() != null) ebRates.add(newestAward.getSpecialEbRateOnCampus()); if (newestAward.getRequestedStartDateInitial() == null || newestAward.getRequestedEndDateInitial() == null) { return mapping.findForward(Constants.MAPPING_BASIC); } if (awardBudgetService.checkRateChange(allBudgetRates, newestAward)) { return confirm( syncBudgetRateConfirmationQuestion(mapping, form, request, response, KeyConstants.QUESTION_SYNCH_AWARD_RATE), CONFIRM_SYNCH_BUDGET_RATE, NO_SYNCH_BUDGET_RATE); } if (budgetRatesService.checkActivityTypeChange(allBudgetRates, newestAward.getActivityTypeCode())) { return confirm( syncBudgetRateConfirmationQuestion(mapping, form, request, response, KeyConstants.QUESTION_SYNCH_BUDGET_RATE), CONFIRM_SYNCH_BUDGET_RATE, NO_SYNCH_BUDGET_RATE); } else if (CollectionUtils.isEmpty(allBudgetRates)) { //Throw Empty Rates message return confirm( syncBudgetRateConfirmationQuestion(mapping, form, request, response, KeyConstants.QUESTION_NO_RATES_ATTEMPT_SYNCH), CONFIRM_SYNCH_BUDGET_RATE, NO_SYNCH_BUDGET_RATE); } else { DocumentService documentService = KcServiceLocator.getService(DocumentService.class); AwardBudgetDocument budgetDocument = (AwardBudgetDocument) documentService .getByDocumentHeaderId(budgetToOpen.getDocumentNumber()); String routeHeaderId = budgetDocument.getDocumentHeader().getWorkflowDocument().getDocumentId(); Budget budget = budgetDocument.getBudget(); if (budget.getActivityTypeCode().equals(DEFAULT_BUDGET_ACTIVITY_TYPE_CODE)) { budget.setActivityTypeCode(getBudgetService().getActivityTypeForBudget(budget)); } String backUrl = URLEncoder.encode(buildActionUrl(awardDocument.getDocumentNumber(), Constants.MAPPING_AWARD_BUDGET_VERSIONS_PAGE, "AwardDocument"), StandardCharsets.UTF_8.name()); String forward = buildForwardUrl(routeHeaderId) + "&backLocation=" + backUrl; forward = StringUtils.replace(forward, AWARD_BUDGET_VERSIONS_ACTION, AWARD_BUDGET_PARAMETERS_ACTION); if (!budget.getActivityTypeCode().equals(newestAward.getActivityTypeCode()) || budget.isRateClassTypesReloaded()) { budget.setActivityTypeCode(newestAward.getActivityTypeCode()); forward = forward.replace(AWARD_BUDGET_PARAMETERS_ACTION, AWARD_BUDGET_PARAMETERS_ACTION + "syncBudgetRate=Y" + AMPERSTAND); } forward = StringUtils.replace(forward, AWARD_BUDGET_PARAMETERS_ACTION, AWARD_BUDGET_PARAMETERS_ACTION + AUDIT_ACTIVATED_URL_PARAM + awardForm.isAuditActivated() + AMPERSTAND); forward = StringUtils.replace(forward, AWARD_BUDGET_PARAMETERS_ACTION, AWARD_BUDGET_PARAMETERS_ACTION + SHOW_ALL_BUDGET_VERSIONS_URL_PARAM + awardForm.isShowAllBudgetVersions() + AMPERSTAND); return new ActionForward(forward, true); } }
From source file:org.kuali.kra.coi.CoiDisclosure.java
public DisclosurePerson getDisclosureReporter() { // TODO : what if the list is empty, then need to initialize if (CollectionUtils.isEmpty(disclosurePersons)) { disclosurePersons = new ArrayList<DisclosurePerson>(); disclosurePersons.add(getCoiDisclosureService().getDisclosureReporter( GlobalVariables.getUserSession().getPrincipalId(), this.getCoiDisclosureId())); }/*from w w w. j a va 2 s . c om*/ return disclosurePersons.get(0); }
From source file:org.kuali.kra.coi.CoiDisclProject.java
private String getSelectDesc() { String description = Constants.EMPTY_STRING; try {//from w w w .j av a2s . co m String valuesFinder = coiDisclosureEventType.getSelectBox1ValuesFinder(); if (StringUtils.isNotBlank(valuesFinder)) { Class valuesFinderClass = Class.forName(valuesFinder); KeyValuesFinder keyValuesFinder = (KeyValuesFinder) valuesFinderClass.newInstance(); List<KeyValue> keyValues = keyValuesFinder.getKeyValues(); if (!CollectionUtils.isEmpty(keyValues)) { for (KeyValue keyValue : keyValues) { if (keyValue.getKey().equals(selectBox1)) { description = keyValue.getValue(); } } } } } catch (Exception e) { //Failed to load select box } return description; }