From 95d5ba219322267287f363009490ed65d133085f Mon Sep 17 00:00:00 2001 From: Rasmus Neikes Date: Sun, 18 Aug 2024 23:35:55 +0200 Subject: [PATCH] added ArcadeDB, gremlin. --- pom.xml | 40 +++++++++++++++++++ .../java/com/stktrk/app/AppApplication.java | 35 +++++++++++----- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 01e54f1..acf99a2 100644 --- a/pom.xml +++ b/pom.xml @@ -107,6 +107,46 @@ arcadedb-server 24.6.1 + + + org.apache.tinkerpop + gremlin-driver + 3.7.2 + + + + + + + + org.apache.tinkerpop + gremlin-groovy + 3.7.2 + + + + + + + org.opencypher.gremlin + translation + 1.0.4 + org.hashids hashids diff --git a/src/main/java/com/stktrk/app/AppApplication.java b/src/main/java/com/stktrk/app/AppApplication.java index d0968f2..be5b9cf 100644 --- a/src/main/java/com/stktrk/app/AppApplication.java +++ b/src/main/java/com/stktrk/app/AppApplication.java @@ -1,26 +1,43 @@ package com.stktrk.app; +import com.arcadedb.gremlin.ArcadeGraph; +import com.arcadedb.gremlin.ArcadeGraphFactory; + +import org.apache.tinkerpop.gremlin.structure.Vertex; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.List; +import java.util.StringJoiner; + // https://stackoverflow.com/questions/51221777/failed-to-configure-a-datasource-url-attribute-is-not-specified-and-no-embedd -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) @RestController public class AppApplication extends SpringBootServletInitializer { - public static void main(String[] args) { - SpringApplication.run(AppApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(AppApplication.class, args); + } - @GetMapping("/hello") - public String sayHello(@RequestParam(value = "myName", defaultValue = "World") String name) { - return String.format("Hello %s!", name); - } + @GetMapping("/hello") + public String sayHello(@RequestParam(value = "myName", defaultValue = "World") String name) { + + + List x = List.of(); + try (ArcadeGraphFactory pool = ArcadeGraphFactory.withRemote("192.168.178.50", 2480, "graph", "root", "playwithdata")) { + try (ArcadeGraph graph = pool.get()) { + x = graph.traversal().V().toList(); + } + } + StringJoiner sj = new StringJoiner(", "); + x.forEach(v -> sj.add((String) v.property("name").value())); + + return "Hello, " + name + "! There are " + x.size() + " vertices.\n" + sj; + } }