Examples of IndexableGraph


Examples of com.tinkerpop.blueprints.IndexableGraph

        if (null != temp)
            id = temp.toString();

        final Index index = this.getIndexFromGraph(graphName, indexName);
        final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName);
        final IndexableGraph graph = (IndexableGraph) rag.getGraph();

        if (null == index) {
            final String msg = "Could not find index [" + indexName + "] on graph [" + graphName + "]";
            logger.info(msg);

            final JSONObject error = generateErrorObject(msg);
            throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).entity(error).build());
        }

        if (key == null && value == null && id == null) {
            try {
                graph.dropIndex(indexName);
                rag.tryCommit();
            } catch (Exception ex) {
                logger.error(ex);

                rag.tryRollback();

                final JSONObject error = generateErrorObjectJsonFail(ex);
                throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
            }
        } else if (null != index & key != null && value != null && id != null) {
            try {
                if (index.getIndexClass().equals(Vertex.class))
                    index.remove(key, value, graph.getVertex(id));
                else
                    index.remove(key, value, graph.getEdge(id));

                rag.tryCommit();
                this.resultObject.put(Tokens.QUERY_TIME, this.sh.stopWatch());

            } catch (JSONException ex) {
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

            idxParamsList.toArray(indexParameters);
        }

        final Index index = this.getIndexFromGraph(graphName, indexName);
        final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName);
        final IndexableGraph graph = (IndexableGraph) rag.getGraph();

        if (null != index) {
            final String msg = "Index [" + indexName + "] on graph [" + graphName + "] already exists";
            logger.info(msg);

            final JSONObject error = generateErrorObject(msg);
            throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
        } else {
            // create an index
            if (null != clazz) {
                final Class c;
                if (clazz.equals(Tokens.VERTEX))
                    c = Vertex.class;
                else if (clazz.equals(Tokens.EDGE))
                    c = Edge.class;
                else {
                    final JSONObject error = generateErrorObject("Index class must be either vertex or edge");
                    throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
                }

                final Index newIndex;
                try {
                    newIndex = graph.createIndex(indexName, c, indexParameters);
                    rag.tryCommit();
                } catch (Exception e) {
                    logger.info(e.getMessage());

                    rag.tryRollback();
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

    @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON})
    @Timed(name = "http.rest.indices.object.put", absolute = true)
    public Response putElementInIndex(@PathParam("graphname") final String graphName, @PathParam("indexName") final String indexName) {
        final Index index = this.getIndexFromGraph(graphName, indexName);
        final RexsterApplicationGraph rag = this.getRexsterApplicationGraph(graphName);
        final IndexableGraph graph = (IndexableGraph) rag.getGraph();

        if (index == null) {
            JSONObject error = generateErrorObject("Index not found.");
            throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).entity(error).build());
        }

        String key = null;
        Object value = null;
        String id = null;

        final JSONObject theRequestObject = this.getRequestObject();

        Object temp = theRequestObject.opt(Tokens.KEY);
        if (null != temp)
            key = temp.toString();
        temp = theRequestObject.opt(Tokens.VALUE);
        if (null != temp)
            value = ElementHelper.getTypedPropertyValue(temp.toString());
        temp = theRequestObject.opt(Tokens.ID);
        if (null != temp)
            id = temp.toString();

        if (key != null && value != null && id != null) {
            try {
                if (Vertex.class.isAssignableFrom(index.getIndexClass())) {
                    index.put(key, value, graph.getVertex(id));
                    rag.tryCommit();
                } else if (Edge.class.isAssignableFrom(index.getIndexClass())) {
                    index.put(key, value, graph.getEdge(id));
                    rag.tryCommit();
                } else {
                    rag.tryRollback();
                    final JSONObject error = generateErrorObject("Index class must be either vertex or edge");
                    throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

    }

    private Index getIndexFromGraph(final String graphName, final String name) {

        final Graph graph = this.getRexsterApplicationGraph(graphName).getUnwrappedGraph();
        final IndexableGraph idxGraph = graph instanceof IndexableGraph ? (IndexableGraph) graph : null;

        if (idxGraph == null) {
            final JSONObject error = this.generateErrorObject("The requested graph is not of type IndexableGraph.");
            throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
        }

        final Iterable<Index<? extends Element>> indices = idxGraph.getIndices();
        for (final Index index : indices) {
            if (index.getIndexName().equals(name)) {
                return index;
            }
        }
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

    }

    protected ResourceHolder<IndexResource> constructIndexResource(final boolean useToyGraph,
                                                                     final HashMap<String, Object> parameters,
                                                                     final MediaType mediaType) {
        final IndexableGraph indexableGraph = (IndexableGraph) this.toyGraph;
        final Index<Vertex> basicNameIndex = indexableGraph.createIndex("index-name-0", Vertex.class);
        indexableGraph.createIndex("index-name-1", Edge.class);
        indexableGraph.createIndex("index-name-2", Vertex.class);
        indexableGraph.createIndex("index-name-3", Vertex.class);
        indexableGraph.createIndex("index-name-4", Vertex.class);
        final Index<Edge> edgeIndex = indexableGraph.createIndex("index-name-5", Edge.class);
        indexableGraph.createIndex("index-name-6", Vertex.class);
        indexableGraph.createIndex("index-name-7", Vertex.class);
        indexableGraph.createIndex("index-name-8", Vertex.class);
        final Index<Vertex> madeUpIndex = indexableGraph.createIndex("index-name-9", Vertex.class);

        basicNameIndex.put("name", "marko", this.toyGraph.getVertex(1));
        basicNameIndex.put("name", "vadas", this.toyGraph.getVertex(2));
        basicNameIndex.put("name", "lop", this.toyGraph.getVertex(3));
        basicNameIndex.put("name", "josh", this.toyGraph.getVertex(4));
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

   * @param existing element to remove index entries
   * @param indexName name of index associated to element
   */
  public static <Type extends Element> void removeFromIndex(Graph database, Type existing, IndexNames indexName) {
    if (database instanceof IndexableGraph) {
      IndexableGraph indexable = (IndexableGraph) database;
      if(indexName.isUsable()) {
        Index<Type> index = (Index<Type>) indexable.getIndex(indexName.getIndexName(), indexName.getIndexed());
        for(String propertyName : existing.getPropertyKeys()) {
          index.remove(propertyName, existing.getProperty(propertyName), existing);
        }
      }
    }
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

   * @param existing element to remove index entries
   * @param indexName name of index associated to element
   */
  public static <Type extends Element> void removeFromIndex(Graph database, Type existing, IndexNames indexName) {
    if (database instanceof IndexableGraph) {
      IndexableGraph indexable = (IndexableGraph) database;
      if(indexName.isUsable()) {
        Index<Type> index = (Index<Type>) indexable.getIndex(indexName.getIndexName(), indexName.getIndexed());
        for(String propertyName : existing.getPropertyKeys()) {
          index.remove(propertyName, existing.getProperty(propertyName), existing);
        }
      }
    }
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

   * @param existing element to remove index entries
   * @param indexName name of index associated to element
   */
  public static <Type extends Element> void removeFromIndex(Graph database, Type existing, IndexNames indexName) {
    if (database instanceof IndexableGraph) {
      IndexableGraph indexable = (IndexableGraph) database;
      if(indexName.isUsable()) {
        Index<Type> index = (Index<Type>) indexable.getIndex(indexName.getIndexName(), indexName.getIndexed());
        for(String propertyName : existing.getPropertyKeys()) {
          index.remove(propertyName, existing.getProperty(propertyName), existing);
        }
      }
    }
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

   * @param existing element to remove index entries
   * @param indexName name of index associated to element
   */
  public static <Type extends Element> void removeFromIndex(Graph database, Type existing, IndexNames indexName) {
    if (database instanceof IndexableGraph) {
      IndexableGraph indexable = (IndexableGraph) database;
      if(indexName.isUsable()) {
        Index<Type> index = (Index<Type>) indexable.getIndex(indexName.getIndexName(), indexName.getIndexed());
        for(String propertyName : existing.getPropertyKeys()) {
          index.remove(propertyName, existing.getProperty(propertyName), existing);
        }
      }
    }
View Full Code Here

Examples of com.tinkerpop.blueprints.IndexableGraph

  @Override
  public void visit(final VertexPropertyTest vertexPropertyTest) {
    // TODO improve that code !!!
    Graph g = service.getDatabase();
    if (g instanceof IndexableGraph) {
      final IndexableGraph indexable = (IndexableGraph) g;
      final Index<Vertex> vertices = indexable
              .getIndex(IndexNames.VERTICES.getIndexName(), Vertex.class);
      result.put(new Iterable<Vertex>() {

        @Override
        public Iterator<Vertex> iterator() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.