From da8082d55ff74bc26883360773d70f1e061b92d1 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 8 Nov 2019 18:37:30 +0100 Subject: [PATCH] The type definition is now created for every type (for *TypeDefinition too) --- .../dbinitialization/DatabaseEnvironment.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 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 eb731ff..4058de7 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -6,12 +6,10 @@ import java.net.URL; import java.security.Key; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.ServiceLoader; -import java.util.Set; import java.util.UUID; import org.gcube.common.encryption.SymmetricKey; @@ -225,33 +223,40 @@ public class DatabaseEnvironment { schemaSecurityContext.create(); - SchemaAction schemaAction = new SchemaActionImpl(); - schemaAction.managePropertyClass(BaseProperty.class); - schemaAction.managePropertyClass(Header.class); - schemaAction.managePropertyClass(PropertyDefinition.class); - schemaAction.managePropertyClass(PropertyTypeDefinition.class); - schemaAction.manageEntityClass(BaseEntity.class); - schemaAction.manageEntityClass(EntityTypeDefinition.class); - schemaAction.manageRelationClass(BaseRelation.class); - schemaAction.manageRelationClass(RelationTypeDefinition.class); - - Set> definitionToBeCreated = new HashSet<>(); + List> definitionToBeCreated = new ArrayList<>(); definitionToBeCreated.add(BaseProperty.class); definitionToBeCreated.add(Header.class); + definitionToBeCreated.add(PropertyDefinition.class); + definitionToBeCreated.add(PropertyTypeDefinition.class); definitionToBeCreated.add(BaseEntity.class); + definitionToBeCreated.add(EntityTypeDefinition.class); definitionToBeCreated.add(BaseRelation.class); + definitionToBeCreated.add(RelationTypeDefinition.class); + + SchemaAction schemaAction = new SchemaActionImpl(); + + for(Class clz : definitionToBeCreated) { + + if(BaseProperty.class.isAssignableFrom(clz)) { + schemaAction.managePropertyClass((Class) clz); + } else if(BaseEntity.class.isAssignableFrom(clz)) { + schemaAction.manageEntityClass((Class) clz); + } else if(BaseRelation.class.isAssignableFrom(clz)) { + schemaAction.manageRelationClass((Class>) clz); + } + } for(Class clz : definitionToBeCreated) { ERManagement erManagement = null; - if(BaseEntity.class.isAssignableFrom(clz)) { + if(BaseProperty.class.isAssignableFrom(clz)) { + erManagement = new PropertyTypeDefinitionManagement(); + } else if(BaseEntity.class.isAssignableFrom(clz)) { erManagement = new EntityTypeDefinitionManagement(); } else if(BaseRelation.class.isAssignableFrom(clz)) { erManagement = new RelationTypeDefinitionManagement(); - } else if(BaseProperty.class.isAssignableFrom(clz)) { - erManagement = new PropertyTypeDefinitionManagement(); - } + } erManagement.setJson(TypeBinder.serializeType(clz)); erManagement.create();