org.neo4j.driver.summary.Notification Java Examples

The following examples show how to use org.neo4j.driver.summary.Notification. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResultSummaryLogger.java    From neo4j-gremlin-bolt with Apache License 2.0 5 votes vote down vote up
public static void log(ResultSummary summary) {
    Objects.requireNonNull(summary, "summary cannot be null");
    // log information
    if (logger.isInfoEnabled() && summary.hasProfile()) {
        // create builder
        StringBuilder builder = new StringBuilder();
        // append statement
        builder.append("Profile for CYPHER statement: ").append(summary.query().text()).append("\n");
        // create profile information
        ProfileInformation profileInformation = new ProfileInformation();
        // process profile
        profileInformation.process(summary.profile());
        // log tabular results
        builder.append(profileInformation.toString());
        // log information
        logger.info(builder.toString());
    }
    // log notifications
    if (logger.isWarnEnabled()) {
        // loop notifications
        for (Notification notification : summary.notifications()) {
            // position if any
            InputPosition position = notification.position();
            // log information
            logger.warn("CYPHER statement [{}] notification; severity: {}, code: {}, title: {}, description: {}{}", summary.query().text(), notification.severity(), notification.code(), notification.title(), notification.description(), position != null ? ", [line: " + position.line() + ", position: " + position.column() + ", offset: " + position.offset() + "]" : "");
        }
    }
}
 
Example #2
Source File: Cypher.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 5 votes vote down vote up
private boolean processSummary( Result result ) {
  boolean error = false;
  ResultSummary summary = result.consume();
  for ( Notification notification : summary.notifications() ) {
    log.logError( notification.title() + " (" + notification.severity() + ")" );
    log.logError( notification.code() + " : " + notification.description() + ", position " + notification.position() );
    error = true;
  }
  return error;
}
 
Example #3
Source File: Neo4JOutput.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 5 votes vote down vote up
private void processSummary( Result result ) throws KettleException {
  boolean error = false;
  ResultSummary summary = result.consume();
  for ( Notification notification : summary.notifications() ) {
    log.logError( notification.title() + " (" + notification.severity() + ")" );
    log.logError( notification.code() + " : " + notification.description() + ", position " + notification.position() );
    error = true;
  }
  if ( error ) {
    throw new KettleException( "Error found while executing cypher statement(s)" );
  }
}
 
Example #4
Source File: GraphOutput.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 5 votes vote down vote up
private boolean processSummary( Result result ) {
  boolean errors = false;
  ResultSummary summary = result.consume();
  for ( Notification notification : summary.notifications() ) {
    log.logError( notification.title() + " (" + notification.severity() + ")" );
    log.logError( notification.code() + " : " + notification.description() + ", position " + notification.position() );
    errors = true;
  }
  return errors;
}
 
Example #5
Source File: Neo4jBoltQueryResult.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 4 votes vote down vote up
@Override
public String getResultSummary() {
    ResultSummary summary = buffer.getResultSummary();
    SummaryCounters counters = summary.counters();

    StringBuilder sb = new StringBuilder();
    sb.append(format("Query type: %s.\n", summary.queryType()));
    if (counters.containsUpdates()) {
        if (counters.nodesCreated() > 0) {
            sb.append(format("Nodes created: %s\n", counters.nodesCreated()));
        }
        if (counters.nodesDeleted() > 0) {
            sb.append(format("Nodes deleted: %s\n", counters.nodesDeleted()));
        }
        if (counters.labelsAdded() > 0) {
            sb.append(format("Labels added: %s\n", counters.labelsAdded()));
        }
        if (counters.labelsRemoved() > 0) {
            sb.append(format("Labels removed: %s\n", counters.labelsRemoved()));
        }
        if (counters.relationshipsCreated() > 0) {
            sb.append(format("Relationships created: %s\n", counters.relationshipsCreated()));
        }
        if (counters.relationshipsDeleted() > 0) {
            sb.append(format("Relationships deleted: %s\n", counters.relationshipsDeleted()));
        }
        if (counters.propertiesSet() > 0) {
            sb.append(format("Properties set: %s\n", counters.propertiesSet()));
        }
        if (counters.indexesAdded() > 0) {
            sb.append(format("Indexes added: %s\n", counters.indexesAdded()));
        }
        if (counters.indexesRemoved() > 0) {
            sb.append(format("Indexes removed: %s\n", counters.indexesRemoved()));
        }
        if (counters.constraintsAdded() > 0) {
            sb.append(format("Constrains added: %s\n", counters.constraintsAdded()));
        }
        if (counters.constraintsRemoved() > 0) {
            sb.append(format("Constrains removed: %s\n", counters.constraintsRemoved()));
        }
    }

    if (summary.hasProfile()) {
        sb.append("Profile:\n");
        profileToString(sb, summary.profile(), 1);
    } else if (summary.hasPlan()) {
        sb.append("Plan:\n");
        planToString(sb, summary.plan(), 1);
    }

    if (summary.notifications().size() > 0) {
        sb.append("Notifications:\n");
        for (Notification notification : summary.notifications()) {
            sb.append(format("[%s] %s(%s) - %s", notification.severity(),
                    notification.title(), notification.code(), notification.description()));
        }
    }
    return sb.toString();
}