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;
}
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);
}
Aggregations