List of usage examples for org.apache.commons.lang StringUtils remove
public static String remove(String str, char remove)
Removes all occurrences of a character from within the source string.
From source file:org.kuali.rice.kew.impl.document.lookup.DocumentLookupCriteriaTranslatorImpl.java
@Override public DocumentLookupCriteria translate(Map<String, String> fieldValues) { DocumentLookupCriteria.Builder criteria = DocumentLookupCriteria.Builder.create(); for (Map.Entry<String, String> field : fieldValues.entrySet()) { try {// w ww .ja v a2 s . c o m if (StringUtils.isNotBlank(field.getValue())) { if (DIRECT_TRANSLATE_FIELD_NAMES_SET.contains(field.getKey())) { PropertyUtils.setNestedProperty(criteria, field.getKey(), field.getValue()); } else if (DATE_RANGE_TRANSLATE_FIELD_NAMES_SET.contains(field.getKey())) { applyDateRangeField(criteria, field.getKey(), field.getValue()); } else if (field.getKey().startsWith(KEWConstants.DOCUMENT_ATTRIBUTE_FIELD_PREFIX)) { String documentAttributeName = field.getKey() .substring(KEWConstants.DOCUMENT_ATTRIBUTE_FIELD_PREFIX.length()); applyDocumentAttribute(criteria, documentAttributeName, field.getValue()); } } } catch (Exception e) { throw new IllegalStateException("Failed to set document lookup criteria field: " + field.getKey(), e); } } String routeNodeLookupLogic = fieldValues.get(ROUTE_NODE_LOOKUP_LOGIC); if (StringUtils.isNotBlank(routeNodeLookupLogic)) { criteria.setRouteNodeLookupLogic(RouteNodeLookupLogic.valueOf(routeNodeLookupLogic)); } String documentStatusesValue = fieldValues.get(DOCUMENT_STATUSES); if (StringUtils.isNotBlank(documentStatusesValue)) { String[] documentStatuses = documentStatusesValue.split(","); for (String documentStatus : documentStatuses) { if (documentStatus.startsWith("category:")) { String categoryCode = StringUtils.remove(documentStatus, "category:"); criteria.getDocumentStatusCategories().add(DocumentStatusCategory.fromCode(categoryCode)); } else { criteria.getDocumentStatuses().add(DocumentStatus.fromCode(documentStatus)); } } } return criteria.build(); }
From source file:org.kuali.rice.kew.impl.document.search.DocumentSearchCriteriaTranslatorImpl.java
@Override public DocumentSearchCriteria translateFieldsToCriteria(Map<String, String> fieldValues) { DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create(); List<String> documentAttributeFields = new ArrayList<String>(); for (Map.Entry<String, String> field : fieldValues.entrySet()) { try {//from w w w. ja v a2 s . c om if (StringUtils.isNotBlank(field.getValue())) { if (DIRECT_TRANSLATE_FIELD_NAMES_SET.contains(field.getKey())) { PropertyUtils.setNestedProperty(criteria, field.getKey(), field.getValue()); } else if (DATE_RANGE_TRANSLATE_FIELD_NAMES_SET.contains(field.getKey())) { applyDateRangeField(criteria, field.getKey(), field.getValue()); } else if (field.getKey().startsWith(KewApiConstants.DOCUMENT_ATTRIBUTE_FIELD_PREFIX)) { documentAttributeFields.add(field.getKey()); } } } catch (Exception e) { throw new IllegalStateException("Failed to set document search criteria field: " + field.getKey(), e); } } if (!documentAttributeFields.isEmpty()) { translateDocumentAttributeFieldsToCriteria(fieldValues, documentAttributeFields, criteria); } String routeNodeLookupLogic = fieldValues.get(ROUTE_NODE_LOOKUP_LOGIC); if (StringUtils.isNotBlank(routeNodeLookupLogic)) { criteria.setRouteNodeLookupLogic(RouteNodeLookupLogic.valueOf(routeNodeLookupLogic)); } String documentStatusesValue = fieldValues .get(KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_STATUS_CODE); if (StringUtils.isNotBlank(documentStatusesValue)) { String[] documentStatuses = documentStatusesValue.split(","); for (String documentStatus : documentStatuses) { if (documentStatus.startsWith("category:")) { String categoryCode = StringUtils.remove(documentStatus, "category:"); criteria.getDocumentStatusCategories().add(DocumentStatusCategory.fromCode(categoryCode)); } else { criteria.getDocumentStatuses().add(DocumentStatus.fromCode(documentStatus)); } } } LinkedHashMap<String, List<String>> applicationDocumentStatusGroupings = ApplicationDocumentStatusUtils .getApplicationDocumentStatusCategories(criteria.getDocumentTypeName()); String applicationDocumentStatusesValue = fieldValues .get(KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_STATUS); if (StringUtils.isNotBlank(applicationDocumentStatusesValue)) { String[] applicationDocumentStatuses = applicationDocumentStatusesValue.split(","); for (String applicationDocumentStatus : applicationDocumentStatuses) { // KULRICE-7786: support for groups (categories) of application document statuses if (applicationDocumentStatus.startsWith("category:")) { String categoryCode = StringUtils.remove(applicationDocumentStatus, "category:"); if (applicationDocumentStatusGroupings.containsKey(categoryCode)) { criteria.getApplicationDocumentStatuses() .addAll(applicationDocumentStatusGroupings.get(categoryCode)); } } else { criteria.getApplicationDocumentStatuses().add(applicationDocumentStatus); } } } // blank the deprecated field out, it's not needed. criteria.setApplicationDocumentStatus(null); return criteria.build(); }
From source file:org.kuali.rice.kns.lookup.LookupUtils.java
/** * Changes ranged search fields like from/to dates into the range operators the lookupable dao expects * ("..",">" etc) this method modifies the passed in map and returns a list containing only the modified fields * * This method does not handle document searchable attributes. This is handled in a second pass by the docsearch-specific * DocumentSearchCriteriaTranslator/* w ww . j a va 2 s . c o m*/ */ public static Map<String, String> preProcessRangeFields(Map<String, String> lookupFormFields) { Map<String, String> fieldsToUpdate = new HashMap<String, String>(); Set<String> fieldsForLookup = lookupFormFields.keySet(); for (String propName : fieldsForLookup) { if (propName.startsWith(KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX)) { String rangedLowerBoundValue = lookupFormFields.get(propName); String rangedFieldName = StringUtils.remove(propName, KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX); String rangedValue = lookupFormFields.get(rangedFieldName); Range range = new Range(); // defaults for general lookup/search range.setLowerBoundInclusive(true); range.setUpperBoundInclusive(true); range.setLowerBoundValue(rangedLowerBoundValue); range.setUpperBoundValue(rangedValue); String expr = range.toString(); if (StringUtils.isEmpty(expr)) { expr = rangedValue; } fieldsToUpdate.put(rangedFieldName, expr); } } //update lookup values from found ranged values to update Set<String> keysToUpdate = fieldsToUpdate.keySet(); for (String updateKey : keysToUpdate) { lookupFormFields.put(updateKey, fieldsToUpdate.get(updateKey)); } return fieldsToUpdate; }
From source file:org.kuali.rice.krad.lookup.LookupUtils.java
/** * Changes from/to dates into the range operators the lookupable dao expects ("..",">" etc) this method modifies * the passed in map and returns an updated search criteria map. * * @param searchCriteria map of criteria currently set for which the date criteria will be adjusted * @return map updated search criteria/*w w w .j a va 2 s. com*/ */ public static Map<String, String> preprocessDateFields(Map<String, String> searchCriteria) { Map<String, String> fieldsToUpdate = new HashMap<String, String>(); Map<String, String> searchCriteriaUpdated = new HashMap<String, String>(searchCriteria); Set<String> fieldsForLookup = searchCriteria.keySet(); for (String propName : fieldsForLookup) { if (propName.startsWith(KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX)) { String from_DateValue = searchCriteria.get(propName); String dateFieldName = StringUtils.remove(propName, KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX); String to_DateValue = searchCriteria.get(dateFieldName); String newPropValue = to_DateValue; if (StringUtils.isNotEmpty(from_DateValue) && StringUtils.isNotEmpty(to_DateValue)) { newPropValue = from_DateValue + SearchOperator.BETWEEN + to_DateValue; } else if (StringUtils.isNotEmpty(from_DateValue) && StringUtils.isEmpty(to_DateValue)) { newPropValue = SearchOperator.GREATER_THAN_EQUAL.op() + from_DateValue; } else if (StringUtils.isNotEmpty(to_DateValue) && StringUtils.isEmpty(from_DateValue)) { newPropValue = SearchOperator.LESS_THAN_EQUAL.op() + to_DateValue; } // could optionally continue on else here fieldsToUpdate.put(dateFieldName, newPropValue); } } // update lookup values from found date values to update Set<String> keysToUpdate = fieldsToUpdate.keySet(); for (String updateKey : keysToUpdate) { searchCriteriaUpdated.put(updateKey, fieldsToUpdate.get(updateKey)); } return searchCriteriaUpdated; }
From source file:org.kuali.rice.krad.messages.providers.ResourceMessageProvider.java
/** * Removes any component declaration within the given resource key * * @param resourceKey resource key to clean * @return String cleaned resource key// www. jav a 2 s . c o m */ protected String cleanResourceKey(String resourceKey) { String cleanedKey = resourceKey; String component = StringUtils.substringBetween(cleanedKey, COMPONENT_PLACEHOLDER_BEGIN, COMPONENT_PLACEHOLDER_END); if (StringUtils.isNotBlank(component)) { cleanedKey = StringUtils.remove(cleanedKey, COMPONENT_PLACEHOLDER_BEGIN + component + COMPONENT_PLACEHOLDER_END); } return cleanedKey; }
From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java
/** * Process a piece of the message that has id content to get a component by id and insert it in the structure * * @param messagePiece String piece with component by id content * @param messageComponentStructure the structure of the message being built * @param currentMessageComponent the state of the current text based message being built * @param view current View//from w w w . jav a 2 s . c om * @return null if currentMessageComponent had a value (it is now added to the messageComponentStructure passed in) */ private static Message processIdComponentContent(String messagePiece, List<Component> messageComponentStructure, Message currentMessageComponent, View view) { //splits around spaces not included in single quotes String[] parts = messagePiece.trim().trim().split("([ ]+(?=([^']*'[^']*')*[^']*$))"); messagePiece = parts[0]; //if there is a currentMessageComponent add it to the structure and reset it to null //because component content is now interrupting the string content if (currentMessageComponent != null && StringUtils.isNotEmpty(currentMessageComponent.getMessageText())) { messageComponentStructure.add(currentMessageComponent); currentMessageComponent = null; } //match component by id from the view messagePiece = StringUtils.remove(messagePiece, "'"); messagePiece = StringUtils.remove(messagePiece, "\""); Component component = ComponentFactory.getNewComponentInstance( StringUtils.removeStart(messagePiece, KRADConstants.MessageParsing.COMPONENT_BY_ID + "=")); if (component != null) { component.addStyleClass(KRADConstants.MessageParsing.INLINE_COMP_CLASS); if (parts.length > 1) { component = processAdditionalProperties(component, parts); } messageComponentStructure.add(component); } return currentMessageComponent; }
From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java
/** * Process a piece of the message that has color content by creating a span with that color style set * * @param messagePiece String piece with color content * @param currentMessageComponent the state of the current text based message being built * @param view current View/*from www. java2 s . c o m*/ * @return currentMessageComponent with the new textual content generated by this method appended to its * messageText */ private static Message processColorContent(String messagePiece, Message currentMessageComponent, View view) { if (!StringUtils.startsWithIgnoreCase(messagePiece, "/")) { messagePiece = StringUtils.remove(messagePiece, "'"); messagePiece = StringUtils.remove(messagePiece, "\""); messagePiece = "<span style='color: " + StringUtils.removeStart(messagePiece, KRADConstants.MessageParsing.COLOR + "=") + ";'>"; } else { messagePiece = "</span>"; } return concatenateStringMessageContent(currentMessageComponent, messagePiece, view); }
From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java
/** * Process a piece of the message that has css content by creating a span with those css classes set * * @param messagePiece String piece with css class content * @param currentMessageComponent the state of the current text based message being built * @param view current View/*from w ww .j a v a 2 s . c o m*/ * @return currentMessageComponent with the new textual content generated by this method appended to its * messageText */ private static Message processCssClassContent(String messagePiece, Message currentMessageComponent, View view) { if (!StringUtils.startsWithIgnoreCase(messagePiece, "/")) { messagePiece = StringUtils.remove(messagePiece, "'"); messagePiece = StringUtils.remove(messagePiece, "\""); messagePiece = "<span class='" + StringUtils.removeStart(messagePiece, KRADConstants.MessageParsing.CSS_CLASSES + "=") + "'>"; } else { messagePiece = "</span>"; } return concatenateStringMessageContent(currentMessageComponent, messagePiece, view); }
From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java
/** * Process a piece of the message that has action link content by creating an anchor (a tag) with the onClick set * to perform either ajaxSubmit or submit to the controller with a methodToCall * * @param messagePiece String piece with action link content * @param currentMessageComponent the state of the current text based message being built * @param view current View//from ww w.j av a 2s. co m * @return currentMessageComponent with the new textual content generated by this method appended to its * messageText */ private static Message processActionLinkContent(String messagePiece, Message currentMessageComponent, View view) { if (!StringUtils.startsWithIgnoreCase(messagePiece, "/")) { messagePiece = StringUtils.removeStart(messagePiece, KRADConstants.MessageParsing.ACTION_LINK + "="); String[] splitData = messagePiece.split(KRADConstants.MessageParsing.ACTION_DATA + "="); String[] params = splitData[0].trim().split("([,]+(?=([^']*'[^']*')*[^']*$))"); String methodToCall = ((params.length >= 1) ? params[0] : ""); String validate = ((params.length >= 2) ? params[1] : "true"); String ajaxSubmit = ((params.length >= 3) ? params[2] : "true"); String successCallback = ((params.length >= 4) ? params[3] : "null"); String submitData = "null"; if (splitData.length > 1) { submitData = splitData[1].trim(); } methodToCall = StringUtils.remove(methodToCall, "'"); methodToCall = StringUtils.remove(methodToCall, "\""); messagePiece = "<a href=\"javascript:void(null)\" onclick=\"submitForm(" + "'" + methodToCall + "'," + submitData + "," + validate + "," + ajaxSubmit + "," + successCallback + "); return false;\">"; ViewPostMetadata viewPostMetadata = ViewLifecycle.getViewPostMetadata(); if (viewPostMetadata != null) { viewPostMetadata.addAccessibleMethodToCall(methodToCall); viewPostMetadata.addAvailableMethodToCall(methodToCall); } } else { messagePiece = "</a>"; } return concatenateStringMessageContent(currentMessageComponent, messagePiece, view); }
From source file:org.kuali.rice.krad.uif.widget.RichTable.java
/** * The following initialization is performed: * * <ul>//from w w w .j ava 2 s . co m * <li>Initializes component options for empty table message</li> * </ul> */ @Override public void performFinalize(Object model, LifecycleElement parent) { super.performFinalize(model, parent); UifFormBase formBase = (UifFormBase) model; if (!isRender()) { return; } if (templateOptions.isEmpty()) { setTemplateOptions(new HashMap<String, String>()); } if (StringUtils.isNotBlank(getEmptyTableMessage()) && !templateOptions.containsKey(UifConstants.TableToolsKeys.LANGUAGE)) { templateOptions.put(UifConstants.TableToolsKeys.LANGUAGE, "{\"" + UifConstants.TableToolsKeys.EMPTY_TABLE + "\" : \"" + getEmptyTableMessage() + "\"}"); } Object domOption = templateOptions.get(UifConstants.TableToolsKeys.SDOM); if (domOption instanceof String) { String sDomOption = (String) domOption; if (StringUtils.isNotBlank(sDomOption)) { if (!isShowExportOption()) { sDomOption = StringUtils.remove(sDomOption, "T"); //Removes Export option } templateOptions.put(UifConstants.TableToolsKeys.SDOM, sDomOption); } } // for add events, disable initial sorting if (UifConstants.ActionEvents.ADD_LINE.equals(formBase.getActionEvent()) || UifConstants.ActionEvents.ADD_BLANK_LINE.equals(formBase.getActionEvent())) { templateOptions.put(UifConstants.TableToolsKeys.AASORTING, "[]"); } if ((parent instanceof CollectionGroup)) { CollectionGroup collectionGroup = (CollectionGroup) parent; LayoutManager layoutManager = collectionGroup.getLayoutManager(); //if useServerPaging is true, add the css cell styling to the template options so it can still be used //since this will not go through the grid ftl if (layoutManager instanceof TableLayoutManager && collectionGroup.isUseServerPaging()) { addCellStyling((TableLayoutManager) layoutManager); } buildTableOptions(collectionGroup); setTotalOptions(collectionGroup); View view = ViewLifecycle.getActiveLifecycle().getView(); if (view instanceof LookupView) { buildSortOptions((LookupView) view, collectionGroup); } } if (isDisableTableSort()) { templateOptions.put(UifConstants.TableToolsKeys.TABLE_SORT, "false"); } String kradUrl = getConfigurationService().getPropertyValueAsString(UifConstants.ConfigProperties.KRAD_URL); if (StringUtils.isNotBlank(ajaxSource)) { templateOptions.put(UifConstants.TableToolsKeys.SAJAX_SOURCE, ajaxSource); } else if (parent instanceof CollectionGroup && ((CollectionGroup) parent).isUseServerPaging()) { // enable required dataTables options for server side paging templateOptions.put(UifConstants.TableToolsKeys.BPROCESSING, "true"); templateOptions.put(UifConstants.TableToolsKeys.BSERVER_SIDE, "true"); // build sAjaxSource url to call templateOptions.put(UifConstants.TableToolsKeys.SAJAX_SOURCE, kradUrl + ((UifFormBase) model).getControllerMapping() + "?" + UifConstants.CONTROLLER_METHOD_DISPATCH_PARAMETER_NAME + "=" + UifConstants.MethodToCallNames.TABLE_JSON + "&" + UifParameters.UPDATE_COMPONENT_ID + "=" + parent.getId() + "&" + UifParameters.FORM_KEY + "=" + ((UifFormBase) model).getFormKey() + "&" + UifParameters.AJAX_RETURN_TYPE + "=" + UifConstants.AjaxReturnTypes.UPDATECOMPONENT.getKey() + "&" + UifParameters.AJAX_REQUEST + "=" + "true"); //TODO: Figure out where to move this script file constant? String pushLookupSelect = "function (aoData) { " + "if(jQuery('table.dataTable').length > 0) { " + " var table = jQuery('table.dataTable'); " + " jQuery( table.find(':input:checked')).each( function (index) { " + " aoData.push({'name': (jQuery(this)).attr('name'),'value': (jQuery(this)).attr('value')}); " + " console.log(jQuery(this).attr('name') + ':' + jQuery(this).attr('value')); " + " }); " + "} " + "}"; templateOptions.put(UifConstants.TableToolsKeys.SERVER_PARAMS, pushLookupSelect); // store col defs so columns can be built on paging request ViewLifecycle.getViewPostMetadata().addComponentPostData(parent.getId(), UifConstants.TableToolsKeys.AO_COLUMN_DEFS, templateOptions.get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS)); } // build export url to call templateOptions.put(UifConstants.TableToolsKeys.SDOWNLOAD_SOURCE, kradUrl + "/" + UifConstants.ControllerMappings.EXPORT + "?" + UifParameters.UPDATE_COMPONENT_ID + "=" + parent.getId() + "&" + UifParameters.FORM_KEY + "=" + ((UifFormBase) model).getFormKey() + "&" + UifParameters.AJAX_RETURN_TYPE + "=" + UifConstants.AjaxReturnTypes.UPDATECOMPONENT.getKey() + "&" + UifParameters.AJAX_REQUEST + "=" + "true"); }