From 88fe4e3ff37468718e0378bc159a6da7e2802e03 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 20 Apr 2023 11:11:52 +0200 Subject: [PATCH] Redesigning E/R instance definition --- .../dbinitialization/DatabaseEnvironment.java | 1 - .../instances/base/ElementManagement.java | 25 ++++++++----------- .../entities/EntityElementManagement.java | 2 -- .../types/TypeManagement.java | 3 --- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java index fb85417..4ca214d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -71,7 +71,6 @@ import com.orientechnologies.orient.core.record.OElement; /** * @author Luca Frosini (ISTI - CNR) */ -@SuppressWarnings("unchecked") public class DatabaseEnvironment { private static Logger logger = LoggerFactory.getLogger(DatabaseEnvironment.class); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java index 7e6ec79..f4f437f 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java @@ -138,9 +138,12 @@ public abstract class ElementManagement { this.accessType = accessType; this.ignoreKeys = new HashSet(); + this.ignoreKeys.add(Element.CLASS_PROPERTY); + this.ignoreKeys.add(Element.SUPERCLASSES_PROPERTY); + this.ignoreKeys.add(IdentifiableElement.UUID_PROPERTY); + this.ignoreKeys.add(IdentifiableElement.METADATA_PROPERTY); this.ignoreStartWithKeys = new HashSet(); - this.ignoreStartWithKeys.add(ElementManagement.AT); this.ignoreStartWithKeys.add(ElementManagement.UNDERSCORE); @@ -433,11 +436,16 @@ public abstract class ElementManagement { try { setOperation(Operation.CREATE); - reallyCreate(); + UUIDManager uuidManager = UUIDManager.getInstance(); if(uuid == null) { - uuid = UUIDManager.getInstance().generateValidRandomUUID(); + uuid = uuidManager.generateValidRandomUUID(); + }else { + uuid = uuidManager.validateUUID(uuid); } + + element = reallyCreate(); + element.setProperty(IdentifiableElement.UUID_PROPERTY, uuid.toString()); MetadataUtility.addMetadata(element); @@ -1071,17 +1079,6 @@ public abstract class ElementManagement { for(String key : properties.keySet()) { try { - - if(key.compareTo(IdentifiableElement.METADATA_PROPERTY)==0) { - // We never update the metadata with the value provided - continue; - } - - if(key.compareTo(IdentifiableElement.UUID_PROPERTY)==0) { - // We never update the uuid with the value provided - continue; - } - JsonNode value = properties.get(key); OProperty oProperty = oClass.getProperty(key); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java index 25cd0b0..6121542 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java @@ -43,8 +43,6 @@ public abstract class EntityElementManagement