Fixed addtoContext and removeFromContext

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@141413 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-12-27 14:31:39 +00:00
parent 7cfce46fa4
commit 0bcdd8a260
3 changed files with 48 additions and 38 deletions

View File

@ -367,8 +367,7 @@ public abstract class RelationManagement<R extends Relation> {
public boolean reallyAddToContext() throws ContextException, public boolean reallyAddToContext() throws ContextException,
ResourceRegistryException { ResourceRegistryException {
getEdge();
ContextUtility.addToActualContext(orientGraph, getEdge());
AddConstraint addConstraint = AddConstraint.unpropagate; AddConstraint addConstraint = AddConstraint.unpropagate;
@ -391,6 +390,12 @@ public abstract class RelationManagement<R extends Relation> {
switch (addConstraint) { switch (addConstraint) {
case propagate: case propagate:
/*
* The relation must be added only in the case the target vertex
* must be added. Otherwise we have a relation which point
* to an entity outside of the context.
*/
ContextUtility.addToActualContext(orientGraph, getEdge());
EntityManagement entityManagement = EntityManagement EntityManagement entityManagement = EntityManagement
.getEntityManagement(orientGraph, target); .getEntityManagement(orientGraph, target);
entityManagement.reallyAddToContext(); entityManagement.reallyAddToContext();
@ -440,6 +445,11 @@ public abstract class RelationManagement<R extends Relation> {
} }
Vertex target = edge.getVertex(Direction.IN); Vertex target = edge.getVertex(Direction.IN);
/*
* In any removeConstraint value the relation MUSt be removed from
* context to avoid to have edge having a source outside of the context.
*/
ContextUtility.removeFromActualContext(orientGraph, edge); ContextUtility.removeFromActualContext(orientGraph, edge);
switch (removeConstraint) { switch (removeConstraint) {

View File

@ -279,7 +279,7 @@ public class MultiContextTest extends ScopedTest {
resourceManagement.setUUID(eServiceUUID); resourceManagement.setUUID(eServiceUUID);
resourceManagement.delete(); resourceManagement.delete();
} catch (ResourceNotFoundException e) { } catch (ResourceNotFoundException e) {
logger.debug("Resource with {} Not Found as Expected", logger.debug("Resource with {} Not Deleted as Expected",
eServiceUUID); eServiceUUID);
} }
@ -298,6 +298,7 @@ public class MultiContextTest extends ScopedTest {
deleted = resourceManagement.delete(); deleted = resourceManagement.delete();
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
} }
// @Test // @Test

View File

@ -11,9 +11,8 @@
<logger name="org.gcube" level="INFO" /> <logger name="org.gcube" level="INFO" />
<logger name="org.gcube.informationsystem" level="DEBUG" /> <logger name="org.gcube.informationsystem" level="DEBUG" />
<logger name="org.gcube.informationsystem.resourceregistry.context" level="INFO" /> <logger name="org.gcube.informationsystem.resourceregistry" level="DEBUG" />
<logger name="org.gcube.informationsystem.resourceregistry.resources.utils" level="INFO" /> <logger name="org.gcube.informationsystem.resourceregistry.context" level="DEBUG" />
<logger name="org.gcube.informationsystem.resourceregistry.resources.impl" level="TRACE" />
<logger name="org.gcube.informationsystem.impl.utils.discovery" level="ERROR" /> <logger name="org.gcube.informationsystem.impl.utils.discovery" level="ERROR" />
<root level="WARN"> <root level="WARN">