Example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty

List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty

Introduction

In this page you can find the example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty.

Prototype

public static boolean isNotEmpty(final Collection<?> coll) 

Source Link

Document

Null-safe check if the specified collection is not empty.

Usage

From source file:org.kuali.coeus.propdev.impl.person.attachment.ProposalDevelopmentPersonnelAttachmentRule.java

private boolean checkForDuplicates(ProposalPersonBiography biography,
        List<ProposalPersonBiography> existingBiographies) {
    boolean rulePassed = true;
    if (CollectionUtils.isNotEmpty(existingBiographies) && biography.getProposalPersonNumber() != null) {
        for (ProposalPersonBiography personBiography : existingBiographies) {
            if (personBiography.getProposalPersonNumber() != null
                    && personBiography.getDocumentTypeCode() != null
                    && !StringUtils.equalsIgnoreCase(
                            getProposalPersonBiographyService().findPropPerDocTypeForOther().getCode(),
                            personBiography.getDocumentTypeCode())
                    && personBiography.getProposalPersonNumber().equals(biography.getProposalPersonNumber())
                    && personBiography.getDocumentTypeCode().equals(biography.getDocumentTypeCode())) {
                if (!personBiography.getBiographyNumber().equals(biography.getBiographyNumber())) {
                    rulePassed = false;// w w w. j av  a  2 s  .co  m
                }
            }
        }
    }
    return rulePassed;
}

From source file:org.kuali.coeus.propdev.impl.person.creditsplit.CreditSplitCustomColumnsCollection.java

@Override
public void performInitialization(Object model) {

    ProposalDevelopmentDocumentForm pdForm = (ProposalDevelopmentDocumentForm) model;
    ((ProposalDevelopmentViewHelperServiceImpl) pdForm.getViewHelperService())
            .setInvestigatorCreditTypes(pdForm);
    if (CollectionUtils.isNotEmpty(
            ((ProposalDevelopmentDocumentForm) model).getDevelopmentProposal().getInvestigators())) {
        List<Object> columnCollection = ObjectPropertyUtils.getPropertyValue(model,
                getColumnBindingInfo().getBindingPath());

        List<Component> columns = new ArrayList<Component>();
        for (Component component : this.getItems()) {
            if (component.isRender() || component.isHidden()) {
                columns.add(component);//from   ww w  .j a  v  a 2  s.  c om
            }
        }

        int index = 0;
        for (Object column : columnCollection) {
            DataFieldBase columnField = ComponentUtils.copy(columnFieldPrototype);
            String columnLabel = StringUtils.isEmpty(columnLabelPropertyName) ? "description"
                    : columnLabelPropertyName;

            try {
                columnField.getFieldLabel()
                        .setLabelText(PropertyUtils.getNestedProperty(column, columnLabel).toString());
                columnField.getBindingInfo().setBindingName("creditSplits[" + index + "].credit");
                columnField.setPropertyName("creditSplits.credit");
                columnField.setOrder(100 + index);
                columns.add(columnField);
            } catch (Exception e) {
                LOG.error("Could not retrieve column label from column collection item", e);
            }
            index++;
        }
        this.setItems(columns);
    }
    super.performInitialization(model);
}

From source file:org.kuali.coeus.propdev.impl.person.KeyPersonnelServiceImpl.java

/**
 * Determines whether the person has valid unit
 * /*w  w  w  .  j  a va2s  .  c  o m*/
 * @param person
 * @return boolean
 */
@SuppressWarnings("unchecked")
public boolean isValidHomeUnit(ProposalPerson person, String unitId) {
    Map valueMap = new HashMap();
    valueMap.put("unitNumber", unitId);
    Collection<Unit> units = getBusinessObjectService().findMatching(Unit.class, valueMap);

    return CollectionUtils.isNotEmpty(units);
}

From source file:org.kuali.coeus.propdev.impl.person.KeyPersonnelServiceImpl.java

protected void populateInvestigatorTotalLineItem(List<ProposalPerson> investigators,
        List<ProposalCreditSplitListDto> creditSplitListItems,
        Map<String, CreditSplit> totalInvestigatorSplits) {
    if (CollectionUtils.isNotEmpty(investigators)) {
        List<CreditSplit> totalInvestigatorCreditSplits = totalInvestigatorSplits.entrySet().stream()
                .map(Map.Entry::getValue).collect(Collectors.toList());
        ProposalCreditSplitListDto investigatorTotalLine = createProposalCreditSplitListDto(
                totalInvestigatorCreditSplits, INVESTIGATOR_TOTAL, INVESTIGATOR_TOTAL_TYPE);
        creditSplitListItems.add(investigatorTotalLine);
    }//from   w w w. ja v a 2s .c  o m
}

From source file:org.kuali.coeus.propdev.impl.s2s.ProposalDevelopmentS2SController.java

@Transactional
@RequestMapping(value = "/proposalDevelopment", params = { "methodToCall=printForms" })
public ModelAndView printForms(@ModelAttribute("KualiForm") ProposalDevelopmentDocumentForm form,
        HttpServletResponse response) throws Exception {
    ProposalDevelopmentDocument proposalDevelopmentDocument = form.getProposalDevelopmentDocument();

    proposalDevelopmentDocumentViewAuthorizer
            .initializeDocumentAuthorizerIfNecessary(form.getProposalDevelopmentDocument());

    if (!((ProposalDevelopmentDocumentAuthorizer) proposalDevelopmentDocumentViewAuthorizer
            .getDocumentAuthorizer()).isAuthorizedToPrint(proposalDevelopmentDocument,
                    globalVariableService.getUserSession().getPerson())) {
        throw new AuthorizationException(globalVariableService.getUserSession().getPrincipalName(),
                "printForms", "Proposal");
    }//from  w  w w.j ava  2s.  co  m

    if (proposalDevelopmentDocument.getDevelopmentProposal().getSelectedS2sOppForms().isEmpty()) {
        getGlobalVariableService().getMessageMap().putError("noKey", ERROR_NO_GRANTS_GOV_FORM_SELECTED);
        return getModelAndViewService().getModelAndView(form);
    }
    FormPrintResult formPrintResult = getFormPrintService().printForm(proposalDevelopmentDocument);

    setValidationErrorMessage(formPrintResult.getErrors());
    KcFile attachmentDataSource = formPrintResult.getFile();
    if (((attachmentDataSource == null || attachmentDataSource.getData() == null
            || attachmentDataSource.getData().length == 0)
            && !proposalDevelopmentDocument.getDevelopmentProposal().getGrantsGovSelectFlag())
            || CollectionUtils.isNotEmpty(formPrintResult.getErrors())) {
        boolean grantsGovErrorExists = copyAuditErrorsToPage(Constants.GRANTSGOV_ERRORS,
                "grantsGovFormValidationErrors");
        if (grantsGovErrorExists) {
            getGlobalVariableService().getMessageMap().putError("grantsGovFormValidationErrors",
                    KeyConstants.VALIDATTION_ERRORS_BEFORE_GRANTS_GOV_SUBMISSION);
        }
        proposalDevelopmentDocument.getDevelopmentProposal().setGrantsGovSelectFlag(false);
        return getModelAndViewService().getModelAndView(form);
    }
    if (proposalDevelopmentDocument.getDevelopmentProposal().getGrantsGovSelectFlag()) {
        File grantsGovXmlDirectoryFile = getS2sSubmissionService()
                .getGrantsGovSavedFile(proposalDevelopmentDocument);
        byte[] bytes = new byte[(int) grantsGovXmlDirectoryFile.length()];
        FileInputStream fileInputStream = new FileInputStream(grantsGovXmlDirectoryFile);
        fileInputStream.read(bytes);
        int size = bytes.length;
        try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(size)) {
            outputStream.write(bytes);
            ControllerFileUtils.streamOutputToResponse(response, outputStream, "binary/octet-stream",
                    grantsGovXmlDirectoryFile.getName(), size);
            response.flushBuffer();
        }
        proposalDevelopmentDocument.getDevelopmentProposal().setGrantsGovSelectFlag(false);
        return getModelAndViewService().getModelAndView(form);
    }

    ControllerFileUtils.streamToResponse(attachmentDataSource, response);
    return getModelAndViewService().getModelAndView(form);
}

From source file:org.kuali.coeus.propdev.impl.sponsor.ProposalDevelopmentSponsorProgramInformationController.java

@Transactional
@RequestMapping(value = "/proposalDevelopment", params = { "methodToCall=navigate",
        "actionParameters[navigateToPageId]=PropDev-SponsorProgramInfoPage" })
public ModelAndView navigate(@ModelAttribute("KualiForm") ProposalDevelopmentDocumentForm form,
        BindingResult result, HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (StringUtils.isNotEmpty(form.getDevelopmentProposal().getContinuedFrom())
            && StringUtils.isEmpty(form.getDevelopmentProposal().getPrevGrantsGovTrackingID())) {
        String instProposalId = getInstitutionalProposalId(form.getDevelopmentProposal().getContinuedFrom());
        DevelopmentProposal continuedFrom = getContinuedFromDevelopmentProposal(instProposalId);
        if (continuedFrom != null && CollectionUtils.isNotEmpty(continuedFrom.getS2sAppSubmission())) {
            String ggTrackingId = continuedFrom.getS2sAppSubmission()
                    .get(continuedFrom.getS2sAppSubmission().size() - 1).getGgTrackingId();
            form.getDevelopmentProposal().setPrevGrantsGovTrackingID(ggTrackingId);
        }/*from ww w  . j a  v  a2s  .  co m*/
    }
    return super.navigate(form, result, request, response);
}

From source file:org.kuali.coeus.propdev.impl.sponsor.ProposalDevelopmentSponsorProgramInformationController.java

protected String getInstitutionalProposalId(String instProposalNumber) {
    List<InstitutionalProposal> institutionalProposals = (List<InstitutionalProposal>) getLegacyDataAdapter()
            .findMatching(InstitutionalProposal.class,
                    Collections.singletonMap("proposalNumber", instProposalNumber));
    if (CollectionUtils.isNotEmpty(institutionalProposals)) {
        return String.valueOf(institutionalProposals.get(0).getProposalId());
    }/* w  w w.j  a va  2 s .c  om*/
    return StringUtils.EMPTY;
}

From source file:org.kuali.coeus.propdev.impl.sponsor.ProposalDevelopmentSponsorProgramInformationController.java

protected DevelopmentProposal getContinuedFromDevelopmentProposal(String instProposalId) {
    List<ProposalAdminDetails> details = (List<ProposalAdminDetails>) getLegacyDataAdapter().findMatching(
            ProposalAdminDetails.class, Collections.singletonMap("instProposalId", instProposalId));
    if (CollectionUtils.isNotEmpty(details)) {
        return getDataObjectService().find(DevelopmentProposal.class, details.get(0).getDevProposalNumber());
    }//  w w  w  .ja v  a2  s  . co m
    return null;
}

From source file:org.kuali.coeus.sys.impl.workflow.KcWorkflowServiceImpl.java

/**
 * Checks to see if the user has asked to receive future requests or not.
 *//*from w ww  .ja  va  2s . co m*/
private boolean willReceiveFutureRequests(WorkflowDocument workflowDoc, String principalId) {
    boolean doNotReceiveFutureRequests = false;

    Map<String, String> variables = workflowDoc.getVariables();
    if (variables != null && CollectionUtils.isNotEmpty(variables.keySet())) {
        Iterator<String> variableIterator = variables.keySet().iterator();
        while (variableIterator.hasNext()) {
            String variableKey = variableIterator.next();
            String variableValue = variables.get(variableKey);
            if (variableKey.startsWith(KewApiConstants.RECEIVE_FUTURE_REQUESTS_BRANCH_STATE_KEY)
                    && variableValue.toUpperCase()
                            .equals(KewApiConstants.DONT_RECEIVE_FUTURE_REQUESTS_BRANCH_STATE_VALUE)
                    && variableKey.contains(principalId)) {
                doNotReceiveFutureRequests = true;
                break;
            }
        }
    }

    return !doNotReceiveFutureRequests;
}