Refs #11288: Made resource-registry more RESTful
Task-Url: https://support.d4science.org/issues/11288 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@168993 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
047f1a678d
commit
cba560a6e8
|
@ -46,7 +46,7 @@ public class ContextManagement extends EntityManagement<Context> {
|
||||||
private void init() {
|
private void init() {
|
||||||
this.ignoreStartWithKeys.add(Context.PARENT_PROPERTY);
|
this.ignoreStartWithKeys.add(Context.PARENT_PROPERTY);
|
||||||
this.ignoreStartWithKeys.add(Context.CHILDREN_PROPERTY);
|
this.ignoreStartWithKeys.add(Context.CHILDREN_PROPERTY);
|
||||||
this.erType = Context.NAME;
|
this.elementType = Context.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContextManagement() {
|
public ContextManagement() {
|
||||||
|
@ -384,7 +384,7 @@ public class ContextManagement extends EntityManagement<Context> {
|
||||||
@Override
|
@Override
|
||||||
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
Iterable<Vertex> iterable = orientGraph.getVerticesOfClass(erType, polymorphic);
|
Iterable<Vertex> iterable = orientGraph.getVerticesOfClass(elementType, polymorphic);
|
||||||
for(Vertex vertex : iterable) {
|
for(Vertex vertex : iterable) {
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
contextManagement.setElement(vertex);
|
contextManagement.setElement(vertex);
|
||||||
|
|
|
@ -80,7 +80,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
protected UUID uuid;
|
protected UUID uuid;
|
||||||
protected JsonNode jsonNode;
|
protected JsonNode jsonNode;
|
||||||
protected OClass oClass;
|
protected OClass oClass;
|
||||||
protected String erType;
|
protected String elementType;
|
||||||
|
|
||||||
protected El element;
|
protected El element;
|
||||||
protected boolean reload;
|
protected boolean reload;
|
||||||
|
@ -159,14 +159,14 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
String type = orientElement.getRecord().getClassName();
|
String type = orientElement.getRecord().getClassName();
|
||||||
oClass = oSchema.getClass(type);
|
oClass = oSchema.getClass(type);
|
||||||
} else {
|
} else {
|
||||||
oClass = SchemaManagementImpl.getTypeSchema(erType, accessType);
|
oClass = SchemaManagementImpl.getTypeSchema(elementType, accessType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return oClass;
|
return oClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setElementType(String erType) throws ResourceRegistryException {
|
public void setElementType(String erType) throws ResourceRegistryException {
|
||||||
this.erType = erType;
|
this.elementType = erType;
|
||||||
if(erType == null || erType.compareTo("") == 0) {
|
if(erType == null || erType.compareTo("") == 0) {
|
||||||
erType = accessType.getName();
|
erType = accessType.getName();
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,11 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getElementType() {
|
||||||
|
return elementType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void checkJSON() throws ResourceRegistryException {
|
protected void checkJSON() throws ResourceRegistryException {
|
||||||
if(uuid == null) {
|
if(uuid == null) {
|
||||||
try {
|
try {
|
||||||
|
@ -185,8 +190,8 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
checkUUIDMatch();
|
checkUUIDMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.erType == null) {
|
if(this.elementType == null) {
|
||||||
this.erType = getClassProperty(jsonNode);
|
this.elementType = getClassProperty(jsonNode);
|
||||||
getOClass();
|
getOClass();
|
||||||
} else {
|
} else {
|
||||||
checkERMatch();
|
checkERMatch();
|
||||||
|
@ -196,9 +201,9 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
protected void checkERMatch() throws ResourceRegistryException {
|
protected void checkERMatch() throws ResourceRegistryException {
|
||||||
if(jsonNode != null) {
|
if(jsonNode != null) {
|
||||||
String type = getClassProperty(jsonNode);
|
String type = getClassProperty(jsonNode);
|
||||||
if(type != null && type.compareTo(erType) != 0) {
|
if(type != null && type.compareTo(elementType) != 0) {
|
||||||
String error = String.format("Requested type does not match with json representation %s!=%s",
|
String error = String.format("Requested type does not match with json representation %s!=%s",
|
||||||
erType, type);
|
elementType, type);
|
||||||
logger.trace(error);
|
logger.trace(error);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +224,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
if(resourceUUID.compareTo(uuid) != 0) {
|
if(resourceUUID.compareTo(uuid) != 0) {
|
||||||
String error = String.format(
|
String error = String.format(
|
||||||
"UUID provided in header (%s) differs from the one (%s) used to identify the %s instance",
|
"UUID provided in header (%s) differs from the one (%s) used to identify the %s instance",
|
||||||
resourceUUID.toString(), uuid.toString(), erType);
|
resourceUUID.toString(), uuid.toString(), elementType);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -259,7 +264,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw new ResourceRegistryException("Error Creating " + erType + " with " + jsonNode, e);
|
throw new ResourceRegistryException("Error Creating " + elementType + " with " + jsonNode, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +282,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw new ResourceRegistryException("Error Updating " + erType + " with " + jsonNode, e);
|
throw new ResourceRegistryException("Error Updating " + elementType + " with " + jsonNode, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +312,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw new ResourceRegistryException("Error Adding " + erType + " to " + targetSecurityContext.toString(), e.getCause());
|
throw new ResourceRegistryException("Error Adding " + elementType + " to " + targetSecurityContext.toString(), e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +327,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw new ResourceRegistryException("Error Removing " + erType + " from " + targetSecurityContext.toString(), e.getCause());
|
throw new ResourceRegistryException("Error Removing " + elementType + " from " + targetSecurityContext.toString(), e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,6 +337,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
}
|
}
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.uuid = HeaderUtility.getHeader(element).getUUID();
|
this.uuid = HeaderUtility.getHeader(element).getUUID();
|
||||||
|
this.elementType = ((OrientElement) element).getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract NotFoundException getSpecificElementNotFoundException(NotFoundException e);
|
protected abstract NotFoundException getSpecificElementNotFoundException(NotFoundException e);
|
||||||
|
@ -348,8 +354,8 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
} catch(NotFoundException e) {
|
} catch(NotFoundException e) {
|
||||||
try {
|
try {
|
||||||
retrieveElementFromAnyContext();
|
retrieveElementFromAnyContext();
|
||||||
throw getSpecificERAvailableInAnotherContextException(erType == null ? accessType.getName()
|
throw getSpecificERAvailableInAnotherContextException(elementType == null ? accessType.getName()
|
||||||
: erType + " with UUID " + uuid + " is available in another "
|
: elementType + " with UUID " + uuid + " is available in another "
|
||||||
+ Context.class.getSimpleName());
|
+ Context.class.getSimpleName());
|
||||||
} catch(AvailableInAnotherContextException e1) {
|
} catch(AvailableInAnotherContextException e1) {
|
||||||
throw e1;
|
throw e1;
|
||||||
|
@ -375,7 +381,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
if(uuid == null) {
|
if(uuid == null) {
|
||||||
throw new NotFoundException("null UUID does not allow to retrieve the Element");
|
throw new NotFoundException("null UUID does not allow to retrieve the Element");
|
||||||
}
|
}
|
||||||
return Utility.getElementByUUID(orientGraph, erType == null ? accessType.getName() : erType, uuid,
|
return Utility.getElementByUUID(orientGraph, elementType == null ? accessType.getName() : elementType, uuid,
|
||||||
elementClass);
|
elementClass);
|
||||||
} catch(NotFoundException e) {
|
} catch(NotFoundException e) {
|
||||||
throw getSpecificElementNotFoundException(e);
|
throw getSpecificElementNotFoundException(e);
|
||||||
|
@ -388,7 +394,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
|
|
||||||
public El retrieveElementFromAnyContext() throws NotFoundException, ResourceRegistryException {
|
public El retrieveElementFromAnyContext() throws NotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
return Utility.getElementByUUIDAsAdmin(erType == null ? accessType.getName() : erType, uuid, elementClass);
|
return Utility.getElementByUUIDAsAdmin(elementType == null ? accessType.getName() : elementType, uuid, elementClass);
|
||||||
} catch(NotFoundException e) {
|
} catch(NotFoundException e) {
|
||||||
throw getSpecificElementNotFoundException(e);
|
throw getSpecificElementNotFoundException(e);
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
|
@ -581,17 +587,17 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
boolean added = internalAddToContext(targetSecurityContext);
|
boolean added = internalAddToContext(targetSecurityContext);
|
||||||
|
|
||||||
orientGraph.commit();
|
orientGraph.commit();
|
||||||
logger.info("{} with UUID {} successfully added to Context with UUID {}", erType, uuid, contextUUID);
|
logger.info("{} with UUID {} successfully added to Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
|
|
||||||
return added;
|
return added;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to add {} with UUID {} to Context with UUID {}", erType, uuid, contextUUID);
|
logger.error("Unable to add {} with UUID {} to Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("Unable to add {} with UUID {} to Context with UUID {}", erType, uuid, contextUUID, e);
|
logger.error("Unable to add {} with UUID {} to Context with UUID {}", elementType, uuid, contextUUID, e);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
|
@ -604,7 +610,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeFromContext(UUID contextUUID) throws NotFoundException, ContextException, ResourceRegistryException {
|
public boolean removeFromContext(UUID contextUUID) throws NotFoundException, ContextException, ResourceRegistryException {
|
||||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", erType, uuid, contextUUID);
|
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -617,17 +623,17 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
boolean removed = internalRemoveFromContext(targetSecurityContext);
|
boolean removed = internalRemoveFromContext(targetSecurityContext);
|
||||||
|
|
||||||
orientGraph.commit();
|
orientGraph.commit();
|
||||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", erType, uuid, contextUUID);
|
logger.info("{} with UUID {} successfully removed from Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", erType, uuid, contextUUID);
|
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", erType, uuid, contextUUID, e);
|
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID, e);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.er.entity;
|
package org.gcube.informationsystem.resourceregistry.er.entity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -124,24 +126,24 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
protected Vertex createVertex() throws EntityAlreadyPresentException, ResourceRegistryException {
|
protected Vertex createVertex() throws EntityAlreadyPresentException, ResourceRegistryException {
|
||||||
|
|
||||||
logger.trace("Going to create {} for {} ({}) using {}", Vertex.class.getSimpleName(), accessType.getName(),
|
logger.trace("Going to create {} for {} ({}) using {}", Vertex.class.getSimpleName(), accessType.getName(),
|
||||||
erType, jsonNode);
|
elementType, jsonNode);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(oClass.isAbstract()) {
|
if(oClass.isAbstract()) {
|
||||||
String error = String.format(
|
String error = String.format(
|
||||||
"Trying to create an instance of %s of type %s which is abstract. The operation will be aborted.",
|
"Trying to create an instance of %s of type %s which is abstract. The operation will be aborted.",
|
||||||
accessType.getName(), erType);
|
accessType.getName(), elementType);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex vertexEntity = orientGraph.addVertex("class:" + erType);
|
Vertex vertexEntity = orientGraph.addVertex("class:" + elementType);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(uuid != null) {
|
if(uuid != null) {
|
||||||
Vertex v = getElement();
|
Vertex v = getElement();
|
||||||
if(v != null) {
|
if(v != null) {
|
||||||
String error = String.format("A %s with UUID %s already exist", erType, uuid.toString());
|
String error = String.format("A %s with UUID %s already exist", elementType, uuid.toString());
|
||||||
throw getSpecificERAlreadyPresentException(error);
|
throw getSpecificERAlreadyPresentException(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,8 +178,8 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.trace("Error while creating {} for {} ({}) using {}", Vertex.class.getSimpleName(),
|
logger.trace("Error while creating {} for {} ({}) using {}", Vertex.class.getSimpleName(),
|
||||||
accessType.getName(), erType, jsonNode, e);
|
accessType.getName(), elementType, jsonNode, e);
|
||||||
throw new ResourceRegistryException("Error Creating " + erType + " with " + jsonNode, e.getCause());
|
throw new ResourceRegistryException("Error Creating " + elementType + " with " + jsonNode, e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +220,7 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
@Override
|
@Override
|
||||||
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
Iterable<Vertex> iterable = orientGraph.getVerticesOfClass(erType, polymorphic);
|
Iterable<Vertex> iterable = orientGraph.getVerticesOfClass(elementType, polymorphic);
|
||||||
for(Vertex vertex : iterable) {
|
for(Vertex vertex : iterable) {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(),
|
EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(),
|
||||||
|
@ -234,10 +236,103 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
return jsonArray.toString();
|
return jsonArray.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String reallyQuery(String relationType, String referenceType, Direction direction, boolean polymorphic,
|
public String reallyQuery(String relationType, String referenceType, UUID referenceUUID, Direction direction,
|
||||||
Map<String,String> constraint) throws ResourceRegistryException {
|
boolean polymorphic, Map<String,String> constraint) throws ResourceRegistryException {
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
|
||||||
|
Iterable<Vertex> references = null;
|
||||||
|
|
||||||
|
if(referenceUUID != null) {
|
||||||
|
Element element = ERManagementUtility.getAnyElementByUUID(referenceUUID);
|
||||||
|
if(element instanceof Vertex) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
EntityManagement<Entity> entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(),
|
||||||
|
orientGraph, (Vertex) element);
|
||||||
|
|
||||||
|
OrientVertexType orientVertexType = ((OrientVertex) element).getType();
|
||||||
|
|
||||||
|
String elementType = entityManagement.getElementType();
|
||||||
|
if(elementType.compareTo(referenceType) != 0) {
|
||||||
|
if(polymorphic && orientVertexType.isSubClassOf(referenceType)) {
|
||||||
|
// OK
|
||||||
|
} else {
|
||||||
|
String error = String.format("Referenced instace with UUID %s is not a %s", referenceUUID,
|
||||||
|
referenceType);
|
||||||
|
throw new InvalidQueryException(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Vertex> vertexes = new ArrayList<>();
|
||||||
|
vertexes.add((Vertex) element);
|
||||||
|
references = vertexes;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String error = String.format("Referenced instace with UUID %s is not an %s", referenceUUID, Entity.NAME);
|
||||||
|
throw new InvalidQueryException(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
references = orientGraph.getVerticesOfClass(referenceType, polymorphic);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Vertex v : references) {
|
||||||
|
List<Direction> directions = new ArrayList<>();
|
||||||
|
if(direction==Direction.BOTH) {
|
||||||
|
directions.add(Direction.IN);
|
||||||
|
directions.add(Direction.OUT);
|
||||||
|
}else {
|
||||||
|
directions.add(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Direction d : directions) {
|
||||||
|
|
||||||
|
Iterable<Edge> edges = v.getEdges(d.opposite(), relationType);
|
||||||
|
for(Edge edge : edges) {
|
||||||
|
Vertex vertex = ((OrientEdge) edge).getVertex(d);
|
||||||
|
OrientVertex orientVertex = (OrientVertex) vertex;
|
||||||
|
|
||||||
|
if(((OrientVertex) v).getIdentity().compareTo(orientVertex.getIdentity()) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(elementType.compareTo(orientVertex.getLabel()) != 0) {
|
||||||
|
OrientVertexType orientVertexType = orientVertex.getType();
|
||||||
|
|
||||||
|
if(polymorphic && orientVertexType.isSubClassOf(elementType)) {
|
||||||
|
// OK
|
||||||
|
} else {
|
||||||
|
// excluding from results
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(),
|
||||||
|
orientGraph, vertex);
|
||||||
|
try {
|
||||||
|
if(entityManagement.getUUID().compareTo(referenceUUID) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = entityManagement.serializeAsJson();
|
||||||
|
jsonArray.put(jsonObject);
|
||||||
|
} catch(ResourceRegistryException e) {
|
||||||
|
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",
|
||||||
|
vertex.toString(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonArray.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String reallyQueryTraversal(String relationType, String referenceType, UUID referenceUUID,
|
||||||
|
Direction direction, boolean polymorphic, Map<String,String> constraint) throws ResourceRegistryException {
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
|
||||||
|
if(referenceUUID != null) {
|
||||||
|
constraint.put(Entity.HEADER_PROPERTY + "." + Header.UUID_PROPERTY, referenceUUID.toString());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO check types
|
// TODO check types
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -254,7 +349,7 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
selectStringBuilder.append("'), ");
|
selectStringBuilder.append("'), ");
|
||||||
selectStringBuilder.append(direction.opposite().name().toLowerCase());
|
selectStringBuilder.append(direction.opposite().name().toLowerCase());
|
||||||
selectStringBuilder.append("V('");
|
selectStringBuilder.append("V('");
|
||||||
selectStringBuilder.append(erType);
|
selectStringBuilder.append(elementType);
|
||||||
selectStringBuilder.append("') FROM (SELECT FROM ");
|
selectStringBuilder.append("') FROM (SELECT FROM ");
|
||||||
selectStringBuilder.append(referenceType);
|
selectStringBuilder.append(referenceType);
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
@ -276,7 +371,7 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
|
|
||||||
if(!polymorphic) {
|
if(!polymorphic) {
|
||||||
selectStringBuilder.append(" WHERE @class='");
|
selectStringBuilder.append(" WHERE @class='");
|
||||||
selectStringBuilder.append(erType);
|
selectStringBuilder.append(elementType);
|
||||||
selectStringBuilder.append("'");
|
selectStringBuilder.append("'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,8 +398,8 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(orientVertexType.getName().compareTo(erType) != 0) {
|
if(orientVertexType.getName().compareTo(elementType) != 0) {
|
||||||
if(!orientVertexType.isSubClassOf(erType)) {
|
if(!orientVertexType.isSubClassOf(elementType)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,6 +412,12 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(),
|
EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(),
|
||||||
orientGraph, vertex);
|
orientGraph, vertex);
|
||||||
try {
|
try {
|
||||||
|
if(constraint.containsKey(Entity.HEADER_PROPERTY + "." + Header.UUID_PROPERTY)) {
|
||||||
|
String uuid = constraint.get(Entity.HEADER_PROPERTY + "." + Header.UUID_PROPERTY);
|
||||||
|
if(entityManagement.getUUID().compareTo(UUID.fromString(uuid)) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
JSONObject jsonObject = entityManagement.serializeAsJson();
|
JSONObject jsonObject = entityManagement.serializeAsJson();
|
||||||
jsonArray.put(jsonObject);
|
jsonArray.put(jsonObject);
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
|
@ -334,13 +435,13 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
orientGraph = getWorkingContext().getGraph(PermissionMode.READER);
|
orientGraph = getWorkingContext().getGraph(PermissionMode.READER);
|
||||||
|
|
||||||
AccessType relationAccessType = ERManagementUtility.getBaseAccessType(relationType);
|
AccessType relationAccessType = ERManagementUtility.getBaseAccessType(relationType);
|
||||||
if(relationAccessType != AccessType.IS_RELATED_TO || relationAccessType != AccessType.CONSISTS_OF) {
|
if(relationAccessType != AccessType.IS_RELATED_TO && relationAccessType != AccessType.CONSISTS_OF) {
|
||||||
String error = String.format("%s must be a relation type", relationType);
|
String error = String.format("%s must be a relation type", relationType);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessType referenceAccessType = ERManagementUtility.getBaseAccessType(referenceType);
|
AccessType referenceAccessType = ERManagementUtility.getBaseAccessType(referenceType);
|
||||||
if(referenceAccessType != AccessType.RESOURCE || relationAccessType != AccessType.FACET) {
|
if(referenceAccessType != AccessType.RESOURCE && referenceAccessType != AccessType.FACET) {
|
||||||
String error = String.format("%s must be a en entity type", referenceType);
|
String error = String.format("%s must be a en entity type", referenceType);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
|
@ -356,7 +457,7 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
|
|
||||||
if(direction != Direction.OUT) {
|
if(direction != Direction.OUT) {
|
||||||
String error = String.format("%s can only goes %s from %s.", relationType,
|
String error = String.format("%s can only goes %s from %s.", relationType,
|
||||||
Direction.OUT.name(), erType);
|
Direction.OUT.name(), elementType);
|
||||||
throw new InvalidQueryException(error);
|
throw new InvalidQueryException(error);
|
||||||
} else {
|
} else {
|
||||||
if(referenceAccessType != AccessType.FACET) {
|
if(referenceAccessType != AccessType.FACET) {
|
||||||
|
@ -372,8 +473,8 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
case FACET:
|
case FACET:
|
||||||
if(relationAccessType != AccessType.CONSISTS_OF || direction != Direction.IN
|
if(relationAccessType != AccessType.CONSISTS_OF || direction != Direction.IN
|
||||||
|| referenceAccessType != AccessType.RESOURCE) {
|
|| referenceAccessType != AccessType.RESOURCE) {
|
||||||
String error = String.format("%s can only has %s %s from a %s.", erType, Direction.IN.name(),
|
String error = String.format("%s can only has %s %s from a %s.", elementType,
|
||||||
ConsistsOf.NAME, Resource.NAME);
|
Direction.IN.name(), ConsistsOf.NAME, Resource.NAME);
|
||||||
throw new InvalidQueryException(error);
|
throw new InvalidQueryException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,11 +484,7 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(referenceUUID != null) {
|
return reallyQuery(relationType, referenceType, referenceUUID, direction, polymorphic, constraint);
|
||||||
constraint.put(Entity.HEADER_PROPERTY + "." + Header.UUID_PROPERTY, referenceUUID.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return reallyQuery(relationType, referenceType, direction, polymorphic, constraint);
|
|
||||||
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -222,7 +222,7 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
targetEntityManagement = newTargetEntityManagement();
|
targetEntityManagement = newTargetEntityManagement();
|
||||||
|
|
||||||
if(!jsonNode.has(Relation.TARGET_PROPERTY)) {
|
if(!jsonNode.has(Relation.TARGET_PROPERTY)) {
|
||||||
throw new ResourceRegistryException("Error while creating " + erType + ". No target definition found");
|
throw new ResourceRegistryException("Error while creating " + elementType + ". No target definition found");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -230,7 +230,7 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
} catch(SchemaException e) {
|
} catch(SchemaException e) {
|
||||||
StringBuilder errorMessage = new StringBuilder();
|
StringBuilder errorMessage = new StringBuilder();
|
||||||
errorMessage.append("A ");
|
errorMessage.append("A ");
|
||||||
errorMessage.append(erType);
|
errorMessage.append(elementType);
|
||||||
errorMessage.append(" can be only created beetween ");
|
errorMessage.append(" can be only created beetween ");
|
||||||
errorMessage.append(sourceEntityManagement.getAccessType().getName());
|
errorMessage.append(sourceEntityManagement.getAccessType().getName());
|
||||||
errorMessage.append(" and ");
|
errorMessage.append(" and ");
|
||||||
|
@ -245,17 +245,17 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("Creating {} beetween {} -> {}", erType, getSourceEntityManagement().serialize(),
|
logger.trace("Creating {} beetween {} -> {}", elementType, getSourceEntityManagement().serialize(),
|
||||||
getTargetEntityManagement().serialize());
|
getTargetEntityManagement().serialize());
|
||||||
|
|
||||||
Vertex source = (Vertex) getSourceEntityManagement().getElement();
|
Vertex source = (Vertex) getSourceEntityManagement().getElement();
|
||||||
Vertex target = (Vertex) getTargetEntityManagement().getElement();
|
Vertex target = (Vertex) getTargetEntityManagement().getElement();
|
||||||
|
|
||||||
element = orientGraph.addEdge(null, source, target, erType);
|
element = orientGraph.addEdge(null, source, target, elementType);
|
||||||
|
|
||||||
ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||||
|
|
||||||
logger.info("{} successfully created", erType);
|
logger.info("{} successfully created", elementType);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
@Override
|
@Override
|
||||||
protected Edge reallyUpdate() throws ResourceRegistryException {
|
protected Edge reallyUpdate() throws ResourceRegistryException {
|
||||||
|
|
||||||
logger.debug("Trying to update {} : {}", erType, jsonNode);
|
logger.debug("Trying to update {} : {}", elementType, jsonNode);
|
||||||
|
|
||||||
Edge edge = getElement();
|
Edge edge = getElement();
|
||||||
ERManagement.updateProperties(oClass, edge, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
ERManagement.updateProperties(oClass, edge, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||||
|
@ -281,7 +281,7 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("{} {} successfully updated", erType, jsonNode);
|
logger.info("{} {} successfully updated", elementType, jsonNode);
|
||||||
|
|
||||||
return edge;
|
return edge;
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
Map<String,JSONObject> visitedSourceResources = new HashMap<>();
|
Map<String,JSONObject> visitedSourceResources = new HashMap<>();
|
||||||
for(Edge edge : edges) {
|
for(Edge edge : edges) {
|
||||||
if(postFilterPolymorphic && edge.getLabel().compareTo(erType) != 0) {
|
if(postFilterPolymorphic && edge.getLabel().compareTo(elementType) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
||||||
Iterable<Edge> edges = orientGraph.getEdgesOfClass(erType, polymorphic);
|
Iterable<Edge> edges = orientGraph.getEdgesOfClass(elementType, polymorphic);
|
||||||
Collection<JSONObject> collection = serializeEdges(edges, false);
|
Collection<JSONObject> collection = serializeEdges(edges, false);
|
||||||
return serializeJSONObjectList(collection);
|
return serializeJSONObjectList(collection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class SharingManagement {
|
||||||
protected void setCalledMethod(HTTPMETHOD httpMethod, String type) {
|
protected void setCalledMethod(HTTPMETHOD httpMethod, String type) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
list.add(SharingPath.SHARING_PATH_PART);
|
list.add(SharingPath.SHARING_PATH_PART);
|
||||||
|
list.add(SharingPath.CONTEXTS_PATH_PART);
|
||||||
list.add("{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}");
|
list.add("{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}");
|
||||||
list.add(type);
|
list.add(type);
|
||||||
list.add("{" + AccessPath.UUID_PATH_PARAM + "}");
|
list.add("{" + AccessPath.UUID_PATH_PARAM + "}");
|
||||||
|
@ -48,8 +49,8 @@ public class SharingManagement {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}" + "/" + AccessPath.TYPE_PATH_PARAM + "/{"
|
@Path("/" + SharingPath.CONTEXTS_PATH_PART + "/{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}" + "/"
|
||||||
+ AccessPath.UUID_PATH_PARAM + "}")
|
+ AccessPath.TYPE_PATH_PARAM + "/{" + AccessPath.UUID_PATH_PARAM + "}")
|
||||||
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public boolean add(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId,
|
public boolean add(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId,
|
||||||
|
@ -88,8 +89,8 @@ public class SharingManagement {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}" + "/" + AccessPath.TYPE_PATH_PARAM + "/{"
|
@Path("/" + SharingPath.CONTEXTS_PATH_PART + "/{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}" + "/"
|
||||||
+ AccessPath.UUID_PATH_PARAM + "}")
|
+ AccessPath.TYPE_PATH_PARAM + "/{" + AccessPath.UUID_PATH_PARAM + "}")
|
||||||
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public boolean remove(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId,
|
public boolean remove(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId,
|
||||||
|
|
|
@ -638,24 +638,21 @@ public class ERManagementTest extends ScopedTest {
|
||||||
String json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, Direction.BOTH, true, null);
|
String json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, Direction.BOTH, true, null);
|
||||||
List<Resource> resourceList = ISMapper.unmarshalList(Resource.class, json);
|
List<Resource> resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==1);
|
Assert.assertTrue(resourceList.size()==1);
|
||||||
Resource sourceResource = resourceList.get(0);
|
Resource resource = resourceList.get(0);
|
||||||
Resource targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
|
Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID)==0);
|
||||||
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID)==0);
|
|
||||||
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID)==0);
|
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, Direction.OUT, true, null);
|
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, Direction.OUT, true, null);
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==1);
|
Assert.assertTrue(resourceList.size()==1);
|
||||||
sourceResource = resourceList.get(0);
|
resource = resourceList.get(0);
|
||||||
targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
|
Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID)==0);
|
||||||
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID)==0);
|
|
||||||
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID)==0);
|
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, Direction.IN, true, null);
|
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, Direction.IN, true, null);
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size()==0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, Direction.BOTH, false, null);
|
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, Direction.BOTH, false, null);
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size()==0);
|
||||||
|
@ -677,24 +674,22 @@ public class ERManagementTest extends ScopedTest {
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.OUT, true, null);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.OUT, true, null);
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
|
Assert.assertTrue(resourceList.size()==0);
|
||||||
|
|
||||||
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.IN, true, null);
|
||||||
|
resourceList = ISMapper.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);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.IN, true, null);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.BOTH, false, null);
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size()==0);
|
||||||
|
|
||||||
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.OUT, false, null);
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.BOTH, true, null);
|
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size()==0);
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.OUT, true, null);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.IN, false, null);
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, Direction.IN, true, null);
|
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size()==0);
|
||||||
/* END Getting HostingNode */
|
/* END Getting HostingNode */
|
||||||
|
@ -713,9 +708,9 @@ public class ERManagementTest extends ScopedTest {
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, Direction.OUT, true, null);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, Direction.OUT, true, null);
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==1);
|
Assert.assertTrue(resourceList.size()==1);
|
||||||
sourceResource = resourceList.get(0);
|
resource = resourceList.get(0);
|
||||||
Facet targetIdentificationFacet = sourceResource.getIdentificationFacets().get(0);
|
Facet targetIdentificationFacet = resource.getIdentificationFacets().get(0);
|
||||||
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(eServiceUUID)==0);
|
Assert.assertTrue(resource.getHeader().getUUID().compareTo(eServiceUUID)==0);
|
||||||
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID)==0);
|
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID)==0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -726,17 +721,17 @@ public class ERManagementTest extends ScopedTest {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, Direction.BOTH, true, null);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, Direction.BOTH, false, null);
|
||||||
}catch(InvalidQueryException e) {
|
}catch(InvalidQueryException e) {
|
||||||
// Ok expected
|
// Ok expected
|
||||||
}
|
}
|
||||||
|
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, Direction.OUT, true, null);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, Direction.OUT, false, null);
|
||||||
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
resourceList = ISMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size()==0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, Direction.IN, true, null);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, Direction.IN, false, null);
|
||||||
}catch(InvalidQueryException e) {
|
}catch(InvalidQueryException e) {
|
||||||
// Ok expected
|
// Ok expected
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue