List of usage examples for org.apache.commons.lang3 StringUtils substringAfter
public static String substringAfter(final String str, final String separator)
Gets the substring after the first occurrence of a separator.
From source file:org.kitodo.forms.WorkflowForm.java
/** * Save updated content of the diagram./* w w w . j a v a 2s .co m*/ */ private void saveFiles() { Map<String, String> requestParameterMap = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap(); xmlDiagram = requestParameterMap.get("diagram"); if (Objects.nonNull(xmlDiagram)) { svgDiagram = StringUtils.substringAfter(xmlDiagram, "kitodo-diagram-separator"); xmlDiagram = StringUtils.substringBefore(xmlDiagram, "kitodo-diagram-separator"); saveXMLDiagram(); saveSVGDiagram(); } }
From source file:org.kitodo.production.forms.WorkflowForm.java
/** * Save content of the diagram files./*w w w.j av a2 s. c o m*/ * * @return true if save, false if not */ private boolean saveFiles() throws IOException, WorkflowException { Map<String, String> requestParameterMap = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap(); Map<String, URI> diagramsUris = getDiagramUris(); URI svgDiagramURI = diagramsUris.get(SVG_DIAGRAM_URI); URI xmlDiagramURI = diagramsUris.get(XML_DIAGRAM_URI); xmlDiagram = requestParameterMap.get("editForm:workflowTabView:xmlDiagram"); if (Objects.nonNull(xmlDiagram)) { svgDiagram = StringUtils.substringAfter(xmlDiagram, "kitodo-diagram-separator"); xmlDiagram = StringUtils.substringBefore(xmlDiagram, "kitodo-diagram-separator"); Reader reader = new Reader(new ByteArrayInputStream(xmlDiagram.getBytes(StandardCharsets.UTF_8))); reader.validateWorkflowTasks(); Converter converter = new Converter( new ByteArrayInputStream(xmlDiagram.getBytes(StandardCharsets.UTF_8))); converter.validateWorkflowTaskList(); saveFile(svgDiagramURI, svgDiagram); saveFile(xmlDiagramURI, xmlDiagram); } return fileService.fileExist(xmlDiagramURI) && fileService.fileExist(svgDiagramURI); }
From source file:org.kuali.coeus.common.impl.KcViewHelperServiceImpl.java
public List<DataValidationItem> populateDataValidation() { List<DataValidationItem> dataValidationItems = new ArrayList<DataValidationItem>(); for (Map.Entry<String, AuditCluster> entry : getGlobalVariableService().getAuditErrorMap().entrySet()) { AuditCluster auditCluster = entry.getValue(); List<AuditError> auditErrors = auditCluster.getAuditErrorList(); String areaName = StringUtils.substringBefore(auditCluster.getLabel(), "."); String sectionName = StringUtils.substringAfter(auditCluster.getLabel(), "."); for (AuditError auditError : auditErrors) { DataValidationItem dataValidationItem = new DataValidationItem(); String pageId = StringUtils.substringBefore(auditError.getLink(), "."); String sectionId = StringUtils.substringAfter(auditError.getLink(), "."); ErrorMessage errorMessage = new ErrorMessage(); errorMessage.setErrorKey(auditError.getMessageKey()); errorMessage.setMessageParameters(auditError.getParams()); dataValidationItem.setArea(areaName); dataValidationItem.setSection(sectionName); dataValidationItem.setDescription(KRADUtils.getMessageText(errorMessage, false)); dataValidationItem.setSeverity(auditCluster.getCategory()); dataValidationItem.setNavigateToPageId(pageId); dataValidationItem.setNavigateToSectionId(sectionId); dataValidationItems.add(dataValidationItem); }/*from ww w. j a v a2s.com*/ } Collections.sort(dataValidationItems, (o1, o2) -> o1.getArea().compareTo(o2.getArea())); return dataValidationItems; }
From source file:org.kuali.coeus.common.notification.impl.service.impl.KcNotificationServiceImpl.java
private List<NotificationRecipient.Builder> createRoleRecipients( List<NotificationTypeRecipient> roleRecipients) { List<NotificationRecipient.Builder> recipients = new ArrayList<NotificationRecipient.Builder>(); for (NotificationTypeRecipient roleRecipient : roleRecipients) { LOG.info("Processing recipient: " + roleRecipient.getRoleName() + " with " + roleRecipient.getRoleQualifiers().size() + " qualifiers."); String roleNamespace = StringUtils.substringBefore(roleRecipient.getRoleName(), Constants.COLON); String roleName = StringUtils.substringAfter(roleRecipient.getRoleName(), Constants.COLON); Collection<String> roleMembers = getRoleMemberPrincipalIds(roleNamespace, roleName, roleRecipient.getRoleQualifiers()); for (String roleMember : roleMembers) { NotificationRecipient.Builder recipient = NotificationRecipient.Builder.create(); try { recipient.setRecipientId(getPersonUserName(roleMember)); recipient.setRecipientType(MemberType.PRINCIPAL.getCode()); recipients.add(recipient); } catch (IllegalArgumentException e) { // Quietly ignore recipients that no longer exist LOG.info("Invalid recipient", e); }/*from w w w . j av a 2 s . com*/ } } return recipients; }
From source file:org.kuali.coeus.propdev.impl.core.ProposalDevelopmentDocumentForm.java
protected List<String> getUnitRulesMessages(String messageType) { List<String> messages = new ArrayList<String>(); for (String message : this.unitRulesMessages) { if (StringUtils.substringBefore(message, KcKrmsConstants.MESSAGE_SEPARATOR).equals(messageType)) { messages.add(StringUtils.substringAfter(message, KcKrmsConstants.MESSAGE_SEPARATOR)); }// w w w. jav a2 s. com } return messages; }
From source file:org.kuali.coeus.s2sgen.impl.generate.S2SBaseFormGenerator.java
protected String getS2sNarrativeFileName(NarrativeContract narrative) { String fileName = narrative.getNarrativeType().getDescription(); String extension = StringUtils.substringAfter(narrative.getNarrativeAttachment().getName(), "."); return cleanFileName(fileName) + "." + extension; }
From source file:org.kuali.coeus.s2sgen.impl.generate.S2SBaseFormGenerator.java
protected String getS2sPersonnelAttachmentFileName(DevelopmentProposalContract developmentProposal, ProposalPersonBiographyContract biography) { String extension = StringUtils.substringAfter(biography.getName(), "."); String fullName = getPerson(developmentProposal, biography.getProposalPersonNumber()).getFullName(); String docType = biography.getPropPerDocType().getDescription(); String fileName = fullName + "_" + docType; return cleanFileName(fileName) + "." + extension; }
From source file:org.kuali.kra.award.web.struts.action.AwardAction.java
/** * This method sets up a sponsor template synchronization loop. * It is called by the ui when a specific set of scopes need to by synchronized. * If no scopes are in the request, then a full synchronization to the scopes: * /*from w ww . ja v a2 s . c om*/ * AWARD_PAGE * SPONSOR_CONTACTS_TAB * PAYMENTS_AND_INVOICES_TAB * TERMS_TAB * REPORTS_TAB * COMMENTS_TAB * * is performed. This method generates and stores the list of scopes to sync * and the map to indicate if confirmation is necessary from the user before * a particular scope is synchronized and then forwards to the method the handles * the request loop. * */ public ActionForward syncAwardTemplate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { AwardForm awardForm = (AwardForm) form; AwardDocument awardDocument = awardForm.getAwardDocument(); AwardTemplateSyncScope[] scopes; String syncScopes = getSyncScopesString(request); if (awardDocument.getAward().getTemplateCode() == null || awardDocument.getAward().getAwardTemplate() == null) { GlobalVariables.getMessageMap().clearErrorMessages(); GlobalVariables.getMessageMap().putError( StringUtils.isBlank(syncScopes) ? "document.award.awardTemplate" : String.format("document.award.awardTemplate.%s", StringUtils.substring(syncScopes, 1)), KeyConstants.ERROR_NO_SPONSOR_TEMPLATE_FOUND, new String[] {}); awardForm.setOldTemplateCode(null); awardForm.setTemplateLookup(false); return mapping.findForward(Constants.MAPPING_AWARD_BASIC); } Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME); if (question != null) return processSyncAward(mapping, awardForm, request, response); awardForm.setCurrentSyncScopes(null); awardForm.setSyncRequiresConfirmationMap(null); /* * The format for the action string is: * methodToCall.syncAwardTemplate:SCOPE1:...:SCOPEN].anchor... * Where: * [PropertyName|MethodName] means to sync by a property name or a method name. * SCOPE1...SCOPEN : A ':' delimited list of scope names that should be synced. If none are specified then the sync is done for every field and method. * */ if (StringUtils.isNotBlank(syncScopes) && syncScopes.length() > 1 && syncScopes.indexOf(":") > -1) { String[] scopeStrings = StringUtils.split(StringUtils.substringAfter(syncScopes, ":")); scopes = new AwardTemplateSyncScope[scopeStrings.length]; for (int i = 0; i < scopeStrings.length; i++) { scopes[i] = Enum.valueOf(AwardTemplateSyncScope.class, scopeStrings[i]); } awardForm.setSyncRequiresConfirmationMap( generateScopeRequiresConfirmationMap(scopes, awardDocument, false, false)); awardForm.setCurrentSyncScopes(scopes); } else { awardForm.setSyncRequiresConfirmationMap(generateScopeRequiresConfirmationMap( DEFAULT_AWARD_TEMPLATE_SYNC_SCOPES, awardDocument, false, false)); awardForm.setCurrentSyncScopes(DEFAULT_AWARD_TEMPLATE_SYNC_SCOPES); } return processSyncAward(mapping, form, request, response); }
From source file:org.lazulite.boot.autoconfigure.core.utils.excel.ImportExcel.java
/** * ??/*from w ww .java 2 s. c om*/ * * @param cls * @param groups */ public <E> List<E> getDataList(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException { List<Object[]> annotationList = Lists.newArrayList(); // Get annotation field Field[] fs = cls.getDeclaredFields(); for (Field f : fs) { ExcelField ef = f.getAnnotation(ExcelField.class); if (ef != null && (ef.type() == 0 || ef.type() == 2)) { if (groups != null && groups.length > 0) { boolean inGroup = false; for (int g : groups) { if (inGroup) { break; } for (int efg : ef.groups()) { if (g == efg) { inGroup = true; annotationList.add(new Object[] { ef, f }); break; } } } } else { annotationList.add(new Object[] { ef, f }); } } } // Get annotation method Method[] ms = cls.getDeclaredMethods(); for (Method m : ms) { ExcelField ef = m.getAnnotation(ExcelField.class); if (ef != null && (ef.type() == 0 || ef.type() == 2)) { if (groups != null && groups.length > 0) { boolean inGroup = false; for (int g : groups) { if (inGroup) { break; } for (int efg : ef.groups()) { if (g == efg) { inGroup = true; annotationList.add(new Object[] { ef, m }); break; } } } } else { annotationList.add(new Object[] { ef, m }); } } } // Field sorting Collections.sort(annotationList, new Comparator<Object[]>() { public int compare(Object[] o1, Object[] o2) { return new Integer(((ExcelField) o1[0]).sort()).compareTo(new Integer(((ExcelField) o2[0]).sort())); } ; }); //log.debug("Import column count:"+annotationList.size()); // Get excel data List<E> dataList = Lists.newArrayList(); for (int i = this.getDataRowNum(); i < this.getLastDataRowNum(); i++) { E e = (E) cls.newInstance(); int column = 0; Row row = this.getRow(i); StringBuilder sb = new StringBuilder(); for (Object[] os : annotationList) { Object val = this.getCellValue(row, column++); if (val != null) { ExcelField ef = (ExcelField) os[0]; // Get param type and type cast Class<?> valType = Class.class; if (os[1] instanceof Field) { valType = ((Field) os[1]).getType(); } else if (os[1] instanceof Method) { Method method = ((Method) os[1]); if ("get".equals(method.getName().substring(0, 3))) { valType = method.getReturnType(); } else if ("set".equals(method.getName().substring(0, 3))) { valType = ((Method) os[1]).getParameterTypes()[0]; } } //log.debug("Import value type: ["+i+","+column+"] " + valType); try { if (valType == String.class) { String s = String.valueOf(val.toString()); if (StringUtils.endsWith(s, ".0")) { val = StringUtils.substringBefore(s, ".0"); } else { val = String.valueOf(val.toString()); } } else if (valType == Integer.class) { val = Double.valueOf(val.toString()).intValue(); } else if (valType == Long.class) { val = Double.valueOf(val.toString()).longValue(); } else if (valType == Double.class) { val = Double.valueOf(val.toString()); } else if (valType == Float.class) { val = Float.valueOf(val.toString()); } else if (valType == Date.class) { val = DateUtil.getJavaDate((Double) val); } else { if (ef.fieldType() != Class.class) { val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString()); } else { val = Class .forName(this.getClass().getName().replaceAll( this.getClass().getSimpleName(), "fieldtype." + valType.getSimpleName() + "Type")) .getMethod("getValue", String.class).invoke(null, val.toString()); } } } catch (Exception ex) { log.info("Get cell value [" + i + "," + column + "] error: " + ex.toString()); val = null; } // set entity value if (os[1] instanceof Field) { ReflectUtils.invokeSetter(e, ((Field) os[1]).getName(), val); } else if (os[1] instanceof Method) { String mthodName = ((Method) os[1]).getName(); if ("get".equals(mthodName.substring(0, 3))) { mthodName = "set" + StringUtils.substringAfter(mthodName, "get"); } ReflectUtils.invokeMethod(e, mthodName, new Class[] { valType }, new Object[] { val }); } } sb.append(val + ", "); } dataList.add(e); log.debug("Read success: [" + i + "] " + sb.toString()); } return dataList; }
From source file:org.lazydog.jdnsaas.utility.RecordFilter.java
/** * Does the value match the search string? * //ww w . j ava2 s . co m * @param value the value. * * @return true if the value matches, otherwise false. */ private boolean matchString(final String value) { boolean match = true; String[] searchTokens = StringUtils.split(this.searchString, SEARCH_STRING_WILDCARD); String stringValue = value; for (String searchToken : searchTokens) { if (StringUtils.indexOfIgnoreCase(stringValue, searchToken) != -1) { stringValue = StringUtils.substringAfter(stringValue, searchToken); } else { match = false; break; } } return match; }