Search in sources :

Example 1 with RelationTypeVertex

use of org.janusgraph.graphdb.types.vertices.RelationTypeVertex in project janusgraph by JanusGraph.

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(JanusGraphSchemaElement 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 JanusGraphIndex) {
        IndexType index = ((JanusGraphIndexWrapper) 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 : RelationType(org.janusgraph.core.RelationType) InternalRelationType(org.janusgraph.graphdb.internal.InternalRelationType) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) IndexType(org.janusgraph.graphdb.types.IndexType) CompositeIndexType(org.janusgraph.graphdb.types.CompositeIndexType) MixedIndexType(org.janusgraph.graphdb.types.MixedIndexType) RelationTypeVertex(org.janusgraph.graphdb.types.vertices.RelationTypeVertex)

Example 2 with RelationTypeVertex

use of org.janusgraph.graphdb.types.vertices.RelationTypeVertex in project janusgraph by JanusGraph.

the class ManagementSystem method setStatusVertex.

private void setStatusVertex(JanusGraphSchemaVertex vertex, SchemaStatus status) {
    Preconditions.checkArgument(vertex instanceof RelationTypeVertex || vertex.asIndexType().isCompositeIndex());
    // Delete current status
    for (JanusGraphVertexProperty 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
    JanusGraphVertexProperty p = transaction.addProperty(vertex, BaseKey.SchemaDefinitionProperty, status);
    p.property(BaseKey.SchemaDefinitionDesc.name(), TypeDefinitionDescription.of(TypeDefinitionCategory.STATUS));
}
Also used : TypeDefinitionDescription(org.janusgraph.graphdb.types.TypeDefinitionDescription) JanusGraphVertexProperty(org.janusgraph.core.JanusGraphVertexProperty) RelationTypeVertex(org.janusgraph.graphdb.types.vertices.RelationTypeVertex)

Aggregations

RelationTypeVertex (org.janusgraph.graphdb.types.vertices.RelationTypeVertex)2 JanusGraphVertexProperty (org.janusgraph.core.JanusGraphVertexProperty)1 RelationType (org.janusgraph.core.RelationType)1 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)1 InternalRelationType (org.janusgraph.graphdb.internal.InternalRelationType)1 CompositeIndexType (org.janusgraph.graphdb.types.CompositeIndexType)1 IndexType (org.janusgraph.graphdb.types.IndexType)1 MixedIndexType (org.janusgraph.graphdb.types.MixedIndexType)1 TypeDefinitionDescription (org.janusgraph.graphdb.types.TypeDefinitionDescription)1