List of usage examples for org.apache.commons.lang StringUtils deleteWhitespace
public static String deleteWhitespace(String str)
Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .
From source file:org.kuali.ole.sys.businessobject.AccountingLineParserBase.java
/** * Calls the appropriate parseAccountingLine method * //from w w w . j a va 2 s . c o m * @param stream * @param transactionalDocument * @param isSource * @return List */ protected List<AccountingLine> importAccountingLines(String fileName, InputStream stream, AccountingDocument transactionalDocument, boolean isSource) { List<AccountingLine> importedAccountingLines = new ArrayList<AccountingLine>(); this.fileName = fileName; BufferedReader br = new BufferedReader(new InputStreamReader(stream)); try { String accountingLineAsString = null; lineNo = 0; while ((accountingLineAsString = br.readLine()) != null) { lineNo++; if (StringUtils.isBlank(StringUtils.remove(StringUtils.deleteWhitespace(accountingLineAsString), OLEConstants.COMMA))) { continue; } AccountingLine accountingLine = null; try { if (isSource) { accountingLine = parseSourceAccountingLine(transactionalDocument, accountingLineAsString); } else { accountingLine = parseTargetAccountingLine(transactionalDocument, accountingLineAsString); } validateImportedAccountingLine(accountingLine, accountingLineAsString); importedAccountingLines.add(accountingLine); } catch (AccountingLineParserException e) { GlobalVariables.getMessageMap().putError( (isSource ? "sourceAccountingLines" : "targetAccountingLines"), OLEKeyConstants.ERROR_ACCOUNTING_DOCUMENT_ACCOUNTING_LINE_IMPORT_GENERAL, new String[] { e.getMessage() }); } } } catch (IOException e) { throw new IllegalArgumentException("unable to readLine from bufferReader in accountingLineParserBase", e); } finally { try { br.close(); } catch (IOException e) { throw new IllegalArgumentException("unable to close bufferReader in accountingLineParserBase", e); } } return importedAccountingLines; }
From source file:org.kuali.rice.kew.clientapp.DocumentContentTest.java
@Test public void testDocumentContent() throws Exception { String startContent = "<" + DOCUMENT_CONTENT + ">"; String endContent = "</" + DOCUMENT_CONTENT + ">"; String emptyContent1 = startContent + endContent; String emptyContent2 = "<" + DOCUMENT_CONTENT + "/>"; WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "TestDocumentType"); // test no content prior to server creation assertEquals("Content should be empty.", "", document.getApplicationContent()); assertEquals("Content should be empty.", "", document.getAttributeContent()); assertEquals("Content should be empty.", "", document.getDocumentContent().getSearchableContent()); String fullContent = document.getDocumentContent().getFullContent(); assertTrue("Invalid content conversion.", fullContent.equals(emptyContent1) || fullContent.equals(emptyContent2)); // test content after server creation document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "TestDocumentType"); // this will create the document on the server document.saveDocumentData();//from w w w . j a va 2 s . c o m assertNotNull(document.getDocumentId()); // the document id on the document content should be there now assertEquals("Incorrect document id.", document.getDocumentId(), document.getDocumentContent().getDocumentId()); assertEquals("Content should be empty.", "", document.getApplicationContent()); assertEquals("Content should be empty.", "", document.getAttributeContent()); assertEquals("Content should be empty.", "", document.getDocumentContent().getSearchableContent()); fullContent = document.getDocumentContent().getFullContent(); assertTrue("Invalid content conversion.", fullContent.equals(emptyContent1) || fullContent.equals(emptyContent2)); // verify the content on the actual document stored in the database DocumentRouteHeaderValue routeHeader = KEWServiceLocator.getRouteHeaderService() .getRouteHeader(document.getDocumentId()); assertTrue("Invalid initial content.", routeHeader.getDocContent().equals(emptyContent1) || routeHeader.getDocContent().equals(emptyContent2)); // test simple case, no attributes document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "TestDocumentType"); String attributeContent = "<attribute1><id value=\"3\"/></attribute1>"; String searchableContent = "<searchable1><data>hello</data></searchable1>"; DocumentContentUpdate.Builder contentVO = DocumentContentUpdate.Builder .create(document.getDocumentContent()); contentVO.setAttributeContent(constructContent(ATTRIBUTE_CONTENT, attributeContent)); contentVO.setSearchableContent(constructContent(SEARCHABLE_CONTENT, searchableContent)); document.updateDocumentContent(contentVO.build()); document.saveDocumentData(); // now reload the document document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), document.getDocumentId()); String expectedContent = startContent + constructContent(ATTRIBUTE_CONTENT, attributeContent) + constructContent(SEARCHABLE_CONTENT, searchableContent) + endContent; fullContent = document.getDocumentContent().getFullContent(); assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(expectedContent), StringUtils.deleteWhitespace(fullContent)); // now, add an attribute and then clear it, document content should remain the same String testAttributeContent = new TestRuleAttribute().getDocContent(); WorkflowAttributeDefinition attributeDefinition = WorkflowAttributeDefinition.Builder .create("TestRuleAttribute").build(); document.addAttributeDefinition(attributeDefinition); document.clearAttributeDefinitions(); document.saveDocumentData(); fullContent = document.getDocumentContent().getFullContent(); assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(expectedContent), StringUtils.deleteWhitespace(fullContent)); // now really add an attribute and save the content document.addAttributeDefinition(attributeDefinition); document.saveDocumentData(); fullContent = document.getDocumentContent().getFullContent(); expectedContent = startContent + constructContent(ATTRIBUTE_CONTENT, attributeContent + testAttributeContent) + constructContent(SEARCHABLE_CONTENT, searchableContent) + endContent; assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(expectedContent), StringUtils.deleteWhitespace(fullContent)); // let's reload the document and try appending a couple of attributes for good measure, this will test appending to existing content on non-materialized document content document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), document.getDocumentId()); document.addAttributeDefinition(attributeDefinition); document.addAttributeDefinition(attributeDefinition); document.saveDocumentData(); fullContent = document.getDocumentContent().getFullContent(); expectedContent = startContent + constructContent(ATTRIBUTE_CONTENT, attributeContent + testAttributeContent + testAttributeContent + testAttributeContent) + constructContent(SEARCHABLE_CONTENT, searchableContent) + endContent; assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(expectedContent), StringUtils.deleteWhitespace(fullContent)); // now let's try clearing the attribute content document.clearAttributeContent(); expectedContent = startContent + constructContent(SEARCHABLE_CONTENT, searchableContent) + endContent; fullContent = document.getDocumentContent().getFullContent(); assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(expectedContent), StringUtils.deleteWhitespace(fullContent)); // now save it and make sure it comes back from the server the same way document.saveDocumentData(); fullContent = document.getDocumentContent().getFullContent(); assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(expectedContent), StringUtils.deleteWhitespace(fullContent)); // Test backward compatibility with old-school document content, this document content could look something // like <myRadContent>abcd</myRadContent>, when converted to the new form, it should come out like // <documentContent><applicationContent><myRadContent>abcd</myRadContent></applicationContent></documentContent> String myRadContent = "<myRadContent>abcd</myRadContent>"; document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "TestDocumentType"); DocumentRouteHeaderValue documentValue = KEWServiceLocator.getRouteHeaderService() .getRouteHeader(document.getDocumentId()); documentValue.setDocContent(myRadContent); KEWServiceLocator.getRouteHeaderService().saveRouteHeader(documentValue); // reload the client document and check that the XML has been auto-magically converted document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("ewestfal"), document.getDocumentId()); String expected = startContent + constructContent(APPLICATION_CONTENT, myRadContent) + endContent; fullContent = document.getDocumentContent().getFullContent(); assertEquals("Backward compatibility failure.", StringUtils.deleteWhitespace(expected), StringUtils.deleteWhitespace(fullContent)); }
From source file:org.kuali.rice.kew.docsearch.SearchableAttributeTest.java
@Test public void testXmlGeneration() { loadXmlFile("testdoc1.xml"); WorkflowAttributeDefinition searchableDefinition = WorkflowAttributeDefinition.Builder .create("SearchAttribute").build(); DocumentContentUpdate.Builder documentContentUpdateBuilder = DocumentContentUpdate.Builder.create(); documentContentUpdateBuilder.getSearchableDefinitions().add(searchableDefinition); WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(getPrincipalId("ewestfal"), "SearchDoc", null, documentContentUpdateBuilder.build()); workflowDocument.route(""); assertTrue(workflowDocument.isFinal()); assertEquals(StringUtils.deleteWhitespace("<" + KewApiConstants.SEARCHABLE_CONTENT_ELEMENT + ">" + MockSearchableAttribute.SEARCH_CONTENT + "</" + KewApiConstants.SEARCHABLE_CONTENT_ELEMENT + ">"), StringUtils.deleteWhitespace(workflowDocument.getDocumentContent().getSearchableContent())); }
From source file:org.kuali.rice.kew.server.BeanConverterTester.java
/** * Tests the conversion of a DocumentContentVO object into an XML String. Includes generating content * for any attributes which are on the DocumentContentVO object. * * TODO there is some crossover between this test and the DocumentContentTest, do we really need both of them??? *///from w w w . j a va 2 s .co m @Test public void testBuildUpdatedDocumentContent() throws Exception { String startContent = "<" + DOCUMENT_CONTENT + ">"; String endContent = "</" + DOCUMENT_CONTENT + ">"; /* * // test no content, this should return null which indicates an unchanged document content VO * //RouteHeaderVO routeHeaderVO = new RouteHeaderVO(); */ // test no content, this should return empty document content DocumentContent contentVO = DocumentContent.Builder.create("1234").build(); String content = contentVO.getFullContent(); assertEquals("Invalid content conversion.", KewApiConstants.DEFAULT_DOCUMENT_CONTENT, content); // test simple case, no attributes String attributeContent = "<attribute1><id value=\"3\"/></attribute1>"; String searchableContent = "<searchable1><data>hello</data></searchable1>"; DocumentContent.Builder contentBuilder = DocumentContent.Builder.create("1234"); contentBuilder.setAttributeContent(constructContent(ATTRIBUTE_CONTENT, attributeContent)); contentBuilder.setSearchableContent(constructContent(SEARCHABLE_CONTENT, searchableContent)); contentVO = contentBuilder.build(); content = contentVO.getFullContent(); String fullContent = startContent + constructContent(ATTRIBUTE_CONTENT, attributeContent) + constructContent(SEARCHABLE_CONTENT, searchableContent) + endContent; assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(fullContent), StringUtils.deleteWhitespace(content)); // now, add an attribute String testAttributeContent = new TestRuleAttribute().getDocContent(); WorkflowAttributeDefinition attributeDefinition = WorkflowAttributeDefinition.Builder .create(TestRuleAttribute.class.getName()).build(); DocumentContentUpdate.Builder contentUpdate = DocumentContentUpdate.Builder.create(); contentUpdate.getAttributeDefinitions().add(attributeDefinition); content = DTOConverter.buildUpdatedDocumentContent(KewApiConstants.DEFAULT_DOCUMENT_CONTENT, contentUpdate.build(), null); fullContent = startContent + constructContent(ATTRIBUTE_CONTENT, attributeContent + testAttributeContent) + constructContent(SEARCHABLE_CONTENT, searchableContent) + endContent; assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(fullContent), StringUtils.deleteWhitespace(content)); }
From source file:org.kuali.rice.kew.server.DTOConverterTest.java
/** * Tests the conversion of a DocumentContentVO object into an XML String. Includes generating content * for any attributes which are on the DocumentContentVO object. * * TODO there is some crossover between this test and the DocumentContentTest, do we really need both of them??? *///from w ww. jav a 2 s .com @Test public void testBuildUpdatedDocumentContent() throws Exception { String startContent = "<" + DOCUMENT_CONTENT + ">"; String endContent = "</" + DOCUMENT_CONTENT + ">"; /* * // test no content, this should return null which indicates an unchanged document content VO * //RouteHeaderVO routeHeaderVO = new RouteHeaderVO(); */ // test no content, this should return empty document content DocumentContentUpdate contentUpdate = DocumentContentUpdate.Builder.create().build(); //routeHeaderVO.setDocumentContent(contentVO); String content = DTOConverter.buildUpdatedDocumentContent(KewApiConstants.DEFAULT_DOCUMENT_CONTENT, contentUpdate, null); assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(KewApiConstants.DEFAULT_DOCUMENT_CONTENT), StringUtils.deleteWhitespace(content)); // test simple case, no attributes String attributeContent = "<attribute1><id value=\"3\"/></attribute1>"; String searchableContent = "<searchable1><data>hello</data></searchable1>"; DocumentContentUpdate.Builder contentUpdateBuilder = DocumentContentUpdate.Builder.create(); contentUpdateBuilder.setAttributeContent(constructContent(ATTRIBUTE_CONTENT, attributeContent)); contentUpdateBuilder.setSearchableContent(constructContent(SEARCHABLE_CONTENT, searchableContent)); content = DTOConverter.buildUpdatedDocumentContent(KewApiConstants.DEFAULT_DOCUMENT_CONTENT, contentUpdateBuilder.build(), null); String fullContent = startContent + "\n" + constructContent(ATTRIBUTE_CONTENT, attributeContent) + "\n" + constructContent(SEARCHABLE_CONTENT, searchableContent) + "\n" + endContent; assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(fullContent), StringUtils.deleteWhitespace(content)); // now, add an attribute String testAttributeContent = new TestRuleAttribute().getDocContent(); WorkflowAttributeDefinition attributeDefinition = WorkflowAttributeDefinition.Builder .create("TestRuleAttribute").build(); contentUpdateBuilder.getAttributeDefinitions().add(attributeDefinition); content = DTOConverter.buildUpdatedDocumentContent(KewApiConstants.DEFAULT_DOCUMENT_CONTENT, contentUpdateBuilder.build(), null); fullContent = startContent + constructContent(ATTRIBUTE_CONTENT, attributeContent + testAttributeContent) + constructContent(SEARCHABLE_CONTENT, searchableContent) + endContent; assertEquals("Invalid content conversion.", StringUtils.deleteWhitespace(fullContent), StringUtils.deleteWhitespace(content)); }
From source file:org.kuali.rice.kew.xml.export.RuleAttributeXmlExporterTest.java
private void assertRuleAttributeExport(RuleAttribute oldRuleAttribute, RuleAttribute newRuleAttribute) { // ids should be the same because we don't version rule attributes, but thier version number should be different assertEquals("Ids should be the same.", oldRuleAttribute.getId(), newRuleAttribute.getId()); assertFalse("Version numbers should be different.", oldRuleAttribute.getVersionNumber().equals(newRuleAttribute.getVersionNumber())); assertEquals(oldRuleAttribute.getDescription(), newRuleAttribute.getDescription()); assertEquals(oldRuleAttribute.getName(), newRuleAttribute.getName()); assertEquals(oldRuleAttribute.getLabel(), newRuleAttribute.getLabel()); assertEquals(oldRuleAttribute.getType(), newRuleAttribute.getType()); assertEquals(StringUtils.deleteWhitespace(oldRuleAttribute.getXmlConfigData()), StringUtils.deleteWhitespace(newRuleAttribute.getXmlConfigData())); assertRuleTemplateAttributes(oldRuleAttribute.getRuleTemplateAttributes(), newRuleAttribute.getRuleTemplateAttributes()); }
From source file:org.metaabm.act.provider.AActItemProvider.java
public String suggestID(IID object) { String suggestID = StringUtils.deleteWhitespace(suggestLabel(object)); suggestID = StringUtils.replaceChars(suggestID, "[]()", null); return StringUtils.uncapitalize(suggestID); }
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);// ww w. j a v a2 s . c o m 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.metaabm.commands.TargetTranslator.java
protected String removeSpecialChars(String otherName) { String legalID = StringUtils.deleteWhitespace(StringUtils.capitalize(otherName)); // todo..make this more generic legalID = StringUtils.replace(legalID, "()", ""); legalID = StringUtils.replace(legalID, "(", "_"); legalID = StringUtils.replace(legalID, ")", "_"); legalID = StringUtils.replace(legalID, "[?]", ""); legalID = StringUtils.replace(legalID, "[", "_"); legalID = StringUtils.replace(legalID, "]", "_"); legalID = StringUtils.replace(legalID, "?", ""); legalID = StringUtils.replace(legalID, "&&", "AND"); legalID = StringUtils.replace(legalID, "&", "And"); legalID = StringUtils.replace(legalID, "!", "Not"); legalID = StringUtils.replace(legalID, "||", "OR"); legalID = StringUtils.replace(legalID, "|", "Or"); legalID = StringUtils.replace(legalID, ",", ""); legalID = StringUtils.replace(legalID, ".", "pt"); legalID = StringUtils.replace(legalID, ":", ""); return legalID; }
From source file:org.metaabm.function.provider.FFunctionItemProvider.java
public String suggestID(IID object) { return StringUtils.uncapitalize(StringUtils .deleteWhitespace(StringUtils.capitalize(getString("_UI_" + object.eClass().getName() + "_type")))); }