public void retrieve(String vertexId, Graph graph, Authorizations authorizations) { Vertex retrievedVertex = graph.getVertex(vertexId, authorizations); if (retrievedVertex == null) { throw new VisalloException("failed to retrieve vertex by id: " + vertexId); } }
public Vertex getVertex(Graph graph, boolean includeHidden, Authorizations authorizations) { if (this.workspaceVertex == null) { this.workspaceVertex = graph.getVertex(getWorkspaceId(), includeHidden ? FetchHint.ALL_INCLUDING_HIDDEN : FetchHint.ALL, authorizations); } return this.workspaceVertex; }
private void benchmarkFindVerticesById(Random random, int vertexCount, int findVerticesByIdCount) { double startTime = System.currentTimeMillis(); for (int i = 0; i < findVerticesByIdCount; i++) { String vertexId = "v" + random.nextInt(vertexCount); graph.getVertex(vertexId, AUTHORIZATIONS_ALL); } graph.flush(); double endTime = System.currentTimeMillis(); LOGGER.info("find vertices by id in %.3fs", (endTime - startTime) / 1000); }
private void benchmarkFindVerticesById(Random random, int vertexCount, int findVerticesByIdCount) { double startTime = System.currentTimeMillis(); for (int i = 0; i < findVerticesByIdCount; i++) { String vertexId = "v" + random.nextInt(vertexCount); graph.getVertex(vertexId, AUTHORIZATIONS_ALL); } graph.flush(); double endTime = System.currentTimeMillis(); LOGGER.info("find vertices by id in %.3fs", (endTime - startTime) / 1000); }
/** * Get the attach vertex on either side of the edge. * * @param direction The side of the edge to get the vertex from (IN or OUT). * @param fetchHints Hint on what should be fetched from the datastore. * @return The vertex. */ default Vertex getVertex(Direction direction, FetchHints fetchHints, Authorizations authorizations) { String vertexId = getVertexId(direction); return getGraph().getVertex(vertexId, fetchHints, authorizations); }
@Override public JSONObject findById(String longRunningProcessId, User user) { Authorizations authorizations = getAuthorizations(user); Vertex vertex = this.graph.getVertex(longRunningProcessId, authorizations); if (vertex == null) { return null; } return LongRunningProcessProperties.QUEUE_ITEM_JSON_PROPERTY.getPropertyValue(vertex); }
/** * Find all term mentions connected to the vertex. */ public Iterable<Vertex> findByVertexId(String vertexId, Authorizations authorizations) { Authorizations authorizationsWithTermMention = getAuthorizations(authorizations); Vertex vertex = graph.getVertex(vertexId, authorizationsWithTermMention); String[] labels = new String[]{ VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION, VisalloProperties.TERM_MENTION_LABEL_RESOLVED_TO }; return vertex.getVertices(Direction.BOTH, labels, authorizationsWithTermMention); }
public Iterable<Vertex> findByOutVertex(String outVertexId, Authorizations authorizations) { Authorizations authorizationsWithTermMention = getAuthorizations(authorizations); Vertex outVertex = graph.getVertex(outVertexId, authorizationsWithTermMention); return outVertex.getVertices( Direction.OUT, VisalloProperties.TERM_MENTION_LABEL_HAS_TERM_MENTION, authorizationsWithTermMention ); }
public Iterable<Vertex> findResolvedTo(String inVertexId, Authorizations authorizations) { Authorizations authorizationsWithTermMention = getAuthorizations(authorizations); Vertex inVertex = graph.getVertex(inVertexId, authorizationsWithTermMention); return inVertex.getVertices( Direction.IN, VisalloProperties.TERM_MENTION_LABEL_RESOLVED_TO, authorizationsWithTermMention ); }
/** * Given a vertexId that represents one side of a relationship, get me the vertex of the other side. */ default Vertex getOtherVertex(String myVertexId, FetchHints fetchHints, Authorizations authorizations) { String vertexId = getOtherVertexId(myVertexId); return getGraph().getVertex(vertexId, fetchHints, authorizations); }
private Iterable<ClientApiSearch> getUserSavedSearches(User user, Authorizations authorizations) { Vertex userVertex = graph.getVertex(user.getUserId(), authorizations); checkNotNull(userVertex, "Could not find user vertex with id " + user.getUserId()); Iterable<Vertex> userSearchVertices = userVertex.getVertices( Direction.OUT, SearchProperties.HAS_SAVED_SEARCH, authorizations ); return stream(userSearchVertices) .map(searchVertex -> toClientApiSearch(searchVertex, ClientApiSearch.Scope.User)) .collect(Collectors.toList()); }
public Vertex getProductVertex(String workspaceId, String productId, User user) { Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations( user, VISIBILITY_STRING, workspaceId ); return getGraph().getVertex(productId, authorizations); }
@Override protected void processInternal(JSONObject jsonObject) { PingLongRunningProcessQueueItem queueItem = ClientApiConverter.toClientApi( jsonObject.toString(), PingLongRunningProcessQueueItem.class ); Authorizations authorizations = authorizationRepository.getGraphAuthorizations(userRepository.getSystemUser()); Vertex vertex = graph.getVertex(queueItem.getVertexId(), authorizations); pingUtil.lrpUpdate(vertex, graph, authorizations); }
private Vertex getVertexFromWorkspace(Workspace workspace, boolean includeHidden, Authorizations authorizations) { if (workspace instanceof VertexiumWorkspace) { return ((VertexiumWorkspace) workspace).getVertex(getGraph(), includeHidden, authorizations); } return getGraph().getVertex( workspace.getWorkspaceId(), includeHidden ? FetchHint.ALL_INCLUDING_HIDDEN : FetchHint.ALL, authorizations ); }
@Test public void testGetSingleVertexWithSameRowPrefix() { graph.addVertex("prefix", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY); graph.addVertex("prefixA", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY); graph.flush(); Vertex v = graph.getVertex("prefix", AUTHORIZATIONS_EMPTY); assertEquals("prefix", v.getId()); v = graph.getVertex("prefixA", AUTHORIZATIONS_EMPTY); assertEquals("prefixA", v.getId()); }
@Override public Vertex getVertex(Object id) { if (id == null) { throw new IllegalArgumentException("Id cannot be null"); } Authorizations authorizations = getAuthorizationsProvider().getAuthorizations(); return VertexiumBlueprintsVertex.create(this, getGraph().getVertex(VertexiumBlueprintsConvert.idToString(id), getFetchHints(), authorizations), authorizations); }
@Test public void testAddRowWithErrorThatSkipsRow() throws Exception { PropertyMapping fraudMapping = findPropertyMapping(TX_FRAUD_NAME); fraudMapping.errorHandlingStrategy = PropertyMapping.ErrorHandlingStrategy.SKIP_ROW; doParse(false, true, 0, new String[]{"John Smith", "3/13/2015", "you bet"}); Iterable<Vertex> vertices = getGraph().getVertices(authorizations); assertEquals("Expected new vertices to be created", 1, Iterables.size(vertices)); // CSV, PERSON Vertex personVertex = getGraph().getVertex("PERSON_VERTEX", authorizations); assertNull("Should not have found new person vertex", personVertex); Vertex txVertex = getGraph().getVertex("TX_VERTEX", authorizations); assertNull("Should not have found the transaction vertex", txVertex); }
@Test public void testBlankVisibilityString() { Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY); assertNotNull(v); assertEquals("v1", v.getId()); graph.flush(); v = graph.getVertex("v1", AUTHORIZATIONS_EMPTY); assertNotNull(v); assertEquals("v1", v.getId()); assertEquals(VISIBILITY_EMPTY, v.getVisibility()); }
@Test public void testBlankVisibilityString() { Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY); assertNotNull(v); assertEquals("v1", v.getId()); graph.flush(); v = graph.getVertex("v1", AUTHORIZATIONS_EMPTY); assertNotNull(v); assertEquals("v1", v.getId()); assertEquals(VISIBILITY_EMPTY, v.getVisibility()); }
@Test public void testStreamingPropertyValueReadAsString() { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("spv", StreamingPropertyValue.create("Hello World"), VISIBILITY_EMPTY) .save(AUTHORIZATIONS_EMPTY); graph.flush(); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_EMPTY); assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString()); assertEquals("Wor", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(6, 3)); assertEquals("", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString("Hello World".length(), 1)); assertEquals("Hello World", ((StreamingPropertyValue) v1.getPropertyValue("spv")).readToString(0, 100)); }