Skip to content

Commit

Permalink
Fixed issue #3
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Aug 13, 2014
1 parent 64e5ddd commit 5da827a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@

public class OEdgeTransformer extends OAbstractLookupTransformer {
protected OrientBaseGraph graph;
protected String edgeClass = "E";
protected String edgeClass = "E";
protected boolean directionOut = true;

@Override
public ODocument getConfiguration() {
return new ODocument().fromJSON("{parameters:["+getCommonConfigurationParameters()+","
return new ODocument().fromJSON("{parameters:[" + getCommonConfigurationParameters() + ","
+ "{joinFieldName:{optional:false,description:'field name containing the value to join'}},"
+ "{class:{optional:true,description:'Edge class name. Default is \'E\''}},"
+ "{lookup:{optional:false,description:'<Class>.<property> or Query to execute'}},"
+ "{direction:{optional:true,description:'Direction between \'in\' and \'out\'. Default is \'out\''}},"
+ "{class:{optional:true,description:'Edge class name. Default is \'E\''}},"
+ "{unresolvedVertexAction:{optional:true,description:'action when a unresolved vertices is found',values:"
+ stringArray2Json(ACTION.values()) + "}}]," + "input:['ODocument','OrientVertex'],output:'OrientVertex'}");
}
Expand All @@ -46,6 +48,17 @@ public ODocument getConfiguration() {
public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, final OBasicCommandContext iContext) {
super.configure(iProcessor, iConfiguration, iContext);
edgeClass = iConfiguration.field("class");

if (iConfiguration.containsField("direction")) {
final String direction = iConfiguration.field("direction");
if ("out".equalsIgnoreCase(direction))
directionOut = true;
else if ("in".equalsIgnoreCase(direction))
directionOut = false;
else
throw new OConfigurationException("Direction can be 'in' or 'out', but found: " + direction);

}
}

@Override
Expand Down Expand Up @@ -110,7 +123,10 @@ else if (input instanceof OrientVertex)
final OrientVertex targetVertex = graph.getVertex(result);

// CREATE THE EDGE
vertex.addEdge(edgeClass, targetVertex);
if (directionOut)
vertex.addEdge(edgeClass, targetVertex);
else
targetVertex.addEdge(edgeClass, vertex);
}
}
return input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class OLogTransformer extends OAbstractTransformer {
@Override
public ODocument getConfiguration() {
return new ODocument().fromJSON("{parameters:[" + getCommonConfigurationParameters() + ","
+ "{prefix:{optional:true,description:'Custom prefix to prepend to the message'}}"
+ "{prefix:{optional:true,description:'Custom prefix to prepend to the message'}},"
+ "{postfix:{optional:true,description:'Custom postfix to append to the message'}}" + "]}");
}

Expand Down

0 comments on commit 5da827a

Please sign in to comment.