List of usage examples for org.apache.commons.validator GenericValidator isBlankOrNull
public static boolean isBlankOrNull(String value)
Checks if the field isn't null and length of the field is greater than zero not including whitespace.
From source file:net.weweave.tubewarder.service.rest.CheckLicenseKeyService.java
private void validateInputParameters(AbstractIdRestRequest request) throws InvalidInputParametersException { if (GenericValidator.isBlankOrNull(request.id)) { throw new InvalidInputParametersException("id", ErrorCode.FIELD_REQUIRED); }/* w w w . j a v a 2 s .co m*/ }
From source file:net.weweave.tubewarder.util.LicenseManager.java
public void checkAllStoredKeys() { boolean licensed = true; boolean hasAnyKey = false; for (int i = 1; i <= 4; i++) { String licenseKey = getConfigItemDao().getString("LICENSE_KEY_" + i, ""); if (!GenericValidator.isBlankOrNull(licenseKey)) { licensed = licensed && isLicensed(licenseKey); hasAnyKey = true;// w w w . j a v a2 s. c o m } } this.licensed = hasAnyKey && licensed; }
From source file:oe.plugin.analyzer.SysmeXTImplementation.java
private void addAnalyzerResultFromLine(List<AnalyzerResults> results, String line) { String[] fields = line.split(DELIMITER); AnalyzerReaderUtil readerUtil = new AnalyzerReaderUtil(); String analyzerAccessionNumber = fields[ID_PATIENT]; //Timestamp timestamp = DateUtil.convertStringDateToTimestampWithPattern(fields[DATE] + " " + fields[TIME], DATE_PATTERN); Timestamp timestamp = DateUtil.convertStringDateToTimestampWithPattern(fields[DATE] + " " + fields[TIME], DATE_PATTERN);/* w ww . ja va 2 s . c om*/ List<AnalyzerResults> readOnlyResults = new ArrayList<AnalyzerResults>(); //the reason for the indirection is to get the order of tests correct for (int i = 0; i < orderedTestIndexs.length; i++) { int testIndex = orderedTestIndexs[i]; if (!GenericValidator.isBlankOrNull(testNameIndex[testIndex])) { MappedTestName mappedName = AnalyzerTestNameCache.instance().getMappedTest("SysmeXT", testNameIndex[testIndex]); if (mappedName == null) { mappedName = AnalyzerTestNameCache.instance().getEmptyMappedTestName("SysmeXT", testNameIndex[testIndex]); } AnalyzerResults analyzerResults = new AnalyzerResults(); analyzerResults.setAnalyzerId(mappedName.getAnalyzerId()); double result = Double.NaN; try { result = Double.parseDouble(fields[testIndex]) / scaleIndex[testIndex]; } catch (NumberFormatException nfe) { //no-op -- defaults to NAN } analyzerResults.setResult(String.valueOf(result)); analyzerResults.setUnits(unitsIndex[testIndex]); analyzerResults.setCompleteDate(timestamp); analyzerResults.setTestId(mappedName.getTestId()); analyzerResults.setAccessionNumber(analyzerAccessionNumber); analyzerResults.setTestName(mappedName.getOpenElisTestName()); analyzerResults.setReadOnly(readOnlyIndex[testIndex]); if (analyzerAccessionNumber != null) { analyzerResults.setIsControl(analyzerAccessionNumber.startsWith(CONTROL_ACCESSION_PREFIX)); } else { analyzerResults.setIsControl(false); } if (analyzerResults.isReadOnly()) { readOnlyResults.add(analyzerResults); } else { results.add(analyzerResults); } AnalyzerResults resultFromDB = readerUtil.createAnalyzerResultFromDB(analyzerResults); if (resultFromDB != null) { results.add(resultFromDB); } } } results.addAll(readOnlyResults); }
From source file:org.agnitas.service.csv.validator.FieldsValidator.java
/** * Checks if the field is mandatory./* w w w .j a va 2 s .co m*/ * * @return boolean If the field isn't <code>null</code> and * has a length greater than zero, <code>true</code> is returned. * Otherwise <code>false</code>. */ public static boolean validateMandatoryField(Object bean, Field field, Validator validator) { String value = getValueAsString(bean, field); final ImportProfile profile = (ImportProfile) validator .getParameterValue("org.agnitas.beans.ImportProfile"); final ColumnMapping currentColumn = getColumnMappingForCurentField(field, profile); return !(currentColumn != null && currentColumn.getMandatory()) || !GenericValidator.isBlankOrNull(value); }
From source file:org.agnitas.service.csv.validator.FieldsValidator.java
/** * Checks if the field is an e-mail address. * * @param value The value validation is being performed on. * @return boolean If the field is an e-mail address * <code>true</code> is returned. * Otherwise <code>false</code>. *//* w w w. j a v a2 s. c om*/ public static boolean validateEmail(Object bean, Field field, Validator validator) { String value = getValueAsString(bean, field); final ImportProfile profile = (ImportProfile) validator .getParameterValue("org.agnitas.beans.ImportProfile"); final ColumnMapping currentColumn = getColumnMappingForCurentField(field, profile); if (currentColumn != null && currentColumn.getMandatory()) { return !GenericValidator.isBlankOrNull(value) && GenericValidator.isEmail(value); } else { return currentColumn == null || GenericValidator.isEmail(value); } }
From source file:org.agnitas.service.csv.validator.FieldsValidator.java
/** * Checks if the field is an e-mail address. * * @param value The value validation is being performed on. * @return boolean If the field is an e-mail address * <code>true</code> is returned. * Otherwise <code>false</code>. *//*from ww w .j a va2 s . c o m*/ public static boolean validateGender(Object bean, Field field, Validator validator) { String value = getValueAsString(bean, field); final ImportProfile profile = (ImportProfile) validator .getParameterValue("org.agnitas.beans.ImportProfile"); Integer maxGenderValue = (Integer) validator.getParameterValue("java.lang.Integer"); if (maxGenderValue == null || maxGenderValue == 0) { maxGenderValue = NewImportWizardService.MAX_GENDER_VALUE_BASIC; } final ColumnMapping currentColumn = getColumnMappingForCurentField(field, profile); if (currentColumn != null && currentColumn.getMandatory()) { return !GenericValidator.isBlankOrNull(value) && genderMappingValidation(value, profile, maxGenderValue); } else { return currentColumn == null || genderMappingValidation(value, profile, maxGenderValue); } }
From source file:org.agnitas.service.csv.validator.FieldsValidator.java
/** * Checks if the field can be successfully converted to a <code>int</code>. * * @param value The value validation is being performed on. * @return boolean If the field can be successfully converted * to a <code>int</code> <code>true</code> is returned. * Otherwise <code>false</code>. *//*from w w w . j a v a 2s. co m*/ public static boolean validateInt(Object bean, Field field, Validator validator) { String value = getValueAsString(bean, field); final ImportProfile profile = (ImportProfile) validator .getParameterValue("org.agnitas.beans.ImportProfile"); final ColumnMapping currentColumn = getColumnMappingForCurentField(field, profile); if (currentColumn != null && currentColumn.getMandatory()) { return !GenericValidator.isBlankOrNull(value) && GenericValidator.isInt(value); } else { return currentColumn == null || GenericValidator.isInt(value); } }
From source file:org.agnitas.service.csv.validator.FieldsValidator.java
/** * Checks if the field can be successfully converted to a <code>int</code>. * * @param value The value validation is being performed on. * @return boolean If the field can be successfully converted * to a <code>int</code> <code>true</code> is returned. * Otherwise <code>false</code>. *//*from w w w. j a va 2 s. c o m*/ public static boolean validateMailType(Object bean, Field field, Validator validator) { String value = getValueAsString(bean, field); final ImportProfile profile = (ImportProfile) validator .getParameterValue("org.agnitas.beans.ImportProfile"); final ColumnMapping currentColumn = getColumnMappingForCurentField(field, profile); if (currentColumn != null && currentColumn.getMandatory()) { return !GenericValidator.isBlankOrNull(value) && isValidMailTypeValue(value); } else { return currentColumn == null || isValidMailTypeValue(value); } }
From source file:org.agnitas.service.csv.validator.FieldsValidator.java
public static boolean checkRange(Object bean, Field field, Validator validator) { final String value = getValueAsString(bean, field); final ImportProfile profile = (ImportProfile) validator .getParameterValue("org.agnitas.beans.ImportProfile"); final ColumnMapping currentColumn = getColumnMappingForCurentField(field, profile); final Integer length = Integer.valueOf(field.getVarValue("maxLength")); if (currentColumn != null && currentColumn.getMandatory()) { return !GenericValidator.isBlankOrNull(value) && checkMaxStringLength(value, length); } else {/* www .j ava 2 s . com*/ return currentColumn == null || checkMaxStringLength(value, length); } }
From source file:org.agnitas.service.csv.validator.FieldsValidator.java
/** * Checks if the field can be successfully converted to a <code>double</code>. * * @param value The value validation is being performed on. * @return boolean If the field can be successfully converted * to a <code>double</code> <code>true</code> is returned. * Otherwise <code>false</code>. *///from ww w . j a va 2s . c o m public static boolean validateDouble(Object bean, Field field, Validator validator) { String value = getValueAsString(bean, field); final ImportProfile profile = (ImportProfile) validator .getParameterValue("org.agnitas.beans.ImportProfile"); final ColumnMapping currentColumn = getColumnMappingForCurentField(field, profile); if (currentColumn != null && currentColumn.getMandatory()) { return !GenericValidator.isBlankOrNull(value) && GenericValidator.isDouble(value); } else { return currentColumn == null || GenericValidator.isDouble(value); } }