Skip to content

Commit

Permalink
store precision as a resource, not as a string literal (#3960)
Browse files Browse the repository at this point in the history
Co-authored-by: Georgy Litvinov <georgy.litvinov@tib.eu>
  • Loading branch information
2 people authored and chenejac committed Apr 5, 2024
1 parent 04ea671 commit 7ae9699
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;

import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.Precision.DAY;
import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.Precision.MONTH;
import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.Precision.YEAR;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -1210,19 +1215,19 @@ protected boolean addDateToResource(VitroRequest vreq, Resource work, ResourceMo
if (date.month != null) {
if (date.day != null) {
formattedDate = String.format("%04d-%02d-%02dT00:00:00", date.year, date.month, date.day);
precision = "http://vivoweb.org/ontology/core#dayPrecision";
precision = DAY.uri();
} else {
formattedDate = String.format("%04d-%02d-01T00:00:00", date.year, date.month);
precision = "http://vivoweb.org/ontology/core#monthPrecision";
precision = MONTH.uri();
}
} else {
formattedDate = String.format("%04d-01-01T00:00:00", date.year);
precision = "http://vivoweb.org/ontology/core#yearPrecision";
precision = YEAR.uri();
}

Resource dateResource = model.createResource(getUnusedUri(vreq)).addProperty(RDF.type, model.getResource("http://vivoweb.org/ontology/core#DateTimeValue"));
dateResource.addProperty(model.createProperty(VIVO_DATETIME), formattedDate);
dateResource.addProperty(model.createProperty(VIVO_DATETIMEPRECISION), precision);
dateResource.addProperty(model.createProperty(VIVO_DATETIMEPRECISION), model.createResource(precision));

work.addProperty(model.createProperty(VIVO_DATETIMEVALUE), dateResource);
return true;
Expand Down

0 comments on commit 7ae9699

Please sign in to comment.