Redesigning E/R instance definition

This commit is contained in:
Luca Frosini 2023-04-20 11:11:52 +02:00
parent 5893cfd61a
commit 88fe4e3ff3
4 changed files with 11 additions and 20 deletions

View File

@ -71,7 +71,6 @@ import com.orientechnologies.orient.core.record.OElement;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */
@SuppressWarnings("unchecked")
public class DatabaseEnvironment { public class DatabaseEnvironment {
private static Logger logger = LoggerFactory.getLogger(DatabaseEnvironment.class); private static Logger logger = LoggerFactory.getLogger(DatabaseEnvironment.class);

View File

@ -138,9 +138,12 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
this.accessType = accessType; this.accessType = accessType;
this.ignoreKeys = new HashSet<String>(); this.ignoreKeys = new HashSet<String>();
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<String>(); this.ignoreStartWithKeys = new HashSet<String>();
this.ignoreStartWithKeys.add(ElementManagement.AT); this.ignoreStartWithKeys.add(ElementManagement.AT);
this.ignoreStartWithKeys.add(ElementManagement.UNDERSCORE); this.ignoreStartWithKeys.add(ElementManagement.UNDERSCORE);
@ -433,11 +436,16 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
try { try {
setOperation(Operation.CREATE); setOperation(Operation.CREATE);
reallyCreate(); UUIDManager uuidManager = UUIDManager.getInstance();
if(uuid == null) { if(uuid == null) {
uuid = UUIDManager.getInstance().generateValidRandomUUID(); uuid = uuidManager.generateValidRandomUUID();
}else {
uuid = uuidManager.validateUUID(uuid);
} }
element = reallyCreate();
element.setProperty(IdentifiableElement.UUID_PROPERTY, uuid.toString()); element.setProperty(IdentifiableElement.UUID_PROPERTY, uuid.toString());
MetadataUtility.addMetadata(element); MetadataUtility.addMetadata(element);
@ -1071,17 +1079,6 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
for(String key : properties.keySet()) { for(String key : properties.keySet()) {
try { 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); JsonNode value = properties.get(key);
OProperty oProperty = oClass.getProperty(key); OProperty oProperty = oClass.getProperty(key);

View File

@ -43,8 +43,6 @@ public abstract class EntityElementManagement<E extends EntityElement, ET extend
protected EntityElementManagement(AccessType accessType) { protected EntityElementManagement(AccessType accessType) {
super(accessType); super(accessType);
this.ignoreKeys.add(EntityElement.METADATA_PROPERTY);
this.ignoreStartWithKeys.add(IN_PREFIX.toLowerCase()); this.ignoreStartWithKeys.add(IN_PREFIX.toLowerCase());
this.ignoreStartWithKeys.add(OUT_PREFIX.toLowerCase()); this.ignoreStartWithKeys.add(OUT_PREFIX.toLowerCase());
this.ignoreStartWithKeys.add(IN_PREFIX.toUpperCase()); this.ignoreStartWithKeys.add(IN_PREFIX.toUpperCase());

View File

@ -513,9 +513,6 @@ public class TypeManagement {
newTypeDefinition.getName()); newTypeDefinition.getName());
} }
if(!(newTypeDefinition instanceof ResourceType)) { if(!(newTypeDefinition instanceof ResourceType)) {
// A Resource cannot contains any properties. // A Resource cannot contains any properties.