List of usage examples for org.apache.commons.lang StringUtils isNumeric
public static boolean isNumeric(String str)
Checks if the String contains only unicode digits.
From source file:gov.nih.nci.cabig.caaers.web.ae.EditAdverseEventController.java
/** * This method will do the following, make the command to be in a consistent state. * /*w w w .j a v a 2 s .c om*/ * If from Review Report page? * 1.- If this is a new data collection: * 1.1. Create Expedited Report, associate it with Reporting period. * 1.2. Initialize the Treatment information * 1.3. Initialize the reporter. * 2. Add/Remove adverse events. * 3. Find the mandatory sections. * 4. Pre-initialize the mandatory section fields. * * If from Manage reports page? * 1. Find the mandatory sections * 2. Refresh/Initialize the Not applicable and mandatory fields. * */ @Override protected void onBindOnNewForm(HttpServletRequest request, Object cmd) throws Exception { super.onBindOnNewForm(request, cmd); HttpSession session = request.getSession(); String screenFlowSource = request.getParameter("from"); EditExpeditedAdverseEventCommand command = (EditExpeditedAdverseEventCommand) cmd; command.setScreenFlowSource(screenFlowSource); command.getNewlySelectedReportDefinitions().clear(); command.getSelectedReportDefinitions().clear(); command.getApplicableReportDefinitions().clear(); ReviewAndReportResult reviewResult = (ReviewAndReportResult) session.getAttribute("reviewResult"); ExpeditedAdverseEventReport aeReport = command.getAeReport(); if ((reviewResult != null) && StringUtils.equals("captureAE", screenFlowSource)) { //If a new data collection? if (reviewResult.getAeReportId() == 0) { //create expedited report. aeReport = new ExpeditedAdverseEventReport(); aeReport.setCreatedAt(nowFactory.getNowTimestamp()); command.setAeReport(aeReport); //populate the reporting period. AdverseEventReportingPeriod adverseEventReportingPeriod = adverseEventReportingPeriodDao .getById(reviewResult.getReportingPeriodId()); command.getAeReport().setReportingPeriod(adverseEventReportingPeriod); command.getAeReport().synchronizeMedicalHistoryFromAssignmentToReport(); //initialize treatment information command.initializeTreatmentInformation(); //set the default reporter as the logged-in person String loginId = SecurityUtils.getUserLoginName(); if (loginId != null) { Person loggedInPerson = getPersonRepository().getByLoginId(loginId); command.getAeReport().getReporter().copy(loggedInPerson); if (loggedInPerson == null) { User loggedInUser = getUserRepository().getUserByLoginName(loginId); command.getAeReport().getReporter().copy(loggedInUser); } } } //Add all the aes to be added for (Integer aeId : reviewResult.getAeList()) { AdverseEvent ae = command.getAdverseEventReportingPeriod().findAdverseEventById(aeId); if (aeReport.findAdverseEventById(aeId) == null) { aeReport.addAdverseEvent(ae); } } //remove all the aes to be removed for (Integer aeId : reviewResult.getUnwantedAEList()) { AdverseEvent ae = aeReport.findAdverseEventById(aeId); if (ae != null && aeReport.getAdverseEvents().remove(ae)) { ae.clearAttributions(); ae.setReport(null); } } //modify the primary ae if necessary command.makeAdverseEventPrimary(reviewResult.getPrimaryAdverseEventId()); //reload- the report definitions (from create & edit list) for (ReportDefinition rd : reviewResult.getCreateList()) { ReportDefinition loaded = reportDefinitionDao.getById(rd.getId()); reportDefinitionDao.initialize(loaded); command.getSelectedReportDefinitions().add(loaded); command.getNewlySelectedReportDefinitions().add(loaded); } for (ReportDefinition rd : reviewResult.getEditList()) { ReportDefinition loaded = reportDefinitionDao.getById(rd.getId()); command.getSelectedReportDefinitions().add(loaded); } //update the applicable report definitions. command.getApplicableReportDefinitions().addAll(command.getSelectedReportDefinitions()); } else { //from manage reports / review and reports, so do cleanup of session attributes explicitly session.removeAttribute("reviewResult"); String action = request.getParameter(ACTION_PARAMETER); String strReportId = request.getParameter("report"); int reportId = -999; if (StringUtils.isNumeric(strReportId)) { reportId = Integer.parseInt(strReportId); } //find the report. Report selectedReport = aeReport.findReportById(reportId); if (selectedReport != null) { command.getSelectedReportDefinitions().add(selectedReport.getReportDefinition()); if (!selectedReport.isActive()) { //if selected report is not active, add it into applicable reports command.getApplicableReportDefinitions().add(selectedReport.getReportDefinition()); } for (Report report : aeReport.getActiveReports()) { if (!command.getApplicableReportDefinitions().contains(report.getReportDefinition())) command.getApplicableReportDefinitions().add(report.getReportDefinition()); } //pre initialize all the report mandatory fields. for (ReportDefinition reportDefinition : command.getApplicableReportDefinitions()) { reportDefinition.getMandatoryFields().size(); ; } //if action is amend, keep a mock reviewResult in session. if (StringUtils.equals(action, "amendReport") && selectedReport.isSubmitted()) { command.getNewlySelectedReportDefinitions().add(selectedReport.getReportDefinition()); reviewResult = new ReviewAndReportResult(); reviewResult.getAmendList().add(selectedReport.getReportDefinition()); reviewResult.getReportsToAmmendList().add(selectedReport); reviewResult.getCreateList().add(selectedReport.getReportDefinition()); session.setAttribute("reviewResult", reviewResult); } } } //synchronize the outcomes command.updateOutcomes(); //find the mandatory sections. command.refreshMandatorySections(); if (aeReport.getId() == null) { //present status. for (AdverseEvent ae : aeReport.getAdverseEvents()) { if (ae.getGrade() == null) continue; if (ae.getGrade().equals(Grade.DEATH)) { aeReport.getResponseDescription().setPresentStatus(PostAdverseEventStatus.DEAD); break; } } } // pre-init the mandatory section fields & set present status if (!command.getNewlySelectedReportDefinitions().isEmpty() || command.getAeReport().isActive()) { command.initializeMandatorySectionFields(); } //will pre determine the display/render-ability of fields command.updateFieldMandatoryness(); //CAAERS-5865, if study is not CTEP-ESYS study, set outOfSync flag as false, //so syncing process will not be triggered if (command.getAeReport().getStudy().getCtepEsysIdentifier() == null) { command.setStudyOutOfSync(false); } }
From source file:fr.paris.lutece.plugins.workflow.modules.mappings.web.CodeMappingJspBean.java
/** * Get confirm remove code mapping// ww w . j a v a 2 s.co m * @param request the HTTP request * @return the HTML code */ public String getConfirmRemoveCodeMapping(HttpServletRequest request) { String strIdCode = request.getParameter(PARAMETER_ID_CODE); if (StringUtils.isBlank(strIdCode) || !StringUtils.isNumeric(strIdCode)) { return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } UrlItem url = new UrlItem(JSP_URL_DO_REMOVE_CODE_MAPPING); url.addParameter(PARAMETER_ID_CODE, strIdCode); return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_REMOVE_CODE_MAPPING, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); }
From source file:com.cubusmail.mail.util.MessageUtils.java
/** * /*from w w w. j a va2 s . c o m*/ * * @param msg * @return */ public static int getMessagePriority(Message msg) { int prio = CubusConstants.PRIORITY_NONE; try { String header[] = msg.getHeader(CubusConstants.FETCH_ITEM_PRIORITY); if (header != null && header.length > 0 && header[0].length() > 0) { String first = header[0].substring(0, 1); if (StringUtils.isNumeric(first)) { return Integer.parseInt(first); } } } catch (MessagingException e) { log.error(e.getMessage(), e); } return prio; }
From source file:com.prowidesoftware.swift.model.field.SwiftParseUtils.java
/** * Returns the alphabetic starting substring of the value. * The split is made when the first numeric character is found. * For example:<br />/* w ww .j a v a 2s. com*/ * ABCD2345,33 will be return ABCD<br /> * If the value does not contain any alphabetic character <code>null</code> is returned. * * @param value * @return s */ public static String getAlphaPrefix(final String value) { if (value != null && value.length() > 0) { int i = 0; while (i < value.length() && !StringUtils.isNumeric("" + value.charAt(i))) { i++; } if (i > 0) { return StringUtils.substring(value, 0, i); } } return null; }
From source file:fi.okm.mpass.shibboleth.attribute.resolver.dc.impl.RestDataConnector.java
/** * Populates the attributes from the given user object to the given result map. * /*from www.j a v a2 s .co m*/ * @param attributes The result map of attributes. * @param ecaUser The source user object. */ protected void populateAttributes(final Map<String, IdPAttribute> attributes, UserDTO ecaUser) { populateAttribute(attributes, ATTR_ID_USERNAME, ecaUser.getUsername()); populateAttribute(attributes, ATTR_ID_FIRSTNAME, ecaUser.getFirstName()); populateAttribute(attributes, ATTR_ID_SURNAME, ecaUser.getLastName()); if (ecaUser.getRoles() != null) { for (int i = 0; i < ecaUser.getRoles().length; i++) { final String rawSchool = ecaUser.getRoles()[i].getSchool(); final String mappedSchool = getSchoolName(getHttpClientBuilder(), rawSchool, nameApiBaseUrl); if (mappedSchool == null) { if (StringUtils.isNumeric(rawSchool)) { populateAttribute(attributes, ATTR_ID_SCHOOL_IDS, rawSchool); populateStructuredRole(attributes, "", rawSchool, ecaUser.getRoles()[i]); } else { populateAttribute(attributes, ATTR_ID_SCHOOLS, rawSchool); populateStructuredRole(attributes, rawSchool, "", ecaUser.getRoles()[i]); } } else { populateAttribute(attributes, ATTR_ID_SCHOOLS, mappedSchool); populateAttribute(attributes, ATTR_ID_SCHOOL_IDS, rawSchool); populateStructuredRole(attributes, mappedSchool, rawSchool, ecaUser.getRoles()[i]); } populateAttribute(attributes, ATTR_ID_GROUPS, ecaUser.getRoles()[i].getGroup()); populateAttribute(attributes, ATTR_ID_ROLES, ecaUser.getRoles()[i].getRole()); populateAttribute(attributes, ATTR_ID_MUNICIPALITIES, ecaUser.getRoles()[i].getMunicipality()); } } if (ecaUser.getAttributes() != null) { for (int i = 0; i < ecaUser.getAttributes().length; i++) { final AttributesDTO attribute = ecaUser.getAttributes()[i]; populateAttribute(attributes, ATTR_PREFIX + attribute.getName(), attribute.getValue()); } } }
From source file:com.gst.infrastructure.core.serialization.DatatableCommandFromApiJsonDeserializer.java
public void validateForUpdate(final String json) { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }/*from w w w . ja v a 2 s . c om*/ // Because all parameters are optional, a check to see if at least one // parameter // has been specified is necessary in order to avoid JSON requests with // no parameters if (!json.matches("(?s)\\A\\{.*?(\\\".*?\\\"\\s*?:\\s*?)+.*?\\}\\z")) { throw new PlatformDataIntegrityException("error.msg.invalid.request.body.no.parameters", "Provided JSON request body does not have any parameters."); } final Type typeOfMap = new TypeToken<Map<String, Object>>() { }.getType(); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParametersForUpdate); final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) .resource("datatable"); final JsonElement element = this.fromApiJsonHelper.parse(json); final String apptableName = this.fromApiJsonHelper.extractStringNamed("apptableName", element); baseDataValidator.reset().parameter("apptableName").value(apptableName).ignoreIfNull().notBlank() .isOneOfTheseValues(this.supportedApptableNames); final String fkColumnName = (apptableName != null) ? apptableName.substring(2) + "_id" : ""; final JsonArray changeColumns = this.fromApiJsonHelper.extractJsonArrayNamed("changeColumns", element); baseDataValidator.reset().parameter("changeColumns").value(changeColumns).ignoreIfNull() .jsonArrayNotEmpty(); if (changeColumns != null) { for (final JsonElement column : changeColumns) { this.fromApiJsonHelper.checkForUnsupportedParameters(column.getAsJsonObject(), this.supportedParametersForChangeColumns); final String name = this.fromApiJsonHelper.extractStringNamed("name", column); baseDataValidator.reset().parameter("name").value(name).notBlank() .isNotOneOfTheseValues("id", fkColumnName) .matchesRegularExpression(DATATABLE_COLUMN_NAME_REGEX_PATTERN); final String newName = this.fromApiJsonHelper.extractStringNamed("newName", column); baseDataValidator.reset().parameter("newName").value(newName).ignoreIfNull().notBlank() .notExceedingLengthOf(50).isNotOneOfTheseValues("id", fkColumnName) .matchesRegularExpression(DATATABLE_NAME_REGEX_PATTERN); if (this.fromApiJsonHelper.parameterExists("length", column)) { final String lengthStr = this.fromApiJsonHelper.extractStringNamed("length", column); if (StringUtils.isWhitespace(lengthStr) || !StringUtils.isNumeric(lengthStr) || StringUtils.isBlank(lengthStr)) { baseDataValidator.reset().parameter("length").failWithCode("not.greater.than.zero"); } else { final Integer length = Integer.parseInt(lengthStr); baseDataValidator.reset().parameter("length").value(length).ignoreIfNull().notBlank() .positiveAmount(); } } final String code = this.fromApiJsonHelper.extractStringNamed("code", column); baseDataValidator.reset().parameter("code").value(code).ignoreIfNull().notBlank() .notExceedingLengthOf(100).matchesRegularExpression(DATATABLE_COLUMN_NAME_REGEX_PATTERN); final String newCode = this.fromApiJsonHelper.extractStringNamed("newCode", column); baseDataValidator.reset().parameter("newCode").value(newCode).ignoreIfNull().notBlank() .notExceedingLengthOf(100).matchesRegularExpression(DATATABLE_COLUMN_NAME_REGEX_PATTERN); if (StringUtils.isBlank(code) && StringUtils.isNotBlank(newCode)) { baseDataValidator.reset().parameter("code").value(code) .cantBeBlankWhenParameterProvidedIs("newCode", newCode); } final Boolean mandatory = this.fromApiJsonHelper.extractBooleanNamed("mandatory", column); baseDataValidator.reset().parameter("mandatory").value(mandatory).ignoreIfNull().notBlank() .isOneOfTheseValues(true, false); final Boolean after = this.fromApiJsonHelper.extractBooleanNamed("after", column); baseDataValidator.reset().parameter("after").value(after).ignoreIfNull().notBlank() .isOneOfTheseValues(true, false); } } final JsonArray addColumns = this.fromApiJsonHelper.extractJsonArrayNamed("addColumns", element); baseDataValidator.reset().parameter("addColumns").value(addColumns).ignoreIfNull().jsonArrayNotEmpty(); if (addColumns != null) { for (final JsonElement column : addColumns) { this.fromApiJsonHelper.checkForUnsupportedParameters(column.getAsJsonObject(), this.supportedParametersForAddColumns); final String name = this.fromApiJsonHelper.extractStringNamed("name", column); baseDataValidator.reset().parameter("name").value(name).notBlank() .isNotOneOfTheseValues("id", fkColumnName) .matchesRegularExpression(DATATABLE_COLUMN_NAME_REGEX_PATTERN); validateType(baseDataValidator, column); final Boolean mandatory = this.fromApiJsonHelper.extractBooleanNamed("mandatory", column); baseDataValidator.reset().parameter("mandatory").value(mandatory).ignoreIfNull().notBlank() .isOneOfTheseValues(true, false); final Boolean after = this.fromApiJsonHelper.extractBooleanNamed("after", column); baseDataValidator.reset().parameter("after").value(after).ignoreIfNull().notBlank() .isOneOfTheseValues(true, false); } } final JsonArray dropColumns = this.fromApiJsonHelper.extractJsonArrayNamed("dropColumns", element); baseDataValidator.reset().parameter("dropColumns").value(dropColumns).ignoreIfNull().jsonArrayNotEmpty(); if (dropColumns != null) { for (final JsonElement column : dropColumns) { this.fromApiJsonHelper.checkForUnsupportedParameters(column.getAsJsonObject(), this.supportedParametersForDropColumns); final String name = this.fromApiJsonHelper.extractStringNamed("name", column); baseDataValidator.reset().parameter("name").value(name).notBlank() .isNotOneOfTheseValues("id", fkColumnName) .matchesRegularExpression(DATATABLE_COLUMN_NAME_REGEX_PATTERN); } } throwExceptionIfValidationWarningsExist(dataValidationErrors); }
From source file:hydrograph.ui.engine.converter.Converter.java
/** * Converts the String to {@link BigInteger} * @param propertyName/* ww w . java 2s.com*/ * @param nameOfFeild * @param fieldKey * @return */ public BigInteger getDBAdditionalParamValue(String propertyName, String nameOfField, String fieldKey) { Map<String, String> propertyValue = (Map<String, String>) properties.get(propertyName); if (StringUtils.isNotBlank(propertyValue.get(nameOfField)) && StringUtils.isNumeric(propertyValue.get(nameOfField))) { BigInteger bigInteger = new BigInteger(String.valueOf(propertyValue.get(nameOfField))); return bigInteger; } else if (ParameterUtil.isParameter(propertyValue.get(nameOfField))) { ComponentXpath.INSTANCE.getXpathMap() .put((ComponentXpathConstants.COMPONENT_XPATH_BOOLEAN.value().replace(ID, component.getComponentId())).replace(Constants.PARAM_PROPERTY_NAME, fieldKey), new ComponentsAttributeAndValue(null, propertyValue.get(nameOfField))); return null; } return null; }
From source file:com.redhat.rhn.common.util.RecurringEventPicker.java
/** * Get the hour of the day// w ww . j a va2 s. c o m * @return the hour */ public Long getHourLong() { String st = getCronValue(2); if (StringUtils.isNumeric(st)) { return Long.parseLong(st); } return -1L; }
From source file:fr.paris.lutece.plugins.crm.web.demand.DemandTypeJspBean.java
/** * Handles the removal form of a demand type * @param request The Http request//from w w w . java 2s . c om * @return the jsp URL to display the form to manage demand types */ public String doRemoveDemandType(HttpServletRequest request) { String strUrl = StringUtils.EMPTY; String strIdDemandType = request.getParameter(CRMConstants.PARAMETER_ID_DEMAND_TYPE); if (StringUtils.isNotBlank(strIdDemandType) && StringUtils.isNumeric(strIdDemandType)) { int nIdDemandType = Integer.parseInt(strIdDemandType); _demandTypeService.remove(nIdDemandType); strUrl = getUrlManageDemandTypes(request).getUrl(); } else { strUrl = AdminMessageService.getMessageUrl(request, CRMConstants.MESSAGE_ERROR, AdminMessage.TYPE_STOP); } return strUrl; }
From source file:edu.msViz.mzTree.MzTree.java
/** * Loads MS data in csv format (mz, rt, intensity, meta1) * @param filePath path to csv file/*from w w w . ja v a 2s. c o m*/ * @throws FileNotFoundException * @throws IOException * @throws Exception */ private void csvLoad(String filePath) throws FileNotFoundException, IOException, Exception { this.importState.setImportStatus(ImportStatus.PARSING); ArrayList<MsDataPoint> points = new ArrayList<>(); // open csv reader on targetted csv file CSVReader reader = new CSVReader(new FileReader(filePath)); // first line might be a header String[] line = reader.readNext(); // if the first line is not a header if (line != null && StringUtils.isNumeric(line[0])) { // convert to msdatapoint, collect MsDataPoint point = this.csvRowToMsDataPoint(line); points.add(point); } // read the remaining lines (now guaranteed no header) while ((line = reader.readNext()) != null) { // convert to msdatapoint, collect MsDataPoint point = this.csvRowToMsDataPoint(line); points.add(point); } // build that tree! this.buildTreeFromRoot(points, Paths.get(filePath)); }