static pool provider, cleaned test and added fake-data library to play with.
This commit is contained in:
parent
f20d14e3af
commit
d938faf618
5
pom.xml
5
pom.xml
@ -162,6 +162,11 @@
|
|||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
<version>2.6.0</version>
|
<version>2.6.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.javafaker</groupId>
|
||||||
|
<artifactId>javafaker</artifactId>
|
||||||
|
<version>1.0.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@ -9,8 +9,8 @@ Might have to
|
|||||||
- mvn spring-boot:run
|
- mvn spring-boot:run
|
||||||
- in IntelliJ: Run Icon in `src/main/java/com/stktrk/app/AppApplication.java`
|
- 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/swagger-ui/index.html
|
||||||
http://localhost:9090/hello?myName=Rasmus
|
http://localhost:9090/actuator
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.stktrk.app;
|
package com.stktrk.app;
|
||||||
|
|
||||||
import com.arcadedb.gremlin.ArcadeGraph;
|
import com.arcadedb.gremlin.ArcadeGraph;
|
||||||
import com.arcadedb.gremlin.ArcadeGraphFactory;
|
|
||||||
|
|
||||||
|
import com.github.javafaker.Faker;
|
||||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
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.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
@ -29,15 +30,37 @@ public class AppApplication extends SpringBootServletInitializer {
|
|||||||
|
|
||||||
|
|
||||||
List<Vertex> x = List.of();
|
List<Vertex> 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()) {
|
try (ArcadeGraph graph = pool.get()) {
|
||||||
x = graph.traversal().V().toList();
|
x = graph.traversal().V().toList();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
StringJoiner sj = new StringJoiner(", ");
|
ArcadeGraph g = ConnectionPool.getGraph();
|
||||||
x.forEach(v -> sj.add((String) v.property("name").value()));
|
|
||||||
|
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("<br />\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.<br/>\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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/main/java/com/stktrk/app/ConnectionPool.java
Normal file
21
src/main/java/com/stktrk/app/ConnectionPool.java
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user