Skip to content

Commit

Permalink
POST & PUT LOI
Browse files Browse the repository at this point in the history
  • Loading branch information
hvarg committed Feb 13, 2024
1 parent c5fc81e commit 0c07cf0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.diskproject.server.api.impl;

import java.io.IOException;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;

Expand Down
14 changes: 9 additions & 5 deletions server/src/main/java/org/diskproject/server/db/DiskDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public KBCache getOnt () {
return this.DISKOnt;
}

public String getLocalId(String fullId) {
return fullId.replaceAll("^.*\\/", "");
}
public String createGoalURI (String id) {
return this.domain + "/goals/" + id;
}
Expand Down Expand Up @@ -235,6 +238,7 @@ private KBObject findOrWriteEndpoint (Endpoint p) {
//Check if this entity exists
Endpoint endpoint = loadEndpoint(KBEndpoint);
if (endpoint == null) {
//FIXME: Cannot create the endpoint here, we need to check that the endpoint is valid first
System.out.println("Endpoint does not exist. Creating...");
domainKB.setPropertyValue(KBEndpoint, DISKOnt.getProperty(DISK.HAS_SOURCE_NAME), domainKB.createLiteral(p.getName()));
domainKB.setPropertyValue(KBEndpoint, DISKOnt.getProperty(DISK.HAS_SOURCE_URL), domainKB.createLiteral(p.getUrl()));
Expand Down Expand Up @@ -349,7 +353,7 @@ public Goal AddOrUpdateGoal (Goal goal, String id) {
// These are necessary fields, should send an appropriate exception here.
return null;
} else {
if ((isCreating || (goal.getId().equals(id) && deleteGoal(id))) && writeGoal(goal)) {
if ((isCreating || (getLocalId(goal.getId()).equals(id) && deleteGoal(id))) && writeGoal(goal)) {
return isCreating ? goal : loadGoal(id);
}
}
Expand Down Expand Up @@ -472,7 +476,7 @@ public List<Goal> listGoals () {
List<Goal> list = new ArrayList<Goal>();
List<String> goalIds = listObjectIdPerClass(DISKOnt.getClass(DISK.GOAL));
for (String fullId: goalIds) {
String id = fullId.replaceAll("^.*\\/", "");
String id = getLocalId(fullId);
list.add(this.loadGoal(id));
}
return list;
Expand Down Expand Up @@ -552,7 +556,7 @@ public LineOfInquiry AddOrUpdateLOI (LineOfInquiry loi, String id) {
// These are necessary fields, should send an appropriate exception here.
return null;
} else {
if ((isCreating || (loi.getId().equals(id) && deleteLOI(id))) && writeLOI(loi)) {
if ((isCreating || (getLocalId(loi.getId()).equals(id) && deleteLOI(id))) && writeLOI(loi)) {
return isCreating ? loi : loadLOI(id);
}
}
Expand Down Expand Up @@ -675,7 +679,7 @@ public List<LineOfInquiry> listLOIPreviews() {
List<String> ids = listObjectIdPerClass(DISKOnt.getClass(DISK.LINE_OF_INQUIRY));

for (String fullId: ids) {
String id = fullId.replaceAll("^.*\\/", "");
String id = getLocalId(fullId);
list.add(this.loadLOI(id));
}
return list;
Expand Down Expand Up @@ -1135,7 +1139,7 @@ public List<TriggeredLOI> listTLOIs() {
List<TriggeredLOI> list = new ArrayList<TriggeredLOI>();
List<String> ids = listObjectIdPerClass(DISKOnt.getClass(DISK.TRIGGERED_LINE_OF_INQUIRY));
for (String fullId: ids) {
String id = fullId.replaceAll("^.*\\/", "");
String id = getLocalId(fullId);
list.add(this.loadTLOI(id));
}
//TriggeredLOI tloi = loadTLOI(username, tloiId.replaceAll("^.*\\/", ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
public class Endpoint {
private String name, url;

public Endpoint() {}

public Endpoint(String name, String url) {
this.name = name;
this.url = url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class DataQueryTemplate {
private Endpoint endpoint;
private String template, description, variablesToShow, footnote;

public DataQueryTemplate () {}

public DataQueryTemplate (DataQueryTemplate src) {
this.endpoint = src.getEndpoint();
this.template = src.getTemplate();
Expand Down

0 comments on commit 0c07cf0

Please sign in to comment.