Esempio n. 1
0
 /**
  * Add a vertex to the underlying graph and return it as a framed vertex.
  *
  * @param id the id of the newly created vertex
  * @param kind the default annotated interface to frame the vertex as
  * @param <F> the default type of the annotated interface
  * @return a proxy object backed by the vertex and interpreted from the perspective of the
  *     annotate interface
  */
 public <F> F addVertex(final Object id, final Class<F> kind) {
   Vertex vertex = addVertex(id);
   for (FrameInitializer initializer : config.getFrameInitializers()) {
     initializer.initElement(kind, this, vertex);
   }
   return this.frame(vertex, kind);
 }
Esempio n. 2
0
 /**
  * Construct a FramedGraph that will frame the elements of the underlying graph.
  *
  * @param baseGraph the graph whose elements to frame
  * @deprecated Use {@link FramedGraphFactory}.
  */
 public FramedGraph(final T baseGraph) {
   this.baseGraph = baseGraph;
   config = new FramedGraphConfiguration();
   config.setConfiguredGraph(baseGraph);
   configViaFactory = false;
   registerAnnotationHandler(new PropertyAnnotationHandler());
   registerAnnotationHandler(new AdjacencyAnnotationHandler());
   registerAnnotationHandler(new IncidenceAnnotationHandler());
   registerAnnotationHandler(new DomainAnnotationHandler());
   registerAnnotationHandler(new RangeAnnotationHandler());
   registerAnnotationHandler(new GremlinGroovyAnnotationHandler());
 }
Esempio n. 3
0
 /**
  * Add an edge to the underlying graph and return it as a framed edge.
  *
  * @param id the id of the newly created edge
  * @param outVertex the outgoing vertex
  * @param inVertex the incoming vertex
  * @param label the label of the edge
  * @param direction the direction of the edge
  * @param kind the default annotated interface to frame the edge as
  * @param <F> the default type of the annotated interface
  * @return a proxy object backed by the edge and interpreted from the perspective of the annotate
  *     interface
  */
 public <F> F addEdge(
     final Object id,
     final Vertex outVertex,
     final Vertex inVertex,
     final String label,
     final Direction direction,
     final Class<F> kind) {
   Edge edge = addEdge(id, outVertex, inVertex, label);
   for (FrameInitializer initializer : config.getFrameInitializers()) {
     initializer.initElement(kind, this, edge);
   }
   return this.frame(edge, direction, kind);
 }
Esempio n. 4
0
  /**
   * A helper method for framing a vertex. Note that all framed vertices implement {@link
   * VertexFrame} to allow access to the underlying element
   *
   * @param vertex the vertex to frame
   * @param kind the default annotated interface to frame the vertex as
   * @param <F> the default type of the annotated interface
   * @return a proxy objects backed by a vertex and interpreted from the perspective of the annotate
   *     interface or null if the vertex parameter was null
   */
  public <F> F frame(final Vertex vertex, final Class<F> kind) {
    if (vertex == null) {
      return null;
    }

    Collection<Class<?>> resolvedTypes = new HashSet<Class<?>>();
    resolvedTypes.add(VertexFrame.class);
    resolvedTypes.add(kind);
    for (TypeResolver typeResolver : config.getTypeResolvers()) {
      resolvedTypes.addAll(Arrays.asList(typeResolver.resolveTypes(vertex, kind)));
    }
    return (F)
        Proxy.newProxyInstance(
            kind.getClassLoader(),
            resolvedTypes.toArray(new Class[resolvedTypes.size()]),
            new FramedElement(this, vertex));
  }
Esempio n. 5
0
 public GraphQuery query() {
   return config.getConfiguredGraph().query();
 }
Esempio n. 6
0
 public void shutdown() {
   config.getConfiguredGraph().shutdown();
 }
Esempio n. 7
0
 public Features getFeatures() {
   Features features = config.getConfiguredGraph().getFeatures().copyFeatures();
   features.isWrapper = true;
   return features;
 }
Esempio n. 8
0
 /**
  * @return
  * @deprecated Use {@link Module}s via {@link FramedGraphFactory}.
  */
 public Collection<AnnotationHandler<? extends Annotation>> getAnnotationHandlers() {
   checkFactoryConfig();
   return config.getAnnotationHandlers().values();
 }
Esempio n. 9
0
 /**
  * @param annotationType the type of annotation handled by the annotation handler
  * @return a boolean indicating if the framedGraph has registered an annotation handler for the
  *     specified type
  * @deprecated Use {@link Module}s via {@link FramedGraphFactory}.
  */
 public boolean hasAnnotationHandler(final Class<? extends Annotation> annotationType) {
   checkFactoryConfig();
   return config.getAnnotationHandlers().containsKey(annotationType);
 }
Esempio n. 10
0
 public Iterable<Vertex> getVertices(final String key, final Object value) {
   return config.getConfiguredGraph().getVertices(key, value);
 }
Esempio n. 11
0
 public Iterable<Vertex> getVertices() {
   return config.getConfiguredGraph().getVertices();
 }
Esempio n. 12
0
 public void removeEdge(final Edge edge) {
   config.getConfiguredGraph().removeEdge(edge);
 }
Esempio n. 13
0
 public void removeVertex(final Vertex vertex) {
   config.getConfiguredGraph().removeVertex(vertex);
 }
Esempio n. 14
0
 public Edge addEdge(
     final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
   return config.getConfiguredGraph().addEdge(id, outVertex, inVertex, label);
 }
Esempio n. 15
0
 public Edge getEdge(final Object id) {
   return config.getConfiguredGraph().getEdge(id);
 }
Esempio n. 16
0
 /**
  * The method used to register a new annotation handler for every new annotation a new annotation
  * handler has to be registered in the framed graph
  *
  * @param handler the annotation handler
  * @deprecated Use {@link Module}s via {@link FramedGraphFactory}.
  */
 public void registerAnnotationHandler(final AnnotationHandler<? extends Annotation> handler) {
   checkFactoryConfig();
   config.addAnnotationhandler(handler);
 }
Esempio n. 17
0
 /**
  * @param annotationType the type of annotation handled by the annotation handler
  * @return the annotation handler associated with the specified type
  * @deprecated Use {@link Module}s via {@link FramedGraphFactory}.
  */
 public AnnotationHandler<?> getAnnotationHandler(
     final Class<? extends Annotation> annotationType) {
   checkFactoryConfig();
   return config.getAnnotationHandlers().get(annotationType);
 }
Esempio n. 18
0
 /**
  * Frame vertices according to a particular kind of annotated interface.
  *
  * @param key the key of the vertices to get
  * @param value the value of the vertices to get
  * @param kind the default annotated interface to frame the vertices as
  * @param <F> the default type of the annotated interface
  * @return an iterable of proxy objects backed by the vertices and interpreted from the
  *     perspective of the annotate interface
  */
 public <F> Iterable<F> getVertices(final String key, final Object value, final Class<F> kind) {
   return new FramedVertexIterable<F>(
       this, config.getConfiguredGraph().getVertices(key, value), kind);
 }
Esempio n. 19
0
 /**
  * @param annotationType the type of the annotation handler to remove
  * @deprecated Use {@link Module}s via {@link FramedGraphFactory}.
  */
 public void unregisterAnnotationHandler(final Class<? extends Annotation> annotationType) {
   checkFactoryConfig();
   config.getAnnotationHandlers().remove(annotationType);
 }
Esempio n. 20
0
 public Iterable<Edge> getEdges() {
   return config.getConfiguredGraph().getEdges();
 }
Esempio n. 21
0
 /**
  * Register a <code>FrameInitializer</code> that will be called whenever a new vertex or edge is
  * added to the graph. The initializer may mutate the vertex (or graph) before returning the
  * framed element to the user.
  *
  * @param frameInitializer the frame initializer
  * @deprecated Use {@link Module}s via {@link FramedGraphFactory}.
  */
 public void registerFrameInitializer(FrameInitializer frameInitializer) {
   checkFactoryConfig();
   config.addFrameInitializer(frameInitializer);
 }
Esempio n. 22
0
 public Iterable<Edge> getEdges(final String key, final Object value) {
   return config.getConfiguredGraph().getEdges(key, value);
 }
Esempio n. 23
0
 /**
  * Frame edges according to a particular kind of annotated interface.
  *
  * @param key the key of the edges to get
  * @param value the value of the edges to get
  * @param direction the direction of the edges
  * @param kind the default annotated interface to frame the edges as
  * @param <F> the default type of the annotated interface
  * @return an iterable of proxy objects backed by the edges and interpreted from the perspective
  *     of the annotate interface
  */
 public <F> Iterable<F> getEdges(
     final String key, final Object value, final Direction direction, final Class<F> kind) {
   return new FramedEdgeIterable<F>(
       this, config.getConfiguredGraph().getEdges(key, value), direction, kind);
 }
Esempio n. 24
0
 public Vertex addVertex(final Object id) {
   return config.getConfiguredGraph().addVertex(id);
 }