Added cache for ModelKnowledge

This commit is contained in:
luca.frosini 2023-10-31 15:59:26 +01:00
parent 30eac775f6
commit 2113a6ee97
3 changed files with 14 additions and 0 deletions

View File

@ -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<Type, TypeInformation> getModelKnowledge();
public void renewModelKnowledge();
public boolean existType(String typeName) throws ResourceRegistryException;
public <ERElem extends ERElement> boolean existType(Class<ERElem> clazz) throws ResourceRegistryException;

View File

@ -236,10 +236,12 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou
return contextCache;
}
@Override
public ModelKnowledge<Type, TypeInformation> getModelKnowledge() {
return typesKnowledge.getModelKnowledge();
}
@Override
public void renewModelKnowledge() {
typesKnowledge.renew();
}

View File

@ -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();