Fixing addRoleToPersonTwoStage so that it can remove an end date of a date time interval. NIHVIVO-1656

This commit is contained in:
bdc34 2011-01-11 23:12:02 +00:00
parent 9a344cfc89
commit b52832208d
2 changed files with 21 additions and 6 deletions

View file

@ -65,6 +65,8 @@ public class DateTimeWithPrecision extends BaseEditElement {
VitroVocabulary.Precision DEFAULT_DISPLAY_LEVEL = VitroVocabulary.Precision.DAY;
VitroVocabulary.Precision[] precisions = VitroVocabulary.Precision.values();
protected static final String BLANK_SENTINEL = ">SUBMITTED VALUE WAS BLANK<";
public DateTimeWithPrecision(Field field) {
super(field);
fieldName = field.getName();
@ -248,6 +250,16 @@ public class DateTimeWithPrecision extends BaseEditElement {
}
protected Literal getDateTime( Map<String, String[]> queryParameters ) {
String submittedPrec = BLANK_SENTINEL;
try {
submittedPrec = getSubmittedPrecision( queryParameters);
} catch (Exception e) {
log.error("could not get submitted precsion",e);
}
if( BLANK_SENTINEL.equals( submittedPrec ) )
return null;
Integer year = parseToInt(fieldName+".year", queryParameters);
//this is the case where date has not been filled out at all.
@ -305,6 +317,7 @@ public class DateTimeWithPrecision extends BaseEditElement {
return Collections.emptyMap();
}
Map<String,String> uriMap = new HashMap<String,String>();
if( precisionUri != null )
uriMap.put(fieldName+".precision", precisionUri);
return uriMap;
}
@ -335,7 +348,8 @@ public class DateTimeWithPrecision extends BaseEditElement {
/* the field wasn't filled out at all */
if( indexOfFirstNull == 0 )
return VitroVocabulary.Precision.NONE.uri();
//return VitroVocabulary.Precision.NONE.uri();
return BLANK_SENTINEL;
/* if they all had values then we have seconds precision */
if( indexOfFirstNull == -1 )

View file

@ -225,10 +225,11 @@ public class DateTimeWithPrecisionTest {
Assert.assertTrue(validationMsgs.size() == 0 );
String precisionURI = null;
precisionURI = dtwp.getSubmittedPrecision( queryParameters );
Assert.assertNotNull(precisionURI);
Assert.assertEquals(VitroVocabulary.Precision.NONE.uri(), precisionURI);
Assert.assertEquals(dtwp.BLANK_SENTINEL, precisionURI);
Literal date = dtwp.getDateTime( queryParameters);
Assert.assertNull(date);