From 2113a6ee9708c5f597be855392c32c554d5ad1b4 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Tue, 31 Oct 2023 15:59:26 +0100 Subject: [PATCH] Added cache for ModelKnowledge --- .../resourceregistry/client/ResourceRegistryClient.java | 6 ++++++ .../resourceregistry/client/ResourceRegistryClientImpl.java | 2 ++ .../resourceregistry/client/ResourceRegistryClientTest.java | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java index 59b6faa..43e2c77 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java @@ -7,6 +7,7 @@ import java.util.UUID; import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.informationsystem.base.reference.Direction; import org.gcube.informationsystem.contexts.reference.entities.Context; +import org.gcube.informationsystem.model.knowledge.ModelKnowledge; import org.gcube.informationsystem.model.reference.ERElement; import org.gcube.informationsystem.model.reference.entities.Entity; import org.gcube.informationsystem.model.reference.entities.Facet; @@ -24,6 +25,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.templ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException; import org.gcube.informationsystem.resourceregistry.api.request.RequestInfo; import org.gcube.informationsystem.tree.Node; +import org.gcube.informationsystem.types.knowledge.TypeInformation; import org.gcube.informationsystem.types.reference.Type; /** @@ -64,6 +66,10 @@ public interface ResourceRegistryClient extends RequestInfo { /* ---------------------------------------------------------------------- */ + public ModelKnowledge getModelKnowledge(); + + public void renewModelKnowledge(); + public boolean existType(String typeName) throws ResourceRegistryException; public boolean existType(Class clazz) throws ResourceRegistryException; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java index 5bd3c59..ae4be57 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java @@ -236,10 +236,12 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou return contextCache; } + @Override public ModelKnowledge getModelKnowledge() { return typesKnowledge.getModelKnowledge(); } + @Override public void renewModelKnowledge() { typesKnowledge.renew(); } diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientTest.java index 4ae6882..e025dc4 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientTest.java @@ -81,6 +81,12 @@ public class ResourceRegistryClientTest extends ContextTest { logger.trace("List size {}\n{}", types.size(), getTypeNames(types)); } + @Test + public void testTypesKnowledgeExpiring() throws Exception { + resourceRegistryClient.getModelKnowledge(); + resourceRegistryClient.renewModelKnowledge(); + } + @Test public void testModelKnowledge() throws SchemaNotFoundException, ResourceRegistryException { AccessType[] modelTypes = AccessType.getModelTypes();