Search in sources :

Example 1 with RelationTypeVertex

use of com.thinkaurelius.titan.graphdb.types.vertices.RelationTypeVertex 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 2 with RelationTypeVertex

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

the class ManagementSystem method setConsistency.

/**
     * Sets the consistency level for those schema elements that support it (types and internal indexes)
     * </p>
     * Note, that it is possible to have a race condition here if two threads simultaneously try to change the
     * consistency level. However, this is resolved when the consistency level is being read by taking the
     * first one and deleting all existing attached consistency levels upon modification.
     *
     * @param element
     * @param consistency
     */
@Override
public void setConsistency(TitanSchemaElement element, ConsistencyModifier consistency) {
    if (element instanceof RelationType) {
        RelationTypeVertex rv = (RelationTypeVertex) element;
        Preconditions.checkArgument(consistency != ConsistencyModifier.FORK || !rv.multiplicity().isConstrained(), "Cannot apply FORK consistency mode to constraint relation type: %s", rv.name());
    } else if (element instanceof TitanGraphIndex) {
        IndexType index = ((TitanGraphIndexWrapper) element).getBaseIndex();
        if (index.isMixedIndex())
            throw new IllegalArgumentException("Cannot change consistency on mixed index: " + element);
    } else
        throw new IllegalArgumentException("Cannot change consistency of schema element: " + element);
    setTypeModifier(element, ModifierType.CONSISTENCY, consistency);
}
Also used : InternalRelationType(com.thinkaurelius.titan.graphdb.internal.InternalRelationType) RelationType(com.thinkaurelius.titan.core.RelationType) IndexType(com.thinkaurelius.titan.graphdb.types.IndexType) MixedIndexType(com.thinkaurelius.titan.graphdb.types.MixedIndexType) CompositeIndexType(com.thinkaurelius.titan.graphdb.types.CompositeIndexType) TitanGraphIndex(com.thinkaurelius.titan.core.schema.TitanGraphIndex) RelationTypeVertex(com.thinkaurelius.titan.graphdb.types.vertices.RelationTypeVertex)

Aggregations

RelationTypeVertex (com.thinkaurelius.titan.graphdb.types.vertices.RelationTypeVertex)2 RelationType (com.thinkaurelius.titan.core.RelationType)1 TitanVertexProperty (com.thinkaurelius.titan.core.TitanVertexProperty)1 TitanGraphIndex (com.thinkaurelius.titan.core.schema.TitanGraphIndex)1 InternalRelationType (com.thinkaurelius.titan.graphdb.internal.InternalRelationType)1 CompositeIndexType (com.thinkaurelius.titan.graphdb.types.CompositeIndexType)1 IndexType (com.thinkaurelius.titan.graphdb.types.IndexType)1 MixedIndexType (com.thinkaurelius.titan.graphdb.types.MixedIndexType)1 TypeDefinitionDescription (com.thinkaurelius.titan.graphdb.types.TypeDefinitionDescription)1