Skip to content

Commit

Permalink
enabled jsonpath, fixed delete
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaCimminoArriaga committed Jan 25, 2022
1 parent 6008d36 commit c3607da
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>es.upm.fi.oeg</groupId>
<artifactId>wothive</artifactId>
<version>0.2.1</version>
<version>0.2.2</version>
<name>Directory for the Web of Things</name>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/directory/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Utils {
public static final String METHOD_PUT = "PUT";

public static final String MIME_DIRECTORY_ERROR = "application/problem+json";
protected static final String DIRECTORY_VERSION = "WoTHive/0.2.1";
protected static final String DIRECTORY_VERSION = "WoTHive/0.2.2";
protected static final String WOT_DIRECTORY_LOGO = "\n"+
"██╗ ██╗ ██████╗ ████████╗\n" +
"██║ ██║██╔═══██╗╚══██╔══╝\n" +
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/directory/search/JsonPathController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonObject;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;

import directory.Utils;
import directory.exceptions.SearchJsonPathException;
import directory.things.ThingsService;
import net.minidev.json.JSONArray;
import spark.Request;
import spark.Response;
Expand All @@ -29,8 +32,8 @@ private JsonPathController() {

response.header(Utils.HEADER_CONTENT_TYPE, Utils.MIME_JSON);
response.status(200);

return null;//ThingsRepository.readAll().parallelStream().map(thing -> mapJsonPath(thing, path)).filter(JsonPathController::validList).flatMap(Collection::stream).collect(Collectors.toList());
List<String> thingsIds = ThingsService.retrieveThingsIds(null, null);
return thingsIds.parallelStream().map(ThingsService::retrieveThing).flatMap(thing -> mapJsonPath(thing, path).stream()).collect(Collectors.toList());
};

private static JsonPath checkJsonPath(String jsonPath) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/directory/things/ThingsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ private ThingsController() {
response.status(200);

List<String> thingsIds = ThingsService.retrieveThingsIds(limit, offset);
System.out.println(thingsIds);
if(limit!=null) // Listing with pagination
prepareListingResponse(response, limit, offset, thingsIds.size());
return thingsIds.parallelStream().map(ThingsService::retrieveThing).collect(Collectors.toList());
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/directory/things/ThingsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public class ThingsService {
// for method: delete
private static final String QUERY_CLEAR_GRAPH = "CLEAR GRAPH <";
private static final String QUERY_CLOSE_URI = ">";
private static final String QUERY_DELETE_THING_1 = "DELETE { <";
private static final String QUERY_DELETE_THING_2 = Utils.buildMessage("> ?p ?o . } WHERE{ GRAPH <",MANAGEMENT_GRAPH,"> { ?s ?p ?o . } }");

private static final String QUERY_DELETE_THING_1 = Utils.buildMessage("DELETE WHERE { GRAPH <",MANAGEMENT_GRAPH,"> { <");
private static final String QUERY_DELETE_THING_2 = "> ?p ?o . } }";
// -- Constructor

private ThingsService() {
Expand Down Expand Up @@ -120,7 +119,7 @@ private static void enrichTd(JsonObject td) {
* @param id of the Thing to be found
* @return returns a JSON-LD 1.1 representation of the Thing
*/
protected static final JsonObject retrieveThing(String id) {
public static final JsonObject retrieveThing(String id) {
System.out.println(id);
String graphId = createGraphId(id);
if(!exists(graphId))
Expand Down

0 comments on commit c3607da

Please sign in to comment.