Search in sources :

Example 1 with VertexiumException

use of org.vertexium.VertexiumException in project vertexium by visallo.

the class SortContainersComparator method compare.

private int compare(QueryBase.SortContainer sortContainer, T vertexiumObject1, T vertexiumObject2) {
    if (vertexiumObject1 instanceof VertexiumObject && vertexiumObject2 instanceof VertexiumObject) {
        VertexiumObject elem1 = (VertexiumObject) vertexiumObject1;
        VertexiumObject elem2 = (VertexiumObject) vertexiumObject2;
        List<Object> elem1PropertyValues = toList(elem1.getPropertyValues(sortContainer.propertyName));
        List<Object> elem2PropertyValues = toList(elem2.getPropertyValues(sortContainer.propertyName));
        if (elem1PropertyValues.size() > 0 && elem2PropertyValues.size() == 0) {
            return -1;
        } else if (elem2PropertyValues.size() > 0 && elem1PropertyValues.size() == 0) {
            return 1;
        } else {
            for (Object elem1PropertyValue : elem1PropertyValues) {
                for (Object elem2PropertyValue : elem2PropertyValues) {
                    int result = comparePropertyValues(elem1PropertyValue, elem2PropertyValue);
                    if (result != 0) {
                        return sortContainer.direction == SortDirection.ASCENDING ? result : -result;
                    }
                }
            }
        }
        return 0;
    } else {
        throw new VertexiumException("unexpected searchable item combination: " + vertexiumObject1.getClass().getName() + ", " + vertexiumObject2.getClass().getName());
    }
}
Also used : VertexiumObject(org.vertexium.VertexiumObject) VertexiumObject(org.vertexium.VertexiumObject) VertexiumException(org.vertexium.VertexiumException)

Example 2 with VertexiumException

use of org.vertexium.VertexiumException in project vertexium by visallo.

the class CypherCstToAstVisitor method toBinaryExpressions.

private <T extends ParseTree> CypherBinaryExpression toBinaryExpressions(List<ParseTree> children, Function<T, CypherAstBase> itemTransform) {
    CypherAstBase left = null;
    CypherBinaryExpression.Op op = null;
    for (int i = 0; i < children.size(); i++) {
        ParseTree child = children.get(i);
        if (child instanceof TerminalNode) {
            CypherBinaryExpression.Op newOp = CypherBinaryExpression.Op.parseOrNull(child.getText());
            if (newOp != null) {
                if (op == null) {
                    op = newOp;
                } else {
                    throw new VertexiumException("unexpected op, found too many ops in a row");
                }
            }
        } else {
            // noinspection unchecked
            CypherAstBase childObj = itemTransform.apply((T) child);
            if (left == null) {
                left = childObj;
            } else {
                if (op == null) {
                    throw new VertexiumException("unexpected binary expression. expected an op between expressions");
                }
                left = new CypherBinaryExpression(left, op, childObj);
            }
            op = null;
        }
    }
    return (CypherBinaryExpression) left;
}
Also used : TerminalNode(org.antlr.v4.runtime.tree.TerminalNode) ParseTree(org.antlr.v4.runtime.tree.ParseTree) VertexiumException(org.vertexium.VertexiumException)

Example 3 with VertexiumException

use of org.vertexium.VertexiumException in project vertexium by visallo.

the class AccumuloGraphConfiguration method createConnector.

public Connector createConnector() {
    try {
        LOGGER.info("Connecting to accumulo instance [%s] zookeeper servers [%s]", this.getAccumuloInstanceName(), this.getZookeeperServers());
        ZooKeeperInstance instance = new ZooKeeperInstance(getClientConfiguration());
        return instance.getConnector(this.getAccumuloUsername(), this.getAuthenticationToken());
    } catch (Exception ex) {
        throw new VertexiumException(String.format("Could not connect to Accumulo instance [%s] zookeeper servers [%s]", this.getAccumuloInstanceName(), this.getZookeeperServers()), ex);
    }
}
Also used : VertexiumException(org.vertexium.VertexiumException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) VertexiumException(org.vertexium.VertexiumException) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 4 with VertexiumException

use of org.vertexium.VertexiumException in project vertexium by visallo.

the class AccumuloGraphTestUtils method createTable.

private static void createTable(Connector connector, String tableName) {
    try {
        NewTableConfiguration config = new NewTableConfiguration().withoutDefaultIterators().setTimeType(TimeType.MILLIS);
        connector.tableOperations().create(tableName, config);
    } catch (Exception e) {
        throw new VertexiumException("Unable to create table " + tableName);
    }
}
Also used : NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) VertexiumException(org.vertexium.VertexiumException) VertexiumException(org.vertexium.VertexiumException)

Example 5 with VertexiumException

use of org.vertexium.VertexiumException in project vertexium by visallo.

the class AccumuloResource method addAuthorizations.

public void addAuthorizations(AccumuloGraph graph, String... authorizations) {
    try {
        String principal = graph.getConnector().whoami();
        Authorizations currentAuthorizations = graph.getConnector().securityOperations().getUserAuthorizations(principal);
        List<byte[]> newAuthorizationsArray = new ArrayList<>();
        for (byte[] currentAuth : currentAuthorizations) {
            newAuthorizationsArray.add(currentAuth);
        }
        for (String authorization : authorizations) {
            if (!currentAuthorizations.contains(authorization)) {
                newAuthorizationsArray.add(authorization.getBytes(UTF_8));
            }
        }
        Authorizations newAuthorizations = new Authorizations(newAuthorizationsArray);
        graph.getConnector().securityOperations().changeUserAuthorizations(principal, newAuthorizations);
    } catch (Exception ex) {
        throw new VertexiumException("could not add authorizations", ex);
    }
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) ArrayList(java.util.ArrayList) VertexiumException(org.vertexium.VertexiumException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) VertexiumException(org.vertexium.VertexiumException)

Aggregations

VertexiumException (org.vertexium.VertexiumException)34 Aggregation (org.elasticsearch.search.aggregations.Aggregation)6 MultiBucketsAggregation (org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)3 Key (org.apache.accumulo.core.data.Key)3 Value (org.apache.accumulo.core.data.Value)3 DataTableRowKey (org.vertexium.accumulo.keys.DataTableRowKey)3 StreamingPropertyValue (org.vertexium.property.StreamingPropertyValue)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 List (java.util.List)2 ScannerBase (org.apache.accumulo.core.client.ScannerBase)2 Span (org.apache.accumulo.core.trace.Span)2 GeoHashGrid (org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGrid)2 InternalGeoHashGrid (org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid)2 Histogram (org.elasticsearch.search.aggregations.bucket.histogram.Histogram)2 InternalDateHistogram (org.elasticsearch.search.aggregations.bucket.histogram.InternalDateHistogram)2 InternalHistogram (org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram)2