Search in sources :

Example 1 with EdgeLabelVertex

use of com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex in project titan by thinkaurelius.

the class StandardTitanTx method makeSchemaVertex.

/*
     * ------------------------------------ Schema Handling ------------------------------------
     */
public final TitanSchemaVertex makeSchemaVertex(TitanSchemaCategory schemaCategory, String name, TypeDefinitionMap definition) {
    verifyOpen();
    Preconditions.checkArgument(!schemaCategory.hasName() || StringUtils.isNotBlank(name), "Need to provide a valid name for type [%s]", schemaCategory);
    schemaCategory.verifyValidDefinition(definition);
    TitanSchemaVertex schemaVertex;
    if (schemaCategory.isRelationType()) {
        if (schemaCategory == TitanSchemaCategory.PROPERTYKEY) {
            schemaVertex = new PropertyKeyVertex(this, IDManager.getTemporaryVertexID(IDManager.VertexIDType.UserPropertyKey, temporaryIds.nextID()), ElementLifeCycle.New);
        } else {
            assert schemaCategory == TitanSchemaCategory.EDGELABEL;
            schemaVertex = new EdgeLabelVertex(this, IDManager.getTemporaryVertexID(IDManager.VertexIDType.UserEdgeLabel, temporaryIds.nextID()), ElementLifeCycle.New);
        }
    } else if (schemaCategory == TitanSchemaCategory.VERTEXLABEL) {
        schemaVertex = new VertexLabelVertex(this, IDManager.getTemporaryVertexID(IDManager.VertexIDType.GenericSchemaType, temporaryIds.nextID()), ElementLifeCycle.New);
    } else {
        schemaVertex = new TitanSchemaVertex(this, IDManager.getTemporaryVertexID(IDManager.VertexIDType.GenericSchemaType, temporaryIds.nextID()), ElementLifeCycle.New);
    }
    graph.assignID(schemaVertex, BaseVertexLabel.DEFAULT_VERTEXLABEL);
    Preconditions.checkArgument(schemaVertex.longId() > 0);
    if (schemaCategory.hasName())
        addProperty(schemaVertex, BaseKey.SchemaName, schemaCategory.getSchemaName(name));
    addProperty(schemaVertex, BaseKey.VertexExists, Boolean.TRUE);
    addProperty(schemaVertex, BaseKey.SchemaCategory, schemaCategory);
    updateSchemaVertex(schemaVertex);
    addProperty(schemaVertex, BaseKey.SchemaUpdateTime, times.getTime(times.getTime()));
    for (Map.Entry<TypeDefinitionCategory, Object> def : definition.entrySet()) {
        TitanVertexProperty p = addProperty(schemaVertex, BaseKey.SchemaDefinitionProperty, def.getValue());
        p.property(BaseKey.SchemaDefinitionDesc.name(), TypeDefinitionDescription.of(def.getKey()));
    }
    vertexCache.add(schemaVertex, schemaVertex.longId());
    if (schemaCategory.hasName())
        newTypeCache.put(schemaCategory.getSchemaName(name), schemaVertex.longId());
    return schemaVertex;
}
Also used : TitanSchemaVertex(com.thinkaurelius.titan.graphdb.types.vertices.TitanSchemaVertex) EdgeLabelVertex(com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex) PropertyKeyVertex(com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex) NonBlockingHashMap(org.cliffc.high_scale_lib.NonBlockingHashMap)

Aggregations

EdgeLabelVertex (com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex)1 PropertyKeyVertex (com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex)1 TitanSchemaVertex (com.thinkaurelius.titan.graphdb.types.vertices.TitanSchemaVertex)1 NonBlockingHashMap (org.cliffc.high_scale_lib.NonBlockingHashMap)1