diff --git a/pom.xml b/pom.xml
index acf99a2..96852c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,6 +162,11 @@
springdoc-openapi-starter-webmvc-ui
2.6.0
+
+ com.github.javafaker
+ javafaker
+ 1.0.2
+
diff --git a/readme.md b/readme.md
index 72af82a..264ca36 100644
--- a/readme.md
+++ b/readme.md
@@ -9,8 +9,8 @@ Might have to
- mvn spring-boot:run
- in IntelliJ: Run Icon in `src/main/java/com/stktrk/app/AppApplication.java`
-http://localhost:9090/swagger-ui/index.html#/app-application/sayHello
-http://localhost:9090/hello?myName=Rasmus
+http://localhost:9090/swagger-ui/index.html
+http://localhost:9090/actuator
diff --git a/src/main/java/com/stktrk/app/AppApplication.java b/src/main/java/com/stktrk/app/AppApplication.java
index be5b9cf..ff53a1b 100644
--- a/src/main/java/com/stktrk/app/AppApplication.java
+++ b/src/main/java/com/stktrk/app/AppApplication.java
@@ -1,8 +1,8 @@
package com.stktrk.app;
import com.arcadedb.gremlin.ArcadeGraph;
-import com.arcadedb.gremlin.ArcadeGraphFactory;
+import com.github.javafaker.Faker;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
+import java.util.Collections;
import java.util.List;
import java.util.StringJoiner;
@@ -29,15 +30,37 @@ public class AppApplication extends SpringBootServletInitializer {
List x = List.of();
- try (ArcadeGraphFactory pool = ArcadeGraphFactory.withRemote("192.168.178.50", 2480, "graph", "root", "playwithdata")) {
+ /* 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()));
+ }*/
+ ArcadeGraph g = ConnectionPool.getGraph();
+
+ Faker faker = new Faker();
+ g.traversal().addV("Profile").property("name", faker.name().firstName()).property("lastName", faker.name().lastName())
+ .iterate();
+ x = g.traversal().V().toList();
+ g.close();
+
+ x.sort((a, b) -> a.id().toString().compareTo(b.id().toString()));
+
+ StringJoiner sj = new StringJoiner("
\n");
+
+
+
+ x.forEach(v -> sj.add(v.id().toString()+ " - " +(String) v.property("name").value() + " " + (String) v.property("lastName").value() ));
+
+ return "Hello, " + name + "! There are " + x.size() + " vertices.
\n" + sj;
+ }
+
+ @GetMapping("/delete")
+ public String delete () {
+ ArcadeGraph g = ConnectionPool.getGraph();
+ g.traversal().V().hasLabel("Profile").drop().iterate();
+ g.close();
+ return "Done.";
- return "Hello, " + name + "! There are " + x.size() + " vertices.\n" + sj;
}
}
diff --git a/src/main/java/com/stktrk/app/ConnectionPool.java b/src/main/java/com/stktrk/app/ConnectionPool.java
new file mode 100644
index 0000000..51ab12e
--- /dev/null
+++ b/src/main/java/com/stktrk/app/ConnectionPool.java
@@ -0,0 +1,21 @@
+package com.stktrk.app;
+
+import com.arcadedb.gremlin.ArcadeGraph;
+import com.arcadedb.gremlin.ArcadeGraphFactory;
+
+public class ConnectionPool {
+ static final ArcadeGraphFactory pool;
+
+
+ static {
+ try {
+ pool = ArcadeGraphFactory.withRemote("192.168.178.50", 2480, "graph", "root", "playwithdata");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static ArcadeGraph getGraph(){
+ return pool.get();
+ }
+}