List of usage examples for org.apache.commons.lang3 StringUtils contains
public static boolean contains(final CharSequence seq, final CharSequence searchSeq)
Checks if CharSequence contains a search CharSequence, handling null .
From source file:org.jevis.commons.unit.UnitFormula.java
private boolean isValid(String formula) { if (StringUtils.contains(formula, PUNCTUATION_START) || StringUtils.contains(formula, PUNCTUATION_END)) { int counterStart = 0; int counterEnd = 0; for (int i = 0; i < formula.length(); i++) { if (formula.charAt(i) == PUNCTUATION_START.charAt(0)) { counterStart++;/*from w ww .j a v a2s.c o m*/ } else if (formula.charAt(i) == PUNCTUATION_END.charAt(0)) { counterEnd++; } } // System.out.println("isValid: " + counterStart + " " + counterEnd); if (counterStart != counterEnd) { System.out.println("Not Valied, uneave count of punctuation"); return false; } } return true; }
From source file:org.kalypso.zml.core.table.model.utils.ZmlModelColumns.java
public static boolean isCloned(final IZmlModelColumn column) { final String identifier = column.getIdentifier(); return StringUtils.contains(identifier, IClonedColumn.CLONED_COLUMN_POSTFIX); }
From source file:org.kisoonlineapp.startup.StartupSqlReader.java
final void readFromInputStream(InputStream is) throws IOException { final BufferedReader br = new BufferedReader(new InputStreamReader(is)); try {/* w ww . jav a 2s . c o m*/ String key = null; StringBuilder value = new StringBuilder(); for (String line; (line = br.readLine()) != null;) { if (StringUtils.startsWithAny(line, new String[] { "#", "---" })) { continue; } line = StringUtils.removeEnd(line, "\\"); if (StringUtils.contains(line, '=')) { if (key == null) { String[] splitted = StringUtils.split(line, "=", 2); if (splitted.length == 2) { key = splitted[0]; value.append(splitted[1]); } else if (splitted.length == 1) { key = splitted[0]; value.append(""); } } else { value.append(line); } } else if (StringUtils.isBlank(line)) { if (key != null) { this.statementMap.put(key, value.toString()); key = null; value = new StringBuilder(); } } else { value.append(line); } } if (key != null) { this.statementMap.put(key, value.toString()); } } finally { br.close(); } }
From source file:org.kisoonlineapp.uc.report.ReportICalVeranstaltungenTest.java
void assertContainsLine(String content, List<String> lines) { int linenr = 0; for (String line : lines) { final String m = "" + linenr + " content: " + content + ": " + line; assertEquals(m, true, StringUtils.contains(content, line)); linenr += 1;/*from w w w . j a v a2 s . com*/ } }
From source file:org.kuali.coeus.common.budget.impl.struts.BudgetActionBase.java
@Override protected void setupPessimisticLockMessages(Document document, HttpServletRequest request) { super.setupPessimisticLockMessages(document, request); List<String> lockMessages = (List<String>) request.getAttribute(KRADConstants.PESSIMISTIC_LOCK_MESSAGES); AwardBudgetDocument budgetDoc = (AwardBudgetDocument) document; for (PessimisticLock lock : budgetDoc.getBudget().getBudgetParent().getDocument().getPessimisticLocks()) { if (StringUtils.contains(lock.getLockDescriptor(), KraAuthorizationConstants.LOCK_DESCRIPTOR_BUDGET) && !lock.isOwnedByUser(GlobalVariables.getUserSession().getPerson())) { String message = generatePessimisticLockMessage(lock); if (!lockMessages.contains(message)) { lockMessages.add(message); }/*from w w w . j a v a 2 s .c om*/ } } request.setAttribute(KRADConstants.PESSIMISTIC_LOCK_MESSAGES, lockMessages); }
From source file:org.kuali.coeus.propdev.impl.action.ProposalDevelopmentActionsAction.java
private boolean canGenerateMultipleApprovalRequests(RoutingReportCriteria reportCriteria, String loggedInPrincipalId, String currentRouteNodeNames) throws Exception { int approvalRequestsCount = 0; WorkflowDocumentActionsService info = GlobalResourceLoader .getService("rice.kew.workflowDocumentActionsService"); DocumentDetail results1 = info.executeSimulation(reportCriteria); for (ActionRequest actionRequest : results1.getActionRequests()) { //!actionRequest.isRoleRequest() && removed from condition for if (actionRequest.isPending() && actionRequest.getActionRequested().getCode() .equalsIgnoreCase(KewApiConstants.ACTION_REQUEST_APPROVE_REQ) && recipientMatchesUser(actionRequest, loggedInPrincipalId) && !StringUtils.contains(currentRouteNodeNames, actionRequest.getNodeName())) { approvalRequestsCount += 1;//from w w w. ja v a 2 s . c o m } } return (approvalRequestsCount > 0); }
From source file:org.kuali.coeus.propdev.impl.budget.subaward.PropDevPropDevBudgetSubAwardServiceImpl.java
@Override public boolean updateSubAwardBudgetDetails(Budget budget, BudgetSubAwards budgetSubAward, List<String[]> errors) throws Exception { boolean result = true; //extarct xml from the pdf because the stored xml has been modified if (budgetSubAward.getSubAwardXfdFileData() == null || budgetSubAward.getSubAwardXfdFileData().length == 0) { errors.add(new String[] { Constants.SUBAWARD_FILE_NOT_EXTRACTED }); return true; }// ww w . jav a 2 s .c o m PdfReader reader = new PdfReader(budgetSubAward.getSubAwardXfdFileData()); byte[] xmlContents = getXMLFromPDF(reader); if (xmlContents == null) { errors.add(new String[] { Constants.SUBAWARD_FILE_NOT_EXTRACTED }); return true; } javax.xml.parsers.DocumentBuilderFactory domParserFactory = javax.xml.parsers.DocumentBuilderFactory .newInstance(); javax.xml.parsers.DocumentBuilder domParser = domParserFactory.newDocumentBuilder(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlContents); org.w3c.dom.Document document = domParser.parse(byteArrayInputStream); NodeList budgetYearList = XPathAPI.selectNodeList(document, "//*[local-name(.) = 'BudgetYear']"); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); boolean fnfForm = StringUtils.contains(budgetSubAward.getFormName(), "RR_FedNonFedBudget"); //reset current line items if replacing with a new one. resetSubAwardPeriodDetails(budgetSubAward); for (int i = 0; i < budgetYearList.getLength(); i++) { Node budgetYear = budgetYearList.item(i); Node startDateNode = XPathAPI.selectSingleNode(budgetYear, "BudgetPeriodStartDate"); if (startDateNode == null) { startDateNode = XPathAPI.selectSingleNode(budgetYear, "PeriodStartDate"); } Node endDateNode = XPathAPI.selectSingleNode(budgetYear, "BudgetPeriodEndDate"); if (endDateNode == null) { endDateNode = XPathAPI.selectSingleNode(budgetYear, "PeriodEndDate"); } Date startDate = dateFormat.parse(startDateNode.getTextContent()); Date endDate = dateFormat.parse(endDateNode.getTextContent()); //attempt to find a matching budget period BudgetSubAwardPeriodDetail periodDetail = findBudgetSubAwardPeriodDetail(budget, budgetSubAward, startDate, endDate); if (periodDetail != null) { Node directCostNode, indirectCostNode, costShareNode = null; if (fnfForm) { directCostNode = XPathAPI.selectSingleNode(budgetYear, "DirectCosts/FederalSummary"); indirectCostNode = XPathAPI.selectSingleNode(budgetYear, "IndirectCosts/TotalIndirectCosts/FederalSummary"); costShareNode = XPathAPI.selectSingleNode(budgetYear, "TotalCosts/NonFederalSummary"); } else { directCostNode = XPathAPI.selectSingleNode(budgetYear, "DirectCosts"); indirectCostNode = XPathAPI.selectSingleNode(budgetYear, "IndirectCosts/TotalIndirectCosts"); } if (directCostNode != null) { periodDetail .setDirectCost(new ScaleTwoDecimal(Float.parseFloat(directCostNode.getTextContent()))); } if (indirectCostNode != null) { periodDetail.setIndirectCost( new ScaleTwoDecimal(Float.parseFloat(indirectCostNode.getTextContent()))); } if (costShareNode != null) { periodDetail .setCostShare(new ScaleTwoDecimal(Float.parseFloat(costShareNode.getTextContent()))); } else { periodDetail.setCostShare(ScaleTwoDecimal.ZERO); } periodDetail.computeTotal(); } else { Node budgetPeriodNode = XPathAPI.selectSingleNode(budgetYear, "BudgetPeriod"); String budgetPeriod = null; if (budgetPeriodNode != null) { budgetPeriod = budgetPeriodNode.getTextContent(); } LOG.debug("Unable to find matching period for uploaded period '" + budgetPeriod + "' -- " + startDateNode.getTextContent() + " - " + endDateNode.getTextContent()); errors.add(new String[] { Constants.SUBAWARD_FILE_PERIOD_NOT_FOUND, (budgetPeriod == null ? "" : budgetPeriod), startDateNode.getTextContent(), endDateNode.getTextContent() }); } } return result; }
From source file:org.kuali.coeus.propdev.impl.core.ProposalDevelopmentSubmitController.java
protected boolean canGenerateMultipleApprovalRequests(RoutingReportCriteria reportCriteria, String loggedInPrincipalId, String currentRouteNodeNames) throws Exception { int approvalRequestsCount = 0; DocumentDetail results1 = getWorkflowDocumentActionsService().executeSimulation(reportCriteria); for (ActionRequest actionRequest : results1.getActionRequests()) { if (actionRequest.isPending() && actionRequest.getActionRequested().getCode() .equalsIgnoreCase(KewApiConstants.ACTION_REQUEST_APPROVE_REQ) && recipientMatchesUser(actionRequest, loggedInPrincipalId) && !StringUtils.contains(currentRouteNodeNames, actionRequest.getNodeName())) { approvalRequestsCount += 1;/* w w w . ja v a 2s . c o m*/ } } return (approvalRequestsCount > 0); }
From source file:org.kuali.coeus.propdev.impl.person.ProposalDevelopmentKeyPersonnelAction.java
public ActionForward updateAnswerToNewVersion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ProposalDevelopmentForm pdform = (ProposalDevelopmentForm) form; ProposalDevelopmentDocument document = pdform.getProposalDevelopmentDocument(); final String formProperty = getFormProperty(request, "updateAnswerToNewVersion"); if (StringUtils.contains(formProperty, ".proposalPersonQuestionnaireHelpers[")) { int selectedPersonIndex = Integer.parseInt(formProperty.substring(36, formProperty.length() - 1)); ProposalPerson person = document.getDevelopmentProposal().getProposalPerson(selectedPersonIndex); ProposalPersonQuestionnaireHelper helper = pdform.getProposalPersonQuestionnaireHelpers() .get(selectedPersonIndex); helper.updateQuestionnaireAnswer(getLineToDelete(request)); getBusinessObjectService().save(helper.getAnswerHeaders().get(getLineToDelete(request))); return mapping.findForward(MAPPING_BASIC); } else {//from www . j ava2s . com throw new RuntimeException(String.format( "Do not know how to process updateAnswerToNewVersion for formProperty %s", formProperty)); } }
From source file:org.kuali.coeus.sys.framework.model.KcTransactionalDocumentFormBase.java
@Override public void populate(HttpServletRequest request) { super.populate(request); // Hack to get panels with add/delete items that are editable after add (Protocol Participants, Special Review) to work correctly with validation. // In this scenario, the user adds a couple of correctly formatted items but then changes one of the fields to an incorrect format and saves. This will // cause validation errors, but if the user now tries to delete the errant entry, validation will fail because the validator in the Kuali Request // ProcessDefinitionDefinitionor still detects the error in the message map. We don't want validation to run for a delete method, so we need to clear the current error // messages, preventing the validator from running and allowing the delete to go through. ///*from w w w . ja v a 2 s . co m*/ // This is detected by the existence of "validate0" on the methodToCall property (similar to finding the line number of a delete). String methodToCallAttribute = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); if (StringUtils.contains(methodToCallAttribute, "validate")) { String validateParameter = StringUtils.substringBetween(methodToCallAttribute, ".validate", "."); if (StringUtils.equals("0", validateParameter)) { GlobalVariables.getMessageMap().clearErrorMessages(); } } }