From 1bad149cc7c39588d45979c2d26d10b7c5aaa5fd Mon Sep 17 00:00:00 2001 From: George Brownbridge Date: Wed, 22 Oct 2025 15:44:09 +0100 Subject: [PATCH 01/12] time-series-for-ontop: Bumped version number. --- stack-clients/docker-compose.yml | 2 +- stack-clients/pom.xml | 2 +- stack-data-uploader/docker-compose.yml | 2 +- stack-data-uploader/pom.xml | 4 ++-- stack-manager/docker-compose.yml | 2 +- stack-manager/pom.xml | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stack-clients/docker-compose.yml b/stack-clients/docker-compose.yml index 61163492..07508678 100644 --- a/stack-clients/docker-compose.yml +++ b/stack-clients/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-client: - image: ghcr.io/theworldavatar/stack-client${IMAGE_SUFFIX}:1.54.0 + image: ghcr.io/theworldavatar/stack-client${IMAGE_SUFFIX}:1.55.0-time-series-for-ontop-SNAPSHOT secrets: - blazegraph_password - postgis_password diff --git a/stack-clients/pom.xml b/stack-clients/pom.xml index d68d9cb4..03816742 100644 --- a/stack-clients/pom.xml +++ b/stack-clients/pom.xml @@ -7,7 +7,7 @@ com.cmclinnovations stack-clients - 1.54.0 + 1.55.0-time-series-for-ontop-SNAPSHOT Stack Clients https://theworldavatar.io diff --git a/stack-data-uploader/docker-compose.yml b/stack-data-uploader/docker-compose.yml index 0baa2a0e..9abc3ae5 100644 --- a/stack-data-uploader/docker-compose.yml +++ b/stack-data-uploader/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-data-uploader: - image: ghcr.io/theworldavatar/stack-data-uploader${IMAGE_SUFFIX}:1.54.0 + image: ghcr.io/theworldavatar/stack-data-uploader${IMAGE_SUFFIX}:1.55.0-time-series-for-ontop-SNAPSHOT secrets: - blazegraph_password - postgis_password diff --git a/stack-data-uploader/pom.xml b/stack-data-uploader/pom.xml index 7f6c9298..c5c84bc9 100644 --- a/stack-data-uploader/pom.xml +++ b/stack-data-uploader/pom.xml @@ -7,7 +7,7 @@ com.cmclinnovations stack-data-uploader - 1.54.0 + 1.55.0-time-series-for-ontop-SNAPSHOT Stack Data Uploader https://theworldavatar.io @@ -38,7 +38,7 @@ com.cmclinnovations stack-clients - 1.54.0 + 1.55.0-time-series-for-ontop-SNAPSHOT diff --git a/stack-manager/docker-compose.yml b/stack-manager/docker-compose.yml index b513371d..fbf56aea 100644 --- a/stack-manager/docker-compose.yml +++ b/stack-manager/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-manager: - image: ghcr.io/theworldavatar/stack-manager${IMAGE_SUFFIX}:1.54.0 + image: ghcr.io/theworldavatar/stack-manager${IMAGE_SUFFIX}:1.55.0-time-series-for-ontop-SNAPSHOT environment: EXTERNAL_PORT: "${EXTERNAL_PORT-3838}" STACK_BASE_DIR: "${STACK_BASE_DIR}" diff --git a/stack-manager/pom.xml b/stack-manager/pom.xml index 8b2f8ebf..e9264895 100644 --- a/stack-manager/pom.xml +++ b/stack-manager/pom.xml @@ -7,7 +7,7 @@ com.cmclinnovations stack-manager - 1.54.0 + 1.55.0-time-series-for-ontop-SNAPSHOT Stack Manager https://theworldavatar.io @@ -38,7 +38,7 @@ com.cmclinnovations stack-clients - 1.54.0 + 1.55.0-time-series-for-ontop-SNAPSHOT From d8e539eab38fbad694037b50ab6f81fd668da4b6 Mon Sep 17 00:00:00 2001 From: George Brownbridge Date: Thu, 23 Oct 2025 21:02:40 +0100 Subject: [PATCH 02/12] time-series-for-ontop: Update base lib version. --- stack-clients/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack-clients/pom.xml b/stack-clients/pom.xml index 03816742..4cceb58d 100644 --- a/stack-clients/pom.xml +++ b/stack-clients/pom.xml @@ -116,7 +116,7 @@ uk.ac.cam.cares.jps jps-base-lib - 1.48.0 + 1.49.0-54-time-series-for-ontop-SNAPSHOT From 55d300fb599016da73524f604d9b9e2ed7f6b17b Mon Sep 17 00:00:00 2001 From: George Brownbridge Date: Thu, 23 Oct 2025 22:24:03 +0100 Subject: [PATCH 03/12] time-series-for-ontop: Added an extension of the `TimeSeriesRDBClientOntop` class with the Ontop specific code. --- .../timeseries/TimeSeriesRDBClient.java | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java diff --git a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java new file mode 100644 index 00000000..64e6f9db --- /dev/null +++ b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java @@ -0,0 +1,172 @@ +package com.cmclinnovations.stack.clients.timeseries; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.sql.Connection; +import java.time.Instant; +import java.util.List; + +import org.apache.commons.io.IOUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.json.JSONArray; + +import com.cmclinnovations.stack.clients.core.EndpointNames; +import com.cmclinnovations.stack.clients.ontop.OntopClient; +import com.cmclinnovations.stack.services.OntopService; +import com.cmclinnovations.stack.services.ServiceManager; +import com.cmclinnovations.stack.services.config.ServiceConfig; + +import uk.ac.cam.cares.jps.base.exception.JPSRuntimeException; +import uk.ac.cam.cares.jps.base.query.RemoteStoreClient; +import uk.ac.cam.cares.jps.base.timeseries.TimeSeriesRDBClientOntop; + +public class TimeSeriesRDBClient extends TimeSeriesRDBClientOntop { + + /** + * Logger for error output. + */ + private static final Logger LOGGER = LogManager.getLogger(TimeSeriesRDBClient.class); + + // IRI of temporal reference system, used in ontop mapping to indicate reference + // of time, e.g. Unix + private String trsIri; + + // name of ontop container + private String ontopName = "ontop-timeseries"; + + public TimeSeriesRDBClient(Class timeClass) { + super(timeClass); + } + + public void setTrs(String trsIri) { + this.trsIri = trsIri; + } + + public void setOntopName(String ontopName) { + this.ontopName = ontopName; + } + + @Override + public List bulkInitTimeSeriesTable(List> dataIRIs, List>> dataClasses, + List tsIRIs, Integer srid, Connection conn) { + List result = super.bulkInitTimeSeriesTable(dataIRIs, dataClasses, tsIRIs, srid, conn); + + // spin up a new ontop container if it does not exist + configureOntop(); + + return result; + } + + public void configureOntop() { + String stackName = System.getenv("STACK_NAME"); + if (stackName == null) { + LOGGER.warn("STACK_NAME not detected, skipping Ontop intialisation"); + return; + } + + ServiceManager serviceManager = new ServiceManager(false); + + ServiceConfig newOntopServiceConfig = serviceManager.duplicateServiceConfig(EndpointNames.ONTOP, ontopName); + newOntopServiceConfig.setEnvironmentVariable(OntopService.ONTOP_DB_NAME, "postgres"); + + newOntopServiceConfig.getEndpoints() + .replaceAll((endpointName, connection) -> new com.cmclinnovations.stack.services.config.Connection( + connection.getUrl(), + connection.getUri(), + URI.create(connection.getExternalPath().toString() + .replace(EndpointNames.ONTOP, ontopName)))); + serviceManager.initialiseService(stackName, ontopName); + + OntopClient ontopClient = OntopClient.getInstance(ontopName); + String ontopUrl = ontopClient.readEndpointConfig().getUrl(); + + // check if mapping exists and only upload mapping if it does not exist + RemoteStoreClient remoteStoreClient = new RemoteStoreClient(ontopUrl); + String query = "SELECT * WHERE { ?x ?y ?z } LIMIT 1"; + + JSONArray queryResult = null; + + // try to send a query to ontop, catch exceptions in case it is still + // initialising + int attempts = 0; + int maxAttempts = 5; + while (attempts < maxAttempts) { + try { + queryResult = remoteStoreClient.executeQuery(query); + break; + } catch (Exception e) { + attempts++; + try { + Thread.sleep(10_000); // wait 10 seconds before retrying + } catch (Exception ie) { + throw new JPSRuntimeException("Interrupted while retrying query to ontop", e); + } + } + } + + if (queryResult == null) { + throw new JPSRuntimeException("Failed to execute query after " + maxAttempts + " attempts."); + } + + if (queryResult.isEmpty()) { + // create temporary file for ontop mapping + Path tempDir; + try { + tempDir = Files.createTempDirectory("timeseries_ontop_"); + } catch (IOException e) { + throw new JPSRuntimeException("Failed to create temporary directory to save ontop file", e); + } + + String obda = prepareMapping(); + + Path filePath = tempDir.resolve("ontop.obda"); + try { + Files.write(filePath, obda.getBytes()); + } catch (IOException e) { + throw new JPSRuntimeException("Failed to write ontop mapping into temporary folder", e); + } + + // sends obda to container + ontopClient.updateOBDA(filePath); + + // clean up + filePath.toFile().delete(); + tempDir.toFile().delete(); + } + } + + /** + * set TRS in Ontop mapping + * + * @return + */ + private String prepareMapping() { + String unixTRS = "http://dbpedia.org/resource/Unix_time"; + String generic = "http://example.org/TRS_placeholder"; + + String obdaTemplate; + // read template from resources folder + try (InputStream is = TimeSeriesRDBClientOntop.class.getResourceAsStream("timeseries_ontop_template.obda")) { + obdaTemplate = IOUtils.toString(is, StandardCharsets.UTF_8); + } catch (IOException e) { + throw new JPSRuntimeException("Error while reading timeseries_ontop_template.obda", e); + } + + if (getTimeClass() == Instant.class) { + LOGGER.info("Time class is Instant, TRS is set to {}", unixTRS); + obdaTemplate = obdaTemplate.replace("[TRS_REPLACE]", unixTRS); + } else if (trsIri == null) { + obdaTemplate = obdaTemplate.replace("[TRS_REPLACE]", generic); + } else { + obdaTemplate = obdaTemplate.replace("[TRS_REPLACE]", trsIri); + } + + return obdaTemplate; + } + +} From bd44f835b408ddb9220f6ffc0e0ac6b21caef936 Mon Sep 17 00:00:00 2001 From: George Brownbridge Date: Thu, 23 Oct 2025 22:39:39 +0100 Subject: [PATCH 04/12] time-series-for-ontop: Simplified the temporary ontop.obda file creation code by using a `LocalTempDir`. --- .../timeseries/TimeSeriesRDBClient.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java index 64e6f9db..e5d3e751 100644 --- a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java +++ b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java @@ -17,6 +17,7 @@ import com.cmclinnovations.stack.clients.core.EndpointNames; import com.cmclinnovations.stack.clients.ontop.OntopClient; +import com.cmclinnovations.stack.clients.utils.LocalTempDir; import com.cmclinnovations.stack.services.OntopService; import com.cmclinnovations.stack.services.ServiceManager; import com.cmclinnovations.stack.services.config.ServiceConfig; @@ -114,30 +115,22 @@ public void configureOntop() { } if (queryResult.isEmpty()) { + // create temporary file for ontop mapping - Path tempDir; - try { - tempDir = Files.createTempDirectory("timeseries_ontop_"); - } catch (IOException e) { - throw new JPSRuntimeException("Failed to create temporary directory to save ontop file", e); - } + try (LocalTempDir tempDir = new LocalTempDir()) { String obda = prepareMapping(); - Path filePath = tempDir.resolve("ontop.obda"); - try { - Files.write(filePath, obda.getBytes()); + Path filePath = tempDir.getPath().resolve("ontop.obda"); + Files.write(filePath, obda.getBytes()); + + // sends obda to container + ontopClient.updateOBDA(filePath); } catch (IOException e) { throw new JPSRuntimeException("Failed to write ontop mapping into temporary folder", e); } - // sends obda to container - ontopClient.updateOBDA(filePath); - - // clean up - filePath.toFile().delete(); - tempDir.toFile().delete(); - } + } } /** From c752b12f5d624fbfd25cfd5590c661e07be9994c Mon Sep 17 00:00:00 2001 From: George Brownbridge Date: Thu, 23 Oct 2025 22:47:29 +0100 Subject: [PATCH 05/12] time-series-for-ontop: Tidied up the TRS IRI code. --- .../timeseries/TimeSeriesRDBClient.java | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java index e5d3e751..c744b8ca 100644 --- a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java +++ b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java @@ -28,6 +28,9 @@ public class TimeSeriesRDBClient extends TimeSeriesRDBClientOntop { + private static final String UNIX_TRS = "http://dbpedia.org/resource/Unix_time"; + private static final String GENERIC_TRS = "http://example.org/TRS_placeholder"; + /** * Logger for error output. */ @@ -42,9 +45,17 @@ public class TimeSeriesRDBClient extends TimeSeriesRDBClientOntop { public TimeSeriesRDBClient(Class timeClass) { super(timeClass); + if (Instant.class == timeClass) { + LOGGER.info("Time class is Instant, TRS is set to {}", UNIX_TRS); + trsIri = UNIX_TRS; + } else { + LOGGER.info("Time class is not Instant, TRS is set to {}", GENERIC_TRS); + trsIri = GENERIC_TRS; + } } public void setTrs(String trsIri) { + LOGGER.info("TRS is set to {}", trsIri); this.trsIri = trsIri; } @@ -63,7 +74,7 @@ public List bulkInitTimeSeriesTable(List> dataIRIs, List Date: Fri, 24 Oct 2025 00:58:07 +0100 Subject: [PATCH 06/12] time-series-for-ontop: Added timeseries obda file from the base lib project. --- .../timeseries/timeseries_ontop_template.obda | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda diff --git a/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda b/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda new file mode 100644 index 00000000..3afb053c --- /dev/null +++ b/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda @@ -0,0 +1,28 @@ +[PrefixDeclaration] +obda: https://w3id.org/obda/vocabulary# +geo: http://www.opengis.net/ont/geosparql# +timeprefix: http://www.w3.org/2006/time# +timeseries: https://www.theworldavatar.com/kg/ontotimeseries/ + +[MappingDeclaration] @collection [[ +mappingId time_series_data +target timeseries:observation/{id} a timeseries:Observation ; + timeseries:observationOf timeseries:data/{data_iri_index} ; + timeseries:hasResult timeseries:result/{id} ; + timeprefix:hasTime timeseries:time/{id} . + timeseries:time/{id} a timeprefix:Instant ; + timeprefix:inXSDDateTime {time_as_timestamp} ; + timeprefix:inTimePosition timeseries:timePosition/{id}. + timeseries:timePosition/{id} a timeprefix:TimePosition ; + timeprefix:numericPosition {time_as_number} ; + timeprefix:unitType timeprefix:unitSecond ; + timeprefix:hasTRS <[TRS_REPLACE]> . + timeseries:result/{id} a timeseries:Result ; + timeseries:hasValue {"double precision"}, {wkt}^^geo:wktLiteral, {int}; + timeseries:hasUnit {unit} . +source SELECT id, time_as_number, time_as_timestamp, data_iri_index, "double precision", ST_AsText("geometry(Point,4326)") AS wkt, int, unit FROM time_series_data + +mappingId equivalent_iri +target <{data_iri}> obda:isCanonicalIRIOf timeseries:data/{data_iri_index} . +source SELECT data_iri, data_iri_index from time_series_data_iri +]] \ No newline at end of file From fc79d06b0c3d716b71dea92de3e152088a7d0cd3 Mon Sep 17 00:00:00 2001 From: Kok Foong Lee Date: Wed, 29 Oct 2025 18:38:29 +0800 Subject: [PATCH 07/12] time-series-for-ontop: make mappings compatible with custom schemas and fixed reading ontop template --- .../timeseries/TimeSeriesRDBClient.java | 57 ++++--------------- .../timeseries/timeseries_ontop_template.obda | 12 ++-- 2 files changed, 17 insertions(+), 52 deletions(-) diff --git a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java index c744b8ca..086bf803 100644 --- a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java +++ b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java @@ -13,7 +13,6 @@ import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.json.JSONArray; import com.cmclinnovations.stack.clients.core.EndpointNames; import com.cmclinnovations.stack.clients.ontop.OntopClient; @@ -23,7 +22,6 @@ import com.cmclinnovations.stack.services.config.ServiceConfig; import uk.ac.cam.cares.jps.base.exception.JPSRuntimeException; -import uk.ac.cam.cares.jps.base.query.RemoteStoreClient; import uk.ac.cam.cares.jps.base.timeseries.TimeSeriesRDBClientOntop; public class TimeSeriesRDBClient extends TimeSeriesRDBClientOntop { @@ -95,52 +93,19 @@ private void configureOntop() { serviceManager.initialiseService(stackName, ontopName); OntopClient ontopClient = OntopClient.getInstance(ontopName); - String ontopUrl = ontopClient.readEndpointConfig().getUrl(); - - // check if mapping exists and only upload mapping if it does not exist - RemoteStoreClient remoteStoreClient = new RemoteStoreClient(ontopUrl); - String query = "SELECT * WHERE { ?x ?y ?z } LIMIT 1"; - - JSONArray queryResult = null; - - // try to send a query to ontop, catch exceptions in case it is still - // initialising - int attempts = 0; - int maxAttempts = 5; - while (attempts < maxAttempts) { - try { - queryResult = remoteStoreClient.executeQuery(query); - break; - } catch (Exception e) { - attempts++; - try { - Thread.sleep(10_000); // wait 10 seconds before retrying - } catch (Exception ie) { - throw new JPSRuntimeException("Interrupted while retrying query to ontop", e); - } - } - } - - if (queryResult == null) { - throw new JPSRuntimeException("Failed to execute query after " + maxAttempts + " attempts."); - } - if (queryResult.isEmpty()) { + // create temporary file for ontop mapping + try (LocalTempDir tempDir = new LocalTempDir()) { - // create temporary file for ontop mapping - try (LocalTempDir tempDir = new LocalTempDir()) { + String obda = prepareMapping(); - String obda = prepareMapping(); - - Path filePath = tempDir.getPath().resolve("ontop.obda"); - Files.write(filePath, obda.getBytes()); - - // sends obda to container - ontopClient.updateOBDA(filePath); - } catch (IOException e) { - throw new JPSRuntimeException("Failed to write ontop mapping into temporary folder", e); - } + Path filePath = tempDir.getPath().resolve("ontop.obda"); + Files.write(filePath, obda.getBytes()); + // sends obda to container + ontopClient.updateOBDA(filePath); + } catch (IOException e) { + throw new JPSRuntimeException("Failed to write ontop mapping into temporary folder", e); } } @@ -151,9 +116,9 @@ private void configureOntop() { */ private String prepareMapping() { // read template from resources folder - try (InputStream is = TimeSeriesRDBClientOntop.class.getResourceAsStream("timeseries_ontop_template.obda")) { + try (InputStream is = TimeSeriesRDBClient.class.getResourceAsStream("timeseries_ontop_template.obda")) { return IOUtils.toString(is, StandardCharsets.UTF_8) - .replace("[TRS_REPLACE]", trsIri); + .replace("[TRS_REPLACE]", trsIri).replace("[SCHEMA]", getSchema()); } catch (IOException e) { throw new JPSRuntimeException("Error while reading timeseries_ontop_template.obda", e); } diff --git a/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda b/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda index 3afb053c..8236658f 100644 --- a/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda +++ b/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda @@ -5,9 +5,9 @@ timeprefix: http://www.w3.org/2006/time# timeseries: https://www.theworldavatar.com/kg/ontotimeseries/ [MappingDeclaration] @collection [[ -mappingId time_series_data +mappingId time_series_data_[SCHEMA] target timeseries:observation/{id} a timeseries:Observation ; - timeseries:observationOf timeseries:data/{data_iri_index} ; + timeseries:observationOf timeseries:data/[SCHEMA]/{data_iri_index} ; timeseries:hasResult timeseries:result/{id} ; timeprefix:hasTime timeseries:time/{id} . timeseries:time/{id} a timeprefix:Instant ; @@ -20,9 +20,9 @@ target timeseries:observation/{id} a timeseries:Observation ; timeseries:result/{id} a timeseries:Result ; timeseries:hasValue {"double precision"}, {wkt}^^geo:wktLiteral, {int}; timeseries:hasUnit {unit} . -source SELECT id, time_as_number, time_as_timestamp, data_iri_index, "double precision", ST_AsText("geometry(Point,4326)") AS wkt, int, unit FROM time_series_data +source SELECT id, time_as_number, time_as_timestamp, data_iri_index, "double precision", ST_AsText("geometry(Point,4326)") AS wkt, int, unit FROM "[SCHEMA]".time_series_data -mappingId equivalent_iri -target <{data_iri}> obda:isCanonicalIRIOf timeseries:data/{data_iri_index} . -source SELECT data_iri, data_iri_index from time_series_data_iri +mappingId equivalent_iri_[SCHEMA] +target <{data_iri}> obda:isCanonicalIRIOf timeseries:data/[SCHEMA]/{data_iri_index} . +source SELECT data_iri, data_iri_index from "[SCHEMA]".time_series_data_iri ]] \ No newline at end of file From 2bdcaba73f67b540e4bb07868d977a8983b18b3f Mon Sep 17 00:00:00 2001 From: Kok Foong Lee Date: Wed, 5 Nov 2025 16:19:07 +0800 Subject: [PATCH 08/12] time-series-for-ontop: corrected ontop mapping for custom schema --- .../timeseries/timeseries_ontop_template.obda | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda b/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda index 8236658f..43471e5c 100644 --- a/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda +++ b/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda @@ -6,18 +6,18 @@ timeseries: https://www.theworldavatar.com/kg/ontotimeseries/ [MappingDeclaration] @collection [[ mappingId time_series_data_[SCHEMA] -target timeseries:observation/{id} a timeseries:Observation ; +target timeseries:observation/[SCHEMA]/{id} a timeseries:Observation ; timeseries:observationOf timeseries:data/[SCHEMA]/{data_iri_index} ; - timeseries:hasResult timeseries:result/{id} ; - timeprefix:hasTime timeseries:time/{id} . - timeseries:time/{id} a timeprefix:Instant ; + timeseries:hasResult timeseries:result/[SCHEMA]/{id} ; + timeprefix:hasTime timeseries:time/[SCHEMA]/{id} . + timeseries:time/[SCHEMA]/{id} a timeprefix:Instant ; timeprefix:inXSDDateTime {time_as_timestamp} ; - timeprefix:inTimePosition timeseries:timePosition/{id}. - timeseries:timePosition/{id} a timeprefix:TimePosition ; + timeprefix:inTimePosition timeseries:timePosition/[SCHEMA]/{id}. + timeseries:timePosition/[SCHEMA]/{id} a timeprefix:TimePosition ; timeprefix:numericPosition {time_as_number} ; timeprefix:unitType timeprefix:unitSecond ; timeprefix:hasTRS <[TRS_REPLACE]> . - timeseries:result/{id} a timeseries:Result ; + timeseries:result/[SCHEMA]/{id} a timeseries:Result ; timeseries:hasValue {"double precision"}, {wkt}^^geo:wktLiteral, {int}; timeseries:hasUnit {unit} . source SELECT id, time_as_number, time_as_timestamp, data_iri_index, "double precision", ST_AsText("geometry(Point,4326)") AS wkt, int, unit FROM "[SCHEMA]".time_series_data From a33e9c3cc83ed6b8e13c8fdcc9232791fcc307c7 Mon Sep 17 00:00:00 2001 From: Kok Foong Lee Date: Thu, 13 Nov 2025 10:19:04 +0800 Subject: [PATCH 09/12] time-series-for-ontop: added inverse of observationOf --- .../stack/clients/timeseries/timeseries_ontop_template.obda | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda b/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda index 43471e5c..06506690 100644 --- a/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda +++ b/stack-clients/src/main/resources/com/cmclinnovations/stack/clients/timeseries/timeseries_ontop_template.obda @@ -6,7 +6,8 @@ timeseries: https://www.theworldavatar.com/kg/ontotimeseries/ [MappingDeclaration] @collection [[ mappingId time_series_data_[SCHEMA] -target timeseries:observation/[SCHEMA]/{id} a timeseries:Observation ; +target timeseries:data/[SCHEMA]/{data_iri_index} timeseries:hasObservation timeseries:observation/[SCHEMA]/{id} . + timeseries:observation/[SCHEMA]/{id} a timeseries:Observation ; timeseries:observationOf timeseries:data/[SCHEMA]/{data_iri_index} ; timeseries:hasResult timeseries:result/[SCHEMA]/{id} ; timeprefix:hasTime timeseries:time/[SCHEMA]/{id} . From 60ee54ea36516fd5e1df7b527f52240874fc043d Mon Sep 17 00:00:00 2001 From: George Brownbridge Date: Fri, 14 Nov 2025 17:02:28 +0000 Subject: [PATCH 10/12] time-series-for-ontop: Removed qualifiers from baselib version. --- stack-clients/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack-clients/pom.xml b/stack-clients/pom.xml index 4cceb58d..e606f773 100644 --- a/stack-clients/pom.xml +++ b/stack-clients/pom.xml @@ -116,7 +116,7 @@ uk.ac.cam.cares.jps jps-base-lib - 1.49.0-54-time-series-for-ontop-SNAPSHOT + 1.49.0 From 702bdca238288988861b6147fd779d6a64d30d1f Mon Sep 17 00:00:00 2001 From: George Brownbridge Date: Fri, 14 Nov 2025 17:17:53 +0000 Subject: [PATCH 11/12] time-series-for-ontop: Made changes to resolve comments. --- .../timeseries/TimeSeriesRDBClient.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java index 086bf803..f8b862f2 100644 --- a/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java +++ b/stack-clients/src/main/java/com/cmclinnovations/stack/clients/timeseries/TimeSeriesRDBClient.java @@ -36,27 +36,31 @@ public class TimeSeriesRDBClient extends TimeSeriesRDBClientOntop { // IRI of temporal reference system, used in ontop mapping to indicate reference // of time, e.g. Unix - private String trsIri; + private final String trsIri; // name of ontop container private String ontopName = "ontop-timeseries"; public TimeSeriesRDBClient(Class timeClass) { + this(timeClass, null); + } + + public TimeSeriesRDBClient(Class timeClass, String trsIri) { super(timeClass); - if (Instant.class == timeClass) { - LOGGER.info("Time class is Instant, TRS is set to {}", UNIX_TRS); - trsIri = UNIX_TRS; + if (null != trsIri) { + this.trsIri = trsIri; + LOGGER.info("TRS is set to {}", trsIri); } else { - LOGGER.info("Time class is not Instant, TRS is set to {}", GENERIC_TRS); - trsIri = GENERIC_TRS; + if (Instant.class == timeClass) { + this.trsIri = UNIX_TRS; + LOGGER.info("Time class is Instant, TRS is set to {}", UNIX_TRS); + } else { + this.trsIri = GENERIC_TRS; + LOGGER.info("Time class is not Instant, TRS is set to {}", GENERIC_TRS); + } } } - public void setTrs(String trsIri) { - LOGGER.info("TRS is set to {}", trsIri); - this.trsIri = trsIri; - } - public void setOntopName(String ontopName) { this.ontopName = ontopName; } @@ -72,7 +76,7 @@ public List bulkInitTimeSeriesTable(List> dataIRIs, List Date: Mon, 17 Nov 2025 12:04:05 +0000 Subject: [PATCH 12/12] time-series-for-ontop: Removed version qualifiers. --- stack-clients/docker-compose.yml | 2 +- stack-clients/pom.xml | 2 +- stack-data-uploader/docker-compose.yml | 2 +- stack-data-uploader/pom.xml | 4 ++-- stack-manager/docker-compose.yml | 2 +- stack-manager/pom.xml | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stack-clients/docker-compose.yml b/stack-clients/docker-compose.yml index 07508678..08aaf438 100644 --- a/stack-clients/docker-compose.yml +++ b/stack-clients/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-client: - image: ghcr.io/theworldavatar/stack-client${IMAGE_SUFFIX}:1.55.0-time-series-for-ontop-SNAPSHOT + image: ghcr.io/theworldavatar/stack-client${IMAGE_SUFFIX}:1.55.0 secrets: - blazegraph_password - postgis_password diff --git a/stack-clients/pom.xml b/stack-clients/pom.xml index e606f773..f04eaa29 100644 --- a/stack-clients/pom.xml +++ b/stack-clients/pom.xml @@ -7,7 +7,7 @@ com.cmclinnovations stack-clients - 1.55.0-time-series-for-ontop-SNAPSHOT + 1.55.0 Stack Clients https://theworldavatar.io diff --git a/stack-data-uploader/docker-compose.yml b/stack-data-uploader/docker-compose.yml index 9abc3ae5..62d8a49a 100644 --- a/stack-data-uploader/docker-compose.yml +++ b/stack-data-uploader/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-data-uploader: - image: ghcr.io/theworldavatar/stack-data-uploader${IMAGE_SUFFIX}:1.55.0-time-series-for-ontop-SNAPSHOT + image: ghcr.io/theworldavatar/stack-data-uploader${IMAGE_SUFFIX}:1.55.0 secrets: - blazegraph_password - postgis_password diff --git a/stack-data-uploader/pom.xml b/stack-data-uploader/pom.xml index c5c84bc9..f5fb4bb0 100644 --- a/stack-data-uploader/pom.xml +++ b/stack-data-uploader/pom.xml @@ -7,7 +7,7 @@ com.cmclinnovations stack-data-uploader - 1.55.0-time-series-for-ontop-SNAPSHOT + 1.55.0 Stack Data Uploader https://theworldavatar.io @@ -38,7 +38,7 @@ com.cmclinnovations stack-clients - 1.55.0-time-series-for-ontop-SNAPSHOT + 1.55.0 diff --git a/stack-manager/docker-compose.yml b/stack-manager/docker-compose.yml index fbf56aea..fae293a3 100644 --- a/stack-manager/docker-compose.yml +++ b/stack-manager/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-manager: - image: ghcr.io/theworldavatar/stack-manager${IMAGE_SUFFIX}:1.55.0-time-series-for-ontop-SNAPSHOT + image: ghcr.io/theworldavatar/stack-manager${IMAGE_SUFFIX}:1.55.0 environment: EXTERNAL_PORT: "${EXTERNAL_PORT-3838}" STACK_BASE_DIR: "${STACK_BASE_DIR}" diff --git a/stack-manager/pom.xml b/stack-manager/pom.xml index e9264895..8e89c0ee 100644 --- a/stack-manager/pom.xml +++ b/stack-manager/pom.xml @@ -7,7 +7,7 @@ com.cmclinnovations stack-manager - 1.55.0-time-series-for-ontop-SNAPSHOT + 1.55.0 Stack Manager https://theworldavatar.io @@ -38,7 +38,7 @@ com.cmclinnovations stack-clients - 1.55.0-time-series-for-ontop-SNAPSHOT + 1.55.0