Redesigning E/R instance definition
This commit is contained in:
parent
e9611dcafc
commit
fdf9e71068
2
pom.xml
2
pom.xml
|
@ -29,7 +29,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>2.2.0</version>
|
<version>2.4.0-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -241,7 +241,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
context = getContextFromServer(ContextPath.CURRENT_CONTEXT_PATH_PART);
|
context = getContextFromServer(ContextPath.CURRENT_CONTEXT_PATH_PART);
|
||||||
contextCache.cleanCache();
|
contextCache.cleanCache();
|
||||||
contextCache.refreshContextsIfNeeded();
|
contextCache.refreshContextsIfNeeded();
|
||||||
Context c = contextCache.getContextByUUID(context.getHeader().getUUID());
|
Context c = contextCache.getContextByUUID(context.getUUID());
|
||||||
if(c!=null){
|
if(c!=null){
|
||||||
context = c;
|
context = c;
|
||||||
}else {
|
}else {
|
||||||
|
@ -260,7 +260,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
context = getContextFromServer(ContextPath.CURRENT_CONTEXT_PATH_PART);
|
context = getContextFromServer(ContextPath.CURRENT_CONTEXT_PATH_PART);
|
||||||
contextCache.cleanCache();
|
contextCache.cleanCache();
|
||||||
contextCache.refreshContextsIfNeeded();
|
contextCache.refreshContextsIfNeeded();
|
||||||
Context c = contextCache.getContextByUUID(context.getHeader().getUUID());
|
Context c = contextCache.getContextByUUID(context.getUUID());
|
||||||
if(c!=null){
|
if(c!=null){
|
||||||
context = c;
|
context = c;
|
||||||
}else {
|
}else {
|
||||||
|
@ -572,7 +572,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
public <R extends Resource, C extends ConsistsOf<?,?>, F extends Facet> List<R> getResourcesFromReferenceFacet(
|
public <R extends Resource, C extends ConsistsOf<?,?>, F extends Facet> List<R> getResourcesFromReferenceFacet(
|
||||||
Class<R> resourceClass, Class<C> consistsOfClass, F referenceFacet,
|
Class<R> resourceClass, Class<C> consistsOfClass, F referenceFacet,
|
||||||
boolean polymorphic) throws ResourceRegistryException {
|
boolean polymorphic) throws ResourceRegistryException {
|
||||||
UUID referenceFacetUUID = referenceFacet.getHeader().getUUID();
|
UUID referenceFacetUUID = referenceFacet.getUUID();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<F> facetClass = (Class<F>) referenceFacet.getClass();
|
Class<F> facetClass = (Class<F>) referenceFacet.getClass();
|
||||||
return getResourcesFromReferenceFacet(resourceClass, consistsOfClass, facetClass, referenceFacetUUID,
|
return getResourcesFromReferenceFacet(resourceClass, consistsOfClass, facetClass, referenceFacetUUID,
|
||||||
|
@ -627,7 +627,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
public <R extends Resource, I extends IsRelatedTo<?,?>, RR extends Resource> List<R> getRelatedResourcesFromReferenceResource(
|
public <R extends Resource, I extends IsRelatedTo<?,?>, RR extends Resource> List<R> getRelatedResourcesFromReferenceResource(
|
||||||
Class<R> resourceClass, Class<I> isRelatedToClass, RR referenceResource,
|
Class<R> resourceClass, Class<I> isRelatedToClass, RR referenceResource,
|
||||||
Direction direction, boolean polymorphic) throws ResourceRegistryException {
|
Direction direction, boolean polymorphic) throws ResourceRegistryException {
|
||||||
UUID referenceResourceUUID = referenceResource.getHeader().getUUID();
|
UUID referenceResourceUUID = referenceResource.getUUID();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<RR> referenceResourceClass = (Class<RR>) referenceResource.getClass();
|
Class<RR> referenceResourceClass = (Class<RR>) referenceResource.getClass();
|
||||||
return getRelatedResourcesFromReferenceResource(resourceClass, isRelatedToClass, referenceResourceClass,
|
return getRelatedResourcesFromReferenceResource(resourceClass, isRelatedToClass, referenceResourceClass,
|
||||||
|
@ -707,7 +707,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
|
||||||
protected <E extends Entity, R extends Relation<?,?>, RE extends Entity> List<E> getRelated(Class<E> entityClass,
|
protected <E extends Entity, R extends Relation<?,?>, RE extends Entity> List<E> getRelated(Class<E> entityClass,
|
||||||
Class<R> relationClass, Class<RE> referenceEntityClass, RE referenceEntity, Direction direction,
|
Class<R> relationClass, Class<RE> referenceEntityClass, RE referenceEntity, Direction direction,
|
||||||
boolean polymorphic) throws ResourceRegistryException {
|
boolean polymorphic) throws ResourceRegistryException {
|
||||||
UUID referenceEntityUUID = referenceEntity.getHeader().getUUID();
|
UUID referenceEntityUUID = referenceEntity.getUUID();
|
||||||
return getRelated(entityClass, relationClass, referenceEntityClass, referenceEntityUUID, direction,
|
return getRelated(entityClass, relationClass, referenceEntityClass, referenceEntityUUID, direction,
|
||||||
polymorphic);
|
polymorphic);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.gcube.common.authorization.utils.secret.SecretUtility;
|
||||||
import org.gcube.common.keycloak.KeycloakClientFactory;
|
import org.gcube.common.keycloak.KeycloakClientFactory;
|
||||||
import org.gcube.common.keycloak.model.TokenResponse;
|
import org.gcube.common.keycloak.model.TokenResponse;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -117,7 +117,7 @@ public class ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUser() {
|
public static String getUser() {
|
||||||
String user = Header.UNKNOWN_USER;
|
String user = Metadata.UNKNOWN_USER;
|
||||||
try {
|
try {
|
||||||
user = SecretManagerProvider.instance.get().getUser().getUsername();
|
user = SecretManagerProvider.instance.get().getUser().getUsername();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
|
|
@ -12,15 +12,16 @@ import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import org.gcube.informationsystem.base.reference.Direction;
|
import org.gcube.informationsystem.base.reference.Direction;
|
||||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||||
import org.gcube.informationsystem.types.reference.Type;
|
import org.gcube.informationsystem.types.reference.Type;
|
||||||
|
import org.gcube.informationsystem.utils.UUIDManager;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.resources.HostingNodeImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.resources.HostingNodeImpl;
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.ContactFacet;
|
import org.gcube.resourcemanagement.model.reference.entities.facets.ContactFacet;
|
||||||
|
@ -131,8 +132,9 @@ public class ResourceRegistryClientTest extends ContextTest {
|
||||||
public void testGetRelatedResourcesFromReferenceResourceByClasses() throws ResourceRegistryException {
|
public void testGetRelatedResourcesFromReferenceResourceByClasses() throws ResourceRegistryException {
|
||||||
UUID uuid = UUID.fromString("b0d15e45-62af-4221-b785-7d014f10e631");
|
UUID uuid = UUID.fromString("b0d15e45-62af-4221-b785-7d014f10e631");
|
||||||
HostingNode hostingNode = new HostingNodeImpl();
|
HostingNode hostingNode = new HostingNodeImpl();
|
||||||
Header header = new HeaderImpl(uuid);
|
hostingNode.setUUID(uuid);
|
||||||
hostingNode.setHeader(header);
|
Metadata metadata = new MetadataImpl();
|
||||||
|
hostingNode.setMetadata(metadata);
|
||||||
List<EService> eServices = resourceRegistryClient.getRelatedResourcesFromReferenceResource(EService.class,
|
List<EService> eServices = resourceRegistryClient.getRelatedResourcesFromReferenceResource(EService.class,
|
||||||
IsRelatedTo.class, hostingNode, Direction.OUT, true);
|
IsRelatedTo.class, hostingNode, Direction.OUT, true);
|
||||||
logger.trace("{}", eServices);
|
logger.trace("{}", eServices);
|
||||||
|
@ -154,9 +156,9 @@ public class ResourceRegistryClientTest extends ContextTest {
|
||||||
// @Test
|
// @Test
|
||||||
public void testGetResourcesFromReferenceFacet() throws ResourceRegistryException, JsonProcessingException {
|
public void testGetResourcesFromReferenceFacet() throws ResourceRegistryException, JsonProcessingException {
|
||||||
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
||||||
UUID uuid = UUID.fromString("cbdf3e61-524c-4800-91a6-3ff3e06fbee3");
|
softwareFacet.setUUID(UUIDManager.getInstance().generateValidRandomUUID());
|
||||||
Header header = new HeaderImpl(uuid);
|
Metadata metadata = new MetadataImpl();
|
||||||
softwareFacet.setHeader(header);
|
softwareFacet.setMetadata(metadata);
|
||||||
List<EService> eServices = resourceRegistryClient.getResourcesFromReferenceFacet(EService.class, IsIdentifiedBy.class, softwareFacet, true);
|
List<EService> eServices = resourceRegistryClient.getResourcesFromReferenceFacet(EService.class, IsIdentifiedBy.class, softwareFacet, true);
|
||||||
for(EService eService : eServices) {
|
for(EService eService : eServices) {
|
||||||
logger.trace("{}", ElementMapper.marshal(eService));
|
logger.trace("{}", ElementMapper.marshal(eService));
|
||||||
|
@ -174,11 +176,11 @@ public class ResourceRegistryClientTest extends ContextTest {
|
||||||
|
|
||||||
|
|
||||||
for(Context c : contexts) {
|
for(Context c : contexts) {
|
||||||
UUID uuid = c.getHeader().getUUID();
|
UUID uuid = c.getUUID();
|
||||||
if(c.getParent()!=null) {
|
if(c.getParent()!=null) {
|
||||||
IsParentOf isParentOf = c.getParent();
|
IsParentOf isParentOf = c.getParent();
|
||||||
Context parentContext = isParentOf.getSource();
|
Context parentContext = isParentOf.getSource();
|
||||||
UUID parentUUID = parentContext.getHeader().getUUID();
|
UUID parentUUID = parentContext.getUUID();
|
||||||
Assert.assertEquals(parentContext, contextCache.getContextByUUID(parentUUID));
|
Assert.assertEquals(parentContext, contextCache.getContextByUUID(parentUUID));
|
||||||
List<IsParentOf> children = parentContext.getChildren();
|
List<IsParentOf> children = parentContext.getChildren();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
@ -189,9 +191,9 @@ public class ResourceRegistryClientTest extends ContextTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert.assertTrue(found);
|
Assert.assertTrue(found);
|
||||||
logger.debug("{} : {} (parent {} : {})", c.getHeader().getUUID(), contextCache.getContextFullNameByUUID(uuid), parentUUID, contextCache.getContextFullNameByUUID(parentUUID));
|
logger.debug("{} : {} (parent {} : {})", c.getUUID(), contextCache.getContextFullNameByUUID(uuid), parentUUID, contextCache.getContextFullNameByUUID(parentUUID));
|
||||||
}else {
|
}else {
|
||||||
logger.debug("{} : {}", c.getHeader().getUUID(), contextCache.getContextFullNameByUUID(uuid));
|
logger.debug("{} : {}", c.getUUID(), contextCache.getContextFullNameByUUID(uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +201,7 @@ public class ResourceRegistryClientTest extends ContextTest {
|
||||||
logger.debug("Current context : {}", currentContext);
|
logger.debug("Current context : {}", currentContext);
|
||||||
|
|
||||||
for(Context c : contexts) {
|
for(Context c : contexts) {
|
||||||
UUID uuid = c.getHeader().getUUID();
|
UUID uuid = c.getUUID();
|
||||||
Context context = resourceRegistryClient.getContext(uuid);
|
Context context = resourceRegistryClient.getContext(uuid);
|
||||||
String fullName = ContextCache.getInstance().getContextFullNameByUUID(uuid);
|
String fullName = ContextCache.getInstance().getContextFullNameByUUID(uuid);
|
||||||
logger.debug("{} - {} : {}", uuid, fullName, context);
|
logger.debug("{} - {} : {}", uuid, fullName, context);
|
||||||
|
|
|
@ -9,9 +9,7 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.base.reference.Direction;
|
import org.gcube.informationsystem.base.reference.Direction;
|
||||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
|
||||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||||
|
@ -74,8 +72,7 @@ public class ResourceRegistryClientTestWikiExamples extends ContextTest {
|
||||||
public void testExample2Alt() throws ResourceRegistryException, Exception{
|
public void testExample2Alt() throws ResourceRegistryException, Exception{
|
||||||
SoftwareFacet softwareFacetInstance = new SoftwareFacetImpl();
|
SoftwareFacet softwareFacetInstance = new SoftwareFacetImpl();
|
||||||
UUID uuid = UUID.fromString("97984812-90e6-4eb7-b804-50a9ad3fe4fb");
|
UUID uuid = UUID.fromString("97984812-90e6-4eb7-b804-50a9ad3fe4fb");
|
||||||
Header header = new HeaderImpl(uuid);
|
softwareFacetInstance.setUUID(uuid);
|
||||||
softwareFacetInstance.setHeader(header);
|
|
||||||
List<EService> list = resourceRegistryClient.getResourcesFromReferenceFacet(EService.class, IsIdentifiedBy.class, softwareFacetInstance, true);
|
List<EService> list = resourceRegistryClient.getResourcesFromReferenceFacet(EService.class, IsIdentifiedBy.class, softwareFacetInstance, true);
|
||||||
logger.debug("{}", list);
|
logger.debug("{}", list);
|
||||||
}
|
}
|
||||||
|
@ -181,8 +178,7 @@ public class ResourceRegistryClientTestWikiExamples extends ContextTest {
|
||||||
public void testExample8Alt() throws ResourceRegistryException, Exception{
|
public void testExample8Alt() throws ResourceRegistryException, Exception{
|
||||||
HostingNode hostingNodeInstance = new HostingNodeImpl();
|
HostingNode hostingNodeInstance = new HostingNodeImpl();
|
||||||
UUID uuid = UUID.fromString("16032d09-3823-444e-a1ff-a67de4f350a");
|
UUID uuid = UUID.fromString("16032d09-3823-444e-a1ff-a67de4f350a");
|
||||||
Header header = new HeaderImpl(uuid);
|
hostingNodeInstance.setUUID(uuid);
|
||||||
hostingNodeInstance.setHeader(header);
|
|
||||||
List<EService> list = resourceRegistryClient.getRelatedResourcesFromReferenceResource(EService.class, Hosts.class, hostingNodeInstance, Direction.IN, true);
|
List<EService> list = resourceRegistryClient.getRelatedResourcesFromReferenceResource(EService.class, Hosts.class, hostingNodeInstance, Direction.IN, true);
|
||||||
logger.debug("{}", list);
|
logger.debug("{}", list);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue