Redesigning E/R instance definition

This commit is contained in:
Luca Frosini 2023-04-18 17:51:40 +02:00
parent ee6fb393d3
commit 9c23f9f42a
4 changed files with 13 additions and 11 deletions

View File

@ -30,7 +30,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>

View File

@ -110,22 +110,24 @@ public class ContextCache {
this.contexts = new ArrayList<>(); this.contexts = new ArrayList<>();
for(Context c : contexts) { for(Context c : contexts) {
UUID uuid = c.getHeader().getUUID(); UUID uuid = c.getUUID();
Context context = new ContextImpl(c.getName()); Context context = new ContextImpl(c.getName());
context.setHeader(c.getHeader()); context.setMetadata(c.getMetadata());
context.setUUID(uuid);
this.contexts.add(context); this.contexts.add(context);
this.uuidToContext.put(uuid, context); this.uuidToContext.put(uuid, context);
} }
for(Context c : contexts) { for(Context c : contexts) {
UUID uuid = c.getHeader().getUUID(); UUID uuid = c.getUUID();
Context context = this.uuidToContext.get(uuid); Context context = this.uuidToContext.get(uuid);
if(c.getParent()!=null) { if(c.getParent()!=null) {
IsParentOf ipo = c.getParent(); IsParentOf ipo = c.getParent();
UUID parentUUID = ipo.getSource().getHeader().getUUID(); UUID parentUUID = ipo.getSource().getUUID();
Context parent = this.uuidToContext.get(parentUUID); Context parent = this.uuidToContext.get(parentUUID);
IsParentOf isParentOf = new IsParentOfImpl(parent, context); IsParentOf isParentOf = new IsParentOfImpl(parent, context);
isParentOf.setHeader(ipo.getHeader()); isParentOf.setUUID(parentUUID);
isParentOf.setMetadata(ipo.getMetadata());
parent.addChild(isParentOf); parent.addChild(isParentOf);
context.setParent(isParentOf); context.setParent(isParentOf);
} }
@ -134,7 +136,7 @@ public class ContextCache {
for(Context context : contexts) { for(Context context : contexts) {
UUID uuid = context.getHeader().getUUID(); UUID uuid = context.getUUID();
String fullName = getContextFullName(context); String fullName = getContextFullName(context);
this.uuidToContextFullName.put(uuid, fullName); this.uuidToContextFullName.put(uuid, fullName);
this.contextFullNameToUUID.put(fullName, uuid); this.contextFullNameToUUID.put(fullName, uuid);
@ -147,7 +149,7 @@ public class ContextCache {
IsParentOf ipo = context.getParent(); IsParentOf ipo = context.getParent();
if(ipo!=null) { if(ipo!=null) {
Context c = ipo.getSource(); Context c = ipo.getSource();
c = uuidToContext.get(c.getHeader().getUUID()); c = uuidToContext.get(c.getUUID());
String parentFullName = getContextFullName(c); String parentFullName = getContextFullName(c);
stringBuilder.append(parentFullName); stringBuilder.append(parentFullName);
} }

View File

@ -26,7 +26,7 @@ public abstract class Utility {
} }
public static String getUUIDStringFromJsonNode(JsonNode jsonNode){ public static String getUUIDStringFromJsonNode(JsonNode jsonNode){
return jsonNode.get(IdentifiableElement.HEADER_PROPERTY).get(Element.CLASS_PROPERTY).asText(); return jsonNode.get(IdentifiableElement.METADATA_PROPERTY).get(Element.CLASS_PROPERTY).asText();
} }
public static UUID getUUIDFromJsonNode(JsonNode jsonNode){ public static UUID getUUIDFromJsonNode(JsonNode jsonNode){
String uuidString = getUUIDStringFromJsonNode(jsonNode); String uuidString = getUUIDStringFromJsonNode(jsonNode);

View File

@ -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;
@ -112,7 +112,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) {