/** * Returns the name of the vertex label for this vertex. * * @return */ @Override default String label() { return vertexLabel().name(); }
private static IDManager.VertexIDType getVertexIDType(JanusGraphVertex v) { return getVertexIDType(v.vertexLabel()); }
public boolean matchesConstraint(JanusGraphSchemaType type, JanusGraphElement element) { Preconditions.checkArgument(type != null && element!=null); assert isInstance(element); assert isValidConstraint(type); switch(this) { case VERTEX: return ((JanusGraphVertex)element).vertexLabel().equals(type); case EDGE: return ((JanusGraphEdge)element).edgeLabel().equals(type); case PROPERTY: return ((JanusGraphVertexProperty)element).propertyKey().equals(type); default: throw new IllegalArgumentException(); } }
private void checkPropertyConstraintForVertexOrCreatePropertyConstraint(JanusGraphVertex vertex, PropertyKey key) { if (config.hasDisabledSchemaConstraints()) return; VertexLabel vertexLabel = vertex.vertexLabel(); if (vertexLabel instanceof BaseVertexLabel) return; Collection<PropertyKey> propertyKeys = vertexLabel.mappedProperties(); if (propertyKeys.contains(key)) return; config.getAutoSchemaMaker().makePropertyConstraintForVertex(vertexLabel, key, this); }
private void checkConnectionConstraintOrCreateConnectionConstraint(JanusGraphVertex outVertex, JanusGraphVertex inVertex, EdgeLabel edgeLabel) { if (config.hasDisabledSchemaConstraints()) return; VertexLabel outVertexLabel = outVertex.vertexLabel(); if (outVertexLabel instanceof BaseVertexLabel) return; VertexLabel inVertexLabel = inVertex.vertexLabel(); if (inVertexLabel instanceof BaseVertexLabel) return; Collection<Connection> connections = outVertexLabel.mappedConnections(); for (Connection connection : connections) { if (connection.getIncomingVertexLabel() != inVertexLabel) continue; if (connection.getEdgeLabel().equals(edgeLabel.name())) return; } config.getAutoSchemaMaker().makeConnectionConstraint(edgeLabel, outVertexLabel, inVertexLabel, this); }
@Test public void testIndexQueryWithLabelsAndContainsIN() { // This test is based on the steps to reproduce #882 String labelName = "labelName"; VertexLabel label = mgmt.makeVertexLabel(labelName).make(); PropertyKey uid = mgmt.makePropertyKey("uid").dataType(String.class).make(); JanusGraphIndex uidCompositeIndex = mgmt.buildIndex("uidIndex", Vertex.class) .indexOnly(label).addKey(uid).unique().buildCompositeIndex(); mgmt.setConsistency(uidCompositeIndex, ConsistencyModifier.LOCK); finishSchema(); JanusGraphVertex foo = graph.addVertex(labelName); JanusGraphVertex bar = graph.addVertex(labelName); foo.property("uid", "foo"); bar.property("uid", "bar"); graph.tx().commit(); Iterable<JanusGraphVertex> vertexes = graph.query() .has("uid", Contain.IN, ImmutableList.of("foo", "bar")) .has(LABEL_NAME, labelName) .vertices(); assertEquals(2, Iterables.size(vertexes)); for (JanusGraphVertex v : vertexes) { assertEquals(labelName, v.vertexLabel().name()); } }