Fix to DateTimeIntervalValidation.java NIHVIVO-1847

This commit is contained in:
bdc34 2011-01-21 23:03:00 +00:00
parent 1b2f34eadc
commit 4cfd4bc706

View file

@ -52,6 +52,11 @@ public class DateTimeIntervalValidation implements N3Validator {
Map<String, String> errors = new HashMap<String, String>(); Map<String, String> errors = new HashMap<String, String>();
if( formStartYear == null && formEndYear != null ){
errors.put(startFieldName, "If there is an end date, there should be a start date");
return errors;
}
if (formStartYear != null && formEndYear != null) { if (formStartYear != null && formEndYear != null) {
errors.putAll(checkDateLiterals(formStartYear, formEndYear, startPrecision, endPrecision)); errors.putAll(checkDateLiterals(formStartYear, formEndYear, startPrecision, endPrecision));
} else if (formStartYear != null && existingEndYear != null) { } else if (formStartYear != null && existingEndYear != null) {
@ -98,14 +103,10 @@ public class DateTimeIntervalValidation implements N3Validator {
VitroVocabulary.Precision startPrecision, VitroVocabulary.Precision endPrecision) { VitroVocabulary.Precision startPrecision, VitroVocabulary.Precision endPrecision) {
Map<String, String> errors = new HashMap<String, String>(); Map<String, String> errors = new HashMap<String, String>();
//check to make sure that there are precisions if( endPrecision == null ){
if( startPrecision == null ) //there is no end date, nothing to check
errors.put("startFieldName", "could not determine start precision");
if( endPrecision == null )
errors.put("endFieldName" , "could not determine end precision");
if( errors.size() > 0 )
return errors; return errors;
}
try{ try{
XSDDateTime startDate = (XSDDateTime)startLit.getValue(); XSDDateTime startDate = (XSDDateTime)startLit.getValue();