Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #171 from mattcasters/master
Browse files Browse the repository at this point in the history
Pushing master to 5.0.0
  • Loading branch information
mattcasters committed Mar 3, 2020
2 parents d4674ec + 84587ba commit a04dda9
Show file tree
Hide file tree
Showing 15 changed files with 456 additions and 208 deletions.
9 changes: 5 additions & 4 deletions pom.xml
Expand Up @@ -4,7 +4,7 @@

<groupId>bi.know.kettle.neo4j.output</groupId>
<artifactId>Neo4JOutput</artifactId>
<version>4.1.4</version>
<version>5.0.0</version>
<packaging>jar</packaging>

<name>Neo4JOutput</name>
Expand All @@ -13,6 +13,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<pdi.version>8.1-SNAPSHOT</pdi.version>
<neo4j.driver.version>4.0.0</neo4j.driver.version>
</properties>

<build>
Expand Down Expand Up @@ -93,7 +94,7 @@
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
<enabled>true</enabled>
</snapshots>
</repository>

Expand All @@ -115,13 +116,13 @@
<dependency>
<groupId>kettle-neo4j</groupId>
<artifactId>kettle-neo4j-core</artifactId>
<version>1.0.3</version>
<version>2.0.2</version>
</dependency>

<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>1.7.5</version>
<version>${neo4j.driver.version}</version>
</dependency>

<dependency>
Expand Down
@@ -1,8 +1,8 @@
package bi.know.kettle.neo4j.entries.check;

import bi.know.kettle.neo4j.shared.MetaStoreUtil;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.Driver;
import org.neo4j.driver.Session;
import org.neo4j.kettle.core.Neo4jDefaults;
import org.neo4j.kettle.shared.DriverSingleton;
import org.neo4j.kettle.shared.NeoConnection;
Expand Down Expand Up @@ -121,8 +121,7 @@ public CheckConnections( String name, String description ) {
}
connection.initializeVariablesFrom( this );

Driver driver = DriverSingleton.getDriver( log, connection );
Session session = driver.session();
Session session = connection.getSession( log );
session.close();

} catch ( Exception e ) {
Expand Down
Expand Up @@ -2,9 +2,9 @@

import bi.know.kettle.neo4j.shared.MetaStoreUtil;
import org.apache.commons.lang.StringUtils;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.Transaction;
import org.neo4j.driver.Driver;
import org.neo4j.driver.Session;
import org.neo4j.driver.Transaction;
import org.neo4j.kettle.core.Neo4jDefaults;
import org.neo4j.kettle.core.metastore.MetaStoreFactory;
import org.neo4j.kettle.shared.DriverSingleton;
Expand Down Expand Up @@ -126,16 +126,14 @@ public CypherScript( String name, String description ) {
//
connection.initializeVariablesFrom( this );

Driver driver = null;
Session session = null;
Transaction transaction = null;
int nrExecuted = 0;
try {

// Connect to the database
//
driver = DriverSingleton.getDriver( log, connection );
session = driver.session();
session = connection.getSession(log);
transaction = session.beginTransaction();

// Split the script into parts : semi-colon at the start of a separate line
Expand All @@ -159,12 +157,12 @@ public CypherScript( String name, String description ) {

// Commit
//
transaction.success();
transaction.commit();
} catch(Exception e) {
// Error connecting or executing
// Roll back
if (transaction!=null) {
transaction.failure();
transaction.rollback();
}
result.increaseErrors( 1L );
result.setResult( false );
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/bi/know/kettle/neo4j/shared/MetaStoreUtil.java
@@ -1,12 +1,15 @@
package bi.know.kettle.neo4j.shared;

import org.apache.commons.lang.StringUtils;
import org.pentaho.di.core.logging.LoggingObjectInterface;
import org.pentaho.di.job.Job;
import org.pentaho.di.metastore.MetaStoreConst;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.metastore.api.IMetaStore;
import org.pentaho.metastore.api.exceptions.MetaStoreException;
import org.pentaho.metastore.stores.delegate.DelegatingMetaStore;
import org.pentaho.metastore.stores.xml.XmlMetaStore;

public class MetaStoreUtil {

Expand Down Expand Up @@ -59,4 +62,37 @@ public static final IMetaStore findMetaStore( LoggingObjectInterface executor )

return MetaStoreConst.openLocalPentahoMetaStore();
}

public static final String getMetaStoreDescription(IMetaStore metaStore) throws MetaStoreException {
String name = metaStore.getName();
String desc = metaStore.getDescription();

String description = "";
if (metaStore instanceof DelegatingMetaStore ) {
DelegatingMetaStore delegatingMetaStore = (DelegatingMetaStore) metaStore;
boolean first = true;
for (IMetaStore store : delegatingMetaStore.getMetaStoreList()) {
if (first) {
description+="{ ";
} else {
description+=", ";
}
description+=getMetaStoreDescription( store );
if (first) {
description+=" }";
first = false;
}
}
} else if (metaStore instanceof XmlMetaStore ) {
String rootFolder = ((XmlMetaStore)metaStore).getRootFolder();
description += name + "( located in folder: " + rootFolder + " )";
} else {
if ( StringUtils.isNotEmpty(desc)) {
description += name + "(" + desc + ")";
} else {
description += name;
}
}
return description;
}
}

0 comments on commit a04dda9

Please sign in to comment.