if (rid != null) {
// REMOVE PUNCTUAL RID
OGraphCommandExecutorSQLFactory.runInTx(new OGraphCommandExecutorSQLFactory.GraphCallBack<Object>() {
@Override
public Object call(OrientBaseGraph graph) {
final OrientEdge e = graph.getEdge(rid);
if (e != null) {
e.remove();
removed = 1;
}
return null;
}
});
} else {
// MULTIPLE EDGES
final Set<OrientEdge> edges = new HashSet<OrientEdge>();
if (query == null) {
OGraphCommandExecutorSQLFactory.runInTx(new OGraphCommandExecutorSQLFactory.GraphCallBack<Object>() {
@Override
public Object call(OrientBaseGraph graph) {
Set<OIdentifiable> fromIds = null;
if (fromExpr != null)
fromIds = OSQLEngine.getInstance().parseRIDTarget(graph.getRawGraph(), fromExpr, context, iArgs);
Set<OIdentifiable> toIds = null;
if (toExpr != null)
toIds = OSQLEngine.getInstance().parseRIDTarget(graph.getRawGraph(), toExpr, context, iArgs);
if (fromIds != null && toIds != null) {
// REMOVE ALL THE EDGES BETWEEN VERTICES
for (OIdentifiable fromId : fromIds) {
final OrientVertex v = graph.getVertex(fromId);
if (v != null)
for (Edge e : v.getEdges(Direction.OUT)) {
final OIdentifiable inV = ((OrientEdge) e).getInVertex();
if (inV != null && toIds.contains(inV.getIdentity()))
edges.add((OrientEdge) e);
}
}
} else if (fromIds != null) {
// REMOVE ALL THE EDGES THAT START FROM A VERTEXES
for (OIdentifiable fromId : fromIds) {
final OrientVertex v = graph.getVertex(fromId);
if (v != null)
edges.add((OrientEdge) v.getEdges(Direction.OUT));
}
} else if (toIds != null) {
// REMOVE ALL THE EDGES THAT ARRIVE TO A VERTEXES
for (OIdentifiable toId : toIds) {
final OrientVertex v = graph.getVertex(toId);
if (v != null) {
edges.add((OrientEdge) v.getEdges(Direction.IN));
}
}
} else
throw new OCommandExecutionException("Invalid target: " + toIds);
if (compiledFilter != null) {
// ADDITIONAL FILTERING
for (Iterator<OrientEdge> it = edges.iterator(); it.hasNext();) {
final OrientEdge edge = it.next();
if (!(Boolean) compiledFilter.evaluate((ODocument) edge.getRecord(), null, context))
it.remove();
}
}
// DELETE THE FOUND EDGES
removed = edges.size();
for (OrientEdge edge : edges)
edge.remove();
return null;
}
});
} else {