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) {
|
||||
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 {
|
||||
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(orientGraph);
|
||||
isParentOfManagement.setElement(edge);
|
||||
JSONObject isParentOf = isParentOfManagement.serializeAsJson(false,false);
|
||||
parent = addRelation(parent, isParentOf, Context.CHILDREN_PROPERTY);
|
||||
|
||||
context.putOpt(Context.PARENT_PROPERTY, parent);
|
||||
JSONObject isParentOf = isParentOfManagement.serializeAsJson(true,false);
|
||||
context.putOpt(Context.PARENT_PROPERTY, isParentOf);
|
||||
} catch (JSONException e) {
|
||||
logger.error("Unable to correctly serialize {}. This is really strange and should not occur.", edge);
|
||||
throw new ContextException("");
|
||||
|
|
|
@ -32,14 +32,14 @@ public class ContextManagementTest {
|
|||
|
||||
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()){
|
||||
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();
|
||||
Assert.assertTrue(context==sameOfContext);
|
||||
|
||||
|
@ -47,6 +47,8 @@ public class ContextManagementTest {
|
|||
List<IsParentOf<Context, Context>> children = context.getChildren();
|
||||
for(IsParentOf<Context, Context> child : children) {
|
||||
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);
|
||||
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