Not including source in consistsOf when serialising Resource #22001
This commit is contained in:
parent
61107110b1
commit
113c3ceb9e
|
@ -181,7 +181,9 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
try {
|
try {
|
||||||
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument);
|
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument);
|
||||||
isParentOfManagement.setElement(edge);
|
isParentOfManagement.setElement(edge);
|
||||||
JsonNode isParentOf = isParentOfManagement.createCompleteJsonNode(true, false);
|
isParentOfManagement.includeSource(true);
|
||||||
|
isParentOfManagement.includeTarget(false);
|
||||||
|
JsonNode isParentOf = isParentOfManagement.createCompleteJsonNode();
|
||||||
if (isParentOf != null) {
|
if (isParentOf != null) {
|
||||||
((ObjectNode) context).replace(Context.PARENT_PROPERTY, isParentOf);
|
((ObjectNode) context).replace(Context.PARENT_PROPERTY, isParentOf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class IsParentOfManagement extends RelationElementManagement<ContextManag
|
||||||
this();
|
this();
|
||||||
this.oDatabaseDocument = oDatabaseDocument;
|
this.oDatabaseDocument = oDatabaseDocument;
|
||||||
getWorkingContext();
|
getWorkingContext();
|
||||||
|
includeSource = false;
|
||||||
|
includeTarget = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,12 +68,7 @@ public class IsParentOfManagement extends RelationElementManagement<ContextManag
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JsonNode createCompleteJsonNode() throws ResourceRegistryException {
|
public JsonNode createCompleteJsonNode()
|
||||||
return createCompleteJsonNode(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonNode createCompleteJsonNode(boolean includeSource, boolean includeTarget)
|
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
JsonNode relation = serializeSelfAsJsonNode();
|
JsonNode relation = serializeSelfAsJsonNode();
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
||||||
protected SEM sourceEntityManagement;
|
protected SEM sourceEntityManagement;
|
||||||
protected TEM targetEntityManagement;
|
protected TEM targetEntityManagement;
|
||||||
|
|
||||||
|
protected boolean includeSource;
|
||||||
|
protected boolean includeTarget;
|
||||||
|
|
||||||
protected RelationElementManagement(AccessType accessType, Class<? extends EntityElement> sourceEntityClass, Class<? extends EntityElement> targetEntityClass) {
|
protected RelationElementManagement(AccessType accessType, Class<? extends EntityElement> sourceEntityClass, Class<? extends EntityElement> targetEntityClass) {
|
||||||
super(accessType);
|
super(accessType);
|
||||||
|
|
||||||
|
@ -57,6 +60,17 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
||||||
|
|
||||||
this.sourceEntityManagement = null;
|
this.sourceEntityManagement = null;
|
||||||
this.targetEntityManagement = null;
|
this.targetEntityManagement = null;
|
||||||
|
|
||||||
|
this.includeSource = true;
|
||||||
|
this.includeTarget = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void includeSource(boolean includeSource) {
|
||||||
|
this.includeSource = includeSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void includeTarget(boolean includeTarget) {
|
||||||
|
this.includeTarget = includeTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RelationElementManagement(AccessType accessType, Class<? extends EntityElement> sourceEntityClass, Class<? extends EntityElement> targetEntityClass, SecurityContext workingContext, ODatabaseDocument orientGraph) {
|
protected RelationElementManagement(AccessType accessType, Class<? extends EntityElement> sourceEntityClass, Class<? extends EntityElement> targetEntityClass, SecurityContext workingContext, ODatabaseDocument orientGraph) {
|
||||||
|
@ -95,10 +109,6 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JsonNode createCompleteJsonNode() throws ResourceRegistryException {
|
protected JsonNode createCompleteJsonNode() throws ResourceRegistryException {
|
||||||
return createCompleteJsonNode(true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected JsonNode createCompleteJsonNode(boolean includeSource, boolean includeTarget) throws ResourceRegistryException {
|
|
||||||
JsonNode relation = serializeSelfAsJsonNode();
|
JsonNode relation = serializeSelfAsJsonNode();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -108,6 +108,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
|
|
||||||
if(relationManagement instanceof ConsistsOfManagement) {
|
if(relationManagement instanceof ConsistsOfManagement) {
|
||||||
try {
|
try {
|
||||||
|
relationManagement.includeSource(false);
|
||||||
JsonNode consistsOf = relationManagement.serializeAsJsonNode();
|
JsonNode consistsOf = relationManagement.serializeAsJsonNode();
|
||||||
sourceResource = addConsistsOf(sourceResource, consistsOf);
|
sourceResource = addConsistsOf(sourceResource, consistsOf);
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
|
|
|
@ -149,10 +149,12 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
* so this variable is initialised as true.
|
* so this variable is initialised as true.
|
||||||
*/
|
*/
|
||||||
this.honourPropagationConstraintsInContextSharing = true;
|
this.honourPropagationConstraintsInContextSharing = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PropagationConstraint propagationConstraint;
|
protected PropagationConstraint propagationConstraint;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OEdge getElement() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
public OEdge getElement() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
|
@ -229,7 +231,9 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
if(this instanceof IsRelatedToManagement) {
|
if(this instanceof IsRelatedToManagement) {
|
||||||
sourceResource = resourceManagement.createCompleteJsonNode();
|
sourceResource = resourceManagement.createCompleteJsonNode();
|
||||||
} else if(this instanceof ConsistsOfManagement) {
|
} else if(this instanceof ConsistsOfManagement) {
|
||||||
sourceResource = resourceManagement.serializeSelfAsJsonNode();
|
if(includeSource) {
|
||||||
|
sourceResource = resourceManagement.serializeSelfAsJsonNode();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String error = String.format("{%s is not a %s nor a %s. %s", this,
|
String error = String.format("{%s is not a %s nor a %s. %s", this,
|
||||||
IsRelatedToManagement.class.getSimpleName(), ConsistsOfManagement.class.getSimpleName(),
|
IsRelatedToManagement.class.getSimpleName(), ConsistsOfManagement.class.getSimpleName(),
|
||||||
|
@ -793,5 +797,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
Collection<JsonNode> collection = serializeEdges(edges, false);
|
Collection<JsonNode> collection = serializeEdges(edges, false);
|
||||||
return serializeJsonNodeCollectionAsString(collection);
|
return serializeJsonNodeCollectionAsString(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue