Search in sources :

Example 1 with TypeDefinitionDescription

use of com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription in project titan by thinkaurelius.

the class ManagementSystem method addSchemaEdge.

private TitanEdge addSchemaEdge(TitanVertex out, TitanVertex in, TypeDefinitionCategory def, Object modifier) {
    assert def.isEdge();
    TitanEdge edge = transaction.addEdge(out, in, BaseLabel.SchemaDefinitionEdge);
    TypeDefinitionDescription desc = new TypeDefinitionDescription(def, modifier);
    edge.property(BaseKey.SchemaDefinitionDesc.name(), desc);
    return edge;
}
Also used : TypeDefinitionDescription(com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription) TitanEdge(com.thinkaurelius.titan.core.TitanEdge)

Example 2 with TypeDefinitionDescription

use of com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription in project titan by thinkaurelius.

the class TypeDefinitionDescriptionSerializer method read.

@Override
public TypeDefinitionDescription read(ScanBuffer buffer) {
    TypeDefinitionCategory defCategory = serializer.readObjectNotNull(buffer, TypeDefinitionCategory.class);
    Object modifier = serializer.readClassAndObject(buffer);
    return new TypeDefinitionDescription(defCategory, modifier);
}
Also used : TypeDefinitionCategory(com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory) TypeDefinitionDescription(com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription)

Example 3 with TypeDefinitionDescription

use of com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription in project titan by thinkaurelius.

the class ManagementSystem method setStatusVertex.

private void setStatusVertex(TitanSchemaVertex vertex, SchemaStatus status) {
    Preconditions.checkArgument(vertex instanceof RelationTypeVertex || vertex.asIndexType().isCompositeIndex());
    //Delete current status
    for (TitanVertexProperty p : vertex.query().types(BaseKey.SchemaDefinitionProperty).properties()) {
        if (p.<TypeDefinitionDescription>valueOrNull(BaseKey.SchemaDefinitionDesc).getCategory() == TypeDefinitionCategory.STATUS) {
            if (p.value().equals(status))
                return;
            else
                p.remove();
        }
    }
    //Add new status
    TitanVertexProperty p = transaction.addProperty(vertex, BaseKey.SchemaDefinitionProperty, status);
    p.property(BaseKey.SchemaDefinitionDesc.name(), TypeDefinitionDescription.of(TypeDefinitionCategory.STATUS));
}
Also used : TypeDefinitionDescription(com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription) TitanVertexProperty(com.thinkaurelius.titan.core.TitanVertexProperty) RelationTypeVertex(com.thinkaurelius.titan.graphdb.types.vertices.RelationTypeVertex)

Example 4 with TypeDefinitionDescription

use of com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription in project titan by thinkaurelius.

the class ManagementSystem method setStatusEdges.

private void setStatusEdges(TitanSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) {
    Preconditions.checkArgument(vertex.asIndexType().isMixedIndex());
    for (TitanEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD, Direction.OUT)) {
        //Only address edges with matching keys
        if (!keys.contains(edge.vertex(Direction.IN)))
            continue;
        TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc);
        assert desc.getCategory() == TypeDefinitionCategory.INDEX_FIELD;
        Parameter[] parameters = (Parameter[]) desc.getModifier();
        assert parameters[parameters.length - 1].key().equals(ParameterType.STATUS.getName());
        if (parameters[parameters.length - 1].value().equals(status))
            continue;
        Parameter[] paraCopy = Arrays.copyOf(parameters, parameters.length);
        paraCopy[parameters.length - 1] = ParameterType.STATUS.getParameter(status);
        edge.remove();
        addSchemaEdge(vertex, edge.vertex(Direction.IN), TypeDefinitionCategory.INDEX_FIELD, paraCopy);
    }
    for (PropertyKeyVertex prop : keys) prop.resetCache();
}
Also used : TypeDefinitionDescription(com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription) Parameter(com.thinkaurelius.titan.core.schema.Parameter) PropertyKeyVertex(com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex) TitanEdge(com.thinkaurelius.titan.core.TitanEdge)

Aggregations

TypeDefinitionDescription (com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription)4 TitanEdge (com.thinkaurelius.titan.core.TitanEdge)2 TitanVertexProperty (com.thinkaurelius.titan.core.TitanVertexProperty)1 Parameter (com.thinkaurelius.titan.core.schema.Parameter)1 TypeDefinitionCategory (com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory)1 PropertyKeyVertex (com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex)1 RelationTypeVertex (com.thinkaurelius.titan.graphdb.types.vertices.RelationTypeVertex)1