org.apache.tinkerpop.gremlin.structure.Graph.Features Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.structure.Graph.Features. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityGraphFactory.java    From baleen with Apache License 2.0 6 votes vote down vote up
/**
 * Load the data form the jCas into the given graph.
 *
 * @param jCas to load the data from
 * @param graph to load the data into
 * @throws AnalysisEngineProcessException
 */
public void load(JCas jCas, Graph graph, Features features)
    throws AnalysisEngineProcessException {

  try (Graph documentGraph = factory.create(jCas)) {
    GraphTraversalSource fromTraversal = documentGraph.traversal();

    GraphTraversalSource destTraversal = graph.traversal();

    mapEntities(features, fromTraversal, destTraversal);
    mapEvents(features, fromTraversal, destTraversal);
    mapRelations(features, fromTraversal, destTraversal);
  } catch (Exception e) {
    throw new AnalysisEngineProcessException(e);
  }
}
 
Example #2
Source File: EntityGraphFactory.java    From baleen with Apache License 2.0 6 votes vote down vote up
private void mapEvents(
    Features features, GraphTraversalSource fromTraversal, GraphTraversalSource destTraversal) {

  fromTraversal
      .V()
      .hasLabel(EVENT)
      .sideEffect(
          tv -> {
            Vertex origEvent = tv.get();
            Vertex transEvent = destTraversal.addV(EVENT).property(id, origEvent.id()).next();
            copyProperties(features, origEvent, transEvent);
            origEvent
                .edges(Direction.BOTH)
                .forEachRemaining(
                    origEdge ->
                        destTraversal
                            .V(origEdge.inVertex().id())
                            .addE(PARTICIPANT_IN)
                            .to(transEvent)
                            .iterate());
          })
      .iterate();
}
 
Example #3
Source File: EntityGraphFactory.java    From baleen with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
protected void addProperty(Features features, Element v, String key, List<?> values) {
  if (v instanceof Vertex && !Cardinality.single.equals(features.vertex().getCardinality(key))) {
    values.stream().filter(not(isNull())).forEach(value -> setProperty(v, key, value));
  } else {
    ValueStrategy valueStrategy = options.getValueStrategyProvider().get(key);
    addSingleProperty(v, key, values, valueStrategy);
  }
}
 
Example #4
Source File: BitsyFeatures.java    From bitsy with Apache License 2.0 4 votes vote down vote up
@Override
public Features.VariableFeatures variables() {
    return variablesFeatures;
}
 
Example #5
Source File: BitsyFeatures.java    From bitsy with Apache License 2.0 4 votes vote down vote up
@Override
public Features.VertexPropertyFeatures properties() {
    return vertexPropertyFeatures;
}
 
Example #6
Source File: BitsyFeatures.java    From bitsy with Apache License 2.0 4 votes vote down vote up
@Override
public Features.EdgePropertyFeatures properties() {
    return edgePropertyFeatures;
}
 
Example #7
Source File: AbstractMigratingDocumentGraphConsumer.java    From baleen with Apache License 2.0 2 votes vote down vote up
/**
 * Override to transform graph before migration
 *
 * @param graph to transform
 * @param features of the target graph
 * @return the transformed graph
 */
protected Graph transformGraph(Graph graph, Features features) {
  return graph;
}
 
Example #8
Source File: AbstractMigratingEntityGraphConsumer.java    From baleen with Apache License 2.0 2 votes vote down vote up
/**
 * Override to transform graph before migration
 *
 * @param graph to transform
 * @param features of the target graph
 * @return the transformed graph
 */
protected Graph transformGraph(Graph graph, Features features) {
  return graph;
}
 
Example #9
Source File: EntityGraphFactory.java    From baleen with Apache License 2.0 2 votes vote down vote up
/**
 * Create a document graph from the given jCas.
 *
 * @param jCas to create the document from
 * @param features to use for the graph
 * @return the document graph
 * @throws AnalysisEngineProcessException
 */
public Graph create(JCas jCas, Features features) throws AnalysisEngineProcessException {
  Graph graph = createTransformGraph(features.vertex().supportsMultiProperties());
  load(jCas, graph, features);
  return graph;
}
 
Example #10
Source File: FramedGraph.java    From peapod with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the {@link Features} exposed by the underlying {@code Graph} implementation.
 *
 * @return a features object
 * @see org.apache.tinkerpop.gremlin.structure.Graph#features()
 */
public Features features() {
    return graph.features();
}