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

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

Introduction

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

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:org.kuali.rice.krad.uif.widget.TableTools.java

/**
 * The following initialization is performed:
 *
 * <ul>//from  www  .j a v  a2s .co  m
 * <li>Initializes component options for empty table message</li>
 * </ul>
 */
@Override
public void performFinalize(View view, Object model, Component component) {
    super.performFinalize(view, model, component);

    if (isRender()) {
        if (StringUtils.isNotBlank(getEmptyTableMessage())) {
            getComponentOptions().put(UifConstants.TableToolsKeys.LANGUAGE, "{\""
                    + UifConstants.TableToolsKeys.EMPTY_TABLE + "\" : \"" + getEmptyTableMessage() + "\"}");
        }

        if (isDisableTableSort()) {
            getComponentOptions().put(UifConstants.TableToolsKeys.TABLE_SORT, "false");
        }

        if (!isShowSearchAndExportOptions()) {
            Object domOption = getComponentOptions().get(UifConstants.TableToolsKeys.SDOM);
            if (domOption instanceof String) {
                String sDomOption = (String) domOption;
                if (StringUtils.isNotBlank(sDomOption)) {
                    sDomOption = StringUtils.remove(sDomOption, "T"); //Removes Export option
                    sDomOption = StringUtils.remove(sDomOption, "f"); //Removes search option
                    getComponentOptions().put(UifConstants.TableToolsKeys.SDOM, sDomOption);
                }
            }

        }

        if (component instanceof CollectionGroup) {
            buildTableSortOptions((CollectionGroup) component);
        }
    }
}

From source file:org.kuali.student.cm.course.service.impl.CourseMaintainableImpl.java

protected void populateOutComesOnWrapper() {

    CourseInfoWrapper courseInfoWrapper = (CourseInfoWrapper) getDataObject();
    courseInfoWrapper.getCreditOptionWrappers().clear();

    for (ResultValuesGroupInfo rvg : courseInfoWrapper.getCourseInfo().getCreditOptions()) {

        ResultValuesGroupInfoWrapper rvgWrapper = new ResultValuesGroupInfoWrapper();
        BeanUtils.copyProperties(rvg, rvgWrapper);
        rvgWrapper.setResultValuesGroupInfo(rvg);

        if (StringUtils.equals(rvg.getTypeKey(), LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE)) {

            StringBuilder resultValue = new StringBuilder("");
            List<String> resultValueList = new ArrayList<String>();

            for (String rvKey : rvg.getResultValueKeys()) {
                String value = StringUtils.strip(rvKey,
                        LrcServiceConstants.RESULT_VALUE_KEY_CREDIT_DEGREE_PREFIX);
                resultValueList.add(StringUtils.remove(value, ".0")); // This can be only be integer at ui.
            }/*  w ww  . j  ava  2  s  . c o  m*/

            // Sort the values to be displayed at ui
            Collections.sort(resultValueList);
            rvgWrapper.getUiHelper().setResultValue(StringUtils.join(resultValueList, ","));

        } else if (StringUtils.equals(rvg.getTypeKey(),
                LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE)) {

            String minValue = StringUtils.remove(rvg.getResultValueRange().getMinValue(), ".0"); // This can be only be integer at ui.
            String maxValue = StringUtils.remove(rvg.getResultValueRange().getMaxValue(), ".0"); // This can be only be integer at ui.

            rvgWrapper.getUiHelper().setResultValue(minValue + "-" + maxValue);
        } else if (StringUtils.equals(rvg.getTypeKey(),
                LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED)) {
            rvgWrapper.getUiHelper()
                    .setResultValue(StringUtils.remove(rvg.getResultValueRange().getMinValue(), ".0"));
        }
        courseInfoWrapper.getCreditOptionWrappers().add(rvgWrapper);
    }

    Collections.sort(courseInfoWrapper.getCreditOptionWrappers(),
            new Comparator<ResultValuesGroupInfoWrapper>() {
                public int compare(ResultValuesGroupInfoWrapper a, ResultValuesGroupInfoWrapper b) {
                    if (a.getTypeKey() == null) {
                        return 1;
                    } else if (b.getTypeKey() == null) {
                        return -1;
                    }
                    return a.getTypeKey().compareToIgnoreCase(b.getTypeKey());
                }
            });

    initializeOutcome(courseInfoWrapper);

}

From source file:org.kuali.student.enrollment.class2.courseoffering.controller.CourseOfferingCreateController.java

/**
 * This will be called whenever the user selects/deselects a joint course. If user deselects a joint course, make sure
 * it doesnt have associated formats. If exists, display a confirmation dialog with all the available formats.
 *
 * XML reference at CourseOfferingCreateMaintenanceView.xml
 *
 *//*from   www  . j  a  va2  s. c o  m*/
@RequestMapping(params = "methodToCall=markCourseForJointOffering")
public ModelAndView markCourseForJointOffering(@ModelAttribute("KualiForm") MaintenanceDocumentForm form,
        @SuppressWarnings("unused") BindingResult result, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    CourseOfferingCreateWrapper wrapper = (CourseOfferingCreateWrapper) form.getDocument()
            .getNewMaintainableObject().getDataObject();
    int index = wrapper.getSelectedJointCourseIndex();
    if (form.getActionParameters().size() > 1) {
        String lineIndex = form.getActionParameters().get("selectedLineIndex");
        index = Integer.parseInt(lineIndex);
        wrapper.setSelectedJointCourseIndex(index);
    }
    JointCourseWrapper joint = wrapper.getJointCourses().get(index);

    if (joint.isSelectedToJointlyOfferred()) {
        String dialogName = CourseOfferingConstants.JOINT_COURSE_FORMATS_DELETE_DIALOG;

        if (!hasDialogBeenAnswered(dialogName, form)) {
            wrapper.setSelectedJointCourseCode(joint.getCourseCode());
            wrapper.setDialogFormatOfferingWrapperList(joint.getFormatOfferingWrappers());
            return showDialog(dialogName, form, request, response);
        }

        boolean dialogAnswer = getBooleanDialogResponse(dialogName, form, request, response);
        form.getDialogManager().resetDialogStatus(dialogName);

        if (dialogAnswer) {
            joint.setSelectedToJointlyOfferred(false);
            String jointCodes = StringUtils.remove(wrapper.getJointCourseCodes(), ", " + joint.getCourseCode());
            wrapper.setJointCourseCodes(jointCodes);
            wrapper.getFormatOfferingWrappers().removeAll(joint.getFormatOfferingWrappers());
        }

    } else {
        wrapper.setJointCourseCodes(wrapper.getJointCourseCodes() + ", " + joint.getCourseCode());
        joint.setSelectedToJointlyOfferred(true);
    }

    return getUIFModelAndView(form);
}

From source file:org.kuali.student.enrollment.class2.courseoffering.helper.impl.ActivityOfferingScheduleHelperImpl.java

protected void buildScheduleWrapper(ActivityOfferingWrapper wrapper, ScheduleWrapper scheduleWrapper,
        ScheduleRequestComponentInfo componentInfo, ContextInfo defaultContextInfo) {

    scheduleWrapper.setTba(componentInfo.getIsTBA());

    try {//from   ww  w. j  ava2 s . c o  m
        List<TimeSlotInfo> timeSlotInfos = CourseOfferingManagementUtil.getSchedulingService()
                .getTimeSlotsByIds(componentInfo.getTimeSlotIds(), defaultContextInfo);

        if (!timeSlotInfos.isEmpty()) {
            int firstTimeSlotInfo = 0;
            scheduleWrapper.setTimeSlot(timeSlotInfos.get(firstTimeSlotInfo));

            TimeOfDayInfo startTime = scheduleWrapper.getTimeSlot().getStartTime();
            if (startTime != null && !startTime.equals(new TimeOfDayInfo(0, 0, 0))) {
                String formattedTime = TimeOfDayHelper.makeFormattedTimeForAOSchedules(startTime);
                scheduleWrapper.setStartTime(formattedTime);
            }

            TimeOfDayInfo endTime = scheduleWrapper.getTimeSlot().getEndTime();
            if (endTime != null && !endTime.equals(new TimeOfDayInfo(0, 0, 0))) {
                String formattedTime = TimeOfDayHelper.makeFormattedTimeForAOSchedules(endTime);
                scheduleWrapper.setEndTime(formattedTime);
            }

            String daysUI = SchedulingServiceUtil
                    .weekdaysList2WeekdaysString(scheduleWrapper.getTimeSlot().getWeekdays());
            scheduleWrapper.setDaysUI(daysUI);
            scheduleWrapper.setDays(StringUtils.remove(daysUI, " "));
        }

        if (!componentInfo.getRoomIds().isEmpty()) {

            RoomInfo room = CourseOfferingManagementUtil.getRoomService()
                    .getRoom(componentInfo.getRoomIds().get(0), defaultContextInfo);

            scheduleWrapper.setRoom(room);
            scheduleWrapper.setRoomCode(room.getRoomCode());

            if (!room.getRoomUsages().isEmpty()) {
                scheduleWrapper.setRoomCapacity(room.getRoomUsages().get(0).getHardCapacity());
            }

            BuildingInfo buildingInfo = CourseOfferingManagementUtil.getRoomService()
                    .getBuilding(room.getBuildingId(), defaultContextInfo);
            scheduleWrapper.setBuilding(buildingInfo);
            scheduleWrapper.setBuildingCode(buildingInfo.getBuildingCode());
            scheduleWrapper.setBuildingId(room.getBuildingId());
        } else if (!componentInfo.getBuildingIds().isEmpty()) {
            String buildingId = componentInfo.getBuildingIds().get(0);
            BuildingInfo buildingInfo = CourseOfferingManagementUtil.getRoomService().getBuilding(buildingId,
                    defaultContextInfo);
            scheduleWrapper.setBuilding(buildingInfo);
            scheduleWrapper.setBuildingCode(buildingInfo.getBuildingCode());
            scheduleWrapper.setBuildingId(buildingId);
        }

    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    loadColocatedAOs(wrapper, scheduleWrapper);
    wrapper.getRequestedScheduleComponents().add(scheduleWrapper);
}

From source file:org.kuali.student.r2.core.class1.search.CourseOfferingManagementSearchImpl.java

/**
 * Builds the crosslist details for each CO.
 *
 * @param resultInfo/*w ww. j  a va 2s  .  c o m*/
 * @param luiIds2AlternateCodes
 */
private void buildCrossListSearchResult(SearchResultInfo resultInfo,
        Map<String, String> luiIds2AlternateCodes) {

    /**
     * If the result needs all the alternate code, iterate all the result set rows and look for
     * the matching Lui. If found, get all the alternate code and add it to the existing result
     * set.
     */
    for (SearchResultRowInfo row : resultInfo.getRows()) {

        String courseOfferingCode = row.getCells().get(0).getValue();
        String courseOfferingId = row.getCells().get(5).getValue();
        boolean isCrossListed = BooleanUtils.toBoolean(row.getCells().get(7).getValue());

        String alternateCodes = luiIds2AlternateCodes.get(courseOfferingId);
        String ownerCode;
        String ownerAliases;
        if (!isCrossListed) {
            alternateCodes = StringUtils.remove(alternateCodes, courseOfferingCode + OWNER_UI_SUFFIX);
            ownerCode = courseOfferingCode;
        } else {
            alternateCodes = StringUtils.remove(alternateCodes, courseOfferingCode);
            String partOfCodes = alternateCodes.substring(0, alternateCodes.indexOf(OWNER_UI_SUFFIX));
            int idx = alternateCodes.substring(0, alternateCodes.indexOf(OWNER_UI_SUFFIX)).lastIndexOf(",");
            if (idx >= 0) {
                ownerCode = partOfCodes.substring(idx + 1);
            } else {
                ownerCode = partOfCodes.substring(0);
            }
        }

        ownerAliases = StringUtils.remove(luiIds2AlternateCodes.get(courseOfferingId),
                ownerCode + OWNER_UI_SUFFIX);
        row.addCell(SearchResultColumns.OWNER_CODE, ownerCode);
        row.addCell(SearchResultColumns.OWNER_ALIASES, ownerAliases);
        row.addCell(SearchResultColumns.CROSS_LISTED_COURSES, alternateCodes);

    }
}

From source file:org.lexevs.system.ResourceManager.java

/**
 * Construct jdbc url for deprecated multi db mode.
 * /*  ww  w.  j a va2 s .co  m*/
 * @param url the url
 * @param dbName the db name
 * 
 * @return the string
 */
private String constructJdbcUrlForDeprecatedMultiDbMode(String url, String dbName) {
    return StringUtils.remove(url, dbName);
}

From source file:org.lisapark.octopus.util.jdbc.DaoUtils.java

/**
 * Converts the object to the string/*  w w  w.jav a  2  s . c  o  m*/
 * with some (very minimal) formating.
 */
public static String convertToSqlString(Object value) {

    if (value == null) {
        return "";
    }
    String newValue;
    if (value instanceof Date) {
        SimpleDateFormat dateFormatter = new SimpleDateFormat("YYYY-mm-dd");
        newValue = dateFormatter.format((Date) value);
    } else if (value instanceof Boolean) {
        boolean bool = ((Boolean) value).booleanValue();
        if (bool) {
            newValue = "1";
        } else {
            newValue = "0";
        }
    } else {
        newValue = value.toString();
    }
    // remove all chars that can be part of numeric value, but not
    // a unicode numeric char (minus, decimal point, and comma)
    String tmp = StringUtils.removeStart(newValue, "-");
    //        tmp = StringUtils.remove(tmp, '.');
    tmp = StringUtils.remove(tmp, ',');

    return StringUtils.isNumeric(tmp) ? (StringUtils.isBlank(newValue) ? "''" : newValue)
            : ("'" + StringEscapeUtils.escapeSql(newValue)) + "'";
}

From source file:org.metaabm.commands.SuggestLabelCommand.java

public SuggestLabelCommand(EditingDomain domain, Collection<? extends IID> ids) {
    super(domain, "Suggest Label", "Suggest Label");
    this.ids = ids;
    for (IID id : this.ids) {
        String idealLabel = StringUtils.remove(id.getLabel(), " Copy");
        oldSame.add(suggestLabel(id).equals(idealLabel));
    }/*from www  .  j av a  2  s  .co m*/
}

From source file:org.metaabm.commands.TargetTranslator.java

public boolean includeFor(EditingDomain domain, EObject source) {
    String sourceName = (String) source.eGet(sourceFeature);
    String oldTranslatedName = translateName(sourceName, (IID) source);
    EObject target = targetFor(source);//from w  w w  . j ava  2s  . c om

    if (target != null) {
        String oldName = (String) target.eGet(targetFeature);
        oldName = StringUtils.remove(oldName, " Copy");
        oldName = StringUtils.remove(oldName, "Copy");
        oldTranslatedName = StringUtils.remove(oldTranslatedName, " Copy");
        oldTranslatedName = StringUtils.remove(oldTranslatedName, "Copy");
        String defaultString = MetaABMEditPlugin.INSTANCE
                .getString("_UI_" + source.eClass().getName() + "_type");
        // System.out.println();
        // System.out.println((new StringBuffer(" : "+oldName).insert(0,
        // "[TargetTranslator.includeFor] oldName")));
        // System.out.println((new StringBuffer(" :
        // "+oldTranslatedName).insert(0, "[TargetTranslator.includeFor]
        // oldTranslatedName")));
        //
        // System.out.println((new StringBuffer(" :
        // "+defaultString).insert(0, "[TargetTranslator.includeFor]
        // defaultString")));

        if (!StringUtils.isEmpty(StringUtils.deleteWhitespace(oldName)) && !oldName.equals(oldTranslatedName)) {
            if (target instanceof IID) {
                SuggestLabelCommand testCmd = new SuggestLabelCommand(domain, (IID) target);
                if (targetFeature == MetaABMPackage.Literals.IID__LABEL
                        && (testCmd.suggestLabel((IID) target).equals(oldName) || defaultString.equals(oldName))
                        || targetFeature == MetaABMPackage.Literals.IID__ID
                                && testCmd.suggestID((IID) target).equals(oldName)) {
                    // || ((targetFeature ==
                    // MetaABMPackage.Literals.SNAMED__PLURAL_LABEL) &&
                    // SetLabelCommand.LABEL_TO_PLURAL_NAME_TRANSLATOR.
                    // translateName(
                    // testCmd.suggestLabel((IID) target)).equals(oldName)))
                    // {
                    return true;
                }
            }
            return false;
        }
    }
    return true;
}

From source file:org.mule.modules.quickbooks.api.oauth.DefaultQuickBooksOAuthClient.java

/**
 * This method is used for avoiding errors in CloudHub's Object Store API
 * @param idToStore key to be stored//from ww  w  .  j av  a  2s . c  o  m
 * @return String without encoded characters
 */
private String removeSpecialCharacters(String idToStore) {
    return StringUtils.remove(idToStore, "%");
}