Example usage for org.apache.commons.lang StringUtils substringBetween

List of usage examples for org.apache.commons.lang StringUtils substringBetween

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils substringBetween.

Prototype

public static String substringBetween(String str, String open, String close) 

Source Link

Document

Gets the String that is nested in between two Strings.

Usage

From source file:org.kuali.kfs.module.purap.document.web.struts.AccountsPayableActionBase.java

/**
 * Will return an array of Strings containing 2 indexes, the first String is the item index and the second String is the account
 * index. These are obtained by parsing the method to call parameter from the request, between the word ".line" and "." The
 * indexes are separated by a semicolon (:)
 *
 * @param request The HttpServletRequest
 * @return An array of Strings containing pairs of two indices, an item index
 *///  w ww.  j  a v  a  2 s . c  o  m
protected String[] getSelectedItemNumber(HttpServletRequest request) {
    String itemString = new String();
    String parameterName = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
        itemString = StringUtils.substringBetween(parameterName, ".line", ".");
    }
    String[] result = StringUtils.split(itemString, ":");

    return result;
}

From source file:org.kuali.kfs.module.purap.document.web.struts.PurchasingAccountsPayableActionBase.java

/**
 * Will return an array of Strings containing 2 indexes, the first String is the item index and the second String is the account
 * index. These are obtained by parsing the method to call parameter from the request, between the word ".line" and "." The
 * indexes are separated by a semicolon (:)
 * //from  w  w w  .j a va2  s  .  co m
 * @param request The HttpServletRequest
 * @return An array of Strings containing pairs of two indices, an item index and a account index
 */
protected String[] getSelectedLineForAccounts(HttpServletRequest request) {
    String accountString = new String();
    String parameterName = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName)) {
        accountString = StringUtils.substringBetween(parameterName, ".line", ".");
    }
    String[] result = StringUtils.split(accountString, ":");

    return result;
}

From source file:org.kuali.kfs.module.purap.document.web.struts.PurchasingActionBase.java

public ActionForward useOffCampusAssetLocationBuildingByDocument(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase baseForm = (PurchasingFormBase) form;
    PurchasingDocument document = (PurchasingDocument) baseForm.getDocument();

    String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
    String systemIndex = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL,
            KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
    String assetLocationIndex = StringUtils.substringBetween(fullParameter,
            KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);

    CapitalAssetSystem system = document.getPurchasingCapitalAssetSystems().get(Integer.parseInt(systemIndex));

    if ("new".equals(assetLocationIndex)) {
        useOffCampusAssetLocationBuilding(baseForm.getNewPurchasingCapitalAssetLocationLine());
    } else {//from w  w w . j  a va  2  s .  c o m
        useOffCampusAssetLocationBuilding(
                system.getCapitalAssetLocations().get(Integer.parseInt(assetLocationIndex)));
    }

    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}

From source file:org.kuali.kfs.module.purap.document.web.struts.PurchasingActionBase.java

public ActionForward useOffCampusAssetLocationBuildingByItem(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase baseForm = (PurchasingFormBase) form;
    PurchasingDocument document = (PurchasingDocument) baseForm.getDocument();

    String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
    String assetItemIndex = StringUtils.substringBetween(fullParameter,
            KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
    String assetLocationIndex = StringUtils.substringBetween(fullParameter,
            KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);

    PurchasingCapitalAssetItem assetItem = document.getPurchasingCapitalAssetItems()
            .get(Integer.parseInt(assetItemIndex));
    CapitalAssetSystem system = assetItem.getPurchasingCapitalAssetSystem();

    if ("new".equals(assetLocationIndex)) {
        useOffCampusAssetLocationBuilding(system.getNewPurchasingCapitalAssetLocationLine());
    } else {// ww w. j a va  2s . co  m
        useOffCampusAssetLocationBuilding(
                system.getCapitalAssetLocations().get(Integer.parseInt(assetLocationIndex)));
    }

    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}

From source file:org.kuali.kfs.module.purap.document.web.struts.PurchasingActionBase.java

/**
 * This method.../*from   w w w  .  ja va  2  s .c o  m*/
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward selectSystemType(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
    PurchasingDocumentBase document = (PurchasingDocumentBase) purchasingForm.getDocument();

    Object question = request.getParameter(PurapConstants.QUESTION_INDEX);
    Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);

    String systemTypeCode = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    systemTypeCode = StringUtils.substringBetween(systemTypeCode, "selectSystemType.", ".");

    if (question == null) {
        String questionText = SpringContext.getBean(ConfigurationService.class)
                .getPropertyValueAsString(PurapConstants.CapitalAssetTabStrings.QUESTION_SYSTEM_SWITCHING);

        return this.performQuestionWithoutInput(mapping, form, request, response,
                PurapConstants.CapitalAssetTabStrings.SYSTEM_SWITCHING_QUESTION, questionText,
                KFSConstants.CONFIRMATION_QUESTION, KFSConstants.ROUTE_METHOD, "0");
    } else if (ConfirmationQuestion.YES.equals(buttonClicked)) {

        // document.setCapitalAssetSystemTypeCode(systemTypeCode);
        document.refreshReferenceObject(PurapPropertyConstants.CAPITAL_ASSET_SYSTEM_TYPE);

        KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PUR_CAPITAL_ASSET_SYSTEM_TYPE_SWITCHED);
    }

    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}

From source file:org.kuali.kfs.module.purap.document.web.struts.PurchasingActionBase.java

public ActionForward deleteItemCapitalAssetByDocument(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    // get specific asset item
    PurchasingCapitalAssetItem assetItem = purDocument.getPurchasingCapitalAssetItems()
            .get(getSelectedLine(request));
    ItemCapitalAsset asset = assetItem.getNewPurchasingItemCapitalAssetLine();

    boolean rulePassed = true; // SpringContext.getBean(KualiRuleService.class).applyRules(new
    // AddPurchasingAccountsPayableItemEvent("", purDocument, item));

    if (rulePassed) {
        String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
        String systemIndex = StringUtils.substringBetween(fullParameter,
                KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
        String assetIndex = StringUtils.substringBetween(fullParameter,
                KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);

        PurchasingCapitalAssetSystemBase system = (PurchasingCapitalAssetSystemBase) purDocument
                .getPurchasingCapitalAssetSystems().get(Integer.parseInt(systemIndex));
        system.getItemCapitalAssets().remove(Integer.parseInt(assetIndex));
    }/*w ww  .  ja v  a  2 s.  c  om*/

    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}

From source file:org.kuali.kfs.module.purap.document.web.struts.PurchasingActionBase.java

public ActionForward deleteItemCapitalAssetByItem(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    // get specific asset item
    PurchasingCapitalAssetItem assetItem = purDocument.getPurchasingCapitalAssetItems()
            .get(getSelectedLine(request));

    ItemCapitalAsset asset = assetItem.getNewPurchasingItemCapitalAssetLine();

    boolean rulePassed = true; // SpringContext.getBean(KualiRuleService.class).applyRules(new
    // AddPurchasingAccountsPayableItemEvent("", purDocument, item));

    if (rulePassed) {
        String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
        String assetIndex = StringUtils.substringBetween(fullParameter,
                KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);
        PurchasingCapitalAssetSystemBase system = (PurchasingCapitalAssetSystemBase) assetItem
                .getPurchasingCapitalAssetSystem();
        system.getItemCapitalAssets().remove(Integer.parseInt(assetIndex));
    }//from   w  w w.j  av  a 2 s.  c o  m

    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}

From source file:org.kuali.kfs.module.purap.document.web.struts.PurchasingActionBase.java

public ActionForward deleteCapitalAssetLocationByDocument(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    CapitalAssetLocation location = purchasingForm.getNewPurchasingCapitalAssetLocationLine();
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();

    boolean rulePassed = true; // SpringContext.getBean(KualiRuleService.class).applyRules(new
    // AddPurchasingAccountsPayableItemEvent("", purDocument, item));

    if (rulePassed) {
        String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
        String systemIndex = StringUtils.substringBetween(fullParameter,
                KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
        String locationIndex = StringUtils.substringBetween(fullParameter,
                KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);

        // get specific asset item and grab system as well and attach asset number
        CapitalAssetSystem system = purDocument.getPurchasingCapitalAssetSystems()
                .get(Integer.parseInt(systemIndex));
        system.getCapitalAssetLocations().remove(Integer.parseInt(locationIndex));
    }//from   w  w  w . j  a  v  a 2  s .co  m

    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}

From source file:org.kuali.kfs.module.purap.document.web.struts.PurchasingActionBase.java

public ActionForward deleteCapitalAssetLocationByItem(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    CapitalAssetLocation location = purchasingForm.getNewPurchasingCapitalAssetLocationLine();
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();

    boolean rulePassed = true; // SpringContext.getBean(KualiRuleService.class).applyRules(new
    // AddPurchasingAccountsPayableItemEvent("", purDocument, item));

    if (rulePassed) {
        String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
        String assetItemIndex = StringUtils.substringBetween(fullParameter,
                KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
        String locationIndex = StringUtils.substringBetween(fullParameter,
                KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);

        // get specific asset item and grab system as well and attach asset number
        PurchasingCapitalAssetItem assetItem = purDocument.getPurchasingCapitalAssetItems()
                .get(Integer.parseInt(assetItemIndex));
        CapitalAssetSystem system = assetItem.getPurchasingCapitalAssetSystem();
        system.getCapitalAssetLocations().remove(Integer.parseInt(locationIndex));
    }//  www.j a v  a 2s .  co m

    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}

From source file:org.kuali.kfs.module.tem.batch.AgencyDataXmlInputFileType.java

/**
 * @see org.kuali.kfs.sys.batch.BatchInputType#getAuthorPrincipalName(java.io.File)
 *//*from   w  w  w.  j av a2  s .  co  m*/
@Override
public String getAuthorPrincipalName(File file) {
    return StringUtils.substringBetween(file.getName(), this.getFileNamePrefix(),
            TemConstants.FILE_NAME_PART_DELIMITER);
}