super(NAME, 2, 3);
}
public Object execute(Object iThis, final OIdentifiable iCurrentRecord, Object iCurrentResult, final Object[] iParams,
final OCommandContext iContext) {
final OrientBaseGraph graph = OGraphCommandExecutorSQLFactory.getGraph(false);
final ORecord record = (ORecord) (iCurrentRecord != null ? iCurrentRecord.getRecord() : null);
Object source = iParams[0];
if (OMultiValue.isMultiValue(source)) {
if (OMultiValue.getSize(source) > 1)
throw new IllegalArgumentException("Only one sourceVertex is allowed");
source = OMultiValue.getFirstValue(source);
}
OrientVertex sourceVertex = graph.getVertex(OSQLHelper.getValue(source, record, iContext));
Object dest = iParams[1];
if (OMultiValue.isMultiValue(dest)) {
if (OMultiValue.getSize(dest) > 1)
throw new IllegalArgumentException("Only one destinationVertex is allowed");
dest = OMultiValue.getFirstValue(dest);
}
OrientVertex destinationVertex = graph.getVertex(OSQLHelper.getValue(dest, record, iContext));
if (sourceVertex.equals(destinationVertex)) {
final List<ORID> result = new ArrayList<ORID>(1);
result.add(destinationVertex.getIdentity());
return result;