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 fd10a51..b45a45f 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -29,7 +29,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityCo import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.types.properties.PropertyTypeDefinitionManagement; import org.gcube.informationsystem.types.TypeBinder; -import org.gcube.informationsystem.types.reference.TypeDefinition; +import org.gcube.informationsystem.types.reference.Type; import org.gcube.informationsystem.types.reference.entities.EntityType; import org.gcube.informationsystem.types.reference.entities.FacetType; import org.gcube.informationsystem.types.reference.entities.ResourceType; @@ -39,7 +39,7 @@ import org.gcube.informationsystem.types.reference.properties.LinkedEntity; import org.gcube.informationsystem.types.reference.relations.ConsistsOfType; import org.gcube.informationsystem.types.reference.relations.IsRelatedToType; import org.gcube.informationsystem.types.reference.relations.RelationType; -import org.gcube.informationsystem.utils.discovery.ISMDiscovery; +import org.gcube.informationsystem.utils.discovery.ElementSpecilizationDiscovery; import org.gcube.informationsystem.utils.discovery.RegistrationProvider; import org.gcube.informationsystem.utils.discovery.SchemaAction; import org.slf4j.Logger; @@ -268,7 +268,7 @@ public class DatabaseEnvironment { List packages = new ArrayList(); - Class tdClz = TypeDefinition.class; + Class tdClz = Type.class; packages.add(tdClz.getPackage()); AccessType[] accessTypes = AccessType.values(); @@ -283,7 +283,7 @@ public class DatabaseEnvironment { packages.addAll(registrationProvider.getPackagesToRegister()); } - ISMDiscovery.manageISM(schemaAction, packages); + ElementSpecilizationDiscovery.manageISM(schemaAction, packages); } logger.info("Database Connection has been properly initialized"); 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 6e380f4..3369b18 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 @@ -18,8 +18,8 @@ import java.util.UUID; import javax.activation.UnsupportedDataTypeException; import org.gcube.informationsystem.base.reference.AccessType; -import org.gcube.informationsystem.base.reference.ER; import org.gcube.informationsystem.base.reference.Element; +import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.context.reference.entities.Context; import org.gcube.informationsystem.model.reference.properties.Header; import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException; @@ -275,7 +275,7 @@ public abstract class ElementManagement { Header entityHeader = HeaderUtility.getHeader(jsonNode, true); if(entityHeader != null) { - element.setProperty(ER.HEADER_PROPERTY, entityHeader); + element.setProperty(IdentifiableElement.HEADER_PROPERTY, entityHeader); } else { entityHeader = HeaderUtility.addHeader(element, null); } @@ -951,7 +951,7 @@ public abstract class ElementManagement { } ObjectMapper objectMapper = new ObjectMapper(); - if(key.compareTo(ER.HEADER_PROPERTY) == 0) { + if(key.compareTo(IdentifiableElement.HEADER_PROPERTY) == 0) { // Keeping the header HeaderOrient headerOrient = HeaderUtility.getHeaderOrient((ODocument) object); return Utility.toJsonNode(headerOrient, false); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java index fe50086..c8ac135 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java @@ -28,7 +28,7 @@ import org.gcube.informationsystem.resourceregistry.instances.model.entities.Fac import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; import org.gcube.informationsystem.resourceregistry.utils.PropagationConstraintOrient; import org.gcube.informationsystem.resourceregistry.utils.Utility; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -188,7 +188,7 @@ public abstract class RelationManagement erManagement = null; @@ -165,22 +166,22 @@ public class SchemaManagementImpl implements SchemaManagement { protected String getTypeDefinitionAsString(OClass oClass) throws SchemaException { try { - TypeDefinition typeDefinition = getTypeDefinition(oClass); - return TypeBinder.serializeTypeDefinition(typeDefinition); + Type type = getType(oClass); + return TypeBinder.serializeTypeDefinition(type); } catch(Exception e) { throw new SchemaException(e); } } protected List getSuperclassesAndCheckCompliancy(ODatabaseDocument oDatabaseDocument, - TypeDefinition typeDefinition, String baseType) throws SchemaException, SchemaNotFoundException { + Type type, String baseType) throws SchemaException, SchemaNotFoundException { - Set superClasses = typeDefinition.getSuperClasses(); + Set superClasses = type.getSuperClasses(); if(baseType != null) { if(superClasses == null || superClasses.size() == 0) { throw new RuntimeException( String.format("No Superclass found in schema %s. The Type Definition must extend %s", - typeDefinition, baseType)); + type, baseType)); } } @@ -194,7 +195,7 @@ public class SchemaManagementImpl implements SchemaManagement { throw new SchemaNotFoundException("Superclass " + superClass + " does not exists"); } if(baseType != null) { - if(typeDefinition.getName().compareTo(baseType) != 0) { + if(type.getName().compareTo(baseType) != 0) { if(!oSuperClass.isSubClassOf(baseType)) { throw new RuntimeException(superClass + " is not a subsclass of " + baseType + ". Each Superclass MUST be a subclass of " + baseType); @@ -207,36 +208,36 @@ public class SchemaManagementImpl implements SchemaManagement { return oSuperclasses; } - private static Set baseTypes; - public static Set typeDefinitionTypes; + private static Set baseElementTypes; + public static Set typeList; static { - baseTypes = new HashSet(); - baseTypes.add(PropertyElement.NAME); - baseTypes.add(EntityElement.NAME); - baseTypes.add(RelationElement.NAME); + baseElementTypes = new HashSet(); + baseElementTypes.add(PropertyElement.NAME); + baseElementTypes.add(EntityElement.NAME); + baseElementTypes.add(RelationElement.NAME); - typeDefinitionTypes = new HashSet(); - typeDefinitionTypes.add(PropertyType.NAME); - typeDefinitionTypes.add(LinkedEntity.NAME); - typeDefinitionTypes.add(EntityType.NAME); - typeDefinitionTypes.add(ResourceType.NAME); - typeDefinitionTypes.add(FacetType.NAME); - typeDefinitionTypes.add(RelationType.NAME); - typeDefinitionTypes.add(IsRelatedToType.NAME); - typeDefinitionTypes.add(ConsistsOfType.NAME); + typeList = new HashSet(); + typeList.add(PropertyType.NAME); + typeList.add(LinkedEntity.NAME); + typeList.add(EntityType.NAME); + typeList.add(ResourceType.NAME); + typeList.add(FacetType.NAME); + typeList.add(RelationType.NAME); + typeList.add(IsRelatedToType.NAME); + typeList.add(ConsistsOfType.NAME); } - protected void registerTypeSchema(TypeDefinition typeDefinition, AccessType baseType) + protected void registerTypeSchema(Type type, AccessType baseElementAccessType) throws SchemaAlreadyPresentException, SchemaException { ODatabaseDocument oDatabaseDocument = null; try { - if(typeName.compareTo(typeDefinition.getName()) != 0) { + if(typeName.compareTo(type.getName()) != 0) { String error = String.format( "Provided type name path argument %s does not match with the type name in the definition %S. Please be coherent.", - typeName, typeDefinition.getName()); + typeName, type.getName()); throw new SchemaCreationException(error); } @@ -248,12 +249,12 @@ public class SchemaManagementImpl implements SchemaManagement { OClass oClass = null; - if(EntityElement.class.isAssignableFrom(baseType.getTypeClass())) { - oClass = oDatabaseDocument.createVertexClass(typeDefinition.getName()); - } else if(RelationElement.class.isAssignableFrom(baseType.getTypeClass())) { - oClass = oDatabaseDocument.createEdgeClass(typeDefinition.getName()); - } else if(PropertyElement.class.isAssignableFrom(baseType.getTypeClass())) { - oClass = oSchema.createClass(typeDefinition.getName()); + if(EntityElement.class.isAssignableFrom(baseElementAccessType.getTypeClass())) { + oClass = oDatabaseDocument.createVertexClass(type.getName()); + } else if(RelationElement.class.isAssignableFrom(baseElementAccessType.getTypeClass())) { + oClass = oDatabaseDocument.createEdgeClass(type.getName()); + } else if(PropertyElement.class.isAssignableFrom(baseElementAccessType.getTypeClass())) { + oClass = oSchema.createClass(type.getName()); } else { String error = String.format("Allowed superclass are %s, %s, %s, or any subclasses of them.", Entity.NAME, Relation.NAME, Property.NAME); @@ -262,7 +263,7 @@ public class SchemaManagementImpl implements SchemaManagement { try { - String description = typeDefinition.getDescription(); + String description = type.getDescription(); if(description != null && description.compareTo("") != 0) { try { oClass.setDescription(description); @@ -275,87 +276,89 @@ public class SchemaManagementImpl implements SchemaManagement { try { // oClass.setAbstract(false); // Used to allow to persist Schema in Context // Management - oClass.setAbstract(typeDefinition.isAbstract()); + oClass.setAbstract(type.isAbstract()); } catch(Exception e) { logger.error( "Unable to set the Vertex Type {} as abstract. This is an OrientDB <= 2.2.12 bug. The Type will be created as it is not abstract.", - typeDefinition.getName()); + type.getName()); } - if(!baseTypes.contains(typeDefinition.getName())) { - List oSuperclasses = getSuperclassesAndCheckCompliancy(oDatabaseDocument, typeDefinition, - baseType.getName()); + if(!baseElementTypes.contains(type.getName())) { + List oSuperclasses = getSuperclassesAndCheckCompliancy(oDatabaseDocument, type, + baseElementAccessType.getName()); oClass.setSuperClasses(oSuperclasses); } - if(!(typeDefinition instanceof ResourceType)) { + if(!(type instanceof ResourceType)) { // A Resource cannot contains any properties. - Set propertyDefinitions = typeDefinition.getProperties(); + Set propertyDefinitions = ((TypeWithProperties) type).getProperties(); - for(PropertyDefinition propertyDefinition : propertyDefinitions) { - - OType oType = OType.getById(propertyDefinition.getType().byteValue()); - - /* - * Types update is not allowed, - * hence bug https://github.com/orientechnologies/orientdb/issues/7354 cannot occur - * Excluding the check from types used for type definition - * - */ - if(!typeDefinitionTypes.contains(typeDefinition.getName())) { - switch(oType) { - case EMBEDDEDLIST: - throw new UnsupportedDataTypeException(OrientDBType.OType.PROPERTYLIST - + " support is currently disabled due to OrientDB bug see https://github.com/orientechnologies/orientdb/issues/7354"); - case EMBEDDEDSET: - throw new UnsupportedDataTypeException(OrientDBType.OType.PROPERTYSET - + " support is currently disabled due to OrientDB bug see https://github.com/orientechnologies/orientdb/issues/7354"); - default: - break; - } - } - - OProperty op = oClass.createProperty(propertyDefinition.getName(), oType); - op.setDescription(propertyDefinition.getDescription()); - - /* - * Mandatory and notNull does not work in distributed mode: so that on Type - * declaration they are forced to false - * ovp.setMandatory(property.isMandatory()); - * ovp.setNotNull(property.isNotnull()); This information are persisted in - * Management Context - */ - op.setMandatory(false); - op.setNotNull(false); - - op.setReadonly(propertyDefinition.isReadonly()); - op.setRegexp(propertyDefinition.getRegexp()); - - if(propertyDefinition.getLinkedClass() != null) { - OClass linkedClass = getOClass(oSchema, propertyDefinition.getLinkedClass()); - if(linkedClass == null) { - logger.trace("class {} not found in schema", propertyDefinition.getLinkedClass()); - throw new Exception( - "class " + propertyDefinition.getLinkedClass() + " not found in schema"); + if(propertyDefinitions!=null) { + for(PropertyDefinition propertyDefinition : propertyDefinitions) { + + OType oType = OType.getById(propertyDefinition.getType().byteValue()); + + /* + * Types update is not allowed, + * hence bug https://github.com/orientechnologies/orientdb/issues/7354 cannot occur + * Excluding the check from types used for type definition + * + */ + if(!typeList.contains(type.getName())) { + switch(oType) { + case EMBEDDEDLIST: + throw new UnsupportedDataTypeException(OrientDBType.OType.PROPERTYLIST + + " support is currently disabled due to OrientDB bug see https://github.com/orientechnologies/orientdb/issues/7354"); + case EMBEDDEDSET: + throw new UnsupportedDataTypeException(OrientDBType.OType.PROPERTYSET + + " support is currently disabled due to OrientDB bug see https://github.com/orientechnologies/orientdb/issues/7354"); + default: + break; + } } - if(linkedClass.isEdgeType() || linkedClass.isVertexType()) { - throw new Exception("A Property Field cannot be an Entity or a Relation"); - } + OProperty op = oClass.createProperty(propertyDefinition.getName(), oType); + op.setDescription(propertyDefinition.getDescription()); - op.setLinkedClass(linkedClass); - } else if(propertyDefinition.getLinkedType() != null) { - op.setLinkedType(OType.getById(propertyDefinition.getLinkedType().byteValue())); + /* + * Mandatory and notNull does not work in distributed mode: so that on Type + * declaration they are forced to false + * ovp.setMandatory(property.isMandatory()); + * ovp.setNotNull(property.isNotnull()); This information are persisted in + * Management Context + */ + op.setMandatory(false); + op.setNotNull(false); + + op.setReadonly(propertyDefinition.isReadonly()); + op.setRegexp(propertyDefinition.getRegexp()); + + if(propertyDefinition.getLinkedClass() != null) { + OClass linkedClass = getOClass(oSchema, propertyDefinition.getLinkedClass()); + if(linkedClass == null) { + logger.trace("class {} not found in schema", propertyDefinition.getLinkedClass()); + throw new Exception( + "class " + propertyDefinition.getLinkedClass() + " not found in schema"); + } + + if(linkedClass.isEdgeType() || linkedClass.isVertexType()) { + throw new Exception("A Property Field cannot be an Entity or a Relation"); + } + + op.setLinkedClass(linkedClass); + } else if(propertyDefinition.getLinkedType() != null) { + op.setLinkedType(OType.getById(propertyDefinition.getLinkedType().byteValue())); + } } } } oDatabaseDocument.commit(); - logger.info("{} {} registered successfully", baseType.getName(), typeDefinition.getName()); + logger.info("{} {} registered successfully", baseElementAccessType.getName(), type.getName()); } catch(Exception e) { - oSchema.dropClass(typeDefinition.getName()); + oSchema.dropClass(type.getName()); throw e; } } catch(OSchemaException ex) { @@ -372,7 +375,7 @@ public class SchemaManagementImpl implements SchemaManagement { } } - protected String getSchema(String type, boolean includeSubtypes) throws SchemaNotFoundException, SchemaException { + protected String getSchema(String typeName, boolean includeSubtypes) throws SchemaNotFoundException, SchemaException { ODatabaseDocument oDatabaseDocument = null; try { AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext(); @@ -380,15 +383,15 @@ public class SchemaManagementImpl implements SchemaManagement { OMetadata oMetadata = oDatabaseDocument.getMetadata(); OSchema oSchema = oMetadata.getSchema(); - OClass baseOClass = oSchema.getClass(type); + OClass baseOClass = oSchema.getClass(typeName); - List typeDefinitions = new ArrayList<>(); - typeDefinitions.add(getTypeDefinition(baseOClass)); + List typeDefinitions = new ArrayList<>(); + typeDefinitions.add(getType(baseOClass)); if(includeSubtypes) { Collection subClasses = baseOClass.getAllSubclasses(); for(OClass oClass : subClasses) { - typeDefinitions.add(getTypeDefinition(oClass)); + typeDefinitions.add(getType(oClass)); } } @@ -406,7 +409,7 @@ public class SchemaManagementImpl implements SchemaManagement { @Override public String create(String jsonSchema, AccessType accessType) throws SchemaAlreadyPresentException, SchemaException { - TypeDefinition typeDefinition = null; + Type typeDefinition = null; try { try { typeDefinition = TypeBinder.deserializeTypeDefinition(jsonSchema); @@ -459,18 +462,18 @@ public class SchemaManagementImpl implements SchemaManagement { } @Override - public String read(String entityType, boolean includeSubtypes) throws SchemaNotFoundException, SchemaException { - return getSchema(entityType, includeSubtypes); + public String read(String typeName, boolean includeSubtypes) throws SchemaNotFoundException, SchemaException { + return getSchema(typeName, includeSubtypes); } @Override - public String update(String entityType, AccessType accessType, String jsonSchema) + public String update(String typeName, AccessType accessType, String jsonSchema) throws SchemaNotFoundException, SchemaException { throw new UnsupportedOperationException(); } @Override - public String delete(String entityType, AccessType accessType) throws SchemaNotFoundException { + public String delete(String typeName, AccessType accessType) throws SchemaNotFoundException { throw new UnsupportedOperationException(); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderUtility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderUtility.java index 36b8a8d..4814fce 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderUtility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderUtility.java @@ -9,10 +9,10 @@ import java.util.UUID; import org.gcube.common.authorization.library.provider.AuthorizationProvider; import org.gcube.common.authorization.library.provider.ClientInfo; import org.gcube.common.authorization.library.utils.Caller; -import org.gcube.informationsystem.base.reference.ER; +import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.model.reference.properties.Header; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,8 +74,8 @@ public class HeaderUtility { public static Header getHeader(JsonNode jsonNode, boolean creation) throws JsonParseException, JsonMappingException, IOException { - if(jsonNode.has(ER.HEADER_PROPERTY)) { - JsonNode headerNode = jsonNode.get(ER.HEADER_PROPERTY); + if(jsonNode.has(IdentifiableElement.HEADER_PROPERTY)) { + JsonNode headerNode = jsonNode.get(IdentifiableElement.HEADER_PROPERTY); if(headerNode.isNull()) { return null; } @@ -100,7 +100,7 @@ public class HeaderUtility { } else { try { HeaderOrient headerOrient = new HeaderOrient(); - Header header = ISMapper.unmarshal(Header.class, oDocument.toJSON()); + Header header = ElementMapper.unmarshal(Header.class, oDocument.toJSON()); headerOrient.setUUID(header.getUUID()); headerOrient.setCreator(header.getCreator()); headerOrient.setCreationTime(header.getCreationTime()); @@ -116,27 +116,27 @@ public class HeaderUtility { public static Header addHeader(OElement element, UUID uuid) { Header header = createHeader(uuid); - element.setProperty(ER.HEADER_PROPERTY, header); + element.setProperty(IdentifiableElement.HEADER_PROPERTY, header); return header; } public static Header addHeader(Edge edge, UUID uuid) { Header header = createHeader(uuid); - edge.setProperty(ER.HEADER_PROPERTY, header); + edge.setProperty(IdentifiableElement.HEADER_PROPERTY, header); return header; } public static Header getHeader(OElement element) throws ResourceRegistryException { - return Utility.getPropertyDocument(Header.class, element, ER.HEADER_PROPERTY); + return Utility.getPropertyDocument(Header.class, element, IdentifiableElement.HEADER_PROPERTY); } public static void updateModifiedByAndLastUpdate(OElement element) throws ResourceRegistryException { - ODocument oDocument = element.getProperty(ER.HEADER_PROPERTY); + ODocument oDocument = element.getProperty(IdentifiableElement.HEADER_PROPERTY); String modifiedBy = getUser(); oDocument.field(Header.MODIFIED_BY_PROPERTY, modifiedBy); Date lastUpdateTime = Calendar.getInstance().getTime(); oDocument.field(Header.LAST_UPDATE_TIME_PROPERTY, lastUpdateTime); - element.setProperty(ER.HEADER_PROPERTY, oDocument); + element.setProperty(IdentifiableElement.HEADER_PROPERTY, oDocument); } } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/Utility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/Utility.java index 2e6d8ee..78e0268 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/Utility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/Utility.java @@ -3,7 +3,7 @@ package org.gcube.informationsystem.resourceregistry.utils; import java.util.HashMap; import java.util.UUID; -import org.gcube.informationsystem.base.reference.ER; +import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.base.reference.properties.PropertyElement; import org.gcube.informationsystem.model.reference.entities.Entity; import org.gcube.informationsystem.model.reference.properties.Header; @@ -14,7 +14,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -97,7 +97,7 @@ public class Utility { } // TODO Rewrite using Gremlin - String select = "SELECT FROM " + elementType + " WHERE " + ER.HEADER_PROPERTY + "." + Header.UUID_PROPERTY + String select = "SELECT FROM " + elementType + " WHERE " + IdentifiableElement.HEADER_PROPERTY + "." + Header.UUID_PROPERTY + " = \"" + uuid.toString() + "\""; OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>()); @@ -127,7 +127,7 @@ public class Utility { throws ResourceRegistryException { try { ODocument oDocument = element.getProperty(property); - P e = ISMapper.unmarshal(clz, oDocument.toJSON()); + P e = ElementMapper.unmarshal(clz, oDocument.toJSON()); return e; } catch(Exception ex) { String error = String.format("Error while getting %s from %s", property, toJsonString(element, true)); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/contexts/ContextManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/contexts/ContextManagementTest.java index 6524be6..77db8b7 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/contexts/ContextManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/contexts/ContextManagementTest.java @@ -20,7 +20,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityCo import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.SecurityType; import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagementTest; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; @@ -116,15 +116,15 @@ public class ContextManagementTest extends ContextTest { String contextString = contextManagement.read(); logger.debug("Read {}", contextString); roleUserAssertions(uuid, null, false); - return ISMapper.unmarshal(Context.class, contextString); + return ElementMapper.unmarshal(Context.class, contextString); } protected Context create(Context context) throws ResourceRegistryException, IOException { ContextManagement contextManagement = new ContextManagement(); - contextManagement.setJson(ISMapper.marshal(context)); + contextManagement.setJson(ElementMapper.marshal(context)); String contextString = contextManagement.create(); logger.debug("Created {}", contextString); - Context c = ISMapper.unmarshal(Context.class, contextString); + Context c = ElementMapper.unmarshal(Context.class, contextString); assertions(context, c, true, true); roleUserAssertions(c.getHeader().getUUID(), null, false); return c; @@ -132,10 +132,10 @@ public class ContextManagementTest extends ContextTest { protected Context update(Context context) throws ResourceRegistryException, IOException { ContextManagement contextManagement = new ContextManagement(); - contextManagement.setJson(ISMapper.marshal(context)); + contextManagement.setJson(ElementMapper.marshal(context)); String contextString = contextManagement.update(); logger.debug("Updated {}", contextString); - Context c = ISMapper.unmarshal(Context.class, contextString); + Context c = ElementMapper.unmarshal(Context.class, contextString); assertions(context, c, true, false); roleUserAssertions(c.getHeader().getUUID(), null, false); return c; @@ -166,23 +166,23 @@ public class ContextManagementTest extends ContextTest { protected void invalidCreate(Context context) throws ResourceRegistryException, IOException { try { Context c = create(context); - throw new RuntimeException(ISMapper.marshal(c) + " was created successfully. This is not what we expected"); + throw new RuntimeException(ElementMapper.marshal(c) + " was created successfully. This is not what we expected"); } catch(ContextAlreadyPresentException e) { - logger.debug("As expected {} cannot be created.", ISMapper.marshal(context)); + logger.debug("As expected {} cannot be created.", ElementMapper.marshal(context)); } } protected void invalidUpdate(Context context) throws ResourceRegistryException, IOException { try { Context c = update(context); - throw new RuntimeException(ISMapper.marshal(c) + " was updated successfully. This is not what we expected"); + throw new RuntimeException(ElementMapper.marshal(c) + " was updated successfully. This is not what we expected"); } catch(ContextAlreadyPresentException e) { - logger.debug("As expected {} cannot be updated.", ISMapper.marshal(context)); + logger.debug("As expected {} cannot be updated.", ElementMapper.marshal(context)); } } protected void invalidDelete(Context context) throws ResourceRegistryException, JsonProcessingException { - String contextString = ISMapper.marshal(context); + String contextString = ElementMapper.marshal(context); try { delete(context); throw new RuntimeException(contextString + " was deleted successfully. This is not what we expected"); @@ -415,7 +415,7 @@ public class ContextManagementTest extends ContextTest { ContextManagement contextManagement = new ContextManagement(); String allString = contextManagement.all(false); logger.trace(allString); - List all = ISMapper.unmarshalList(Context.class, allString); + List all = ElementMapper.unmarshalList(Context.class, allString); return all; } @@ -440,7 +440,7 @@ public class ContextManagementTest extends ContextTest { public void testGetAll() throws Exception { List contexts = getAll(); for(Context context : contexts) { - logger.trace(ISMapper.marshal(context)); + logger.trace(ElementMapper.marshal(context)); List children = context.getChildren(); for(IsParentOf child : children) { Assert.assertTrue(child.getSource() == context); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/AbstractERManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/AbstractERManagementTest.java index bd66d31..f4c0c86 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/AbstractERManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/AbstractERManagementTest.java @@ -1,9 +1,9 @@ package org.gcube.informationsystem.resourceregistry.instances; -import org.gcube.informationsystem.base.reference.ER; +import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; -public abstract class AbstractERManagementTest { +public abstract class AbstractERManagementTest { public abstract Er create(Er er) throws ResourceRegistryException; diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/DiscoveryTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/DiscoveryTest.java index c751260..2448944 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/DiscoveryTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/DiscoveryTest.java @@ -7,7 +7,7 @@ import java.util.ServiceLoader; import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.types.TypeBinder; -import org.gcube.informationsystem.utils.discovery.ISMDiscovery; +import org.gcube.informationsystem.utils.discovery.ElementSpecilizationDiscovery; import org.gcube.informationsystem.utils.discovery.RegistrationProvider; import org.junit.Test; import org.slf4j.Logger; @@ -27,7 +27,7 @@ public class DiscoveryTest { } Package[] packagesArray = packages.stream().toArray(Package[]::new); - ISMDiscovery resourceDiscovery = new ISMDiscovery<>(Resource.class); + ElementSpecilizationDiscovery resourceDiscovery = new ElementSpecilizationDiscovery<>(Resource.class); Arrays.stream(packagesArray).forEach(p -> resourceDiscovery.addPackage(p)); resourceDiscovery.discover(); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/ERManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/ERManagementTest.java index 04fd93f..2266f1c 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/ERManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/ERManagementTest.java @@ -37,7 +37,7 @@ import org.gcube.informationsystem.resourceregistry.instances.model.entities.Fac import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement; import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.informationsystem.utils.Utility; import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl; import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl; @@ -102,7 +102,7 @@ public class ERManagementTest extends ContextTest { FacetManagement facetManagement = new FacetManagement(); facetManagement.setElementType(CPUFacet.NAME); - String json = ISMapper.marshal(cpuFacet); + String json = ElementMapper.marshal(cpuFacet); logger.debug("{}", json); facetManagement.setJson(json); @@ -138,7 +138,7 @@ public class ERManagementTest extends ContextTest { encrypted.setEncryptedValue(encryptedValue); accessPointFacet.setAdditionalProperty("Enc", encrypted); - String marshalled = ISMapper.marshal(accessPointFacet); + String marshalled = ElementMapper.marshal(accessPointFacet); logger.debug(marshalled); FacetManagement facetManagement = new FacetManagement(); @@ -147,7 +147,7 @@ public class ERManagementTest extends ContextTest { String createdJson = facetManagement.create(); logger.debug("Created:\nRaw Json : {}", createdJson); - AccessPointFacet apf = ISMapper.unmarshal(AccessPointFacet.class, createdJson); + AccessPointFacet apf = ElementMapper.unmarshal(AccessPointFacet.class, createdJson); Assert.assertTrue(apf.getAuthorization() instanceof ValueSchema); Assert.assertTrue(apf.getAdditionalProperty("Enc") instanceof Encrypted); @@ -218,11 +218,11 @@ public class ERManagementTest extends ContextTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setElementType(EService.NAME); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); String json = resourceManagement.create(); logger.debug("Created : {}", json); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); logger.debug("Unmarshalled {} {}", EService.NAME, eService); resourceManagement = new ResourceManagement(); @@ -260,7 +260,7 @@ public class ERManagementTest extends ContextTest { FacetManagement facetManagement = new FacetManagement(); facetManagement.setElementType(StateFacet.NAME); - String json = ISMapper.marshal(stateFacet); + String json = ElementMapper.marshal(stateFacet); logger.debug(json); facetManagement.setJson(json); @@ -273,7 +273,7 @@ public class ERManagementTest extends ContextTest { FacetManagement facetManagement = new FacetManagement(); facetManagement.setElementType(ContactFacet.NAME); - facetManagement.setJson(ISMapper.marshal(simpleFacet)); + facetManagement.setJson(ElementMapper.marshal(simpleFacet)); facetManagement.create(); } @@ -291,10 +291,10 @@ public class ERManagementTest extends ContextTest { FacetManagement facetManagement = new FacetManagement(); facetManagement.setElementType(CPUFacet.NAME); - facetManagement.setJson(ISMapper.marshal(cpuFacet)); + facetManagement.setJson(ElementMapper.marshal(cpuFacet)); String cpuFacetJson = facetManagement.create(); - CPUFacet createdCpuFacet = ISMapper.unmarshal(CPUFacet.class, + CPUFacet createdCpuFacet = ElementMapper.unmarshal(CPUFacet.class, cpuFacetJson); logger.debug("Created:\nRaw Json : {}\nUnmarshalled : {}", cpuFacetJson, createdCpuFacet); @@ -312,7 +312,7 @@ public class ERManagementTest extends ContextTest { facetManagement.setUUID(uuid); String readJson = facetManagement.read(); - CPUFacet readCpuFacet = ISMapper.unmarshal(CPUFacet.class, readJson); + CPUFacet readCpuFacet = ElementMapper.unmarshal(CPUFacet.class, readJson); logger.debug("Read:\nRaw Json : {}\nUnmarshalled : {}", readJson, readCpuFacet); Assert.assertTrue(cpuFacet.getClockSpeed().compareTo( @@ -337,10 +337,10 @@ public class ERManagementTest extends ContextTest { facetManagement = new FacetManagement(); facetManagement.setUUID(uuid); - facetManagement.setJson(ISMapper.marshal(readCpuFacet)); + facetManagement.setJson(ElementMapper.marshal(readCpuFacet)); String updatedJson = facetManagement.update(); - CPUFacet updatedCpuFacet = ISMapper.unmarshal(CPUFacet.class, + CPUFacet updatedCpuFacet = ElementMapper.unmarshal(CPUFacet.class, updatedJson); logger.debug("Updated:\nRaw Json : {}\nUnmarshalled : {}", updatedJson, updatedCpuFacet); @@ -363,7 +363,7 @@ public class ERManagementTest extends ContextTest { facetManagement.setUUID(uuid); String readUpdatedJson = facetManagement.read(); - CPUFacet readUpdatedCpuFacet = ISMapper.unmarshal(CPUFacet.class, + CPUFacet readUpdatedCpuFacet = ElementMapper.unmarshal(CPUFacet.class, readUpdatedJson); logger.debug("Read Updated:\nRaw Json : {}\nUnmarshalled : {}", readUpdatedJson, readUpdatedCpuFacet); @@ -403,11 +403,11 @@ public class ERManagementTest extends ContextTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setElementType(EService.NAME); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); String json = resourceManagement.create(); logger.debug("Created : {}", json); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); logger.debug("Unmarshalled {} {}", EService.NAME, eService); map.put(EService.NAME, eService); @@ -442,11 +442,11 @@ public class ERManagementTest extends ContextTest { resourceManagement = new ResourceManagement(); resourceManagement.setElementType(HostingNode.NAME); - resourceManagement.setJson(ISMapper.marshal(hostingNode)); + resourceManagement.setJson(ElementMapper.marshal(hostingNode)); json = resourceManagement.create(); logger.debug("Created : {}", json); - hostingNode = ISMapper.unmarshal(HostingNode.class, json); + hostingNode = ElementMapper.unmarshal(HostingNode.class, json); logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode); map.put(HostingNode.NAME, hostingNode); @@ -486,7 +486,7 @@ public class ERManagementTest extends ContextTest { try { ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement(); - String json = ISMapper.marshal(consistsOf); + String json = ElementMapper.marshal(consistsOf); json = json.replaceAll(SimpleFacet.NAME, EService.NAME); consistsOfManagement.setJson(json); @@ -525,7 +525,7 @@ public class ERManagementTest extends ContextTest { consistsOfManagement.setElementType(ConsistsOf.NAME); consistsOfManagement.setJson("{}"); ConsistsOf consistsOf = new ConsistsOfImpl<>(eService, shared, null); - consistsOfManagement.setJson(ISMapper.marshal(consistsOf)); + consistsOfManagement.setJson(ElementMapper.marshal(consistsOf)); String json = consistsOfManagement.create(); logger.debug("Created : {}", json); @@ -560,7 +560,7 @@ public class ERManagementTest extends ContextTest { resourceManagement.setJson("{}"); String json = resourceManagement.create(); - HostingNode hostingNode = ISMapper.unmarshal(HostingNode.class, json); + HostingNode hostingNode = ElementMapper.unmarshal(HostingNode.class, json); UUID resourceUUID = hostingNode.getHeader().getUUID(); CPUFacet cpuFacet = new CPUFacetImpl(); @@ -569,15 +569,15 @@ public class ERManagementTest extends ContextTest { cpuFacet.setVendor("AMD"); FacetManagement facetManagement = new FacetManagement(); - facetManagement.setJson(ISMapper.marshal(cpuFacet)); + facetManagement.setJson(ElementMapper.marshal(cpuFacet)); facetManagement.setElementType(CPUFacet.NAME); json = facetManagement.create(); - CPUFacet createdCPUFacet = ISMapper.unmarshal(CPUFacet.class, json); + CPUFacet createdCPUFacet = ElementMapper.unmarshal(CPUFacet.class, json); ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement(); consistsOfManagement.setElementType(ConsistsOf.NAME); ConsistsOf consistsOf = new ConsistsOfImpl<>(hostingNode, createdCPUFacet, null); - consistsOfManagement.setJson(ISMapper.marshal(consistsOf)); + consistsOfManagement.setJson(ElementMapper.marshal(consistsOf)); json = consistsOfManagement.create(); logger.debug("Facet attached : {}", json); @@ -631,7 +631,7 @@ public class ERManagementTest extends ContextTest { ResourceManagement resourceManagement = (ResourceManagement) ElementManagementUtility.getERManagement(key); String json = resourceManagement.all(false); - List list = ISMapper.unmarshalList(Resource.class, json); + List list = ElementMapper.unmarshalList(Resource.class, json); logger.debug("{} are {} : {} ", key, list.size(), list); Assert.assertTrue(list.size()==MAX); } @@ -642,13 +642,13 @@ public class ERManagementTest extends ContextTest { ResourceManagement resourceManagement = (ResourceManagement) ElementManagementUtility.getERManagement(Resource.NAME); String json = resourceManagement.all(true); - List list = ISMapper.unmarshalList(Resource.class, json); + List list = ElementMapper.unmarshalList(Resource.class, json); logger.debug("{} are {} : {} ", Resource.NAME, list.size(), list); Assert.assertTrue(list.size()==(MAX*typeNumber)); json = resourceManagement.all(false); - list = ISMapper.unmarshalList(Resource.class, json); + list = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(list.size()==0); @@ -658,13 +658,13 @@ public class ERManagementTest extends ContextTest { json = isRelatedToManagement.all(true); - List resourcesList = ISMapper.unmarshalList(Resource.class, json); + List resourcesList = ElementMapper.unmarshalList(Resource.class, json); logger.debug("{} are {} : {} ", IsRelatedTo.NAME, resourcesList.size(), resourcesList); Assert.assertTrue(resourcesList.size()==MAX); json = isRelatedToManagement.all(false); - resourcesList = ISMapper.unmarshalList(Resource.class, json); + resourcesList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourcesList.size()==0); @@ -675,12 +675,12 @@ public class ERManagementTest extends ContextTest { ConsistsOfManagement consistsOfManagement = (ConsistsOfManagement) ElementManagementUtility.getERManagement(ConsistsOf.NAME); json = consistsOfManagement.all(true); - List consistsOfPolimorphicList = ISMapper.unmarshalList(Resource.class, json); + List consistsOfPolimorphicList = ElementMapper.unmarshalList(Resource.class, json); logger.debug("{} are {} : {} ", IsRelatedTo.NAME, consistsOfPolimorphicList.size(), consistsOfPolimorphicList); json = consistsOfManagement.all(false); - List consistsOfNonPolimorphicList = ISMapper.unmarshalList(Resource.class, json); + List consistsOfNonPolimorphicList = ElementMapper.unmarshalList(Resource.class, json); logger.debug("{} are {} : {} ", IsRelatedTo.NAME, consistsOfNonPolimorphicList.size(), consistsOfNonPolimorphicList); Assert.assertTrue(consistsOfPolimorphicList.size()>=consistsOfNonPolimorphicList.size()); @@ -716,31 +716,31 @@ public class ERManagementTest extends ContextTest { /* Getting Hosting Node */ String json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, true, null); - List resourceList = ISMapper.unmarshalList(Resource.class, json); + List resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==1); Resource resource = resourceList.get(0); Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID)==0); json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, true, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==1); resource = resourceList.get(0); Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID)==0); json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, true, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, false, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, false, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, false, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); /* END Getting Hosting Node */ @@ -748,29 +748,29 @@ public class ERManagementTest extends ContextTest { /* Getting EService */ json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, true, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==1); Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID)==0); json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, true, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, true, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==1); Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID)==0); json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, false, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, false, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, false, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); /* END Getting HostingNode */ @@ -786,7 +786,7 @@ public class ERManagementTest extends ContextTest { } json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, true, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==1); resource = resourceList.get(0); Facet targetIdentificationFacet = ((GCubeResource) resource).getIdentificationFacets().get(0); @@ -807,7 +807,7 @@ public class ERManagementTest extends ContextTest { } json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, false, null); - resourceList = ISMapper.unmarshalList(Resource.class, json); + resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size()==0); try { @@ -837,11 +837,11 @@ public class ERManagementTest extends ContextTest { logger.debug("{}", file.getAbsolutePath()); FileInputStream fileInputStream = new FileInputStream(file); - EService eService = ISMapper.unmarshal(EService.class, fileInputStream); + EService eService = ElementMapper.unmarshal(EService.class, fileInputStream); ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setUUID(eService.getHeader().getUUID()); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); resourceManagement.update(); @@ -856,12 +856,12 @@ public class ERManagementTest extends ContextTest { String res = resourceManagement.read(); logger.debug(res); - Configuration configuration = ISMapper.unmarshal(Configuration.class, res); + Configuration configuration = ElementMapper.unmarshal(Configuration.class, res); resourceManagement = new ResourceManagement(); resourceManagement.setUUID(configuration.getHeader().getUUID()); - resourceManagement.setJson(ISMapper.marshal(configuration)); + resourceManagement.setJson(ElementMapper.marshal(configuration)); resourceManagement.update(); @@ -907,22 +907,22 @@ public class ERManagementTest extends ContextTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setElementType(EService.NAME); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); String json = resourceManagement.create(); logger.trace("Created {}", json); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); final String newVersion = "1.2.0"; eService.getFacets(SoftwareFacet.class).get(0).setVersion(newVersion); resourceManagement = new ResourceManagement(); resourceManagement.setUUID(eService.getHeader().getUUID()); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); json = resourceManagement.update(); logger.trace("Updated {}", json); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); Assert.assertTrue(eService.getFacets(SoftwareFacet.class).get(0).getVersion().compareTo(newVersion)==0); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/SmartgearResourcesTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/SmartgearResourcesTest.java index 12dfba8..3b75888 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/SmartgearResourcesTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/SmartgearResourcesTest.java @@ -34,7 +34,7 @@ import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.resourceregistry.ContextTest; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl; import org.gcube.resourcemanagement.model.impl.entities.facets.ContainerStateFacetImpl; import org.gcube.resourcemanagement.model.impl.entities.facets.MemoryFacetImpl; @@ -80,7 +80,7 @@ public class SmartgearResourcesTest extends ContextTest { @Test public void testHostingNode() throws JsonParseException, JsonMappingException, IOException, ResourceRegistryException { - HostingNode hostingNode = ISMapper.unmarshal(HostingNode.class, + HostingNode hostingNode = ElementMapper.unmarshal(HostingNode.class, HOSTING_NODE); logger.debug("{}", hostingNode); @@ -90,7 +90,7 @@ public class SmartgearResourcesTest extends ContextTest { String hnJson = resourceManagement.create(); logger.debug("Created : {}", hnJson); - hostingNode = ISMapper.unmarshal(HostingNode.class, hnJson); + hostingNode = ElementMapper.unmarshal(HostingNode.class, hnJson); logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode); UUID hnUUID = hostingNode.getHeader().getUUID(); @@ -98,7 +98,7 @@ public class SmartgearResourcesTest extends ContextTest { resourceManagement = new ResourceManagement(); resourceManagement.setUUID(hnUUID); String read = resourceManagement.read(); - HostingNode readHN = ISMapper.unmarshal(HostingNode.class, read); + HostingNode readHN = ElementMapper.unmarshal(HostingNode.class, read); logger.debug("Read {} {}", HostingNode.NAME, readHN); Assert.assertTrue(hnUUID.compareTo(readHN.getHeader().getUUID()) == 0); @@ -123,7 +123,7 @@ public class SmartgearResourcesTest extends ContextTest { @Test public void testEService() throws JsonParseException, JsonMappingException, IOException, ResourceRegistryException { - EService eService = ISMapper.unmarshal(EService.class, ESERVICE); + EService eService = ElementMapper.unmarshal(EService.class, ESERVICE); logger.debug("{}", eService); ResourceManagement resourceManagement = new ResourceManagement(); @@ -131,7 +131,7 @@ public class SmartgearResourcesTest extends ContextTest { resourceManagement.setJson(ESERVICE); String json = resourceManagement.create(); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); logger.debug("Created {} {}", EService.NAME, eService); UUID eServiceUUID = eService.getHeader().getUUID(); @@ -139,7 +139,7 @@ public class SmartgearResourcesTest extends ContextTest { resourceManagement = new ResourceManagement(); resourceManagement.setUUID(eServiceUUID); String read = resourceManagement.read(); - EService readEService = ISMapper.unmarshal(EService.class, read); + EService readEService = ElementMapper.unmarshal(EService.class, read); logger.debug("Read {} {}", EService.NAME, readEService); Assert.assertTrue(eServiceUUID.compareTo(readEService.getHeader() @@ -231,11 +231,11 @@ public class SmartgearResourcesTest extends ContextTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setElementType(HostingNode.NAME); - resourceManagement.setJson(ISMapper.marshal(hostingNode)); + resourceManagement.setJson(ElementMapper.marshal(hostingNode)); String json = resourceManagement.create(); - HostingNode hostingNodeToUpdate = ISMapper.unmarshal(HostingNode.class, + HostingNode hostingNodeToUpdate = ElementMapper.unmarshal(HostingNode.class, json); @@ -317,12 +317,12 @@ public class SmartgearResourcesTest extends ContextTest { resourceManagement = new ResourceManagement(); resourceManagement.setUUID(uuid); - resourceManagement.setJson(ISMapper.marshal(hostingNodeToUpdate)); + resourceManagement.setJson(ElementMapper.marshal(hostingNodeToUpdate)); String updatedHN = resourceManagement.update(); logger.debug("Updated {}", updatedHN); - HostingNode updatedHostingNode = ISMapper.unmarshal(HostingNode.class, + HostingNode updatedHostingNode = ElementMapper.unmarshal(HostingNode.class, updatedHN); logger.debug("Updated Hosting Node {}", updatedHostingNode); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/FacetManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/FacetManagementTest.java index 67d4855..9b7f837 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/FacetManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/FacetManagementTest.java @@ -2,7 +2,7 @@ package org.gcube.informationsystem.resourceregistry.instances.model.entity; import java.util.UUID; -import org.gcube.informationsystem.base.reference.ER; +import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.model.reference.entities.Facet; import org.gcube.informationsystem.resourceregistry.ContextTest; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException; @@ -13,7 +13,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest; import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement; import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl; import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet; import org.junit.Assert; @@ -47,7 +47,7 @@ public class FacetManagementTest extends ContextTest { Assert.assertTrue(softwareFacet.getVersion().compareTo(version) == 0); } - public static void checkHeader(ER er, UUID uuid, boolean create) { + public static void checkHeader(IdentifiableElement er, UUID uuid, boolean create) { Assert.assertTrue(er.getHeader() != null); Assert.assertTrue(er.getHeader().getUUID() != null); @@ -72,14 +72,14 @@ public class FacetManagementTest extends ContextTest { protected F create(F facet) throws Exception { FacetManagement facetManagement = new FacetManagement(); - String facetType = Utility.getType(facet); + String facetType = Utility.getTypeName(facet); facetManagement.setElementType(facetType); - facetManagement.setJson(ISMapper.marshal(facet)); + facetManagement.setJson(ElementMapper.marshal(facet)); String json = facetManagement.create(); logger.debug("Created : {}", json); @SuppressWarnings("unchecked") - F createdFacet = (F) ISMapper.unmarshal(facet.getClass(), json); + F createdFacet = (F) ElementMapper.unmarshal(facet.getClass(), json); logger.debug("Unmarshalled {}", createdFacet); UUID uuid = null; @@ -92,14 +92,14 @@ public class FacetManagementTest extends ContextTest { protected F update(F facet) throws Exception { FacetManagement facetManagement = new FacetManagement(); - String facetType = Utility.getType(facet); + String facetType = Utility.getTypeName(facet); facetManagement.setElementType(facetType); - facetManagement.setJson(ISMapper.marshal(facet)); + facetManagement.setJson(ElementMapper.marshal(facet)); String json = facetManagement.update(); logger.debug("Updated : {}", json); @SuppressWarnings("unchecked") - F updatedFacet = (F) ISMapper.unmarshal(facet.getClass(), json); + F updatedFacet = (F) ElementMapper.unmarshal(facet.getClass(), json); logger.debug("Unmarshalled {}", updatedFacet); UUID uuid = facet.getHeader().getUUID(); @@ -112,14 +112,14 @@ public class FacetManagementTest extends ContextTest { UUID uuid = facet.getHeader().getUUID(); FacetManagement facetManagement = new FacetManagement(); - String facetType = Utility.getType(facet); + String facetType = Utility.getTypeName(facet); facetManagement.setElementType(facetType); facetManagement.setUUID(uuid); String json = facetManagement.read(); logger.debug("Read : {}", json); @SuppressWarnings("unchecked") - F readFacet = (F) ISMapper.unmarshal(facet.getClass(), json); + F readFacet = (F) ElementMapper.unmarshal(facet.getClass(), json); logger.debug("Unmarshalled {}", readFacet); checkAssertion(readFacet, uuid, false); @@ -129,7 +129,7 @@ public class FacetManagementTest extends ContextTest { protected boolean delete(F facet) throws Exception { FacetManagement facetManagement = new FacetManagement(); - String facetType = Utility.getType(facet); + String facetType = Utility.getTypeName(facet); facetManagement.setElementType(facetType); facetManagement.setUUID(facet.getHeader().getUUID()); @@ -147,7 +147,7 @@ public class FacetManagementTest extends ContextTest { protected boolean addToContext(F facet) throws Exception { FacetManagement facetManagement = new FacetManagement(); - String facetType = Utility.getType(facet); + String facetType = Utility.getTypeName(facet); facetManagement.setElementType(facetType); facetManagement.setUUID(facet.getHeader().getUUID()); @@ -159,7 +159,7 @@ public class FacetManagementTest extends ContextTest { protected boolean removeFromContext(F facet) throws Exception { FacetManagement facetManagement = new FacetManagement(); - String facetType = Utility.getType(facet); + String facetType = Utility.getTypeName(facet); facetManagement.setElementType(facetType); facetManagement.setUUID(facet.getHeader().getUUID()); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/ResourceManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/ResourceManagementTest.java index fb8bd0b..74f8a1f 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/ResourceManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/ResourceManagementTest.java @@ -11,7 +11,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl; import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl; import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet; @@ -51,10 +51,10 @@ public class ResourceManagementTest extends ContextTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setElementType(EService.NAME); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); String json = resourceManagement.create(); logger.trace("Created {}", json); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); checkAssertion(eService, null, true); FacetManagementTest.checkSoftwareFacetAssertion(softwareFacet, FacetManagementTest.VERSION); @@ -68,11 +68,11 @@ public class ResourceManagementTest extends ContextTest { resourceManagement = new ResourceManagement(); resourceManagement.setUUID(eService.getHeader().getUUID()); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); json = resourceManagement.update(); logger.trace("Updated {}", json); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); checkAssertion(eService, uuid, false); softwareFacet = eService.getFacets(SoftwareFacet.class).get(0); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/BasicTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/BasicTest.java index 638a407..30cfa3d 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/BasicTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/BasicTest.java @@ -25,7 +25,7 @@ import org.gcube.informationsystem.resourceregistry.instances.SmartgearResources import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement; import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl; import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl; import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl; @@ -77,13 +77,13 @@ public class BasicTest extends ContextTest { cpuFacet.setVendor("AMD"); FacetManagement facetManagement = new FacetManagement(); - facetManagement.setJson(ISMapper.marshal(cpuFacet)); + facetManagement.setJson(ElementMapper.marshal(cpuFacet)); facetManagement.setElementType(CPUFacet.NAME); String json = facetManagement.create(); logger.debug("Created : {}", json); - CPUFacet createdCPUFacet = ISMapper.unmarshal(CPUFacet.class, json); + CPUFacet createdCPUFacet = ElementMapper.unmarshal(CPUFacet.class, json); UUID uuid = createdCPUFacet.getHeader().getUUID(); facetManagement = new FacetManagement(); @@ -126,7 +126,7 @@ public class BasicTest extends ContextTest { try { facetManagement = new FacetManagement(); facetManagement.setUUID(uuid); - facetManagement.setJson(ISMapper.marshal(cpuFacet)); + facetManagement.setJson(ElementMapper.marshal(cpuFacet)); readJson = facetManagement.update(); logger.debug("You should not be able to update Facet with UUID {}", uuid); @@ -143,7 +143,7 @@ public class BasicTest extends ContextTest { facetManagement = new FacetManagement(); facetManagement.setUUID(uuid); - facetManagement.setJson(ISMapper.marshal(cpuFacet)); + facetManagement.setJson(ElementMapper.marshal(cpuFacet)); readJson = facetManagement.update(); logger.debug("Updated : {}", readJson); @@ -195,11 +195,11 @@ public class BasicTest extends ContextTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setElementType(EService.NAME); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); String json = resourceManagement.create(); logger.debug("Created : {}", json); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); logger.debug("Unmarshalled {} {}", EService.NAME, eService); @@ -246,11 +246,11 @@ public class BasicTest extends ContextTest { resourceManagement = new ResourceManagement(); resourceManagement.setElementType(HostingNode.NAME); - resourceManagement.setJson(ISMapper.marshal(hostingNode)); + resourceManagement.setJson(ElementMapper.marshal(hostingNode)); String hnJson = resourceManagement.create(); logger.debug("Created : {}", hnJson); - hostingNode = ISMapper.unmarshal(HostingNode.class, hnJson); + hostingNode = ElementMapper.unmarshal(HostingNode.class, hnJson); logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode); UUID uuid = hostingNode.getHeader().getUUID(); @@ -269,7 +269,7 @@ public class BasicTest extends ContextTest { resourceManagement.setUUID(uuid); String hnString = resourceManagement.read(); - HostingNode readHN = ISMapper.unmarshal(HostingNode.class, hnString); + HostingNode readHN = ElementMapper.unmarshal(HostingNode.class, hnString); Assert.assertTrue(readHN.getHeader().getUUID().compareTo(uuid) == 0); UUID eServiceUUID = eService.getHeader().getUUID(); @@ -334,7 +334,7 @@ public class BasicTest extends ContextTest { String hnJson = resourceManagement.create(); logger.debug("Created : {}", hnJson); - HostingNode hostingNode = ISMapper.unmarshal(HostingNode.class, hnJson); + HostingNode hostingNode = ElementMapper.unmarshal(HostingNode.class, hnJson); logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode); UUID hnUUID = hostingNode.getHeader().getUUID(); @@ -348,7 +348,7 @@ public class BasicTest extends ContextTest { String eservicejson = resourceManagement.create(); logger.debug("Created : {}", eservicejson); - EService eService = ISMapper.unmarshal(EService.class, eservicejson); + EService eService = ElementMapper.unmarshal(EService.class, eservicejson); logger.debug("Unmarshalled {} {}", EService.NAME, eService); UUID eServiceUUID = eService.getHeader().getUUID(); @@ -368,13 +368,13 @@ public class BasicTest extends ContextTest { IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement(); isRelatedToManagement.setElementType(Activates.NAME); - String activatesJson = ISMapper.marshal(activates); + String activatesJson = ElementMapper.marshal(activates); isRelatedToManagement.setJson(activatesJson); String createdActivatesJson = isRelatedToManagement.create(); logger.debug("Created : {}", createdActivatesJson); @SuppressWarnings("unchecked") - Activates createdActivates = ISMapper.unmarshal(Activates.class, createdActivatesJson); + Activates createdActivates = ElementMapper.unmarshal(Activates.class, createdActivatesJson); UUID activatesUUID = createdActivates.getHeader().getUUID(); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/RuleTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/RuleTest.java index 3e4ca44..4755bd5 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/RuleTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/RuleTest.java @@ -8,7 +8,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet. import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAlreadyPresentException; import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement; import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl; import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl; import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl; @@ -38,11 +38,11 @@ public class RuleTest extends ContextTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setElementType(EService.NAME); - resourceManagement.setJson(ISMapper.marshal(eService)); + resourceManagement.setJson(ElementMapper.marshal(eService)); String json = resourceManagement.create(); logger.debug("Created : {}", json); - eService = ISMapper.unmarshal(EService.class, json); + eService = ElementMapper.unmarshal(EService.class, json); logger.debug("Unmarshalled {} {}", EService.NAME, eService); return eService; @@ -54,7 +54,7 @@ public class RuleTest extends ContextTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setUUID(eServiceUUID); String json = resourceManagement.read(); - EService readEService = ISMapper.unmarshal(EService.class, json); + EService readEService = ElementMapper.unmarshal(EService.class, json); Assert.assertTrue(readEService.getHeader().getUUID().compareTo(eServiceUUID) == 0); return eServiceUUID; @@ -67,7 +67,7 @@ public class RuleTest extends ContextTest { FacetManagement facetManagement = new FacetManagement(); facetManagement.setUUID(softwareFacetUUID); String json = facetManagement.read(); - SoftwareFacet readSoftwareFacet = ISMapper.unmarshal(SoftwareFacet.class, json); + SoftwareFacet readSoftwareFacet = ElementMapper.unmarshal(SoftwareFacet.class, json); Assert.assertTrue(readSoftwareFacet.getHeader().getUUID().compareTo(softwareFacetUUID) == 0); return softwareFacetUUID; @@ -83,7 +83,7 @@ public class RuleTest extends ContextTest { UUID softwareFacetUUID = checkFacetCreation(eService); SoftwareFacet softwareFacet = (SoftwareFacet) eService.getIdentificationFacets().get(0); - String softwareFacetString = ISMapper.marshal(softwareFacet); + String softwareFacetString = ElementMapper.marshal(softwareFacet); // Trying to recreate SoftwareFacet FacetManagement softwareFacetManagement = new FacetManagement(); @@ -100,7 +100,7 @@ public class RuleTest extends ContextTest { // Trying to recreate EService - String eServiceString = ISMapper.marshal(eService); + String eServiceString = ElementMapper.marshal(eService); ResourceManagement eServiceManagement = new ResourceManagement(); eServiceManagement.setElementType(EService.NAME); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImplTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImplTest.java index 3dd5f3d..e195d1a 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImplTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImplTest.java @@ -24,11 +24,11 @@ import org.gcube.informationsystem.types.TypeBinder; import org.gcube.informationsystem.types.impl.entities.EntityTypeImpl; import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl; import org.gcube.informationsystem.types.impl.relations.RelationTypeImpl; -import org.gcube.informationsystem.types.reference.TypeDefinition; +import org.gcube.informationsystem.types.reference.Type; import org.gcube.informationsystem.types.reference.entities.EntityType; import org.gcube.informationsystem.types.reference.properties.PropertyType; import org.gcube.informationsystem.types.reference.relations.RelationType; -import org.gcube.informationsystem.utils.ISMapper; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.resourcemanagement.model.reference.entities.facets.AccessPointFacet; import org.gcube.resourcemanagement.model.reference.entities.facets.ContactFacet; import org.gcube.resourcemanagement.model.reference.entities.resources.Actor; @@ -73,7 +73,7 @@ public class SchemaManagementImplTest { public void getFacetSchema() throws Exception { String json = new SchemaManagementImpl().read(ContactFacet.NAME, false); logger.info(json); - List typeDefinitions = TypeBinder.deserializeTypeDefinitions(json); + List typeDefinitions = TypeBinder.deserializeTypeDefinitions(json); logger.info("{}", typeDefinitions); } @@ -194,7 +194,7 @@ public class SchemaManagementImplTest { SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(ValueSchema.NAME); - String ret = schemaManagement.create(ISMapper.marshal(propertyTypeDefinition), AccessType.PROPERTY); + String ret = schemaManagement.create(ElementMapper.marshal(propertyTypeDefinition), AccessType.PROPERTY); logger.debug(ret); @@ -206,7 +206,7 @@ public class SchemaManagementImplTest { SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(Encrypted.NAME); - String ret = schemaManagement.create(ISMapper.marshal(propertyTypeDefinition), AccessType.PROPERTY); + String ret = schemaManagement.create(ElementMapper.marshal(propertyTypeDefinition), AccessType.PROPERTY); logger.debug(ret); @@ -218,7 +218,7 @@ public class SchemaManagementImplTest { SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(Context.NAME); - String ret = schemaManagement.create(ISMapper.marshal(entityTypeDefinition), AccessType.ENTITY_ELEMENT); + String ret = schemaManagement.create(ElementMapper.marshal(entityTypeDefinition), AccessType.ENTITY_ELEMENT); logger.debug(ret); @@ -230,7 +230,7 @@ public class SchemaManagementImplTest { SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(AccessPointFacet.NAME); - String ret = schemaManagement.create(ISMapper.marshal(entityTypeDefinition), AccessType.FACET); + String ret = schemaManagement.create(ElementMapper.marshal(entityTypeDefinition), AccessType.FACET); logger.debug(ret); @@ -242,7 +242,7 @@ public class SchemaManagementImplTest { SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(EService.NAME); - String ret = schemaManagement.create(ISMapper.marshal(entityTypeDefinition), AccessType.RESOURCE); + String ret = schemaManagement.create(ElementMapper.marshal(entityTypeDefinition), AccessType.RESOURCE); logger.debug(ret); @@ -250,7 +250,7 @@ public class SchemaManagementImplTest { schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(RunningPlugin.NAME); - ret = schemaManagement.create(ISMapper.marshal(entityTypeDefinition), AccessType.RESOURCE); + ret = schemaManagement.create(ElementMapper.marshal(entityTypeDefinition), AccessType.RESOURCE); logger.debug(ret); @@ -264,7 +264,7 @@ public class SchemaManagementImplTest { SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(RelationType.NAME); - String ret = ISMapper.marshal(relationTypeDefinition); + String ret = ElementMapper.marshal(relationTypeDefinition); //String ret = schemaManagement.create(ISMapper.marshal(relationTypeDefinition), AccessType.BASE_RELATION);