本文整理匯總了Java中com.tinkerpop.blueprints.Edge.setProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Edge.setProperty方法的具體用法?Java Edge.setProperty怎麽用?Java Edge.setProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.tinkerpop.blueprints.Edge
的用法示例。
在下文中一共展示了Edge.setProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
public void run() {
for (int i = 0; i < noNodes; i++) {
Vertex v = bgraph.addVertex(i);
v.setProperty("name", getName(i));
v.setProperty("uid", i);
}
for (int i = 0; i < noNodes; i++) {
// Out vertex
Vertex n = bgraph.getVertex(i);
// Iterate over in vertices
for (int e = 0; e < noEdgesPerNode; e++) {
Vertex n2 = bgraph.getVertex(wrapAround(i + e, noNodes));
Edge edge = n.addEdge("knows", n2);
edge.setProperty("uid", RandomGenerator.randomInt(0, Integer.MAX_VALUE));
edge.setProperty("weight", Math.random());
}
}
bgraph.commit();
}
示例2: annotate
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
/**
* As in {@code vertexAnnotator} above, choose a sequence of
* contiguously-stored property names with a random offset and length.
* However, omit the initial {@link Schema#getEdgeLabels()} property
* keys from consideration. These keys are used by sort keys.
* <p>
* In addition to the preceding, lookup the sort key for the edge's
* label and set that to a randomly chosen value.
*/
@Override
public void annotate(Edge edge) {
// Set sort key edge property
edge.setProperty(schema.getSortKeyForLabel(edge.getLabel()),
random.nextInt(schema.getMaxEdgePropVal()));
// Set additional (non-sort-key) edge properties
if (0 >= schema.getEdgePropKeys() - schema.getEdgeLabels())
return;
int eligible = schema.getEdgePropKeys() - schema.getEdgeLabels();
Preconditions.checkArgument(0 < eligible);
int count = random.nextInt(eligible);
int offset = random.nextInt(eligible);
int length = schema.getEdgePropKeys();
Preconditions.checkArgument(length == eligible + schema.getEdgeLabels());
Preconditions.checkArgument(length >= count + schema.getEdgeLabels());
for (int i = 0; i < count; i++) {
String key = schema.getEdgePropertyName(schema.getEdgeLabels() + ((offset + i) % eligible));
edge.setProperty(key, random.nextInt(schema.getMaxEdgePropVal()));
}
}
示例3: createEdge
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
protected void createEdge(ShapeData sd1, ShapeData sd2, String edgeType, Double x, Double y) {
// note: visio doesn't always support direction, and neither do we. So, to
// save time, and make sure we don't accidentally create duplicate
// edges, we sort by id
ShapeData from = sd1;
ShapeData to = sd2;
if (sd1.shapeId > sd2.shapeId) {
from = sd2;
to = sd1;
}
String eId = getConnId(from, to);
Edge edge = graph.getEdge(eId);
if (edge == null) {
edge = graph.addEdge(eId, from.vertex, to.vertex, edgeType);
if (x != null && y != null) {
edge.setProperty("x", x);
edge.setProperty("y", y);
}
}
}
示例4: createNewFieldEdge
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
private Edge createNewFieldEdge(Vertex container, Vertex binary, String fileName, String contentType, String dominantColor, String fieldKey) {
Edge edge = getGraph().addEdge("class:BinaryGraphFieldImpl", container, binary, "HAS_FIELD");
edge.setProperty("ferma_type", "BinaryGraphFieldImpl");
edge.setProperty("uuid", randomUUID());
edge.setProperty(BINARY_FILENAME_PROPERTY_KEY, fileName);
edge.setProperty(BINARY_CONTENT_TYPE_PROPERTY_KEY, contentType);
if (dominantColor != null) {
edge.setProperty(BINARY_IMAGE_DOMINANT_COLOR_PROPERTY_KEY, dominantColor);
}
edge.setProperty(FIELD_KEY_PROPERTY_KEY, fieldKey);
return null;
}
示例5: migrateBaseNode
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
/**
* Migrate the basenode and create a new NodeGraphFieldContainer for it.
*
* @param baseNode
* @param admin
*/
private void migrateBaseNode(Vertex baseNode, Vertex admin) {
log.info("Migrating basenode {" + baseNode.getProperty("uuid") + "}");
Vertex schemaContainer = baseNode.getVertices(Direction.OUT, "HAS_SCHEMA_CONTAINER").iterator().next();
Vertex schemaVersion = schemaContainer.getVertices(Direction.OUT, "HAS_LATEST_VERSION").iterator().next();
Vertex english = findEnglish();
Iterator<Edge> it = baseNode.getEdges(Direction.OUT, "HAS_FIELD_CONTAINER").iterator();
// The base node has no field containers. Lets create the default one
if (!it.hasNext()) {
Vertex container = getGraph().addVertex("class:NodeGraphFieldContainerImpl");
container.setProperty("ferma_type", "NodeGraphFieldContainerImpl");
container.setProperty("uuid", randomUUID());
// Fields
container.setProperty("name-field", "name");
container.setProperty("name-string", "");
// field container edge which will later be migrated
Edge edge = baseNode.addEdge("HAS_FIELD_CONTAINER", container);
edge.setProperty("ferma_type", "GraphFieldContainerEdgeImpl");
edge.setProperty("languageTag", "en");
container.addEdge("HAS_SCHEMA_CONTAINER_VERSION", schemaVersion);
container.addEdge("HAS_LANGUAGE", english);
}
}
示例6: migrateFermaTypes
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
private void migrateFermaTypes() {
int i = 0;
log.info("Migrating vertices");
for (Vertex vertex : getGraph().getVertices()) {
String type = vertex.getProperty("ferma_type");
if (type != null && type.endsWith("TagGraphFieldContainerImpl")) {
vertex.setProperty("ferma_type", "com.gentics.mesh.core.data.container.impl.TagGraphFieldContainerImpl");
i++;
}
if (type != null && type.endsWith("SchemaContainerImpl")) {
vertex.setProperty("ferma_type", "com.gentics.mesh.core.data.schema.impl.SchemaContainerImpl");
i++;
}
if (type != null && type.endsWith("NodeGraphFieldContainerImpl")) {
vertex.setProperty("ferma_type", "com.gentics.mesh.core.data.container.impl.NodeGraphFieldContainerImpl");
i++;
}
}
log.info("Completed migration of " + i + " vertices.");
log.info("Migrating edges");
i = 0;
for (Edge edge : getGraph().getEdges()) {
if ("com.gentics.mesh.core.data.node.field.impl.nesting.NodeGraphFieldImpl".equals(edge.getProperty("ferma_type"))) {
edge.setProperty("ferma_type", "com.gentics.mesh.core.data.node.field.impl.NodeGraphFieldImpl");
i++;
}
}
log.info("Completed migration of " + i + " edges.");
}
示例7: processRow
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
@Override
protected void processRow(String[] row)
{
if (row.length < 3)
return;
String srcId = row[0];
String dstId = row[1];
String label = row[2];
Graph graph = importer.getGraph();
Vertex outVertex = lookupVertex(srcId, graph);
Vertex inVertex = lookupVertex(dstId, graph);
if (outVertex == null)
{
logger.info("Cannot resolve source node {} for {} -> {}", srcId,
srcId, dstId);
return;
}
if (inVertex == null)
{
logger.info("Cannot resolve destination node {} for {} -> {}",
dstId, srcId, dstId);
return;
}
Edge edge = graph.addEdge(0, outVertex, inVertex, label);
for (int i = 3; i < row.length; i++)
{
edge.setProperty(importer.getEdgeKeys()[i], row[i]);
}
}
示例8: savePermission
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
public void savePermission(Object id, Permission permission) {
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
if (permission.getId() == null) {
Vertex doc = getOrientGraph().getVertex(id);
Vertex role = getOrientGraph().getVertex(permission.getOut().getId());
Edge perm = getOrientGraph().addEdge("class:Permission", role, doc, null);
perm.setProperty("permissions", permission.getPermissions());
} else {
getOrientGraph().getEdge(permission.getId()).setProperty("permissions", permission.getPermissions());
}
}
}
示例9: inheritPermissions
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
private void inheritPermissions(ODocument parent, ODocument doc) {
Vertex parentV = getOrientGraph().getVertex(parent.getIdentity());
Vertex docV = getOrientGraph().getVertex(doc.getIdentity());
Iterable<Edge> permissions = parentV.getEdges(Direction.IN, "Permission");
for (Edge permission : permissions) {
Vertex role = permission.getVertex(Direction.OUT);
Edge perm = getOrientGraph().addEdge("class:Permission", role, docV, null);
perm.setProperty("permissions", permission.getProperty("permissions"));
}
}
示例10: saveProcessModule
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
private Module saveProcessModule(Module module) {
ProcessModel processModel;
if (module.getModel() == null) {
processModel = ProcessModel.createDefault();
processModel.setName(module.getName());
processModel.setTitle(module.getTitle());
module.setModel(HybridbpmCoreUtil.objectToJson(processModel));
} else {
processModel = HybridbpmCoreUtil.jsonToObject(module.getModel(), ProcessModel.class);
}
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
module.setUpdateDate(new Date());
module = database.save(module);
database.command(new OCommandSQL("DELETE EDGE Permission WHERE in = " + module.getId())).execute();
Vertex pv = getOrientGraph().getVertex(module.getId());
List<Permission.PERMISSION> permissions = new ArrayList<>();
for (Permission.PERMISSION permission : Permission.PERMISSION.getPermissionsForClass(Module.class)) {
permissions.add(permission);
}
for (TaskModel taskModel : processModel.getStartTaskModels().values()) {
if (taskModel.getRole() != null && !taskModel.getRole().isEmpty()) {
Vertex role = getOrientGraph().getVertex(getRole(taskModel.getRole()).getId());
Edge perm = getOrientGraph().addEdge("class:Permission", role, pv, null);
perm.setProperty("permissions", permissions);
perm.setProperty("parameter", taskModel.getName());
}
}
database.commit();
module = detach(module);
return module;
}
}
示例11: saveDocumentPermission
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
public void saveDocumentPermission(Document document, Permission permission) {
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
if (permission.getId() == null) {
Vertex doc = getOrientGraph().getVertex(document.getId());
Vertex role = getOrientGraph().getVertex(permission.getOut().getId());
Edge perm = getOrientGraph().addEdge("class:Permission", role, doc, null);
perm.setProperty("permissions", permission.getPermissions());
} else {
getOrientGraph().getEdge(permission.getId()).setProperty("permissions", permission.getPermissions());
}
}
}
示例12: defaultPermissions
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
private void defaultPermissions(ODocument doc) {
List<Permission.PERMISSION> permissions = new ArrayList<>();
for (Permission.PERMISSION permission : Permission.PERMISSION.getPermissionsForClass(Document.class)) {
permissions.add(permission);
}
Vertex role = getOrientGraph().getVertex(getRole(Role.ADMINISTRATOR).getId());
Vertex docV = getOrientGraph().getVertex(doc.getIdentity());
Edge perm = getOrientGraph().addEdge("class:Permission", role, docV, null);
perm.setProperty("permissions", permissions);
}
示例13: createEdge
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
void createEdge( NodeID idFrom, NodeID idTo, String className, String linkName ) {
Vertex from = graph.getVertex( idFrom );
Vertex to = graph.getVertex( idTo );
Edge e = graph.addEdge( null, from, to, className );
if( linkName != null )
e.setProperty( "name", linkName );
graph.commit();
}
示例14: testEdgeTTLWithVertexCentricIndex
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
@Category({ BrittleTests.class })
@Test
public void testEdgeTTLWithVertexCentricIndex() throws Exception {
if (!features.hasCellTTL()) {
return;
}
int ttl = 1; // artificially low TTL for test
final PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).make();
EdgeLabel wavedAt = mgmt.makeEdgeLabel("wavedAt").signature(time).make();
mgmt.buildEdgeIndex(wavedAt, "timeindex", Direction.BOTH, Order.DESC, time);
mgmt.setTTL(wavedAt, ttl, TimeUnit.SECONDS);
assertEquals(0, mgmt.getTTL(time).getLength(TimeUnit.SECONDS));
assertEquals(ttl, mgmt.getTTL(wavedAt).getLength(TimeUnit.SECONDS));
mgmt.commit();
Vertex v1 = graph.addVertex(null), v2 = graph.addVertex(null);
Edge e1 = graph.addEdge(null, v1, v2, "wavedAt");
e1.setProperty("time", 42);
assertTrue(v1.getEdges(Direction.OUT).iterator().hasNext());
assertTrue(v1.query().direction(Direction.OUT).interval("time", 0, 100).edges().iterator().hasNext());
graph.commit();
long commitTime = System.currentTimeMillis();
assertTrue(v1.getEdges(Direction.OUT).iterator().hasNext());
assertTrue(v1.query().direction(Direction.OUT).interval("time", 0, 100).edges().iterator().hasNext());
Thread.sleep(commitTime + (ttl * 1000L + 100) - System.currentTimeMillis());
graph.rollback();
assertFalse(v1.getEdges(Direction.OUT).iterator().hasNext());
assertFalse(v1.query().direction(Direction.OUT).interval("time", 0, 100).edges().iterator().hasNext());
}
示例15: testEdgeTTLWithCompositeIndex
import com.tinkerpop.blueprints.Edge; //導入方法依賴的package包/類
@Test
public void testEdgeTTLWithCompositeIndex() throws Exception {
if (!features.hasCellTTL()) {
return;
}
PropertyKey edgeName = mgmt.makePropertyKey("edge-name").dataType(String.class).make();
mgmt.buildIndex("edge-name", Edge.class).addKey(edgeName).buildCompositeIndex();
EdgeLabel label = mgmt.makeEdgeLabel("likes").make();
mgmt.setTTL(label, 1, TimeUnit.SECONDS);
assertEquals(0, mgmt.getTTL(edgeName).getLength(TimeUnit.SECONDS));
assertEquals(1, mgmt.getTTL(label).getLength(TimeUnit.SECONDS));
mgmt.commit();
Vertex v1 = graph.addVertex(null), v2 = graph.addVertex(null);
Edge e = graph.addEdge(null, v1, v2, "likes");
e.setProperty("edge-name", "v1-likes-v2");
graph.commit();
assertTrue(v1.getEdges(Direction.OUT).iterator().hasNext());
assertTrue(graph.getEdges("edge-name", "v1-likes-v2").iterator().hasNext());
Thread.sleep(1001);
graph.rollback();
// the edge is gone not only from its previous endpoints, but also from key indices
assertFalse(graph.getEdges("edge-name", "v1-likes-v2").iterator().hasNext());
assertFalse(v1.getEdges(Direction.OUT).iterator().hasNext());
}