vivo 638 fixing query for existing interval value to utilize variable for object so editing works correctly
This commit is contained in:
parent
46b9340655
commit
8a490c6125
3 changed files with 58 additions and 59 deletions
|
@ -167,40 +167,50 @@ public class DateTimeWithPrecisionVTwo extends BaseEditElementVTwo {
|
|||
|
||||
DateTime value = getTimeValue(editConfig,editSub);
|
||||
/* This is the case where there is a precision so there should be a datetime */
|
||||
if( value == null )
|
||||
log.debug("Field " + getFieldName() + " has precision " + precisionUri
|
||||
+ " but the date time is " + value);
|
||||
|
||||
/* only put the values in the map for ones which are significant based on the precision */
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.SECOND.ordinal() )
|
||||
map.put("second", Integer.toString(value.getSecondOfMinute() )) ;
|
||||
else
|
||||
map.put("second", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.MINUTE.ordinal() )
|
||||
map.put("minute", Integer.toString(value.getMinuteOfHour()) );
|
||||
else
|
||||
map.put("minute", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.HOUR.ordinal() )
|
||||
map.put("hour", Integer.toString(value.getHourOfDay()) );
|
||||
else
|
||||
map.put("hour", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.DAY.ordinal() )
|
||||
map.put("day", Integer.toString(value.getDayOfMonth()) );
|
||||
else
|
||||
map.put("day", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.MONTH.ordinal() )
|
||||
map.put("month", Integer.toString(value.getMonthOfYear()));
|
||||
else
|
||||
map.put("month", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.YEAR.ordinal() )
|
||||
map.put("year", Integer.toString(value.getYear()));
|
||||
else
|
||||
if( value == null ) {
|
||||
//If there is no value, then this is an error condition
|
||||
log.error("Field " + getFieldName() + " has precision " + precisionUri
|
||||
+ " but the date time value is null ");
|
||||
map.put("year", "");
|
||||
map.put("month", "");
|
||||
map.put("day", "");
|
||||
map.put("hour", "");
|
||||
map.put("minute", "");
|
||||
map.put("second", "") ;
|
||||
|
||||
} else {
|
||||
|
||||
/* only put the values in the map for ones which are significant based on the precision */
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.SECOND.ordinal() )
|
||||
map.put("second", Integer.toString(value.getSecondOfMinute() )) ;
|
||||
else
|
||||
map.put("second", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.MINUTE.ordinal() )
|
||||
map.put("minute", Integer.toString(value.getMinuteOfHour()) );
|
||||
else
|
||||
map.put("minute", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.HOUR.ordinal() )
|
||||
map.put("hour", Integer.toString(value.getHourOfDay()) );
|
||||
else
|
||||
map.put("hour", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.DAY.ordinal() )
|
||||
map.put("day", Integer.toString(value.getDayOfMonth()) );
|
||||
else
|
||||
map.put("day", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.MONTH.ordinal() )
|
||||
map.put("month", Integer.toString(value.getMonthOfYear()));
|
||||
else
|
||||
map.put("month", "");
|
||||
|
||||
if( existingPrec.ordinal() >= VitroVocabulary.Precision.YEAR.ordinal() )
|
||||
map.put("year", Integer.toString(value.getYear()));
|
||||
else
|
||||
map.put("year", "");
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
|
|
|
@ -70,8 +70,7 @@ public class DateTimeIntervalFormGenerator extends
|
|||
"startField-value", existingStartDateQuery);
|
||||
conf.addSparqlForExistingLiteral(
|
||||
"endField-value", existingEndDateQuery);
|
||||
conf.addSparqlForExistingUris(
|
||||
getNodeVar(), existingIntervalNodeQuery);
|
||||
|
||||
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
|
||||
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
|
||||
conf.addSparqlForExistingUris(
|
||||
|
@ -115,7 +114,7 @@ public class DateTimeIntervalFormGenerator extends
|
|||
|
||||
final String existingStartDateQuery =
|
||||
"SELECT ?existingDateStart WHERE { \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" +
|
||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||
|
@ -123,34 +122,30 @@ public class DateTimeIntervalFormGenerator extends
|
|||
|
||||
final String existingEndDateQuery =
|
||||
"SELECT ?existingEndDate WHERE { \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" +
|
||||
"?endNode a <" + dateTimeValueType + "> . \n " +
|
||||
"?endNode <" + dateTimeValue + "> ?existingEndDate . }";
|
||||
|
||||
final String existingIntervalNodeQuery =
|
||||
"SELECT ?existingIntervalNode WHERE { \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
"?existingIntervalNode a <" + intervalType + "> . }";
|
||||
|
||||
final String existingStartNodeQuery =
|
||||
"SELECT ?existingStartNode WHERE { \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToStart + "> ?existingStartNode . \n" +
|
||||
"?existingStartNode a <" + dateTimeValueType + "> .} ";
|
||||
|
||||
final String existingEndNodeQuery =
|
||||
"SELECT ?existingEndNode WHERE { \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToEnd + "> ?existingEndNode . \n" +
|
||||
"?existingEndNode a <" + dateTimeValueType + "> .} ";
|
||||
|
||||
final String existingStartPrecisionQuery =
|
||||
"SELECT ?existingStartPrecision WHERE { \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" +
|
||||
"?startNode a <" + dateTimeValueType + "> . \n" +
|
||||
|
@ -158,7 +153,7 @@ public class DateTimeIntervalFormGenerator extends
|
|||
|
||||
final String existingEndPrecisionQuery =
|
||||
"SELECT ?existingEndPrecision WHERE { \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
|
||||
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
|
||||
getNodeN3Var() + " a <" + intervalType + "> . \n" +
|
||||
getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" +
|
||||
"?endNode a <" + dateTimeValueType + "> . \n" +
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
|
|||
conf.setVarNameForSubject("subject");
|
||||
conf.setVarNameForPredicate("toDateTimeValue");
|
||||
conf.setVarNameForObject("valueNode");
|
||||
|
||||
//Value node value will be in scope if we have an object uri that exists for editing
|
||||
conf.setN3Optional(Arrays.asList(getN3ForValue()));
|
||||
|
||||
conf.addNewResource("valueNode", DEFAULT_NS_FOR_NEW_RESOURCE);
|
||||
|
@ -55,7 +55,6 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
|
|||
"dateTimeField-value", getExistingDateTimeValueQuery());
|
||||
conf.addSparqlForExistingUris(
|
||||
"dateTimeField-precision", getExistingPrecisionQuery());
|
||||
conf.addSparqlForExistingUris("valueNode", getExistingNodeQuery());
|
||||
|
||||
FieldVTwo dateTimeField = new FieldVTwo().setName(this.getDateTimeFieldName());
|
||||
dateTimeField.setEditElement(new DateTimeWithPrecisionVTwo(dateTimeField,
|
||||
|
@ -84,23 +83,18 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
|
|||
|
||||
protected String getExistingDateTimeValueQuery () {
|
||||
return "SELECT ?existingDateTimeValue WHERE { \n" +
|
||||
"?subject <" + this.getToDateTimeValuePredicate() + "> ?existingValueNode . \n" +
|
||||
"?existingValueNode a <" + valueType + "> . \n" +
|
||||
"?existingValueNode <" + dateTimeValue + "> ?existingDateTimeValue }";
|
||||
"?subject <" + this.getToDateTimeValuePredicate() + "> ?valueNode . \n" +
|
||||
"?valueNode a <" + valueType + "> . \n" +
|
||||
"?valueNode <" + dateTimeValue + "> ?existingDateTimeValue }";
|
||||
}
|
||||
|
||||
protected String getExistingPrecisionQuery() {
|
||||
return "SELECT ?existingPrecision WHERE { \n" +
|
||||
"?subject <" + this.getToDateTimeValuePredicate() + "> ?existingValueNode . \n" +
|
||||
"?existingValueNode a <" + valueType + "> . \n" +
|
||||
"?existingValueNode <" + dateTimePrecision + "> ?existingPrecision }";
|
||||
}
|
||||
protected String getExistingNodeQuery() {
|
||||
return "SELECT ?existingNode WHERE { \n" +
|
||||
"?subject <" + this.getToDateTimeValuePredicate() + "> ?existingNode . \n" +
|
||||
"?existingNode a <" + valueType + "> }";
|
||||
|
||||
"?subject <" + this.getToDateTimeValuePredicate() + "> ?valueNode . \n" +
|
||||
"?valueNode a <" + valueType + "> . \n" +
|
||||
"?valueNode <" + dateTimePrecision + "> ?existingPrecision }";
|
||||
}
|
||||
|
||||
public static String getNodeVar() {
|
||||
return "valueNode";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue