本文整理匯總了Java中org.apache.tinkerpop.gremlin.structure.Vertex.property方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertex.property方法的具體用法?Java Vertex.property怎麽用?Java Vertex.property使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.tinkerpop.gremlin.structure.Vertex
的用法示例。
在下文中一共展示了Vertex.property方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetPropertyKeysOnVertex
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Test
public void testGetPropertyKeysOnVertex() {
Vertex vertex = createVertex();
// Test that the following properties exists on the vertex.
Map<String, String> expected = MapUtils.map(
T("value", "value")
);
Set<String> keys = vertex.keys();
Set<VertexProperty<Object>> properties = SetUtils.set(vertex.properties());
assertEquals(expected.size(), keys.size());
assertEquals(expected.size(), properties.size());
for (Map.Entry<String, String> entry : expected.entrySet()) {
assertTrue(keys.contains(entry.getKey()));
VertexProperty<Object> property = vertex.property(entry.getKey());
assertNotNull(property.id());
assertEquals(entry.getValue(), property.value());
assertEquals(property.key(), property.label());
assertEquals(StringFactory.propertyString(property), property.toString());
assertSame(vertex, property.element());
}
}
示例2: deserializersTestsVertex
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Test
public void deserializersTestsVertex() {
final TinkerGraph tg = TinkerGraph.open();
final Vertex v = tg.addVertex("vertexTest");
v.property("born", LocalDateTime.of(1971, 1, 2, 20, 50));
v.property("dead", LocalDateTime.of(1971, 1, 7, 20, 50));
final GraphWriter writer = getWriter(defaultMapperV2d0);
final GraphReader reader = getReader(defaultMapperV2d0);
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, v);
final String json = out.toString();
// Object works, because there's a type in the payload now
// Vertex.class would work as well
// Anything else would not because we check the type in param here with what's in the JSON, for safety.
final Vertex vRead = (Vertex)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
assertEquals(v, vRead);
} catch (IOException e) {
e.printStackTrace();
fail("Should not have thrown exception: " + e.getMessage());
}
}
開發者ID:ShiftLeftSecurity,項目名稱:tinkergraph-gremlin,代碼行數:26,代碼來源:TinkerGraphGraphSONSerializerV2d0Test.java
示例3: shouldNotAddEdgeToAVertexThatWasRemoved
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Test(expected = IllegalStateException.class)
public void shouldNotAddEdgeToAVertexThatWasRemoved() {
final TinkerGraph graph = TinkerGraph.open();
final Vertex v = graph.addVertex();
v.property("name", "stephen");
assertEquals("stephen", v.value("name"));
v.remove();
v.addEdge("self", v);
}
示例4: updateVertexProperties
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Override
void updateVertexProperties(final ResourceEntity entity, final Vertex vertex) {
String resourceAttributesJson = entity.getAttributesAsJson();
if (StringUtils.isEmpty(resourceAttributesJson)) {
resourceAttributesJson = EMPTY_ATTRIBUTES;
}
vertex.property(ATTRIBUTES_PROPERTY_KEY, resourceAttributesJson);
}
示例5: shouldKeepTypesWhenDeserializingSerializedTinkerGraph
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
/**
* Those kinds of types are declared differently in the GraphSON type deserializer, check that all are handled
* properly.
*/
@Test
public void shouldKeepTypesWhenDeserializingSerializedTinkerGraph() throws IOException {
final TinkerGraph tg = TinkerGraph.open();
final Vertex v = tg.addVertex("vertexTest");
final UUID uuidProp = UUID.randomUUID();
final Duration durationProp = Duration.ofHours(3);
final Long longProp = 2L;
final ByteBuffer byteBufferProp = ByteBuffer.wrap("testbb".getBytes());
final InetAddress inetAddressProp = InetAddress.getByName("10.10.10.10");
// One Java util type natively supported by Jackson
v.property("uuid", uuidProp);
// One custom time type added by the GraphSON module
v.property("duration", durationProp);
// One Java native type not handled by JSON natively
v.property("long", longProp);
// One Java util type added by GraphSON
v.property("bytebuffer", byteBufferProp);
v.property("inetaddress", inetAddressProp);
final GraphWriter writer = getWriter(defaultMapperV2d0);
final GraphReader reader = getReader(defaultMapperV2d0);
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeGraph(out, tg);
final String json = out.toString();
final TinkerGraph read = TinkerGraph.open();
reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
final Vertex vRead = read.traversal().V().hasLabel("vertexTest").next();
assertEquals(vRead.property("uuid").value(), uuidProp);
assertEquals(vRead.property("duration").value(), durationProp);
assertEquals(vRead.property("long").value(), longProp);
assertEquals(vRead.property("bytebuffer").value(), byteBufferProp);
assertEquals(vRead.property("inetaddress").value(), inetAddressProp);
}
}
開發者ID:ShiftLeftSecurity,項目名稱:tinkergraph-gremlin,代碼行數:42,代碼來源:TinkerGraphGraphSONSerializerV2d0Test.java
示例6: shouldNotModifyAVertexThatWasRemoved
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Test(expected = IllegalStateException.class)
public void shouldNotModifyAVertexThatWasRemoved() {
final TinkerGraph graph = TinkerGraph.open();
final Vertex v = graph.addVertex();
v.property("name", "stephen");
assertEquals("stephen", v.value("name"));
v.remove();
v.property("status", 1);
}
示例7: shouldNotReadValueOfPropertyOnVertexThatWasRemoved
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Test(expected = IllegalStateException.class)
public void shouldNotReadValueOfPropertyOnVertexThatWasRemoved() {
final TinkerGraph graph = TinkerGraph.open();
final Vertex v = graph.addVertex();
v.property("name", "stephen");
assertEquals("stephen", v.value("name"));
v.remove();
v.value("name");
}
示例8: shouldUseLongIdManagerToCoerceTypes
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Test
public void shouldUseLongIdManagerToCoerceTypes() {
final Graph graph = TinkerGraph.open(longIdManagerConfig);
final Vertex v = graph.addVertex(T.id, vertexIdValue);
final VertexProperty vp = v.property(VertexProperty.Cardinality.single, "test", "value", T.id, vertexPropertyIdValue);
final Edge e = v.addEdge("self", v, T.id, edgeIdValue);
assertEquals(100l, v.id());
assertEquals(200l, e.id());
assertEquals(300l, vp.id());
}
示例9: getPropertyOrFail
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
public static String getPropertyOrFail(final Vertex vertex, final String propertyKey) {
VertexProperty<String> property = vertex.property(propertyKey);
if (property.isPresent()) {
return property.value();
}
throw new IllegalStateException(
String.format("The vertex with id '%s' does not conatin the expected property '%s'.", vertex.id(),
propertyKey));
}
示例10: createNewLiteralVertex
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
private Vertex createNewLiteralVertex(final Value value) {
Vertex vertex = createVertex(Schema.VertexLabel.Literal.name(), value);
IRI datatype = ((Literal) value).getDatatype();
vertex.property(Schema.VertexProperties.DATATYPE, datatype.stringValue());
if (datatype.equals(RDF.LANGSTRING)) {
vertex.property(Schema.VertexProperties.LANGUAGE, ((Literal) value).getLanguage().get());
}
return vertex;
}
示例11: getPropertyOrNull
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
public static String getPropertyOrNull(final Vertex vertex, final String propertyKey) {
VertexProperty<String> property = vertex.property(propertyKey);
if (property.isPresent()) {
return property.value();
}
return null;
}
示例12: testReturnEmptyPropertyIfKeyNonExistent
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Test
public void testReturnEmptyPropertyIfKeyNonExistent() {
Vertex vertex = createVertex();
VertexProperty property = vertex.property("something");
assertEquals(VertexProperty.empty(), property);
}
示例13: generateTheCrew
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
public static void generateTheCrew(final TinkerGraph g) {
final Vertex marko = g.addVertex(T.id, 1, T.label, "person", "name", "marko");
final Vertex stephen = g.addVertex(T.id, 7, T.label, "person", "name", "stephen");
final Vertex matthias = g.addVertex(T.id, 8, T.label, "person", "name", "matthias");
final Vertex daniel = g.addVertex(T.id, 9, T.label, "person", "name", "daniel");
final Vertex gremlin = g.addVertex(T.id, 10, T.label, "software", "name", "gremlin");
final Vertex tinkergraph = g.addVertex(T.id, 11, T.label, "software", "name", "tinkergraph");
marko.property(VertexProperty.Cardinality.list, "location", "san diego", "startTime", 1997, "endTime", 2001);
marko.property(VertexProperty.Cardinality.list, "location", "santa cruz", "startTime", 2001, "endTime", 2004);
marko.property(VertexProperty.Cardinality.list, "location", "brussels", "startTime", 2004, "endTime", 2005);
marko.property(VertexProperty.Cardinality.list, "location", "santa fe", "startTime", 2005);
stephen.property(VertexProperty.Cardinality.list, "location", "centreville", "startTime", 1990, "endTime", 2000);
stephen.property(VertexProperty.Cardinality.list, "location", "dulles", "startTime", 2000, "endTime", 2006);
stephen.property(VertexProperty.Cardinality.list, "location", "purcellville", "startTime", 2006);
matthias.property(VertexProperty.Cardinality.list, "location", "bremen", "startTime", 2004, "endTime", 2007);
matthias.property(VertexProperty.Cardinality.list, "location", "baltimore", "startTime", 2007, "endTime", 2011);
matthias.property(VertexProperty.Cardinality.list, "location", "oakland", "startTime", 2011, "endTime", 2014);
matthias.property(VertexProperty.Cardinality.list, "location", "seattle", "startTime", 2014);
daniel.property(VertexProperty.Cardinality.list, "location", "spremberg", "startTime", 1982, "endTime", 2005);
daniel.property(VertexProperty.Cardinality.list, "location", "kaiserslautern", "startTime", 2005, "endTime", 2009);
daniel.property(VertexProperty.Cardinality.list, "location", "aachen", "startTime", 2009);
marko.addEdge("develops", gremlin, T.id, 13, "since", 2009);
marko.addEdge("develops", tinkergraph, T.id, 14, "since", 2010);
marko.addEdge("uses", gremlin, T.id, 15, "skill", 4);
marko.addEdge("uses", tinkergraph, T.id, 16, "skill", 5);
stephen.addEdge("develops", gremlin, T.id, 17, "since", 2010);
stephen.addEdge("develops", tinkergraph, T.id, 18, "since", 2011);
stephen.addEdge("uses", gremlin, T.id, 19, "skill", 5);
stephen.addEdge("uses", tinkergraph, T.id, 20, "skill", 4);
matthias.addEdge("develops", gremlin, T.id, 21, "since", 2012);
matthias.addEdge("uses", gremlin, T.id, 22, "skill", 3);
matthias.addEdge("uses", tinkergraph, T.id, 23, "skill", 3);
daniel.addEdge("uses", gremlin, T.id, 24, "skill", 5);
daniel.addEdge("uses", tinkergraph, T.id, 25, "skill", 3);
gremlin.addEdge("traverses", tinkergraph, T.id, 26);
g.variables().set("creator", "marko");
g.variables().set("lastModified", 2014);
g.variables().set("comment", "this graph was created to provide examples and test coverage for tinkerpop3 api advances");
}
示例14: addUser
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
/**
* Add a user vertex
* @param userName username for this user
* @return the created vertex
*/
private Vertex addUser(String userName){
Vertex user = graph.addVertex(Schema.USER);
user.property(Schema.USER_NAME, userName);
return user;
}
示例15: addStatusUpdatew
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
private Vertex addStatusUpdatew(Vertex user, String statusUpdateContent) {
Vertex statusUpdate = graph.addVertex(Schema.STATUS_UPDATE);
statusUpdate.property(Schema.CONTENT, statusUpdateContent);
user.addEdge(Schema.POSTS, statusUpdate, Schema.CREATED_AT, getTimestamp());
return statusUpdate;
}