@Test public void pathsAreReturnedCorrectly() { path.setVendorExtension("x-query","MATCH (n {iri:'http: TinkerGraph graph = (TinkerGraph) inflector.apply(context).getEntity(); assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(1)); }
@AddCuries @Override public Response apply(ContainerRequestContext context) { logger.fine("Serving dynamic request"); Multimap<String, Object> paramMap = MultivaluedMapUtils.merge(context.getUriInfo()); paramMap = resolveCuries(paramMap); try (Transaction tx = graphDb.beginTx()) { long start = System.currentTimeMillis(); start = System.currentTimeMillis(); Result result = cypherUtil.execute((String)path.getVendorExtensions().get("x-query"), paramMap); logger.fine((System.currentTimeMillis() - start) + " to execute query" ); start = System.currentTimeMillis(); TinkerGraphUtil tgu = new TinkerGraphUtil(curieUtil); Graph graph = tgu.resultToGraph(result); tgu.setGraph(graph); logger.fine((System.currentTimeMillis() - start) + " to convert to graph" ); start = System.currentTimeMillis(); for (String key: aspectMap.keySet()) { if ("true".equals(getFirst(paramMap.get(key), "false"))) { aspectMap.get(key).invoke(graph); } } if (paramMap.containsKey("project")) { @SuppressWarnings("unchecked") Collection<String> projection = (Collection<String>)(Collection<?>)paramMap.get("project"); tgu.project(projection); } ArrayPropertyTransformer.transform(graph); tx.success(); Object cacheControlNode = path.getVendorExtensions().get("x-cacheControl"); if (cacheControlNode != null) { try { CacheControl cacheControl = new ObjectMapper().readValue(cacheControlNode.toString(), CacheControl.class); return Response.ok(graph).cacheControl(cacheControl).build(); } catch (Throwable e) { return Response.ok(graph).cacheControl(null).build(); } } return Response.ok(graph).cacheControl(null).build(); } }
CypherInflector implements Inflector<ContainerRequestContext, Response> { @AddCuries @Override public Response apply(ContainerRequestContext context) { logger.fine("Serving dynamic request"); Multimap<String, Object> paramMap = MultivaluedMapUtils.merge(context.getUriInfo()); paramMap = resolveCuries(paramMap); try (Transaction tx = graphDb.beginTx()) { long start = System.currentTimeMillis(); start = System.currentTimeMillis(); Result result = cypherUtil.execute((String)path.getVendorExtensions().get("x-query"), paramMap); logger.fine((System.currentTimeMillis() - start) + " to execute query" ); start = System.currentTimeMillis(); TinkerGraphUtil tgu = new TinkerGraphUtil(curieUtil); Graph graph = tgu.resultToGraph(result); tgu.setGraph(graph); logger.fine((System.currentTimeMillis() - start) + " to convert to graph" ); start = System.currentTimeMillis(); for (String key: aspectMap.keySet()) { if ("true".equals(getFirst(paramMap.get(key), "false"))) { aspectMap.get(key).invoke(graph); } } if (paramMap.containsKey("project")) { @SuppressWarnings("unchecked") Collection<String> projection = (Collection<String>)(Collection<?>)paramMap.get("project"); tgu.project(projection); } ArrayPropertyTransformer.transform(graph); tx.success(); Object cacheControlNode = path.getVendorExtensions().get("x-cacheControl"); if (cacheControlNode != null) { try { CacheControl cacheControl = new ObjectMapper().readValue(cacheControlNode.toString(), CacheControl.class); return Response.ok(graph).cacheControl(cacheControl).build(); } catch (Throwable e) { return Response.ok(graph).cacheControl(null).build(); } } return Response.ok(graph).cacheControl(null).build(); } } }
CypherInflector implements Inflector<ContainerRequestContext, Response> { @AddCuries @Override public Response apply(ContainerRequestContext context) { logger.fine("Serving dynamic request"); Multimap<String, Object> paramMap = MultivaluedMapUtils.merge(context.getUriInfo()); paramMap = resolveCuries(paramMap); try (Transaction tx = graphDb.beginTx()) { long start = System.currentTimeMillis(); start = System.currentTimeMillis(); Result result = cypherUtil.execute((String)path.getVendorExtensions().get("x-query"), paramMap); logger.fine((System.currentTimeMillis() - start) + " to execute query" ); start = System.currentTimeMillis(); TinkerGraphUtil tgu = new TinkerGraphUtil(curieUtil); Graph graph = tgu.resultToGraph(result); tgu.setGraph(graph); logger.fine((System.currentTimeMillis() - start) + " to convert to graph" ); start = System.currentTimeMillis(); for (String key: aspectMap.keySet()) { if ("true".equals(getFirst(paramMap.get(key), "false"))) { aspectMap.get(key).invoke(graph); } } if (paramMap.containsKey("project")) { @SuppressWarnings("unchecked") Collection<String> projection = (Collection<String>)(Collection<?>)paramMap.get("project"); tgu.project(projection); } ArrayPropertyTransformer.transform(graph); tx.success(); Object cacheControlNode = path.getVendorExtensions().get("x-cacheControl"); if (cacheControlNode != null) { try { CacheControl cacheControl = new ObjectMapper().readValue(cacheControlNode.toString(), CacheControl.class); return Response.ok(graph).cacheControl(cacheControl).build(); } catch (Throwable e) { return Response.ok(graph).cacheControl(null).build(); } } return Response.ok(graph).cacheControl(null).build(); } } @Inject  CypherInflector(GraphDatabaseService graphDb, CypherUtil cypherUtil, CurieUtil curieUtil,
      @Assisted String pathName, @Assisted Path path, Map<String, GraphAspect> aspectMap); }
CypherInflector implements Inflector<ContainerRequestContext, Response> { @AddCuries @Override public Response apply(ContainerRequestContext context) { logger.fine("Serving dynamic request"); Multimap<String, Object> paramMap = MultivaluedMapUtils.merge(context.getUriInfo()); paramMap = resolveCuries(paramMap); try (Transaction tx = graphDb.beginTx()) { long start = System.currentTimeMillis(); start = System.currentTimeMillis(); Result result = cypherUtil.execute((String)path.getVendorExtensions().get("x-query"), paramMap); logger.fine((System.currentTimeMillis() - start) + " to execute query" ); start = System.currentTimeMillis(); TinkerGraphUtil tgu = new TinkerGraphUtil(curieUtil); Graph graph = tgu.resultToGraph(result); tgu.setGraph(graph); logger.fine((System.currentTimeMillis() - start) + " to convert to graph" ); start = System.currentTimeMillis(); for (String key: aspectMap.keySet()) { if ("true".equals(getFirst(paramMap.get(key), "false"))) { aspectMap.get(key).invoke(graph); } } if (paramMap.containsKey("project")) { @SuppressWarnings("unchecked") Collection<String> projection = (Collection<String>)(Collection<?>)paramMap.get("project"); tgu.project(projection); } ArrayPropertyTransformer.transform(graph); tx.success(); Object cacheControlNode = path.getVendorExtensions().get("x-cacheControl"); if (cacheControlNode != null) { try { CacheControl cacheControl = new ObjectMapper().readValue(cacheControlNode.toString(), CacheControl.class); return Response.ok(graph).cacheControl(cacheControl).build(); } catch (Throwable e) { return Response.ok(graph).cacheControl(null).build(); } } return Response.ok(graph).cacheControl(null).build(); } } @Inject  CypherInflector(GraphDatabaseService graphDb, CypherUtil cypherUtil, CurieUtil curieUtil,
      @Assisted String pathName, @Assisted Path path, Map<String, GraphAspect> aspectMap); @AddCuries @Override Response apply(ContainerRequestContext context); }
CypherInflector implements Inflector<ContainerRequestContext, Response> { @AddCuries @Override public Response apply(ContainerRequestContext context) { logger.fine("Serving dynamic request"); Multimap<String, Object> paramMap = MultivaluedMapUtils.merge(context.getUriInfo()); paramMap = resolveCuries(paramMap); try (Transaction tx = graphDb.beginTx()) { long start = System.currentTimeMillis(); start = System.currentTimeMillis(); Result result = cypherUtil.execute((String)path.getVendorExtensions().get("x-query"), paramMap); logger.fine((System.currentTimeMillis() - start) + " to execute query" ); start = System.currentTimeMillis(); TinkerGraphUtil tgu = new TinkerGraphUtil(curieUtil); Graph graph = tgu.resultToGraph(result); tgu.setGraph(graph); logger.fine((System.currentTimeMillis() - start) + " to convert to graph" ); start = System.currentTimeMillis(); for (String key: aspectMap.keySet()) { if ("true".equals(getFirst(paramMap.get(key), "false"))) { aspectMap.get(key).invoke(graph); } } if (paramMap.containsKey("project")) { @SuppressWarnings("unchecked") Collection<String> projection = (Collection<String>)(Collection<?>)paramMap.get("project"); tgu.project(projection); } ArrayPropertyTransformer.transform(graph); tx.success(); Object cacheControlNode = path.getVendorExtensions().get("x-cacheControl"); if (cacheControlNode != null) { try { CacheControl cacheControl = new ObjectMapper().readValue(cacheControlNode.toString(), CacheControl.class); return Response.ok(graph).cacheControl(cacheControl).build(); } catch (Throwable e) { return Response.ok(graph).cacheControl(null).build(); } } return Response.ok(graph).cacheControl(null).build(); } } @Inject  CypherInflector(GraphDatabaseService graphDb, CypherUtil cypherUtil, CurieUtil curieUtil,
      @Assisted String pathName, @Assisted Path path, Map<String, GraphAspect> aspectMap); @AddCuries @Override Response apply(ContainerRequestContext context);  }