Search in sources :

Example 1 with ColumnPrinter

use of org.neo4j.shell.ColumnPrinter in project neo4j by neo4j.

the class Schema method reportNodeIndexes.

private void reportNodeIndexes(Output out, org.neo4j.graphdb.schema.Schema schema, Label[] labels, String property, boolean verbose) throws RemoteException {
    ColumnPrinter printer = new ColumnPrinter(indent("ON "), "", "");
    Iterable<IndexDefinition> indexes = indexesByLabelAndProperty(schema, labels, property);
    int i = 0;
    for (IndexDefinition index : sort(indexes, LABEL_COMPARE_FUNCTION)) {
        if (i == 0) {
            out.println("Indexes");
        }
        String labelAndProperties = String.format(":%s(%s)", index.getLabel().name(), commaSeparate(index.getPropertyKeys()));
        IndexState state = schema.getIndexState(index);
        String uniqueOrNot = index.isConstraintIndex() ? "(for uniqueness constraint)" : "";
        printer.add(labelAndProperties, state, uniqueOrNot);
        if (verbose && state == IndexState.FAILED) {
            printer.addRaw(schema.getIndexFailure(index));
        }
        i++;
    }
    if (i == 0) {
        out.println("No indexes");
    } else {
        printer.print(out);
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) ColumnPrinter(org.neo4j.shell.ColumnPrinter) IndexState(org.neo4j.graphdb.schema.Schema.IndexState)

Example 2 with ColumnPrinter

use of org.neo4j.shell.ColumnPrinter in project neo4j by neo4j.

the class Ls method displayProperties.

private void displayProperties(NodeOrRelationship thing, Output out, boolean verbose, boolean quiet, Map<String, Object> filterMap, boolean caseInsensitiveFilters, boolean looseFilters, boolean brief) throws RemoteException {
    ColumnPrinter columnPrinter = quiet ? new ColumnPrinter("*") : new ColumnPrinter("*", "=");
    int count = 0;
    for (String key : sortKeys(thing.getPropertyKeys())) {
        Object value = thing.getProperty(key);
        if (!filterMatches(filterMap, caseInsensitiveFilters, looseFilters, key, value)) {
            continue;
        }
        count++;
        if (!brief) {
            if (quiet) {
                columnPrinter.add(key);
            } else {
                columnPrinter.add(key, verbose ? format(value, true) + " (" + getNiceType(value) + ")" : format(value, true));
            }
        }
    }
    columnPrinter.print(out);
    if (brief) {
        out.println("Property count: " + count);
    }
}
Also used : ColumnPrinter(org.neo4j.shell.ColumnPrinter)

Aggregations

ColumnPrinter (org.neo4j.shell.ColumnPrinter)2 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)1 IndexState (org.neo4j.graphdb.schema.Schema.IndexState)1