Search in sources :

Example 46 with HugeClient

use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.

the class EdgeLabelService method get.

public EdgeLabelEntity get(String name, int connId) {
    HugeClient client = this.client(connId);
    try {
        EdgeLabel edgeLabel = client.schema().getEdgeLabel(name);
        List<IndexLabel> indexLabels = client.schema().getIndexLabels();
        return convert(edgeLabel, indexLabels);
    } catch (ServerException e) {
        if (e.status() == Constant.STATUS_NOT_FOUND) {
            throw new ExternalException("schema.edgelabel.not-exist", e, name);
        }
        throw new ExternalException("schema.edgelabel.get.failed", e, name);
    }
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) ServerException(com.baidu.hugegraph.exception.ServerException) IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) ExternalException(com.baidu.hugegraph.exception.ExternalException)

Example 47 with HugeClient

use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyService method checkUsing.

/**
 * Check the property key is being used, used means that there is
 * any vertex label or edge label contains the property(name)
 */
public boolean checkUsing(String name, int connId) {
    HugeClient client = this.client(connId);
    List<VertexLabel> vertexLabels = client.schema().getVertexLabels();
    for (VertexLabel vertexLabel : vertexLabels) {
        if (vertexLabel.properties().contains(name)) {
            return true;
        }
    }
    List<EdgeLabel> edgeLabels = client.schema().getEdgeLabels();
    for (EdgeLabel edgeLabel : edgeLabels) {
        if (edgeLabel.properties().contains(name)) {
            return true;
        }
    }
    return false;
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel)

Example 48 with HugeClient

use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyService method add.

public void add(PropertyKeyEntity entity, int connId) {
    HugeClient client = this.client(connId);
    PropertyKey propertyKey = convert(entity, client);
    client.schema().addPropertyKey(propertyKey);
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey)

Example 49 with HugeClient

use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyService method list.

public List<PropertyKeyEntity> list(Collection<String> names, int connId, boolean emptyAsAll) {
    HugeClient client = this.client(connId);
    List<PropertyKey> propertyKeys;
    if (CollectionUtils.isEmpty(names)) {
        if (emptyAsAll) {
            propertyKeys = client.schema().getPropertyKeys();
        } else {
            propertyKeys = new ArrayList<>();
        }
    } else {
        propertyKeys = client.schema().getPropertyKeys(new ArrayList<>(names));
    }
    List<PropertyKeyEntity> results = new ArrayList<>(propertyKeys.size());
    propertyKeys.forEach(propertyKey -> {
        results.add(convert(propertyKey));
    });
    return results;
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) ArrayList(java.util.ArrayList) PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) PropertyKeyEntity(com.baidu.hugegraph.entity.schema.PropertyKeyEntity)

Example 50 with HugeClient

use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyService method remove.

public void remove(String name, int connId) {
    HugeClient client = this.client(connId);
    client.schema().removePropertyKey(name);
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient)

Aggregations

HugeClient (com.baidu.hugegraph.driver.HugeClient)66 Vertex (com.baidu.hugegraph.structure.graph.Vertex)21 ArrayList (java.util.ArrayList)16 ExternalException (com.baidu.hugegraph.exception.ExternalException)15 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)14 ServerException (com.baidu.hugegraph.exception.ServerException)12 GraphManager (com.baidu.hugegraph.driver.GraphManager)11 Edge (com.baidu.hugegraph.structure.graph.Edge)10 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)9 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)8 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)8 Test (org.junit.Test)8 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)7 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)6 ExecuteHistory (com.baidu.hugegraph.entity.query.ExecuteHistory)4 GraphView (com.baidu.hugegraph.entity.query.GraphView)4 LoadOptions (com.baidu.hugegraph.loader.executor.LoadOptions)4 ClientException (com.baidu.hugegraph.rest.ClientException)4 BeforeClass (org.junit.BeforeClass)4 GraphConnection (com.baidu.hugegraph.entity.GraphConnection)3