@Override public Vertex addVertex(Visibility visibility, Authorizations authorizations) { return prepareVertex(visibility).save(authorizations); }
@Test public void testLargeFieldValuesThatAreMarkedWithExactMatch() { graph.defineProperty("field1").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH).define(); StringBuilder largeText = new StringBuilder(); for (int i = 0; i < 10000; i++) { largeText.append("test "); } graph.prepareVertex("v1", VISIBILITY_EMPTY) .addPropertyValue("", "field1", largeText.toString(), VISIBILITY_EMPTY) .save(AUTHORIZATIONS_EMPTY); graph.flush(); }
@Test public void testNullPropertyValue() { try { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("prop1", null, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); throw new VertexiumException("expected null check"); } catch (NullPointerException ex) { assertTrue(ex.getMessage().contains("prop1")); } }
void updatePropertiesInternal(VertexBuilder vertexBuilder) { updatePropertiesInternal( vertexBuilder.getProperties(), vertexBuilder.getPropertyDeletes(), vertexBuilder.getPropertySoftDeletes(), vertexBuilder.getExtendedData(), vertexBuilder.getExtendedDataDeletes(), vertexBuilder.getIndexHint() ); }
public void saveVertexBuilder(AccumuloGraph graph, VertexBuilder vertexBuilder, long timestamp) { Mutation m = createMutationForVertexBuilder(graph, vertexBuilder, timestamp); saveVertexMutation(m); saveExtendedDataMutations(graph, ElementType.VERTEX, vertexBuilder); saveExtendedDataDeletes(graph, vertexBuilder.getElementId(), ElementType.VERTEX, vertexBuilder.getExtendedDataDeletes()); }
private Mutation createMutationForVertexBuilder(AccumuloGraph graph, VertexBuilder vertexBuilder, long timestamp) { String vertexRowKey = vertexBuilder.getElementId(); Mutation m = new Mutation(vertexRowKey); m.put(AccumuloVertex.CF_SIGNAL, EMPTY_TEXT, visibilityToAccumuloVisibility(vertexBuilder.getVisibility()), timestamp, EMPTY_VALUE); createMutationForElementBuilder(graph, vertexBuilder, vertexRowKey, m); return m; }
@Test public void testExceptionDeletingSandboxedPropertiesWithVertices() throws Exception { createSampleOntology(); VisibilityJson json = VisibilityJson.updateVisibilitySourceAndAddWorkspaceId(new VisibilityJson(), "", workspaceId); Visibility visibility = getVisibilityTranslator().toVisibility(json).getVisibility(); VertexBuilder vb = getGraph().prepareVertex(visibility); vb.setProperty(SANDBOX_PROPERTY_IRI, "a value", visibility); vb.save(authorizations); thrown.expect(VisalloException.class); thrown.expectMessage("Unable to delete property that have elements using it"); getOntologyRepository().deleteProperty(SANDBOX_PROPERTY_IRI, adminUser, workspaceId); }
private Vertex save(IngestOptions ingestOptions, ConceptBuilder conceptBuilder) { Visibility conceptVisibility = getVisibility(ingestOptions, conceptBuilder.getVisibility()); VertexBuilder vertexBuilder = graph.prepareVertex( conceptBuilder.getId(), getTimestamp(ingestOptions, conceptBuilder.getTimestamp()), conceptVisibility ); vertexBuilder.setProperty( VisalloProperties.CONCEPT_TYPE.getPropertyName(), conceptBuilder.getIri(), visibilityTranslator.getDefaultVisibility() ); addProperties(ingestOptions, conceptVisibility, vertexBuilder, conceptBuilder); LOGGER.trace("Saving vertex: %s", vertexBuilder.getVertexId()); return vertexBuilder.save(getAuthorizations(ingestOptions)); }
@Test public void testDifferentKey() throws UnsupportedEncodingException { VertexBuilder v = getGraph().prepareVertex("v1", visibility); StreamingPropertyValue textValue = new StreamingPropertyValue(new ByteArrayInputStream("<html><body>Text1</body></html>".getBytes("UTF-8")), byte[].class); textValue.searchIndex(false); Metadata metadata = new Metadata(); metadata.add(VisalloProperties.MIME_TYPE.getPropertyName(), "text/html", getVisibilityTranslator().getDefaultVisibility()); v.addPropertyValue("key1", "http://visallo.org/test#raw1", textValue, metadata, visibility); v.save(getGraphAuthorizations()); Vertex vertex = getGraph().getVertex("v1", getGraphAuthorizations()); run(gpw, createWorkerPrepareData(), vertex); Property text1Property = vertex.getProperty("key1", "http://visallo.org/test#text1"); assertTrue(text1Property != null); assertThat(((StreamingPropertyValue) text1Property.getValue()).readToString(), equalTo("Text1")); }
WorkspaceProperties.TITLE.setProperty(productVertex, "Migrated", workspace.getVisibility()); WorkspaceProperties.PRODUCT_KIND.setProperty(productVertex, GRAPH_KIND, workspace.getVisibility()); String productId = productVertex.getVertexId(); productVertex.save(authorizations); EdgeBuilderByVertexId workspaceToProductEdge = graph.prepareEdge(workspace.getId() + "_hasProduct_" + productId, workspace.getId(), productId, WORKSPACE_TO_PRODUCT_RELATIONSHIP_IRI, workspace.getVisibility());
@Test public void testExtendedDataQueryVerticesAfterVisibilityChange() { String nameColumnName = "name.column"; String tableName = "table.one"; String rowOneName = "row.one"; String rowTwoName = "row.two"; graph.defineProperty(nameColumnName).sortable(true).textIndexHint(TextIndexHint.values()).dataType(String.class).define(); graph.prepareVertex("v1", VISIBILITY_A) .addExtendedData(tableName, rowOneName, nameColumnName, "value 1", VISIBILITY_A) .addExtendedData(tableName, rowTwoName, nameColumnName, "value 2", VISIBILITY_A) .save(AUTHORIZATIONS_A); graph.prepareVertex("v2", VISIBILITY_A) .save(AUTHORIZATIONS_A); graph.flush(); QueryResultsIterable<? extends VertexiumObject> searchResults = graph.query("value", AUTHORIZATIONS_A) .search(); assertResultsCount(2, 2, searchResults); assertRowIdsAnyOrder(Lists.newArrayList(rowOneName, rowTwoName), searchResults); graph.createAuthorizations(AUTHORIZATIONS_A_AND_B); graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A) .prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); searchResults = graph.query("value", AUTHORIZATIONS_A) .search(); assertResultsCount(0, 0, searchResults); }
public String getVertexId() { return getElementId(); }
@Test public void testExceptionDeletingSandboxedConceptsWithVertices() throws Exception { createSampleOntology(); Concept concept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId); assertTrue("Concept exists", concept != null && concept.getIRI().equals(SANDBOX_CONCEPT_IRI)); VisibilityJson json = VisibilityJson.updateVisibilitySourceAndAddWorkspaceId(new VisibilityJson(), "", workspaceId); Visibility visibility = getVisibilityTranslator().toVisibility(json).getVisibility(); VertexBuilder vb = getGraph().prepareVertex(visibility); vb.setProperty(VisalloProperties.CONCEPT_TYPE.getPropertyName(), SANDBOX_CONCEPT_IRI, visibility); vb.save(authorizations); thrown.expect(VisalloException.class); thrown.expectMessage("Unable to delete concept that have vertices assigned to it"); getOntologyRepository().deleteConcept(SANDBOX_CONCEPT_IRI, adminUser, workspaceId); }
public void saveVertexBuilder(AccumuloGraph graph, VertexBuilder vertexBuilder, long timestamp) { Mutation m = createMutationForVertexBuilder(graph, vertexBuilder, timestamp); saveVertexMutation(m); saveExtendedDataMutations(graph, ElementType.VERTEX, vertexBuilder); saveExtendedDataDeletes(graph, vertexBuilder.getElementId(), ElementType.VERTEX, vertexBuilder.getExtendedDataDeletes()); }
private Mutation createMutationForVertexBuilder(AccumuloGraph graph, VertexBuilder vertexBuilder, long timestamp) { String vertexRowKey = vertexBuilder.getElementId(); Mutation m = new Mutation(vertexRowKey); m.put(AccumuloVertex.CF_SIGNAL, EMPTY_TEXT, visibilityToAccumuloVisibility(vertexBuilder.getVisibility()), timestamp, EMPTY_VALUE); createMutationForElementBuilder(graph, vertexBuilder, vertexRowKey, m); return m; }
public String getVertexId() { return getElementId(); }
@Override public Vertex addVertex(String vertexId, Visibility visibility, Authorizations authorizations) { return prepareVertex(vertexId, visibility).save(authorizations); }
@Test public void testMultipleRaws() throws UnsupportedEncodingException { VertexBuilder v = getGraph().prepareVertex("v1", visibility); StreamingPropertyValue textValue = new StreamingPropertyValue(new ByteArrayInputStream("<html><body>Text1</body></html>".getBytes("UTF-8")), byte[].class); textValue.searchIndex(false); Metadata metadata = new Metadata(); metadata.add(VisalloProperties.MIME_TYPE.getPropertyName(), "text/html", getVisibilityTranslator().getDefaultVisibility()); v.setProperty("http://visallo.org/test#raw1", textValue, metadata, visibility); textValue = new StreamingPropertyValue(new ByteArrayInputStream("<html><body>Text2</body></html>".getBytes("UTF-8")), byte[].class); textValue.searchIndex(false); metadata = new Metadata(); metadata.add(VisalloProperties.MIME_TYPE.getPropertyName(), "text/html", getVisibilityTranslator().getDefaultVisibility()); v.setProperty("http://visallo.org/test#raw2", textValue, metadata, visibility); v.save(getGraphAuthorizations()); Vertex vertex = getGraph().getVertex("v1", getGraphAuthorizations()); run(gpw, createWorkerPrepareData(), vertex); Property text1Property = vertex.getProperty("http://visallo.org/test#text1"); assertTrue(text1Property != null); assertThat(((StreamingPropertyValue) text1Property.getValue()).readToString(), equalTo("Text1")); assertThat(VisalloProperties.TEXT_DESCRIPTION_METADATA.getMetadataValue(text1Property.getMetadata()), equalTo("Text 1")); Property text2Property = vertex.getProperty("http://visallo.org/test#text2"); assertTrue(text2Property != null); assertThat(((StreamingPropertyValue) text2Property.getValue()).readToString(), equalTo("Text2")); assertThat(VisalloProperties.TEXT_DESCRIPTION_METADATA.getMetadataValue(text2Property.getMetadata()), equalTo(null)); }
@Test public void testLargeFieldValuesThatAreMarkedWithExactMatch() { graph.defineProperty("field1").dataType(String.class).textIndexHint(TextIndexHint.EXACT_MATCH).define(); StringBuilder largeText = new StringBuilder(); for (int i = 0; i < 10000; i++) { largeText.append("test "); } graph.prepareVertex("v1", VISIBILITY_EMPTY) .addPropertyValue("", "field1", largeText.toString(), VISIBILITY_EMPTY) .save(AUTHORIZATIONS_EMPTY); graph.flush(); }
@Test public void testNullPropertyValue() { try { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("prop1", null, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); throw new VertexiumException("expected null check"); } catch (NullPointerException ex) { assertTrue(ex.getMessage().contains("prop1")); } }