本文整理了Java中org.vertexium.Vertex.getProperty()
方法的一些代码示例,展示了Vertex.getProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.getProperty()
方法的具体详情如下:
包路径:org.vertexium.Vertex
类名称:Vertex
方法名:getProperty
暂无
代码示例来源:origin: org.visallo/visallo-web
private String imageTitle(Vertex entityVertex, String workspaceId) {
Property titleProperty = VisalloProperties.TITLE.getFirstProperty(entityVertex);
Object title;
if (titleProperty == null) {
String conceptTypeProperty = VisalloProperties.CONCEPT_TYPE.getPropertyName();
String vertexConceptType = (String) entityVertex.getProperty(conceptTypeProperty).getValue();
Concept concept = ontologyRepository.getConceptByIRI(vertexConceptType, workspaceId);
title = concept.getDisplayName();
} else {
title = titleProperty.getValue();
}
return String.format("Image of %s", title.toString());
}
代码示例来源:origin: org.visallo/visallo-gpw-tika-text-extractor
@Test
public void testExtractWithEmptyHtml() throws Exception {
String data = "<html>";
data += "<head>";
data += "<title>Test Title</title>";
data += "<meta content=\"2013-01-01T18:09:20Z\" itemprop=\"datePublished\" name=\"pubdate\"/>";
data += "</head>";
data += "<body>";
data += "</body>";
data += "</html>";
createVertex(data, "text/html");
InputStream in = new ByteArrayInputStream(data.getBytes());
Vertex vertex = getGraph().getVertex("v1", getGraphAuthorizations());
Property property = vertex.getProperty(VisalloProperties.RAW.getPropertyName());
run(gpw, createWorkerPrepareData(), vertex, property, in);
vertex = getGraph().getVertex("v1", getGraphAuthorizations());
assertEquals("Test Title", vertex.getPropertyValue(DOCUMENT_TITLE_PROPERTY_IRI));
assertEquals("", IOUtils.toString(VisalloProperties.TEXT.getOnlyPropertyValue(vertex).getInputStream(), "UTF-8"));
assertEquals(new Date(1357063760000L), VisalloProperties.MODIFIED_DATE.getPropertyValue(vertex));
}
代码示例来源:origin: visallo/vertexium
@Override
protected Property getP() {
Vertex vertex = getE();
if (vertex == null) {
return null;
}
return vertex.getProperty(getKey(), getName(), getVisibility());
}
代码示例来源:origin: org.visallo/visallo-gpw-tika-text-extractor
@Test
public void testExtractWithNotHtml() throws Exception {
String data = "<title>Test Title</title>";
data += "<meta content=\"2013-01-01T18:09:20Z\" itemprop=\"datePublished\" name=\"pubdate\"/>";
data += "<h1>Five reasons why Windows 8 has failed</h1>";
data += "<p>The numbers speak for themselves. Vista, universally acknowledged as a failure, actually had significantly better adoption numbers than Windows 8. At similar points in their roll-outs, Vista had a desktop market share of 4.52% compared to Windows 8's share of 2.67%. Underlining just how poorly Windows 8's adoption has gone, Vista didn't even have the advantage of holiday season sales to boost its numbers. Tablets--and not Surface RT tablets--were what people bought last December, not Windows 8 PCs.</p>";
data += "</body>";
data += "</html>";
createVertex(data, "text/html");
InputStream in = new ByteArrayInputStream(data.getBytes());
Vertex vertex = getGraph().getVertex("v1", getGraphAuthorizations());
Property property = vertex.getProperty(VisalloProperties.RAW.getPropertyName());
run(gpw, createWorkerPrepareData(), vertex, property, in);
vertex = getGraph().getVertex("v1", getGraphAuthorizations());
assertEquals("Test Title", vertex.getPropertyValue(DOCUMENT_TITLE_PROPERTY_IRI));
assertEquals(
"Five reasons why Windows 8 has failed\n" +
"The numbers speak for themselves. Vista, universally acknowledged as a failure, actually had significantly better adoption numbers than Windows 8. At similar points in their roll-outs, Vista had a desktop market share of 4.52% compared to Windows 8's share of 2.67%. Underlining just how poorly Windows 8's adoption has gone, Vista didn't even have the advantage of holiday season sales to boost its numbers. Tablets--and not Surface RT tablets--were what people bought last December, not Windows 8 PCs.\n",
IOUtils.toString(VisalloProperties.TEXT.getOnlyPropertyValue(vertex).getInputStream(), "UTF-8")
);
assertEquals(new Date(1357063760000L), VisalloProperties.MODIFIED_DATE.getPropertyValue(vertex));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testMetadata() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("prop1", "value1", VISIBILITY_A)
.setProperty("prop1", "value1", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
ExistingElementMutation<Vertex> m = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B).prepareMutation();
m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_A), "metadata1", "metadata-value1aa", VISIBILITY_A);
m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_A), "metadata1", "metadata-value1ab", VISIBILITY_B);
m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_B), "metadata1", "metadata-value1bb", VISIBILITY_B);
m.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
Property prop1A = v1.getProperty("prop1", VISIBILITY_A);
assertEquals(2, prop1A.getMetadata().entrySet().size());
assertEquals("metadata-value1aa", prop1A.getMetadata().getValue("metadata1", VISIBILITY_A));
assertEquals("metadata-value1ab", prop1A.getMetadata().getValue("metadata1", VISIBILITY_B));
Property prop1B = v1.getProperty("prop1", VISIBILITY_B);
assertEquals(1, prop1B.getMetadata().entrySet().size());
assertEquals("metadata-value1bb", prop1B.getMetadata().getValue("metadata1", VISIBILITY_B));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testMetadata() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("prop1", "value1", VISIBILITY_A)
.setProperty("prop1", "value1", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
ExistingElementMutation<Vertex> m = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B).prepareMutation();
m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_A), "metadata1", "metadata-value1aa", VISIBILITY_A);
m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_A), "metadata1", "metadata-value1ab", VISIBILITY_B);
m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_B), "metadata1", "metadata-value1bb", VISIBILITY_B);
m.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
Property prop1A = v1.getProperty("prop1", VISIBILITY_A);
assertEquals(2, prop1A.getMetadata().entrySet().size());
assertEquals("metadata-value1aa", prop1A.getMetadata().getValue("metadata1", VISIBILITY_A));
assertEquals("metadata-value1ab", prop1A.getMetadata().getValue("metadata1", VISIBILITY_B));
Property prop1B = v1.getProperty("prop1", VISIBILITY_B);
assertEquals(1, prop1B.getMetadata().entrySet().size());
assertEquals("metadata-value1bb", prop1B.getMetadata().getValue("metadata1", VISIBILITY_B));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testTimestampsInExistingElementMutation() {
long t1 = createDate(2017, 1, 18, 9, 20, 0).getTime();
long t2 = createDate(2017, 1, 19, 9, 20, 0).getTime();
graph.prepareVertex("v1", VISIBILITY_EMPTY)
.addPropertyValue("k1", "prop1", "test1", Metadata.create(), t1, VISIBILITY_EMPTY)
.save(AUTHORIZATIONS_ALL);
graph.flush();
Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_ALL);
assertEquals(t1, v1.getProperty("k1", "prop1").getTimestamp());
graph.getVertex("v1", AUTHORIZATIONS_ALL)
.prepareMutation()
.addPropertyValue("k1", "prop1", "test2", Metadata.create(), t2, VISIBILITY_EMPTY)
.save(AUTHORIZATIONS_ALL);
graph.flush();
v1 = graph.getVertex("v1", AUTHORIZATIONS_ALL);
assertEquals(t2, v1.getProperty("k1", "prop1").getTimestamp());
List<HistoricalPropertyValue> historicalValues = toList(v1.getHistoricalPropertyValues("k1", "prop1", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL));
assertEquals(2, historicalValues.size());
assertEquals(t1, historicalValues.get(1).getTimestamp());
assertEquals(t2, historicalValues.get(0).getTimestamp());
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testAlterVisibilityAndSetMetadataInOneMutation() {
Metadata prop1Metadata = Metadata.create();
prop1Metadata.add("prop1_key1", "metadata1", VISIBILITY_EMPTY);
graph.prepareVertex("v1", VISIBILITY_EMPTY)
.setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
Vertex v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
v1.prepareMutation()
.alterPropertyVisibility("prop1", VISIBILITY_B)
.setPropertyMetadata("prop1", "prop1_key1", "metadata1New", VISIBILITY_EMPTY)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
assertNotNull(v1.getProperty("prop1"));
assertEquals(VISIBILITY_B, v1.getProperty("prop1").getVisibility());
assertEquals("metadata1New", v1.getProperty("prop1").getMetadata().getValue("prop1_key1"));
List<HistoricalPropertyValue> historicalPropertyValues = toList(v1.getHistoricalPropertyValues(AUTHORIZATIONS_A_AND_B));
assertEquals(2, historicalPropertyValues.size());
assertEquals("metadata1New", historicalPropertyValues.get(0).getMetadata().getValue("prop1_key1"));
assertEquals("metadata1", historicalPropertyValues.get(1).getMetadata().getValue("prop1_key1"));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testAlterVisibilityAndSetMetadataInOneMutation() {
Metadata prop1Metadata = Metadata.create();
prop1Metadata.add("prop1_key1", "metadata1", VISIBILITY_EMPTY);
graph.prepareVertex("v1", VISIBILITY_EMPTY)
.setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
Vertex v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
v1.prepareMutation()
.alterPropertyVisibility("prop1", VISIBILITY_B)
.setPropertyMetadata("prop1", "prop1_key1", "metadata1New", VISIBILITY_EMPTY)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
assertNotNull(v1.getProperty("prop1"));
assertEquals(VISIBILITY_B, v1.getProperty("prop1").getVisibility());
assertEquals("metadata1New", v1.getProperty("prop1").getMetadata().getValue("prop1_key1"));
List<HistoricalPropertyValue> historicalPropertyValues = toList(v1.getHistoricalPropertyValues(AUTHORIZATIONS_A_AND_B));
assertEquals(2, historicalPropertyValues.size());
assertEquals("metadata1New", historicalPropertyValues.get(0).getMetadata().getValue("prop1_key1"));
assertEquals("metadata1", historicalPropertyValues.get(1).getMetadata().getValue("prop1_key1"));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testMutationChangePropertyVisibilityFollowedByMetadataUsingPropertyObject() {
Metadata prop1Metadata = Metadata.create();
prop1Metadata.add("prop1_key1", "valueOld", VISIBILITY_A);
graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
Vertex v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
Property p1 = v1.getProperty("prop1", VISIBILITY_A);
v1.prepareMutation()
.alterPropertyVisibility(p1, VISIBILITY_B)
.setPropertyMetadata(p1, "prop1_key1", "valueNew", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
assertEquals("valueNew", v1.getProperty("prop1", VISIBILITY_B).getMetadata().getEntry("prop1_key1", VISIBILITY_B).getValue());
}
代码示例来源:origin: visallo/vertexium
@Test
public void testMutationChangePropertyVisibilityFollowedByMetadataUsingPropertyObject() {
Metadata prop1Metadata = Metadata.create();
prop1Metadata.add("prop1_key1", "valueOld", VISIBILITY_A);
graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
Vertex v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
Property p1 = v1.getProperty("prop1", VISIBILITY_A);
v1.prepareMutation()
.alterPropertyVisibility(p1, VISIBILITY_B)
.setPropertyMetadata(p1, "prop1_key1", "valueNew", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A_AND_B);
assertEquals("valueNew", v1.getProperty("prop1", VISIBILITY_B).getMetadata().getEntry("prop1_key1", VISIBILITY_B).getValue());
}
代码示例来源:origin: org.visallo/visallo-gpw-tika-text-extractor
@Test
public void testExtractTextWithAccentCharacters() throws Exception {
String data = "the Quita Suena\u0301 bank";
createVertex(data, "text/plain; charset=utf-8");
InputStream in = new ByteArrayInputStream(data.getBytes("UTF-8"));
Vertex vertex = getGraph().getVertex("v1", getGraphAuthorizations());
Property property = vertex.getProperty(VisalloProperties.RAW.getPropertyName());
run(gpw, createWorkerPrepareData(), vertex, property, in);
vertex = getGraph().getVertex("v1", getGraphAuthorizations());
String expected = "the Quita Suená bank ";
String actual = IOUtils.toString(VisalloProperties.TEXT.getOnlyPropertyValue(vertex).getInputStream(), "UTF-8");
assertEquals(21, expected.length());
assertEquals(expected, actual);
assertEquals(expected.length(), actual.length());
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testSoftDeletePropertyOnAHiddenVertex() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_EMPTY)
.addPropertyValue("key1", "name1", "value1", VISIBILITY_EMPTY)
.save(AUTHORIZATIONS_A);
graph.flush();
graph.markVertexHidden(v1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A);
v1.softDeleteProperty("key1", "name1", AUTHORIZATIONS_A);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A);
assertNull(v1.getProperty("key1", "name1", VISIBILITY_EMPTY));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testSoftDeletePropertyOnAHiddenVertex() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_EMPTY)
.addPropertyValue("key1", "name1", "value1", VISIBILITY_EMPTY)
.save(AUTHORIZATIONS_A);
graph.flush();
graph.markVertexHidden(v1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A);
v1.softDeleteProperty("key1", "name1", AUTHORIZATIONS_A);
graph.flush();
v1 = graph.getVertex("v1", FetchHints.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A);
assertNull(v1.getProperty("key1", "name1", VISIBILITY_EMPTY));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testMetadataMutationsOnVertex() {
Metadata metadataPropB = Metadata.create();
metadataPropB.add("meta1", "meta1", VISIBILITY_A);
Vertex vertex = graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("propBmeta", "propBmeta", metadataPropB, VISIBILITY_A)
.save(AUTHORIZATIONS_ALL);
graph.flush();
ExistingElementMutation<Vertex> m = vertex.prepareMutation();
m.setPropertyMetadata("propBmeta", "meta1", "meta2", VISIBILITY_A);
vertex = m.save(AUTHORIZATIONS_ALL);
assertEquals("meta2", vertex.getProperty("propBmeta").getMetadata().getEntry("meta1").getValue());
}
代码示例来源:origin: visallo/vertexium
@Test
public void testMetadataMutationsOnVertex() {
Metadata metadataPropB = Metadata.create();
metadataPropB.add("meta1", "meta1", VISIBILITY_A);
Vertex vertex = graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("propBmeta", "propBmeta", metadataPropB, VISIBILITY_A)
.save(AUTHORIZATIONS_ALL);
graph.flush();
ExistingElementMutation<Vertex> m = vertex.prepareMutation();
m.setPropertyMetadata("propBmeta", "meta1", "meta2", VISIBILITY_A);
vertex = m.save(AUTHORIZATIONS_ALL);
assertEquals("meta2", vertex.getProperty("propBmeta").getMetadata().getEntry("meta1").getValue());
}
代码示例来源:origin: org.visallo/visallo-gpw-tika-text-extractor
@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));
}
代码示例来源:origin: org.visallo/visallo-gpw-tika-text-extractor
@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"));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testDeleteVertexWithProperties() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("prop1", "value1", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
Property prop1 = v1.getProperty("prop1");
Assert.assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A)));
graph.deleteVertex("v1", AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A_AND_B)));
assertEvents(
new AddVertexEvent(graph, v1),
new AddPropertyEvent(graph, v1, prop1),
new DeleteVertexEvent(graph, v1)
);
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testDeleteVertexWithProperties() {
Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A)
.setProperty("prop1", "value1", VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
Property prop1 = v1.getProperty("prop1");
Assert.assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A)));
graph.deleteVertex("v1", AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A_AND_B)));
assertEvents(
new AddVertexEvent(graph, v1),
new AddPropertyEvent(graph, v1, prop1),
new DeleteVertexEvent(graph, v1)
);
}
内容来源于网络,如有侵权,请联系作者删除!