Search in sources :

Example 1 with TitanSchemaCategory

use of com.thinkaurelius.titan.graphdb.internal.TitanSchemaCategory in project titan by thinkaurelius.

the class ManagementSystem method changeName.

@Override
public void changeName(TitanSchemaElement element, String newName) {
    Preconditions.checkArgument(StringUtils.isNotBlank(newName), "Invalid name: %s", newName);
    TitanSchemaVertex schemaVertex = getSchemaVertex(element);
    if (schemaVertex.name().equals(newName))
        return;
    TitanSchemaCategory 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);
        TitanSchemaCategory cat = relType.isEdgeLabel() ? TitanSchemaCategory.EDGELABEL : TitanSchemaCategory.PROPERTYKEY;
        SystemTypeManager.isNotSystemName(cat, newName);
    } else if (element instanceof VertexLabel) {
        SystemTypeManager.isNotSystemName(TitanSchemaCategory.VERTEXLABEL, newName);
    } else if (element instanceof TitanGraphIndex) {
        checkIndexName(newName);
    }
    transaction.addProperty(schemaVertex, BaseKey.SchemaName, schemaCategory.getSchemaName(newName));
    updateSchemaVertex(schemaVertex);
    schemaVertex.resetCache();
    updatedTypes.add(schemaVertex);
}
Also used : TitanSchemaVertex(com.thinkaurelius.titan.graphdb.types.vertices.TitanSchemaVertex) TitanSchemaCategory(com.thinkaurelius.titan.graphdb.internal.TitanSchemaCategory) VertexLabel(com.thinkaurelius.titan.core.VertexLabel) InternalRelationType(com.thinkaurelius.titan.graphdb.internal.InternalRelationType) RelationType(com.thinkaurelius.titan.core.RelationType) InternalRelationType(com.thinkaurelius.titan.graphdb.internal.InternalRelationType) RelationTypeIndex(com.thinkaurelius.titan.core.schema.RelationTypeIndex) TitanGraphIndex(com.thinkaurelius.titan.core.schema.TitanGraphIndex)

Example 2 with TitanSchemaCategory

use of com.thinkaurelius.titan.graphdb.internal.TitanSchemaCategory in project titan by thinkaurelius.

the class TitanHadoopSetupImpl method getTypeInspector.

@Override
public TypeInspector getTypeInspector() {
    //Pre-load schema
    for (TitanSchemaCategory sc : TitanSchemaCategory.values()) {
        for (TitanVertex k : QueryUtil.getVertices(tx, BaseKey.SchemaCategory, sc)) {
            assert k instanceof TitanSchemaVertex;
            TitanSchemaVertex s = (TitanSchemaVertex) 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 : TitanVertex(com.thinkaurelius.titan.core.TitanVertex) TitanSchemaVertex(com.thinkaurelius.titan.graphdb.types.vertices.TitanSchemaVertex) TitanSchemaCategory(com.thinkaurelius.titan.graphdb.internal.TitanSchemaCategory) TypeDefinitionMap(com.thinkaurelius.titan.graphdb.types.TypeDefinitionMap)

Aggregations

TitanSchemaCategory (com.thinkaurelius.titan.graphdb.internal.TitanSchemaCategory)2 TitanSchemaVertex (com.thinkaurelius.titan.graphdb.types.vertices.TitanSchemaVertex)2 RelationType (com.thinkaurelius.titan.core.RelationType)1 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)1 VertexLabel (com.thinkaurelius.titan.core.VertexLabel)1 RelationTypeIndex (com.thinkaurelius.titan.core.schema.RelationTypeIndex)1 TitanGraphIndex (com.thinkaurelius.titan.core.schema.TitanGraphIndex)1 InternalRelationType (com.thinkaurelius.titan.graphdb.internal.InternalRelationType)1 TypeDefinitionMap (com.thinkaurelius.titan.graphdb.types.TypeDefinitionMap)1