Example usage for org.apache.commons.collections4 ListUtils emptyIfNull

List of usage examples for org.apache.commons.collections4 ListUtils emptyIfNull

Introduction

In this page you can find the example usage for org.apache.commons.collections4 ListUtils emptyIfNull.

Prototype

public static <T> List<T> emptyIfNull(final List<T> list) 

Source Link

Document

Returns an immutable empty list if the argument is null, or the argument itself otherwise.

Usage

From source file:org.kuali.coeus.common.budget.impl.personnel.BudgetPersonSalaryServiceImpl.java

protected List<BudgetPersonSalaryDetails> findSalaryDetailsByBudgetIdAndPersonIdAndBudgetPeriod(Long budgetId,
        String personId, Integer budgetPeriod) {
    final HashMap<String, Object> criteria = new HashMap<>();
    criteria.put("budgetId", budgetId);
    criteria.put("personId", personId);
    criteria.put("budgetPeriod", budgetPeriod);
    return ListUtils.emptyIfNull((List<BudgetPersonSalaryDetails>) businessObjectService
            .findMatchingOrderBy(BudgetPersonSalaryDetails.class, criteria, "personSequenceNumber", true));
}

From source file:org.kuali.coeus.common.impl.motd.MessageOfTheDayServiceImpl.java

@Override
public List<MessageOfTheDay> getMessagesOfTheDay() {
    final List<MessageOfTheDay> results = new ArrayList<MessageOfTheDay>(
            businessObjectService.findMatchingOrderBy(MessageOfTheDay.class,
                    Collections.singletonMap(ACTIVE, "Y"), DISPLAY_ORDER, true));

    return ListUtils.emptyIfNull(results);
}

From source file:org.kuali.coeus.common.impl.sponsor.SponsorSearchServiceImpl.java

@Override
public List<SponsorSearchResult> findSponsors(String searchString) {
    if (StringUtils.isBlank(searchString)) {
        throw new IllegalArgumentException("searchString is blank");
    }//from w  w w.j av  a  2 s  .co m

    final String likeCriteria = "%" + searchString.toUpperCase() + "%";
    TypedQuery<SponsorSearchResult> query = entityManager.createQuery(
            "SELECT NEW org.kuali.coeus.common.framework.sponsor.SponsorSearchResult(t.sponsorCode, t.sponsorName) "
                    + "FROM Sponsor t "
                    + "WHERE UPPER(t.sponsorCode) like :likeCriteria OR UPPER(t.acronym) like :likeCriteria or UPPER(t.sponsorName) like :likeCriteria",
            SponsorSearchResult.class).setParameter("likeCriteria", likeCriteria);

    return ListUtils.emptyIfNull(query.setMaxResults(25).getResultList());
}

From source file:org.kuali.coeus.common.impl.unit.UnitRepositoryServiceImpl.java

@Override
public List<UnitContract> getUnitHierarchyForUnit(String unitNumber) {
    if (StringUtils.isBlank(unitNumber)) {
        throw new IllegalArgumentException("unitNumber is blank");
    }/*from  ww  w . ja v  a2s  .c o m*/
    List<UnitContract> unitContractList = new ArrayList<UnitContract>();
    unitContractList.addAll(unitService.getUnitHierarchyForUnit(unitNumber));
    return ListUtils.emptyIfNull(unitContractList);
}

From source file:org.kuali.coeus.instprop.impl.admin.ProposalAdminDetailsServiceImpl.java

@Override
public List<? extends ProposalAdminDetailsContract> findProposalAdminDetailsByPropDevNumber(
        String proposalNumber) {//from ww w. j  ava2s  .  c  om
    if (StringUtils.isBlank(proposalNumber)) {
        throw new IllegalArgumentException("proposalNumber is blank");
    }

    return ListUtils.emptyIfNull((List<ProposalAdminDetails>) businessObjectService.findMatching(
            ProposalAdminDetails.class, Collections.singletonMap("devProposalNumber", proposalNumber)));
}

From source file:org.kuali.coeus.propdev.impl.questionnaire.PropDevQuestionAnswerServiceImpl.java

@Override
public List<? extends AnswerContract> getQuestionnaireAnswers(String proposalNumber, String namespace,
        String formName) {//from ww w.  jav a2  s. co  m
    if (StringUtils.isBlank(proposalNumber)) {
        throw new IllegalArgumentException("proposalNumber is blank");
    }

    if (StringUtils.isBlank(namespace)) {
        throw new IllegalArgumentException("namespace is blank");
    }

    if (StringUtils.isBlank(formName)) {
        throw new IllegalArgumentException("formName is blank");
    }

    final DevelopmentProposal developmentProposal = dataObjectService.find(DevelopmentProposal.class,
            proposalNumber);
    if (developmentProposal != null) {
        final List<AnswerHeader> answerHeaders = getProposalDevelopmentS2sQuestionnaireService()
                .getProposalAnswerHeaderForForm(developmentProposal, namespace, formName);
        final List<Answer> questionnaireAnswers = new ArrayList<Answer>();
        for (AnswerHeader answerHeader : answerHeaders) {
            final Questionnaire questionnaire = answerHeader.getQuestionnaire();
            final List<QuestionnaireQuestion> questionnaireQuestions = questionnaire
                    .getQuestionnaireQuestions();
            for (QuestionnaireQuestion questionnaireQuestion : questionnaireQuestions) {
                final Answer questionAnswer = getAnswer(questionnaireQuestion, answerHeader);
                if (questionAnswer != null) {
                    questionnaireAnswers.add(questionAnswer);
                }
            }
        }
        return ListUtils.emptyIfNull(questionnaireAnswers);
    }
    return Collections.emptyList();
}

From source file:org.kuali.coeus.propdev.impl.questionnaire.PropDevQuestionAnswerServiceImpl.java

@Override
public List<? extends AnswerHeaderContract> getQuestionnaireAnswerHeaders(String proposalNumber,
        String namespace, String formName) {
    if (StringUtils.isBlank(proposalNumber)) {
        throw new IllegalArgumentException("proposalNumber is blank");
    }/*from   w  ww .  j a v  a 2s  .  c  om*/

    if (StringUtils.isBlank(namespace)) {
        throw new IllegalArgumentException("namespace is blank");
    }

    if (StringUtils.isBlank(formName)) {
        throw new IllegalArgumentException("formName is blank");
    }

    final DevelopmentProposal developmentProposal = dataObjectService.find(DevelopmentProposal.class,
            proposalNumber);
    return ListUtils.emptyIfNull(proposalDevelopmentS2sQuestionnaireService
            .getProposalAnswerHeaderForForm(developmentProposal, namespace, formName));
}

From source file:org.kuali.coeus.propdev.impl.questionnaire.PropDevQuestionAnswerServiceImpl.java

@Override
public List<? extends AnswerHeaderContract> getQuestionnaireAnswerHeaders(String proposalNumber) {
    if (StringUtils.isBlank(proposalNumber)) {
        throw new IllegalArgumentException("proposalNumber is blank");
    }//from  w  w  w . j  a  v a2  s .c o  m

    final DevelopmentProposal developmentProposal = dataObjectService.find(DevelopmentProposal.class,
            proposalNumber);
    final ModuleQuestionnaireBean moduleQuestionnaireBean = new ProposalDevelopmentModuleQuestionnaireBean(
            developmentProposal);
    return ListUtils.emptyIfNull(questionnaireAnswerService.getQuestionnaireAnswer(moduleQuestionnaireBean));
}

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

protected List<S2sUserAttachedForm> findUserAttachedFormByProposalNumber(String proposalNumber) {
    final Map<String, String> fieldMap = new HashMap<>();
    fieldMap.put("proposalNumber", proposalNumber);
    return ListUtils.emptyIfNull(dataObjectService
            .findMatching(S2sUserAttachedForm.class, QueryByCriteria.Builder.andAttributes(fieldMap).build())
            .getResults());/* w  w  w  . j ava2s  . co m*/
}

From source file:org.ligoj.app.plugin.vm.aws.VmAwsSnapshotResource.java

/**
 * Convert a XML AMI node to a {@link Snapshot} instance.
 */// w w w.ja v  a2s  . c  o  m
private Snapshot toAmi(final Element element) {
    final Snapshot snapshot = new Snapshot();
    snapshot.setId(xml.getTagText(element, "imageId"));
    snapshot.setName(xml.getTagText(element, "name"));
    snapshot.setDescription(StringUtils.trimToNull(xml.getTagText(element, "description")));
    snapshot.setStatusText(xml.getTagText(element, "imageState"));
    snapshot.setAvailable("available".equals(snapshot.getStatusText()));
    snapshot.setPending("pending".equals(snapshot.getStatusText()));

    final String date = xml.getTagText(element, "creationDate");
    final XPath xPath = xml.xpathFactory.newXPath();
    try {
        // Author
        final NodeList tags = (NodeList) xPath.compile("tagSet/item").evaluate(element, XPathConstants.NODESET);
        snapshot.setAuthor(IntStream.range(0, tags.getLength()).mapToObj(tags::item)
                .filter(t -> TAG_AUDIT.equals(xml.getTagText((Element) t, "key")))
                .map(t -> xml.getTagText((Element) t, "value")).map(this::getUser).findAny().orElse(null));

        // Volumes
        final NodeList volumes = (NodeList) xPath.compile("blockDeviceMapping/item").evaluate(element,
                XPathConstants.NODESET);
        snapshot.setVolumes(IntStream.range(0, volumes.getLength()).mapToObj(volumes::item)
                .map(v -> toVolume((Element) v)).filter(v -> v.getId() != null).collect(Collectors.toList()));

        // Creation date
        snapshot.setDate(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").parse(date));
    } catch (final Exception pe) {
        // Invalid of not correctly managed XML content
        snapshot.setVolumes(ListUtils.emptyIfNull(snapshot.getVolumes()));
        snapshot.setDate(new Date(0));
        log.info("Details of AMI {} cannot be fully parsed", snapshot.getId(), pe);
    }

    return snapshot;
}