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