Skip to content
Permalink
Browse files

Merge pull request #141 from mattcasters/master

4.1.1
  • Loading branch information...
mattcasters committed Sep 20, 2019
2 parents dd85443 + d28fd3e commit 25d21a710859976af31c0210e2f516729ad0aefd
@@ -4,7 +4,7 @@

<groupId>bi.know.kettle.neo4j.output</groupId>
<artifactId>Neo4JOutput</artifactId>
<version>4.1.0</version>
<version>4.1.1</version>
<packaging>jar</packaging>

<name>Neo4JOutput</name>
@@ -115,7 +115,7 @@
<dependency>
<groupId>kettle-neo4j</groupId>
<artifactId>kettle-neo4j-core</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>

<dependency>
@@ -107,7 +107,7 @@
connectionFactory = new MetaStoreFactory<>( NeoConnection.class, Spoon.getInstance().getMetaStore(), Neo4jDefaults.NAMESPACE );
modelsFactory = new MetaStoreFactory<>( GraphModel.class, Spoon.getInstance().getMetaStore(), Neo4jDefaults.NAMESPACE );

addAdminTab();
// addAdminTab();

/*
* To make compatible with webSpoon
@@ -128,6 +128,9 @@
private void addAdminTab() throws Exception {

final XulTabAndPanel tabAndPanel = createTab();
if (tabAndPanel==null) {
return; // some error occurred
}
tabAndPanel.tab.setLabel( "Admin" );

PropsUI props = PropsUI.getInstance();
@@ -34,10 +34,10 @@
private static final Class<?> PKG = Neo4jSpoonPlugin.class;
private ResourceBundle resourceBundle = new XulSpoonResourceBundle( PKG );

private Neo4jPerspective perspective;
// private Neo4jPerspective perspective;

public Neo4jSpoonPlugin() throws XulException {
this.perspective = new Neo4jPerspective();
// this.perspective = new Neo4jPerspective();
}

@Override
@@ -62,7 +62,8 @@ public SpoonLifecycleListener getLifecycleListener() {

@Override
public SpoonPerspective getPerspective() {
return perspective;
// return perspective;
return null;
}

}
@@ -246,8 +246,12 @@ private void reconnect() {
// retry once after reconnecting.
// This can fix certain time-out issues
//
reconnect();
runCypherStatement( row, data.cypher, parameters );
if (meta.isRetrying()) {
reconnect();
runCypherStatement( row, data.cypher, parameters );
} else {
throw e;
}
}
}

@@ -341,11 +345,15 @@ private StatementResult writeUnwindList() throws KettleException {
// retry once after reconnecting.
// This can fix certain time-out issues
//
reconnect();
if ( meta.isReadOnly() ) {
result = data.session.readTransaction( tx -> tx.run( data.cypher, unwindMap ) );
if (meta.isRetrying()) {
reconnect();
if ( meta.isReadOnly() ) {
result = data.session.readTransaction( tx -> tx.run( data.cypher, unwindMap ) );
} else {
result = data.session.writeTransaction( tx -> tx.run( data.cypher, unwindMap ) );
}
} else {
result = data.session.writeTransaction( tx -> tx.run( data.cypher, unwindMap ) );
throw e;
}
}

@@ -73,6 +73,7 @@
private CCombo wConnection;
private TextVar wBatchSize;
private Button wReadOnly;
private Button wRetry;
private Button wCypherFromField;
private CCombo wCypherField;
private Button wUnwind;
@@ -230,6 +231,24 @@ public CypherDialog( Shell parent, Object inputMetadata, TransMeta transMeta, St
wReadOnly.setLayoutData( fdReadOnly );
lastControl = wReadOnly;

Label wlRetry = new Label( wComposite, SWT.RIGHT );
wlRetry.setText( "Retry connecting after disconnection? " );
props.setLook( wlRetry );
FormData fdlRetry = new FormData();
fdlRetry.left = new FormAttachment( 0, 0 );
fdlRetry.right = new FormAttachment( middle, -margin );
fdlRetry.top = new FormAttachment( lastControl, 2 * margin );
wlRetry.setLayoutData( fdlRetry );
wRetry = new Button( wComposite, SWT.CHECK | SWT.BORDER );
props.setLook( wRetry );
FormData fdRetry = new FormData();
fdRetry.left = new FormAttachment( middle, 0 );
fdRetry.right = new FormAttachment( 100, 0 );
fdRetry.top = new FormAttachment( wlRetry, 0, SWT.CENTER );
wRetry.setLayoutData( fdRetry );
lastControl = wRetry;


Label wlCypherFromField = new Label( wComposite, SWT.RIGHT );
wlCypherFromField.setText( "Get Cypher from input field? " );
props.setLook( wlCypherFromField );
@@ -509,6 +528,7 @@ public void widgetDefaultSelected( SelectionEvent e ) {
wStepname.addSelectionListener( lsDef );
wBatchSize.addSelectionListener( lsDef );
wReadOnly.addSelectionListener( lsDef );
wRetry.addSelectionListener( lsDef );
wCypherFromField.addSelectionListener( lsDef );
wCypherField.addSelectionListener( lsDef );
wUnwind.addSelectionListener( lsDef );
@@ -578,6 +598,7 @@ public void getData() {
wConnection.setText( Const.NVL( input.getConnectionName(), "" ) );

wReadOnly.setSelection( input.isReadOnly() );
wRetry.setSelection( input.isRetrying() );
wCypherFromField.setSelection( input.isCypherFromField() );
wCypherField.setText( Const.NVL( input.getCypherField(), "" ) );
try {
@@ -644,6 +665,7 @@ private void getInfo(CypherMeta meta) {
meta.setCypher( wCypher.getText() );

meta.setReadOnly( wReadOnly.getSelection() );
meta.setRetrying( wRetry.getSelection() );
meta.setCypherFromField( wCypherFromField.getSelection() );
meta.setCypherField( wCypherField.getText() );

@@ -48,6 +48,7 @@
public static final String CYPHER = "cypher";
public static final String BATCH_SIZE = "batch_size";
public static final String READ_ONLY = "read_only";
public static final String RETRY = "retry";
public static final String CYPHER_FROM_FIELD = "cypher_from_field";
public static final String CYPHER_FIELD = "cypher_field";
public static final String UNWIND = "unwind";
@@ -84,6 +85,9 @@
@Injection( name = READ_ONLY )
private boolean readOnly;

@Injection( name = RETRY )
private boolean retrying;

@Injection( name = CYPHER_FROM_FIELD )
private boolean cypherFromField;

@@ -115,7 +119,7 @@ public CypherMeta() {
}

@Override public void setDefault() {

retrying = true;
}

@Override public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int i, TransMeta transMeta, Trans trans ) {
@@ -167,6 +171,7 @@ public CypherMeta() {
xml.append( XMLHandler.addTagValue( CYPHER, cypher ) );
xml.append( XMLHandler.addTagValue( BATCH_SIZE, batchSize ) );
xml.append( XMLHandler.addTagValue( READ_ONLY, readOnly ) );
xml.append( XMLHandler.addTagValue( RETRY, retrying ) );
xml.append( XMLHandler.addTagValue( CYPHER_FROM_FIELD, cypherFromField ) );
xml.append( XMLHandler.addTagValue( CYPHER_FIELD, cypherField ) );
xml.append( XMLHandler.addTagValue( UNWIND, usingUnwind ) );
@@ -203,6 +208,8 @@ public CypherMeta() {
cypher = XMLHandler.getTagValue( stepnode, CYPHER );
batchSize = XMLHandler.getTagValue( stepnode, BATCH_SIZE );
readOnly = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, READ_ONLY ) );
String retryString = XMLHandler.getTagValue( stepnode, RETRY );
retrying = StringUtils.isEmpty( retryString ) || "Y".equalsIgnoreCase( retryString );
cypherFromField = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, CYPHER_FROM_FIELD ) );
cypherField = XMLHandler.getTagValue( stepnode, CYPHER_FIELD );
usingUnwind = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, UNWIND ) );
@@ -245,6 +252,7 @@ public CypherMeta() {
rep.saveStepAttribute( transformationId, stepId, CYPHER, cypher );
rep.saveStepAttribute( transformationId, stepId, BATCH_SIZE, batchSize );
rep.saveStepAttribute( transformationId, stepId, READ_ONLY, readOnly );
rep.saveStepAttribute( transformationId, stepId, 0, RETRY, retrying );
rep.saveStepAttribute( transformationId, stepId, CYPHER_FROM_FIELD, cypherFromField );
rep.saveStepAttribute( transformationId, stepId, CYPHER_FIELD, cypherField );
rep.saveStepAttribute( transformationId, stepId, UNWIND, usingUnwind );
@@ -271,6 +279,7 @@ public CypherMeta() {
cypher = rep.getStepAttributeString( stepId, CYPHER );
batchSize = rep.getStepAttributeString( stepId, BATCH_SIZE );
readOnly = rep.getStepAttributeBoolean( stepId, READ_ONLY );
retrying = rep.getStepAttributeBoolean( stepId, 0, RETRY, true );
cypherFromField = rep.getStepAttributeBoolean( stepId, CYPHER_FROM_FIELD );
cypherField = rep.getStepAttributeString( stepId, CYPHER_FIELD );
usingUnwind = rep.getStepAttributeBoolean( stepId, UNWIND );
@@ -380,6 +389,22 @@ public void setReadOnly( boolean readOnly ) {
this.readOnly = readOnly;
}

/**
* Gets retrying
*
* @return value of retrying
*/
public boolean isRetrying() {
return retrying;
}

/**
* @param retrying The retrying to set
*/
public void setRetrying( boolean retrying ) {
this.retrying = retrying;
}

/**
* Gets cypherField
*

0 comments on commit 25d21a7

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