Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Index


    @PUT
    @Path("/{indexName}")
    @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


        parameters.put("class", "vertex");
        parameters.put("keys", "[name]");
        final IndexResource resource = constructIndexResource(true, parameters).getResource();
        resource.postIndex(graphName, "index-name-100");

        final Index idx = ((IndexableGraph) this.toyGraph).getIndex("index-name-100", Vertex.class);
        Assert.assertNotNull(idx);
    }
View Full Code Here

        parameters.put("class", "edge");
        parameters.put("keys", "[weight]");
        final IndexResource resource = constructIndexResource(true, parameters).getResource();
        resource.postIndex(graphName, "index-name-100");

        final Index idx = ((IndexableGraph) this.toyGraph).getIndex("index-name-100", Edge.class);
        Assert.assertNotNull(idx);
    }
View Full Code Here

        this.indices.put(index.getIndexName(), index);
        return index;
    }

    public <T extends Element> Index<T> getIndex(final String indexName, final Class<T> indexClass) {
        Index index = this.indices.get(indexName);
        if (null == index)
            return null;
        if (!indexClass.isAssignableFrom(index.getIndexClass()))
            throw ExceptionFactory.indexDoesNotSupportClass(indexName, indexClass);
        else
            return index;
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.Index

Copyright © 2018 www.massapicom. 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.