Example usage for org.apache.commons.lang3 StringUtils startsWith

List of usage examples for org.apache.commons.lang3 StringUtils startsWith

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils startsWith.

Prototype

public static boolean startsWith(final CharSequence str, final CharSequence prefix) 

Source Link

Document

Check if a CharSequence starts with a specified prefix.

null s are handled without exceptions.

Usage

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

@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
    String campusCode = fieldValues.remove(CAMPUS_CODE_FIELD);
    List<Unit> searchResults = (List<Unit>) super.getSearchResults(fieldValues);

    List<Unit> filteredSearchResults = CollectionUtils.createCorrectImplementationForCollection(searchResults);
    filteredSearchResults.addAll(//from w  ww. j a  v  a2 s .com
            searchResults.stream().filter(unit -> StringUtils.startsWith(unit.getUnitNumber(), campusCode))
                    .collect(Collectors.toList()));

    return filteredSearchResults;
}

From source file:org.kuali.coeus.propdev.impl.abstrct.AbstractTypeValuesFinder.java

private String getFieldValue(ViewModel model, InputField field) {
    if (!StringUtils.startsWith(field.getBindingInfo().getBindingPath(), "new")) {
        try {/*from  www . j a  va 2s. c  om*/
            return (String) PropertyUtils.getNestedProperty(model, field.getBindingInfo().getBindingPath());
        } catch (Exception e) {
            throw new RuntimeException("could not retrieve abstract type from the input field", e);
        }
    }
    return StringUtils.EMPTY;
}

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

@Transactional
@RequestMapping(value = "/proposalDevelopment", params = "methodToCall=revertToPreviousNarrativeType")
public ModelAndView revertToPreviousNarrativeType(
        @ModelAttribute("KualiForm") ProposalDevelopmentDocumentForm form) throws Exception {
    String propertyPath = form.getProposalDevelopmentAttachmentHelper().getNarrativeTypePropertyPath();
    String previousNarrativeTypeValue = form.getProposalDevelopmentAttachmentHelper()
            .getPreviousNarrativeTypeValue();
    ObjectPropertyUtils.setPropertyValue(form, propertyPath, previousNarrativeTypeValue);
    if (StringUtils.startsWith(propertyPath,
            ProposalDevelopmentConstants.KradConstants.PROPOSAL_DEVELOPMENT_ATTACHMENT_HELPER)) {
        form.setAjaxReturnType(UifConstants.AjaxReturnTypes.UPDATECOMPONENT.getKey());
        form.setUpdateComponentId(/*from   w  ww .  j  a  v a  2 s  .c om*/
                ProposalDevelopmentConstants.KradConstants.PROP_DEV_ATTACHMENTS_PAGE_PROPOSAL_DETAILS);
    }
    return getModelAndViewService().getModelAndView(form);
}

From source file:org.kuali.coeus.propdev.impl.specialreview.ProposalDevelopmentSpecialReviewAction.java

@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    ActionForward forward = super.refresh(mapping, form, request, response);

    String prefix = getSpecialReviewService().getProtocolSaveLocationPrefix(request.getParameterMap());
    ProposalDevelopmentForm proposalDevelopmentForm = (ProposalDevelopmentForm) form;

    ProposalSpecialReview proposalSpecialReview = null;

    if (StringUtils.startsWith(prefix, "specialReviewHelper.newSpecialReview")) {
        proposalSpecialReview = proposalDevelopmentForm.getSpecialReviewHelper().getNewSpecialReview();
    } else {// ww w  . ja va2  s  . co m
        int index = getSpecialReviewService().getProtocolIndex(prefix);
        if (index != -1) {
            proposalSpecialReview = proposalDevelopmentForm.getProposalDevelopmentDocument()
                    .getDevelopmentProposal().getPropSpecialReviews().get(index);
        }
    }

    proposalDevelopmentForm.getSpecialReviewHelper().prepareProtocolLinkViewFields(proposalSpecialReview);

    return forward;
}

From source file:org.kuali.kfs.kns.util.WebUtils.java

/**
 * Attempts to reopen sub tabs which would have been closed for inactive records
 *
 * @param sections       the list of Sections whose rows and fields to set the open tab state on
 * @param tabStates      the map of tabKey->tabState.  This map will be modified to set entries to "OPEN"
 * @param collectionName the name of the collection reopening
 *//*from   w w  w  .  j  a v a2  s.  co  m*/
public static void reopenInactiveRecords(List<Section> sections, Map<String, String> tabStates,
        String collectionName) {
    for (Section section : sections) {
        for (Row row : section.getRows()) {
            for (Field field : row.getFields()) {
                if (field != null) {
                    if (Field.CONTAINER.equals(field.getFieldType())
                            && StringUtils.startsWith(field.getContainerName(), collectionName)) {
                        final String tabKey = WebUtils
                                .generateTabKey(FieldUtils.generateCollectionSubTabName(field));
                        tabStates.put(tabKey, KualiForm.TabState.OPEN.name());
                    }
                }
            }
        }
    }
}

From source file:org.kuali.kra.award.web.struts.action.AwardSpecialReviewAction.java

@Override
@SuppressWarnings("unchecked")
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    ActionForward forward = super.refresh(mapping, form, request, response);

    String prefix = getSpecialReviewService().getProtocolSaveLocationPrefix(request.getParameterMap());
    AwardForm awardForm = (AwardForm) form;

    AwardSpecialReview awardSpecialReview = null;
    if (StringUtils.startsWith(prefix, "specialReviewHelper.newSpecialReview")) {
        awardSpecialReview = awardForm.getSpecialReviewHelper().getNewSpecialReview();
    } else {//from  w  ww.  ja v a2  s.  com
        int index = getSpecialReviewService().getProtocolIndex(prefix);
        if (index != -1) {
            awardSpecialReview = awardForm.getAwardDocument().getAward().getSpecialReviews().get(index);
        }
    }

    awardForm.getSpecialReviewHelper().prepareProtocolLinkViewFields(awardSpecialReview);

    return forward;
}

From source file:org.kuali.kra.iacuc.actions.IacucProtocolNotificationEditorAction.java

/**
 * Sends a Notification.//  ww w  .j a  v a  2s.  c  om
 * 
 * @param mapping the action mapping
 * @param form the action form
 * @param request the request
 * @param response the response
 * @return the action forward
 * @throws Exception
 */
public ActionForward sendNotification(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionForward actionForward = mapping.findForward(Constants.MAPPING_BASIC);

    IacucProtocolForm protocolForm = (IacucProtocolForm) form;
    IacucProtocolDocument document = protocolForm.getIacucProtocolDocument();
    KcNotification notification = protocolForm.getNotificationHelper().getNotification();
    List<NotificationTypeRecipient> notificationRecipients = protocolForm.getNotificationHelper()
            .getNotificationRecipients();

    if (applyRules(new SendNotificationEvent(document, notification, notificationRecipients))) {
        protocolForm.getNotificationHelper().sendNotificationAndPersist(new IacucProtocolNotification(),
                document.getProtocol());
        String forwardName = protocolForm.getNotificationHelper().getNotificationContext().getForwardName();
        protocolForm.getNotificationHelper().setNotificationContext(null);
        if (StringUtils.isNotBlank(forwardName)) {
            if (StringUtils.startsWith(forwardName, "holdingPage")) {
                if (StringUtils.equals(forwardName, "holdingPage")) {
                    return routeProtocolToHoldingPage(mapping, protocolForm);
                } else {
                    String[] params = StringUtils.split(forwardName, ":");
                    return routeProtocolOLRToHoldingPage(mapping, protocolForm, params[1], params[2]);
                }
            } else {
                actionForward = mapping.findForward(forwardName);
            }
        } else {
            recordProtocolActionSuccess("Send Notification");
            actionForward = mapping.findForward(PROTOCOL_ACTIONS_TAB);
        }
    }
    @SuppressWarnings("unused")
    Object notificationRequestBeans = GlobalVariables.getUserSession().retrieveObject("removeReviewer");
    return actionForward;
}

From source file:org.kuali.kra.institutionalproposal.web.struts.action.InstitutionalProposalSpecialReviewAction.java

@Override
@SuppressWarnings("unchecked")
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    ActionForward forward = super.refresh(mapping, form, request, response);

    String prefix = getSpecialReviewService().getProtocolSaveLocationPrefix(request.getParameterMap());
    InstitutionalProposalForm proposalForm = (InstitutionalProposalForm) form;

    InstitutionalProposalSpecialReview proposalSpecialReview = null;
    if (StringUtils.startsWith(prefix, "specialReviewHelper.newSpecialReview")) {
        proposalSpecialReview = proposalForm.getSpecialReviewHelper().getNewSpecialReview();
    } else {/*from ww w.j a v  a2  s  .  c  om*/
        int index = getSpecialReviewService().getProtocolIndex(prefix);
        if (index != -1) {
            proposalSpecialReview = proposalForm.getInstitutionalProposalDocument().getInstitutionalProposal()
                    .getSpecialReviews().get(index);
        }
    }

    proposalForm.getSpecialReviewHelper().prepareProtocolLinkViewFields(proposalSpecialReview);

    return forward;
}

From source file:org.kuali.kra.irb.actions.ProtocolNotificationEditorAction.java

/**
 * Sends a Notification./*from ww  w .  jav  a  2s .co m*/
 * 
 * @param mapping the action mapping
 * @param form the action form
 * @param request the request
 * @param response the response
 * @return the action forward
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public ActionForward sendNotification(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionForward actionForward = mapping.findForward(Constants.MAPPING_BASIC);

    ProtocolForm protocolForm = (ProtocolForm) form;
    ProtocolDocument document = protocolForm.getProtocolDocument();
    KcNotification notification = protocolForm.getNotificationHelper().getNotification();
    List<NotificationTypeRecipient> notificationRecipients = protocolForm.getNotificationHelper()
            .getNotificationRecipients();

    if (applyRules(new SendNotificationEvent(document, notification, notificationRecipients))) {
        protocolForm.getNotificationHelper().sendNotificationAndPersist(new IRBProtocolNotification(),
                document.getProtocol());
        String forwardName = protocolForm.getNotificationHelper().getNotificationContext().getForwardName();
        protocolForm.getNotificationHelper().setNotificationContext(null);
        if (StringUtils.isNotBlank(forwardName)) {
            if (StringUtils.startsWith(forwardName, "holdingPage")) {
                if (StringUtils.equals(forwardName, "holdingPage")) {
                    return routeProtocolToHoldingPage(mapping, protocolForm);
                } else {
                    String[] params = StringUtils.split(forwardName, ":");
                    return routeProtocolOLRToHoldingPage(mapping, protocolForm, params[1], params[2]);
                }
            } else {
                actionForward = mapping.findForward(forwardName);
            }
        } else {
            recordProtocolActionSuccess("Send Notification");
            actionForward = mapping.findForward("protocolActions");
        }
    }
    Object notificationRequestBeans = GlobalVariables.getUserSession().retrieveObject("removeReviewer");
    if (notificationRequestBeans != null) {
        // This is specifically for 'assign reviewers" where it is possible that add/remove in the same action
        GlobalVariables.getUserSession().removeObject("removeReviewer");
        actionForward = checkToSendNotification(mapping, mapping.findForward(PROTOCOL_ACTIONS_TAB),
                protocolForm, (List<ProtocolNotificationRequestBean>) notificationRequestBeans);
    }
    return actionForward;
}

From source file:org.kuali.kra.lookup.UnitLookupableHelperServiceImplTest.java

@Test
public void testCampusCodeSearchResults() {
    service.setBusinessObjectClass(Unit.class);

    Map<String, String> fieldValues = new HashMap<String, String>();
    fieldValues.put(CAMPUS_CODE_FIELD, CAMPUS_CODE);
    List<? extends BusinessObject> searchResults = service.getSearchResults(fieldValues);
    assertEquals(SEARCH_RESULTS_CAMPUS_CODE_COUNT, searchResults.size());

    for (BusinessObject searchResult : searchResults) {
        Unit unit = (Unit) searchResult;
        assertTrue(StringUtils.startsWith(unit.getUnitNumber(), CAMPUS_CODE));
    }//  www  .java 2  s  . c  o  m
}