Search in sources :

Example 1 with JanusGraphSchemaCategory

use of org.janusgraph.graphdb.internal.JanusGraphSchemaCategory in project janusgraph by JanusGraph.

the class JanusGraphHadoopSetupImpl method getTypeInspector.

@Override
public TypeInspector getTypeInspector() {
    // Pre-load schema
    for (JanusGraphSchemaCategory sc : JanusGraphSchemaCategory.values()) {
        for (JanusGraphVertex k : QueryUtil.getVertices(tx, BaseKey.SchemaCategory, sc)) {
            assert k instanceof JanusGraphSchemaVertex;
            JanusGraphSchemaVertex s = (JanusGraphSchemaVertex) k;
            if (sc.hasName()) {
                String name = s.name();
                Preconditions.checkNotNull(name);
            }
            TypeDefinitionMap dm = s.getDefinition();
            Preconditions.checkNotNull(dm);
            s.getRelated(TypeDefinitionCategory.TYPE_MODIFIER, Direction.OUT);
            s.getRelated(TypeDefinitionCategory.TYPE_MODIFIER, Direction.IN);
        }
    }
    return tx;
}
Also used : JanusGraphVertex(org.janusgraph.core.JanusGraphVertex) JanusGraphSchemaVertex(org.janusgraph.graphdb.types.vertices.JanusGraphSchemaVertex) JanusGraphSchemaCategory(org.janusgraph.graphdb.internal.JanusGraphSchemaCategory) TypeDefinitionMap(org.janusgraph.graphdb.types.TypeDefinitionMap)

Example 2 with JanusGraphSchemaCategory

use of org.janusgraph.graphdb.internal.JanusGraphSchemaCategory in project janusgraph by JanusGraph.

the class ManagementSystem method changeName.

@Override
public void changeName(JanusGraphSchemaElement element, String newName) {
    Preconditions.checkArgument(StringUtils.isNotBlank(newName), "Invalid name: %s", newName);
    JanusGraphSchemaVertex schemaVertex = getSchemaVertex(element);
    if (schemaVertex.name().equals(newName))
        return;
    JanusGraphSchemaCategory schemaCategory = schemaVertex.valueOrNull(BaseKey.SchemaCategory);
    Preconditions.checkArgument(schemaCategory.hasName(), "Invalid schema element: %s", element);
    if (schemaVertex instanceof RelationType) {
        InternalRelationType relType = (InternalRelationType) schemaVertex;
        if (relType.getBaseType() != null) {
            newName = composeRelationTypeIndexName(relType.getBaseType(), newName);
        } else
            assert !(element instanceof RelationTypeIndex);
        JanusGraphSchemaCategory cat = relType.isEdgeLabel() ? JanusGraphSchemaCategory.EDGELABEL : JanusGraphSchemaCategory.PROPERTYKEY;
        SystemTypeManager.throwIfSystemName(cat, newName);
    } else if (element instanceof VertexLabel) {
        SystemTypeManager.throwIfSystemName(JanusGraphSchemaCategory.VERTEXLABEL, newName);
    } else if (element instanceof JanusGraphIndex) {
        checkIndexName(newName);
    }
    transaction.addProperty(schemaVertex, BaseKey.SchemaName, schemaCategory.getSchemaName(newName));
    updateSchemaVertex(schemaVertex);
    schemaVertex.resetCache();
    updatedTypes.add(schemaVertex);
}
Also used : VertexLabel(org.janusgraph.core.VertexLabel) RelationType(org.janusgraph.core.RelationType) InternalRelationType(org.janusgraph.graphdb.internal.InternalRelationType) JanusGraphSchemaVertex(org.janusgraph.graphdb.types.vertices.JanusGraphSchemaVertex) InternalRelationType(org.janusgraph.graphdb.internal.InternalRelationType) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) JanusGraphSchemaCategory(org.janusgraph.graphdb.internal.JanusGraphSchemaCategory) RelationTypeIndex(org.janusgraph.core.schema.RelationTypeIndex)

Aggregations

JanusGraphSchemaCategory (org.janusgraph.graphdb.internal.JanusGraphSchemaCategory)2 JanusGraphSchemaVertex (org.janusgraph.graphdb.types.vertices.JanusGraphSchemaVertex)2 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)1 RelationType (org.janusgraph.core.RelationType)1 VertexLabel (org.janusgraph.core.VertexLabel)1 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)1 RelationTypeIndex (org.janusgraph.core.schema.RelationTypeIndex)1 InternalRelationType (org.janusgraph.graphdb.internal.InternalRelationType)1 TypeDefinitionMap (org.janusgraph.graphdb.types.TypeDefinitionMap)1