use of org.janusgraph.graphdb.types.TypeDefinitionDescription in project janusgraph by JanusGraph.
the class ManagementSystem method setStatusEdges.
private void setStatusEdges(JanusGraphSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) {
Preconditions.checkArgument(vertex.asIndexType().isMixedIndex());
for (JanusGraphEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD, Direction.OUT)) {
// Only address edges with matching keys
if (!keys.contains(edge.vertex(Direction.IN)))
continue;
TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc);
assert desc.getCategory() == TypeDefinitionCategory.INDEX_FIELD;
Parameter[] parameters = (Parameter[]) desc.getModifier();
assert parameters[parameters.length - 1].key().equals(ParameterType.STATUS.getName());
if (parameters[parameters.length - 1].value().equals(status))
continue;
Parameter[] paraCopy = Arrays.copyOf(parameters, parameters.length);
paraCopy[parameters.length - 1] = ParameterType.STATUS.getParameter(status);
edge.remove();
addSchemaEdge(vertex, edge.vertex(Direction.IN), TypeDefinitionCategory.INDEX_FIELD, paraCopy);
}
for (PropertyKeyVertex prop : keys) prop.resetCache();
}
use of org.janusgraph.graphdb.types.TypeDefinitionDescription 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));
}
use of org.janusgraph.graphdb.types.TypeDefinitionDescription in project janusgraph by JanusGraph.
the class StandardJanusGraphTx method addSchemaEdge.
public JanusGraphEdge addSchemaEdge(JanusGraphVertex out, JanusGraphVertex in, TypeDefinitionCategory def, Object modifier) {
assert def.isEdge();
JanusGraphEdge edge = addEdge(out, in, BaseLabel.SchemaDefinitionEdge);
TypeDefinitionDescription desc = new TypeDefinitionDescription(def, modifier);
edge.property(BaseKey.SchemaDefinitionDesc.name(), desc);
return edge;
}
Aggregations