本文整理匯總了Java中com.tinkerpop.blueprints.Vertex.addEdge方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertex.addEdge方法的具體用法?Java Vertex.addEdge怎麽用?Java Vertex.addEdge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.tinkerpop.blueprints.Vertex
的用法示例。
在下文中一共展示了Vertex.addEdge方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeData
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
@Override
public void initializeData() {
final OrientBaseGraph db = context.getConnection();
// init only empty database
if (db.countVertices(CLASS_NAME) > 0) {
return;
}
Vertex previous = null;
for (int i = 0; i < 10; i++) {
// note usage of "class:" prefix - it is required to reference registered class,
// otherwise orient could try to register new class
final Vertex node = db.addVertex("class:" + CLASS_NAME,
"name", "Sample" + i,
"amount", (int) (Math.random() * 200));
if (previous != null) {
// bottom-up connection: second Sample BelongsTo previous sample (graph is directed)
node.addEdge("belongsTo", previous);
}
previous = node;
}
}
示例2: migrateBaseNode
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的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);
}
}
示例3: getOrFixUserReference
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
private Vertex getOrFixUserReference(Vertex element, String edge) {
Vertex creator = null;
Iterator<Vertex> creatorIterator = element.getVertices(Direction.OUT, edge).iterator();
if (!creatorIterator.hasNext()) {
log.error("The element {" + element.getProperty("uuid") + "} has no {" + edge + "}. Using admin instead.");
creator = findAdmin();
element.addEdge(edge, creator);
} else {
creator = creatorIterator.next();
}
return creator;
}
示例4: migrateSchemaContainerRootEdges
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
/**
* The edge label has change. Migrate existing edges.
*/
private void migrateSchemaContainerRootEdges(Vertex schemaRoot) {
for (Edge edge : schemaRoot.getEdges(Direction.OUT, "HAS_SCHEMA_CONTAINER")) {
Vertex container = edge.getVertex(Direction.IN);
schemaRoot.addEdge("HAS_SCHEMA_CONTAINER_ITEM", container);
edge.remove();
}
}
示例5: apply
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
@Override
public void apply() {
Vertex meshRoot = MeshGraphHelper.getMeshRootVertex(getGraph());
Vertex projectRoot = meshRoot.getVertices(Direction.OUT, "HAS_PROJECT_ROOT").iterator().next();
for (Vertex project : projectRoot.getVertices(Direction.OUT, "HAS_PROJECT")) {
Iterator<Vertex> it = project.getVertices(Direction.OUT, "HAS_RELEASE_ROOT").iterator();
if (it.hasNext()) {
Vertex releaseRoot = it.next();
for (Vertex release : releaseRoot.getVertices(Direction.OUT, "HAS_RELEASE")) {
// Assign the release to the project
release.addEdge("ASSIGNED_TO_PROJECT", project);
}
}
}
}
示例6: apply
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
@Override
public void apply() {
Vertex meshRootVertex = getMeshRootVertex();
Vertex mopedVertex = getGraph().addVertex("TheMoped2");
mopedVertex.setProperty("name", "moped2");
meshRootVertex.addEdge("HAS_MOPED2", mopedVertex);
log.info("Added moped2");
}
示例7: apply
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
@Override
public void apply() {
Vertex meshRootVertex = getMeshRootVertex();
Vertex mopedVertex = getGraph().addVertex("TheMoped");
mopedVertex.setProperty("name", "moped");
meshRootVertex.addEdge("HAS_MOPED", mopedVertex);
log.info("Added moped");
}
示例8: addChild
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
public Vertex addChild(Vertex parent, String name, int amount) {
final Vertex child = context.getConnection().addVertex("class:" + CLASS_NAME, "name", name, "amount", amount);
child.addEdge("belongsTo", parent);
return child;
}
示例9: migrateTagFamilies
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
private void migrateTagFamilies(Vertex project) {
Vertex tagFamilyRoot = project.getVertices(Direction.OUT, "HAS_TAGFAMILY_ROOT").iterator().next();
for (Vertex tagFamily : tagFamilyRoot.getVertices(Direction.OUT, "HAS_TAG_FAMILY")) {
// Check dates
Object tagFamilyCreationTimeStamp = tagFamily.getProperty("creation_timestamp");
if (tagFamilyCreationTimeStamp == null) {
tagFamily.setProperty("creation_timestamp", System.currentTimeMillis());
}
Object tagFamilyEditTimeStamp = tagFamily.getProperty("last_edited_timestamp");
if (tagFamilyEditTimeStamp == null) {
tagFamily.setProperty("last_edited_timestamp", System.currentTimeMillis());
}
// Create a new tag root vertex for the tagfamily and link the tags to this vertex instead to the tag family itself.
Vertex tagRoot = getGraph().addVertex("class:TagRootImpl");
tagRoot.setProperty("ferma_type", "com.gentics.mesh.core.data.root.impl.TagRootImpl");
tagRoot.setProperty("uuid", randomUUID());
for (Edge tagEdge : tagFamily.getEdges(Direction.OUT, "HAS_TAG")) {
Vertex tag = tagEdge.getVertex(Direction.IN);
tagEdge.remove();
tagRoot.addEdge("HAS_TAG", tag);
tag.getEdges(Direction.OUT, "HAS_TAGFAMILY_ROOT").forEach(edge -> edge.remove());
tag.addEdge("HAS_TAGFAMILY_ROOT", tagFamily);
if (!tag.getEdges(Direction.OUT, "ASSIGNED_TO_PROJECT").iterator().hasNext()) {
log.error("Tag {" + tag.getProperty("uuid") + " has no project assigned to it. Fixing it...");
tag.addEdge("ASSIGNED_TO_PROJECT", project);
}
Object creationTimeStamp = tag.getProperty("creation_timestamp");
if (creationTimeStamp == null) {
tag.setProperty("creation_timestamp", System.currentTimeMillis());
}
Object editTimeStamp = tag.getProperty("last_edited_timestamp");
if (editTimeStamp == null) {
tag.setProperty("last_edited_timestamp", System.currentTimeMillis());
}
}
tagFamily.addEdge("HAS_TAG_ROOT", tagRoot);
if (!tagFamily.getEdges(Direction.OUT, "ASSIGNED_TO_PROJECT").iterator().hasNext()) {
log.error("TagFamily {" + tagFamily.getProperty("uuid") + " has no project assigned to it. Fixing it...");
tagFamily.addEdge("ASSIGNED_TO_PROJECT", project);
}
getOrFixUserReference(tagFamily, "HAS_EDITOR");
getOrFixUserReference(tagFamily, "HAS_CREATOR");
}
}
示例10: migrateSchemaContainers
import com.tinkerpop.blueprints.Vertex; //導入方法依賴的package包/類
/**
* Add the schema container versions to schema containers.
*/
private void migrateSchemaContainers() {
log.info("Migrating schema containers");
for (Vertex schemaContainer : getGraph().getVertices()) {
String type = schemaContainer.getProperty("ferma_type");
if (type != null && type.endsWith("SchemaContainerImpl")) {
String name = schemaContainer.getProperty("name");
log.info("Migrating schema {" + name + "}");
String json = schemaContainer.getProperty("json");
schemaContainer.removeProperty("json");
try {
JSONObject schema = new JSONObject(json);
// TVC does not use segment fields. Remove the segment field properties from the schema
if (schema.has("segmentField")) {
schema.remove("segmentField");
}
if (schema.has("meshVersion")) {
schema.remove("meshVersion");
}
// property was renamed
if (schema.has("folder")) {
schema.put("container", schema.getBoolean("folder"));
schema.remove("folder");
}
if (schema.has("binary") && schema.getBoolean("binary")) {
JSONObject binaryFieldSchema = new JSONObject();
binaryFieldSchema.put("name", "binary");
binaryFieldSchema.put("label", "Binary Content");
binaryFieldSchema.put("required", false);
binaryFieldSchema.put("type", "binary");
schema.getJSONArray("fields").put(binaryFieldSchema);
}
// Check whether all fields have a name
JSONArray fields = schema.getJSONArray("fields");
for (int i = 0; i < fields.length(); i++) {
// Remove fields which have no name to it.
JSONObject field = fields.getJSONObject(i);
if (!field.has("name")) {
fields.remove(field);
}
}
schema.remove("fields");
schema.put("fields", fields);
schema.put("version", "1");
if (schema.has("binary")) {
schema.remove("binary");
}
json = schema.toString();
} catch (JSONException e) {
throw new RuntimeException("Could not parse stored schema {" + json + "}");
}
Vertex version = getGraph().addVertex("class:SchemaContainerVersionImpl");
version.setProperty("uuid", randomUUID());
version.setProperty("name", name);
version.setProperty("json", json);
version.setProperty("version", 1);
version.setProperty("ferma_type", "com.gentics.mesh.core.data.schema.impl.SchemaContainerVersionImpl");
schemaContainer.addEdge("HAS_LATEST_VERSION", version);
schemaContainer.addEdge("HAS_PARENT_CONTAINER", version);
}
}
log.info("Completed migration of schema containers");
}