Refs #10238: Refactor Context Port Type
Task-Url: https://support.d4science.org/issues/10238 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@158560 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
996a00f10f
commit
3794de9127
|
@ -48,16 +48,11 @@ public class ContextManagement extends EntityManagement<Context> {
|
||||||
if(++count>1) {
|
if(++count>1) {
|
||||||
throw new ContextException("A " + Context.NAME + " can not have more than one parent");
|
throw new ContextException("A " + Context.NAME + " can not have more than one parent");
|
||||||
}
|
}
|
||||||
ContextManagement contextManagement = new ContextManagement(orientGraph);
|
|
||||||
contextManagement.setElement(edge.getVertex(Direction.OUT));
|
|
||||||
JSONObject parent = contextManagement.serializeSelfOnly();
|
|
||||||
try {
|
try {
|
||||||
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(orientGraph);
|
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(orientGraph);
|
||||||
isParentOfManagement.setElement(edge);
|
isParentOfManagement.setElement(edge);
|
||||||
JSONObject isParentOf = isParentOfManagement.serializeAsJson(false,false);
|
JSONObject isParentOf = isParentOfManagement.serializeAsJson(true,false);
|
||||||
parent = addRelation(parent, isParentOf, Context.CHILDREN_PROPERTY);
|
context.putOpt(Context.PARENT_PROPERTY, isParentOf);
|
||||||
|
|
||||||
context.putOpt(Context.PARENT_PROPERTY, parent);
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
logger.error("Unable to correctly serialize {}. This is really strange and should not occur.", edge);
|
logger.error("Unable to correctly serialize {}. This is really strange and should not occur.", edge);
|
||||||
throw new ContextException("");
|
throw new ContextException("");
|
||||||
|
|
|
@ -32,14 +32,14 @@ public class ContextManagementTest {
|
||||||
|
|
||||||
logger.debug("{}", ISMapper.marshal(context));
|
logger.debug("{}", ISMapper.marshal(context));
|
||||||
|
|
||||||
logger.debug("Parent : {}", ISMapper.marshal(context.getParent()));
|
logger.debug("Parent : {}", ISMapper.marshal(context.getParent().getSource()));
|
||||||
|
|
||||||
for(IsParentOf<Context, Context> isParentOf : context.getChildren()){
|
for(IsParentOf<Context, Context> isParentOf : context.getChildren()){
|
||||||
logger.debug("Children : {}", ISMapper.marshal(isParentOf));
|
logger.debug("Children : {}", ISMapper.marshal(isParentOf.getTarget()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Context parent = context.getParent(); //.getSource();
|
Context parent = context.getParent().getSource();
|
||||||
Context sameOfContext = parent.getChildren().get(0).getTarget();
|
Context sameOfContext = parent.getChildren().get(0).getTarget();
|
||||||
Assert.assertTrue(context==sameOfContext);
|
Assert.assertTrue(context==sameOfContext);
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ public class ContextManagementTest {
|
||||||
List<IsParentOf<Context, Context>> children = context.getChildren();
|
List<IsParentOf<Context, Context>> children = context.getChildren();
|
||||||
for(IsParentOf<Context, Context> child : children) {
|
for(IsParentOf<Context, Context> child : children) {
|
||||||
Assert.assertTrue(child.getSource()==context);
|
Assert.assertTrue(child.getSource()==context);
|
||||||
|
Context childContext = child.getTarget();
|
||||||
|
Assert.assertTrue(childContext.getParent().getSource()==context);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +75,14 @@ public class ContextManagementTest {
|
||||||
devNext.addChild(NextNext);
|
devNext.addChild(NextNext);
|
||||||
logger.debug("NextNext : {}", ISMapper.marshal(NextNext));
|
logger.debug("NextNext : {}", ISMapper.marshal(NextNext));
|
||||||
|
|
||||||
|
|
||||||
|
logger.debug("------------------------------------");
|
||||||
|
|
||||||
|
logger.debug("gcube : {}", ISMapper.marshal(gcube));
|
||||||
|
logger.debug("devsec : {}", ISMapper.marshal(devsec));
|
||||||
|
logger.debug("devVRE : {}", ISMapper.marshal(devVRE));
|
||||||
|
logger.debug("devNext : {}", ISMapper.marshal(devNext));
|
||||||
|
logger.debug("NextNext : {}", ISMapper.marshal(NextNext));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue