Search in sources :

Example 16 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyTest method testSetCheckExist.

@Test
public void testSetCheckExist() {
    SchemaManager schema = schema();
    PropertyKey age = schema.propertyKey("age").userdata("min", 0).userdata("max", 100).create();
    Assert.assertTrue(age.checkExist());
    age.checkExist(false);
    Assert.assertFalse(age.checkExist());
}
Also used : SchemaManager(com.baidu.hugegraph.driver.SchemaManager) PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 17 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyTest method testPropertyKeyV58.

@Test
public void testPropertyKeyV58() {
    PropertyKey.Builder builder = new PropertyKey.BuilderImpl("name", null);
    PropertyKey propertyKey = builder.dataType(DataType.INT).cardinality(Cardinality.SINGLE).userdata("min", 1).userdata("max", 100).build();
    PropertyKey.PropertyKeyV58 propertyKeyV58 = propertyKey.switchV58();
    String pkV58String = "{name=name, cardinality=SINGLE, " + "dataType=INT, aggregateType=NONE, properties=[]}";
    Assert.assertEquals(pkV58String, propertyKeyV58.toString());
    Assert.assertEquals(HugeType.PROPERTY_KEY.string(), propertyKeyV58.type());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 18 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyTest method testPropertyKey.

@Test
public void testPropertyKey() {
    PropertyKey.Builder builder = new PropertyKey.BuilderImpl("name", null);
    PropertyKey propertyKey = builder.dataType(DataType.INT).cardinality(Cardinality.SINGLE).userdata("min", 1).userdata("max", 100).build();
    String pkString = "{name=name, cardinality=SINGLE, dataType=INT, " + "aggregateType=NONE, properties=[], " + "writeType=OLTP}";
    Assert.assertEquals(pkString, propertyKey.toString());
    Assert.assertEquals(HugeType.PROPERTY_KEY.string(), propertyKey.type());
    Assert.assertEquals(0, propertyKey.aggregateType().code());
    Assert.assertEquals("none", propertyKey.aggregateType().string());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 19 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyTest method testPropertyKeyV46.

@Test
public void testPropertyKeyV46() {
    PropertyKey.Builder builder = new PropertyKey.BuilderImpl("name", null);
    PropertyKey propertyKey = builder.dataType(DataType.INT).cardinality(Cardinality.SINGLE).userdata("min", 1).userdata("max", 100).build();
    PropertyKey.PropertyKeyV46 propertyKeyV46 = propertyKey.switchV46();
    String pkV46String = "{name=name, cardinality=SINGLE, " + "dataType=INT, properties=[]}";
    Assert.assertEquals(pkV46String, propertyKeyV46.toString());
    Assert.assertEquals(HugeType.PROPERTY_KEY.string(), propertyKeyV46.type());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 20 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey 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)

Aggregations

PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)40 Test (org.junit.Test)27 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)7 HugeClient (com.baidu.hugegraph.driver.HugeClient)6 RestResult (com.baidu.hugegraph.rest.RestResult)6 ExternalException (com.baidu.hugegraph.exception.ExternalException)4 Date (java.util.Date)4 ServerException (com.baidu.hugegraph.exception.ServerException)3 PropertyKeyEntity (com.baidu.hugegraph.entity.schema.PropertyKeyEntity)2 Vertex (com.baidu.hugegraph.structure.graph.Vertex)2 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)2 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)2 GremlinRequest (com.baidu.hugegraph.api.gremlin.GremlinRequest)1 NotSupportException (com.baidu.hugegraph.exception.NotSupportException)1 InputSource (com.baidu.hugegraph.loader.source.InputSource)1 FileSource (com.baidu.hugegraph.loader.source.file.FileSource)1 ListFormat (com.baidu.hugegraph.loader.source.file.ListFormat)1 Edge (com.baidu.hugegraph.structure.graph.Edge)1 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)1 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)1