bamaer commented on code in PR #9360:
URL: https://github.com/apache/hop/pull/9360#discussion_r4539243916
##########
plugins/tech/neo4j/src/main/java/org/apache/hop/neo4j/actions/index/Neo4jIndex.java:
##########
@@ -75,40 +75,37 @@ public Result execute(Result result, int nr) throws
HopException {
// Success unless something goes wrong, whatever the result of the
previous action
result.setResult(true);
- connection =
- NeoConnectionUtils.findGraphConnection(getMetadataProvider(),
resolve(connectionName));
-
- if (connection == null) {
- result.setResult(false);
- result.increaseErrors(1L);
- throw new HopException("Please specify a Neo4j connection to use");
- }
+ try {
+ connection =
+ NeoConnectionUtils.getGraphConnection(getMetadataProvider(),
resolve(connectionName));
- // Loop over the index updates to see which need deleting...
- //
- for (IndexUpdate indexUpdate : indexUpdates) {
- if (indexUpdate.getType() == null) {
- throw new HopException("Please make sure to always specify an index
update type");
+ for (IndexUpdate indexUpdate : indexUpdates) {
+ if (indexUpdate.getType() == null) {
+ throw new HopException("Please make sure to always specify an index
update type");
+ }
}
- switch (indexUpdate.getType()) {
- case DROP:
+
+ // Drop the indexes first...
+ //
+ for (IndexUpdate indexUpdate : indexUpdates) {
+ if (indexUpdate.getType() == UpdateType.DROP) {
dropIndex(indexUpdate);
- break;
- default:
- break;
+ }
}
- }
- // Create the indexes if needed
- //
- for (IndexUpdate indexUpdate : indexUpdates) {
- switch (indexUpdate.getType()) {
- case CREATE:
+ // ... then create the indexes
+ //
+ for (IndexUpdate indexUpdate : indexUpdates) {
+ if (indexUpdate.getType() == UpdateType.CREATE) {
createIndex(indexUpdate);
- break;
- default:
- break;
+ }
}
+ } catch (Exception e) {
Review Comment:
Agreed that it belongs in the engine. It changes what happens for every
action that throws today, so I'd keep it for a separate issue rather than this
PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]