Skip to content
Permalink
Browse files

Merge pull request #149 from mattcasters/master

Fix for issue #148
  • Loading branch information
mattcasters committed Nov 20, 2019
2 parents f7b9e93 + d344008 commit 3317d9fe1f69d28fc3e4f8139d452c5e6159d9f5
@@ -4,7 +4,7 @@

<groupId>bi.know.kettle.neo4j.output</groupId>
<artifactId>Neo4JOutput</artifactId>
<version>4.1.2</version>
<version>4.1.3</version>
<packaging>jar</packaging>

<name>Neo4JOutput</name>
@@ -128,6 +128,7 @@ public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws
data.dynamicToLabels = determineDynamicLabels( meta.getToNodeLabels() );
data.dynamicRelLabel = StringUtils.isNotEmpty( meta.getRelationship() );

data.previousToLabels = null;
data.previousFromLabelsClause = null;
data.previousToLabelsClause = null;
data.previousRelationshipLabel = null;
@@ -221,7 +222,9 @@ public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws

// Remember the previous labels
//
data.previousFromLabels = data.fromLabels;
data.previousFromLabelsClause = data.fromLabelsClause;
data.previousToLabels = data.toLabels;
data.previousToLabelsClause = data.toLabelsClause;
data.previousRelationshipLabel = data.relationshipLabel;
}
@@ -265,7 +268,7 @@ private void emptyUnwindList( boolean changedLabel ) throws KettleException {
case CREATE:
cypher
.append( "CREATE( " )
.append( data.fromLabelsClause )
.append( data.previousFromLabelsClause )
.append( " " )
.append( getMatchClause( meta.getFromNodePropNames(), meta.getFromNodePropPrimary(), data.fromNodePropIndexes, "f" ) )
.append( ") " )
@@ -278,12 +281,12 @@ private void emptyUnwindList( boolean changedLabel ) throws KettleException {
.append( Const.CR )
;
}
updateUsageMap( data.fromLabels, GraphUsage.NODE_CREATE );
updateUsageMap( data.previousFromLabels, GraphUsage.NODE_CREATE );
break;
case MERGE:
cypher
.append( "MERGE( " )
.append( data.fromLabelsClause )
.append( data.previousFromLabelsClause )
.append( " " )
.append( getMatchClause( meta.getFromNodePropNames(), meta.getFromNodePropPrimary(), data.fromNodePropIndexes, "f" ) )
.append( ") " )
@@ -296,18 +299,18 @@ private void emptyUnwindList( boolean changedLabel ) throws KettleException {
.append( Const.CR )
;
}
updateUsageMap( data.fromLabels, GraphUsage.NODE_UPDATE );
updateUsageMap( data.previousFromLabels, GraphUsage.NODE_UPDATE );
break;
case MATCH:
cypher
.append( "MATCH( " )
.append( data.fromLabelsClause )
.append( data.previousFromLabelsClause )
.append( " " )
.append( getMatchClause( meta.getFromNodePropNames(), meta.getFromNodePropPrimary(), data.fromNodePropIndexes, "f" ) )
.append( ") " )
.append( Const.CR )
;
updateUsageMap( data.toLabels, GraphUsage.NODE_READ );
updateUsageMap( data.previousFromLabels, GraphUsage.NODE_READ );
break;
default:
throw new KettleException( "Unsupported operation type for the 'from' node: " + data.fromOperationType );
@@ -321,7 +324,7 @@ private void emptyUnwindList( boolean changedLabel ) throws KettleException {
case CREATE:
cypher
.append( "CREATE( " )
.append( data.toLabelsClause )
.append( data.previousToLabelsClause )
.append( " " )
.append( getMatchClause( meta.getToNodePropNames(), meta.getToNodePropPrimary(), data.toNodePropIndexes, "t" ) )
.append( ") " )
@@ -334,12 +337,12 @@ private void emptyUnwindList( boolean changedLabel ) throws KettleException {
.append( Const.CR )
;
}
updateUsageMap( data.toLabels, GraphUsage.NODE_CREATE );
updateUsageMap( data.previousToLabels, GraphUsage.NODE_CREATE );
break;
case MERGE:
cypher
.append( "MERGE( " )
.append( data.toLabelsClause )
.append( data.previousToLabelsClause )
.append( " " )
.append( getMatchClause( meta.getToNodePropNames(), meta.getToNodePropPrimary(), data.toNodePropIndexes, "t" ) )
.append( ") " )
@@ -352,18 +355,18 @@ private void emptyUnwindList( boolean changedLabel ) throws KettleException {
.append( Const.CR )
;
}
updateUsageMap( data.toLabels, GraphUsage.NODE_UPDATE );
updateUsageMap( data.previousToLabels, GraphUsage.NODE_UPDATE );
break;
case MATCH:
cypher
.append( "MATCH( " )
.append( data.toLabelsClause )
.append( data.previousToLabelsClause )
.append( " " )
.append( getMatchClause( meta.getToNodePropNames(), meta.getToNodePropPrimary(), data.toNodePropIndexes, "t" ) )
.append( ") " )
.append( Const.CR )
;
updateUsageMap( data.toLabels, GraphUsage.NODE_READ );
updateUsageMap( data.previousToLabels, GraphUsage.NODE_READ );
break;
default:
throw new KettleException( "Unsupported operation type for the 'to' node: " + data.toOperationType );
@@ -378,26 +381,26 @@ private void emptyUnwindList( boolean changedLabel ) throws KettleException {
cypher
.append( "MERGE (f)-[" )
.append( "r:" )
.append( data.relationshipLabel )
.append( data.previousRelationshipLabel )
.append( "]->(t) " )
.append( Const.CR )
.append( getSetClause( false, "r", meta.getRelPropNames(), new boolean[ meta.getRelPropNames().length ], data.relPropIndexes ) )
.append( Const.CR )
;
updateUsageMap( Arrays.asList( data.relationshipLabel ), GraphUsage.RELATIONSHIP_UPDATE );
updateUsageMap( Arrays.asList( data.previousRelationshipLabel ), GraphUsage.RELATIONSHIP_UPDATE );
;
break;
case CREATE:
cypher
.append( "CREATE (f)-[" )
.append( "r:" )
.append( data.relationshipLabel )
.append( data.previousRelationshipLabel )
.append( "]->(t) " )
.append( Const.CR )
.append( getSetClause( false, "r", meta.getRelPropNames(), new boolean[ meta.getRelPropNames().length ], data.relPropIndexes ) )
.append( Const.CR )
;
updateUsageMap( Arrays.asList( data.relationshipLabel ), GraphUsage.RELATIONSHIP_CREATE );
updateUsageMap( Arrays.asList( data.previousRelationshipLabel ), GraphUsage.RELATIONSHIP_CREATE );
break;
}

@@ -874,7 +877,7 @@ private void createIndexForNode( Neo4JOutputData data, String[] nodeLabelFields,
private void wrapUpTransaction() throws KettleException {

if ( data.unwindList != null && data.unwindList.size() > 0 ) {
emptyUnwindList( false );
emptyUnwindList( true ); // true: force re-creation of cypher statement
}

// Allow gc
@@ -47,16 +47,18 @@

public String previousFromLabelsClause;
public String previousToLabelsClause;
public String previousRelationshipLabel;

public IMetaStore metaStore;
public boolean dynamicFromLabels;
public boolean dynamicToLabels;
public boolean dynamicRelLabel;
public String relationshipLabel;

public List<String> previousFromLabels;
public List<String> fromLabels;
public List<String> previousToLabels;
public List<String> toLabels;

public String previousRelationshipLabel;
public String relationshipLabel;

public OperationType fromOperationType;
public OperationType toOperationType;

0 comments on commit 3317d9f

Please sign in to comment.
You can’t perform that action at this time.