Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8a0acb2ba0ae
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 62b8bf838403
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Mar 8, 2014

  1. TRUNK-4166: Added check in BaseAttributeTypeValidator to prevent Data…

    …typeConfiguration to be blank if Datatype is equal to Regex-Validated Text
    LukasBreitwieser committed Mar 8, 2014
    Copy the full SHA
    9fd7cf1 View commit details
  2. Copy the full SHA
    334724a View commit details

Commits on Mar 20, 2014

  1. Merge pull request #725 from lbat/TRUNK-4166

    TRUNK-4166: Added check in BaseAttributeTypeValidator to prevent Datatyp...
    dkayiwa committed Mar 20, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    62b8bf8 View commit details
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import org.openmrs.customdatatype.CustomDatatype;
import org.openmrs.customdatatype.CustomDatatypeHandler;
import org.openmrs.customdatatype.CustomDatatypeUtil;
import org.openmrs.customdatatype.datatype.RegexValidatedTextDatatype;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
@@ -75,7 +76,11 @@ public void validate(Object target, Errors errors) {
errors.rejectValue("datatypeClassname", "error.null");
} else {
try {
CustomDatatypeUtil.getDatatype(attributeType);
CustomDatatype<?> datatype = CustomDatatypeUtil.getDatatype(attributeType);
if (datatype instanceof RegexValidatedTextDatatype
&& StringUtils.isBlank(attributeType.getDatatypeConfig())) {
errors.rejectValue("datatypeConfig", "error.null");
}
}
catch (Exception ex) {
errors.rejectValue("datatypeConfig", "AttributeType.datatypeConfig.invalid", new Object[] { ex
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.junit.Test;
import org.openmrs.VisitAttributeType;
import org.openmrs.attribute.AttributeType;
import org.openmrs.customdatatype.datatype.RegexValidatedTextDatatype;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;

@@ -77,4 +78,16 @@ public void validate_shouldRequireName() throws Exception {
validator.validate(attributeType, errors);
Assert.assertTrue(errors.getFieldErrors("name").size() > 0);
}

/**
* @see BaseAttributeTypeValidator#validate(Object,Errors)
* @verifies require DatatypeConfiguration if Datatype equals
* Regex-Validated Text
*/
@Test
public void validate_shouldRequireDatatypeConfigurationIfDatatypeRegexValidatedText() throws Exception {
attributeType.setDatatypeClassname(RegexValidatedTextDatatype.class.getName());
validator.validate(attributeType, errors);
Assert.assertTrue(errors.getFieldErrors("datatypeConfig").size() > 0);
}
}