Added code (and commented) to return also target Resource on Resource marshalling.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@135176 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
78213468eb
commit
6d0d99f0a8
|
@ -21,7 +21,7 @@ import org.gcube.informationsystem.impl.utils.Entities;
|
||||||
import org.gcube.informationsystem.model.embedded.Embedded;
|
import org.gcube.informationsystem.model.embedded.Embedded;
|
||||||
import org.gcube.informationsystem.model.embedded.Header;
|
import org.gcube.informationsystem.model.embedded.Header;
|
||||||
import org.gcube.informationsystem.model.embedded.RelationProperty;
|
import org.gcube.informationsystem.model.embedded.RelationProperty;
|
||||||
import org.gcube.informationsystem.model.embedded.RelationProperty.ReferentiaIntegrity;
|
import org.gcube.informationsystem.model.embedded.RelationProperty.ReferentialIntegrity;
|
||||||
import org.gcube.informationsystem.model.entity.Entity;
|
import org.gcube.informationsystem.model.entity.Entity;
|
||||||
import org.gcube.informationsystem.model.entity.Facet;
|
import org.gcube.informationsystem.model.entity.Facet;
|
||||||
import org.gcube.informationsystem.model.entity.Resource;
|
import org.gcube.informationsystem.model.entity.Resource;
|
||||||
|
@ -61,6 +61,7 @@ import com.tinkerpop.blueprints.Element;
|
||||||
import com.tinkerpop.blueprints.Vertex;
|
import com.tinkerpop.blueprints.Vertex;
|
||||||
import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph;
|
import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph;
|
||||||
import com.tinkerpop.blueprints.impls.orient.OrientEdge;
|
import com.tinkerpop.blueprints.impls.orient.OrientEdge;
|
||||||
|
import com.tinkerpop.blueprints.impls.orient.OrientEdgeType;
|
||||||
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
|
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
|
||||||
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
|
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
|
||||||
|
|
||||||
|
@ -1169,33 +1170,43 @@ public class EntityManagementImpl implements EntityManagement {
|
||||||
true);
|
true);
|
||||||
|
|
||||||
JSONArray consistsOfArray = new JSONArray();
|
JSONArray consistsOfArray = new JSONArray();
|
||||||
|
/*
|
||||||
|
JSONArray isRelatedToArray = new JSONArray();
|
||||||
|
*/
|
||||||
|
|
||||||
Iterable<Edge> edges = vertex.getEdges(Direction.OUT);
|
Iterable<Edge> edges = vertex.getEdges(Direction.OUT);
|
||||||
|
|
||||||
for (Edge edge : edges) {
|
for (Edge edge : edges) {
|
||||||
|
|
||||||
String edgeType = edge.getLabel();
|
|
||||||
|
|
||||||
try {
|
OrientEdgeType orientEdgeType = ((OrientEdge) edge).getType();
|
||||||
SchemaManagementImpl.getTypeSchema(orientGraph, edgeType,
|
|
||||||
ConsistsOf.NAME);
|
|
||||||
} catch (SchemaNotFoundException e) {
|
|
||||||
// This not an ConsistsOf Edge. it will be skipped
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject jsonObjectEdge = Utility.toJsonObject((OrientEdge) edge,
|
JSONObject jsonObjectEdge = Utility.toJsonObject((OrientEdge) edge,
|
||||||
true);
|
true);
|
||||||
Vertex facetVertex = edge.getVertex(Direction.IN);
|
|
||||||
|
Vertex targetVertex = edge.getVertex(Direction.IN);
|
||||||
|
|
||||||
jsonObjectEdge.put(Relation.TARGET_PROPERTY,
|
jsonObjectEdge.put(Relation.TARGET_PROPERTY,
|
||||||
Utility.toJsonObject((OrientVertex) facetVertex, true));
|
Utility.toJsonObject((OrientVertex) targetVertex, true));
|
||||||
consistsOfArray.put(jsonObjectEdge);
|
|
||||||
|
|
||||||
|
if(orientEdgeType.isSubClassOf(ConsistsOf.NAME)){
|
||||||
|
consistsOfArray.put(jsonObjectEdge);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
else if(orientEdgeType.isSubClassOf(IsRelatedTo.NAME)){
|
||||||
|
isRelatedToArray.put(jsonObjectEdge);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonObject.put(lowerCaseFirstCharacter(ConsistsOf.NAME),
|
jsonObject.put(lowerCaseFirstCharacter(ConsistsOf.NAME),
|
||||||
consistsOfArray);
|
consistsOfArray);
|
||||||
|
/*
|
||||||
|
jsonObject.put(lowerCaseFirstCharacter(IsRelatedTo.NAME),
|
||||||
|
isRelatedToArray);
|
||||||
|
*/
|
||||||
|
|
||||||
return jsonObject.toString();
|
return jsonObject.toString();
|
||||||
}
|
}
|
||||||
|
@ -1390,8 +1401,8 @@ public class EntityManagementImpl implements EntityManagement {
|
||||||
//+ rid
|
//+ rid
|
||||||
+ ") "
|
+ ") "
|
||||||
+ "WHERE ("
|
+ "WHERE ("
|
||||||
+ Relation.RELATION_PROPERTY + "." + RelationProperty.REFERENTIAL_INTEGRITY + " = '" + ReferentiaIntegrity.onDeleteCascade.toString() + "' OR ("
|
+ Relation.RELATION_PROPERTY + "." + RelationProperty.REFERENTIAL_INTEGRITY + " = '" + ReferentialIntegrity.onDeleteCascade.toString() + "' OR ("
|
||||||
+ Relation.RELATION_PROPERTY + "." + RelationProperty.REFERENTIAL_INTEGRITY + " = '" + ReferentiaIntegrity.onDeleteCascadeWhenOrphan.toString() + "' AND "
|
+ Relation.RELATION_PROPERTY + "." + RelationProperty.REFERENTIAL_INTEGRITY + " = '" + ReferentialIntegrity.onDeleteCascadeWhenOrphan.toString() + "' AND "
|
||||||
+ "inV().inE().size()=1"
|
+ "inV().inE().size()=1"
|
||||||
+ ")"
|
+ ")"
|
||||||
+ ")";
|
+ ")";
|
||||||
|
@ -1436,6 +1447,7 @@ public class EntityManagementImpl implements EntityManagement {
|
||||||
OrientEdge relation = iterator.next();
|
OrientEdge relation = iterator.next();
|
||||||
ODocument oDocument = relation.getInVertex().getRecord();
|
ODocument oDocument = relation.getInVertex().getRecord();
|
||||||
oDocument.delete();
|
oDocument.delete();
|
||||||
|
relation.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.informationsystem.resourceregistry.resources.impl;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ReferentialIntegrityTest {
|
||||||
|
|
||||||
|
protected EntityManagementImpl entityManagementImpl;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before(){
|
||||||
|
ScopeProvider.instance.set("/gcube/devNext");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ReferentialIntegrityTest() {
|
||||||
|
entityManagementImpl = new EntityManagementImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -132,7 +132,7 @@ public class SmartgearResourcesTest {
|
||||||
networkingFacet.setAdditionalProperty("Port", 8080);
|
networkingFacet.setAdditionalProperty("Port", 8080);
|
||||||
|
|
||||||
RelationProperty relationProperty = new RelationPropertyImpl();
|
RelationProperty relationProperty = new RelationPropertyImpl();
|
||||||
relationProperty.setReferentialIntegrity(RelationProperty.ReferentiaIntegrity.onDeleteCascadeWhenOrphan);
|
relationProperty.setReferentialIntegrity(RelationProperty.ReferentialIntegrity.onDeleteCascadeWhenOrphan);
|
||||||
|
|
||||||
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedBy =
|
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedBy =
|
||||||
new IsIdentifiedByImpl<>(hostingNode, networkingFacet, relationProperty);
|
new IsIdentifiedByImpl<>(hostingNode, networkingFacet, relationProperty);
|
||||||
|
|
Loading…
Reference in New Issue