Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Nov 6, 2024
1 parent b89ca6e commit 2d3135b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,18 @@ dashboard.
```bash
export GATEWAY_PUBLIC_IP=52.53.186.26

# healthcheck
curl -v -i -s -k -X POST https://api.paion-data.dev:8444/services \
--data name=wilhelm-ws-healthcheck \
--data url="http://${GATEWAY_PUBLIC_IP}:8080/v1/data/healthcheck"
curl -i -k -X POST https://api.paion-data.dev:8444/services/wilhelm-ws-healthcheck/routes \
--data "paths[]=/wilhelm/healthcheck" \
--data name=wilhelm-ws-healthcheck

# language paged
# vocabulary paged & count
curl -v -i -s -k -X POST https://api.paion-data.dev:8444/services \
--data name=wilhelm-ws-languages \
--data url="http://${GATEWAY_PUBLIC_IP}:8080/v1/data/languages"
--data url="http://${GATEWAY_PUBLIC_IP}:8080/v1/neo4j/languages"
curl -i -k -X POST https://api.paion-data.dev:8444/services/wilhelm-ws-languages/routes \
--data "paths[]=/wilhelm/languages" \
--data name=wilhelm-ws-languages

# expand
curl -v -i -s -k -X POST https://api.paion-data.dev:8444/services \
--data name=wilhelm-ws-expand \
--data url="http://${GATEWAY_PUBLIC_IP}:8080/v1/data/expand"
--data url="http://${GATEWAY_PUBLIC_IP}:8080/v1/neo4j/expand"
curl -i -k -X POST https://api.paion-data.dev:8444/services/wilhelm-ws-expand/routes \
--data "paths[]=/wilhelm/expand" \
--data name=wilhelm-ws-expand
Expand Down
25 changes: 6 additions & 19 deletions src/main/java/org/qubitpi/wilhelm/web/endpoints/Neo4JServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
@Singleton
@Immutable
@ThreadSafe
@Path("/data")
@Path("/neo4j")
@Produces(MediaType.APPLICATION_JSON)
public class Neo4JServlet {

Expand All @@ -78,19 +78,6 @@ public Neo4JServlet() {
// intentionally left blank
}

/**
* A webservice sanity-check endpoint.
*
* @return 200 OK response
*/
@GET
@Path("/healthcheck")
public Response healthcheck() {
return Response
.status(Response.Status.OK)
.build();
}

/**
* Returns the total number of terms of a specified langauges.
*
Expand Down Expand Up @@ -177,13 +164,13 @@ public Response expand(@NotNull @PathParam("word") final String word) {
* @return a JSON representation of the expanded sub-graph
*/
@GET
@Path("/expandBfs/{word}")
@Path("/expandDfs/{word}")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("MultipleStringLiterals")
public Response expandBfs(@NotNull @PathParam("word") final String word) {
public Response expandDfs(@NotNull @PathParam("word") final String word) {
return Response
.status(Response.Status.OK)
.entity(expandBfs(word, new HashSet<>()))
.entity(expandDfs(word, new HashSet<>()))
.build();
}

Expand All @@ -196,7 +183,7 @@ public Response expandBfs(@NotNull @PathParam("word") final String word) {
*
* @return the expanded sub-graph
*/
private Graph expandBfs(@NotNull final String label, @NotNull final Set<String> visited) {
private Graph expandDfs(@NotNull final String label, @NotNull final Set<String> visited) {
if (visited.contains(label)) {
return Graph.emptyGraph();
}
Expand All @@ -212,7 +199,7 @@ private Graph expandBfs(@NotNull final String label, @NotNull final Set<String>
return new IllegalArgumentException(message);
});
return oneHopExpand.getUndirectedNeighborsOf(wordNode).stream()
.map(neighbor -> expandBfs(neighbor.getLabel(), visited))
.map(neighbor -> expandDfs(neighbor.getLabel(), visited))
.reduce(oneHopExpand, Graph::merge);
}

Expand Down

0 comments on commit 2d3135b

Please sign in to comment.