From 7ae96998ce337d873ed7b4488a1c61e93535362a Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Wed, 20 Mar 2024 14:29:04 +0100 Subject: [PATCH] store precision as a resource, not as a string literal (#3960) Co-authored-by: Georgy Litvinov --- .../freemarker/CreateAndLinkResourceController.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/org/vivoweb/webapp/controller/freemarker/CreateAndLinkResourceController.java b/api/src/main/java/org/vivoweb/webapp/controller/freemarker/CreateAndLinkResourceController.java index e531452188..67e0e86139 100644 --- a/api/src/main/java/org/vivoweb/webapp/controller/freemarker/CreateAndLinkResourceController.java +++ b/api/src/main/java/org/vivoweb/webapp/controller/freemarker/CreateAndLinkResourceController.java @@ -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; @@ -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;