Skip to content

Commit

Permalink
Fix data query result constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
hvarg committed Apr 7, 2024
1 parent 1e6cd9f commit bfac72b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.diskproject.server.quering;
package org.diskproject.server.querying;

import org.diskproject.shared.classes.adapters.DataAdapter;
import org.diskproject.shared.classes.adapters.DataResult;
Expand Down Expand Up @@ -311,15 +311,15 @@ private List<WorkflowInstantiation> createWorkflowInstance (WorkflowSeed seed) {
private List<DataResult> filterQueryResults (Set<String> allowedVariables) {
// If the query results includes variables not used on the workflow, these are removed if the contents are the same.
List<DataResult> list = new ArrayList<DataResult>();
String lastLine = "";
Set<String> read = new HashSet<String>();
for (DataResult cell: queryResult) {
String currentLine = "";
for (String v: allowedVariables) {
String varName = v.startsWith("?") ? v.substring(1) : v;
currentLine += cell.getValue(varName) + ",";
}
if (!currentLine.equals(lastLine)) {
lastLine = currentLine;
if (!read.contains(currentLine)) {
read.add(currentLine);
list.add(cell);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.diskproject.server.managers.MethodAdapterManager;
import org.diskproject.server.managers.StorageManager;
import org.diskproject.server.managers.VocabularyManager;
import org.diskproject.server.quering.Match;
import org.diskproject.server.querying.Match;
import org.diskproject.server.threads.ThreadManager;
import org.diskproject.server.util.Config;
import org.diskproject.server.util.KBUtils;
Expand Down Expand Up @@ -529,6 +529,7 @@ public List<TriggeredLOI> queryGoal (String id) throws Exception, QueryParseExce
continue;
} else {
System.out.println("LOI " + DiskDB.getLocalId(cur.getId()) + " got " + solutions.size() + " results. ");
System.out.println(query);
}

if (loiMatch.fullCSV) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ private Status getOverallStatus () {
for (String runId: this.runList) {
Execution run = this.runInfo.get(runId);
Status status = run.getStatus();
if (status == Status.INTERNAL_ERROR)
return Status.INTERNAL_ERROR;
if (status == Status.FAILED)
return Status.FAILED;
if (status != Status.SUCCESSFUL) //If all of them are pending then the tloi should be pending too.
Expand Down Expand Up @@ -107,16 +109,13 @@ public void run() {

// If we cannot get the status but the run was pending, it means that the run is in the WINGS queue.
if (updatedRun == null || updatedRun.getStatus() == null || updatedRun.getStatus() == Status.INTERNAL_ERROR) {
System.out.println("[E] Cannot get status for " + tloi.getId() + " - RUN " + runId);
if (pendingRun.getStatus() == Status.PENDING) { // In queue
if (updatedRun == null) {
updatedRun = pendingRun;
} else if (updatedRun != null && updatedRun.getStatus() == Status.INTERNAL_ERROR) {
}
if (updatedRun.getStatus() != Status.INTERNAL_ERROR) {
updatedRun.setStatus(Status.FAILED);
System.out.println("[E] Internal error for run: " + runId);
} else {
System.out.println("[E] This should not happen");
return;
}
System.out.println("[E] Cannot get status for " + tloi.getId() + " - RUN " + runId);
}
updateRun(wf, updatedRun);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.diskproject.server.threads;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -15,7 +13,6 @@
import org.diskproject.shared.classes.loi.LineOfInquiry;
import org.diskproject.shared.classes.loi.TriggeredLOI;
import org.diskproject.shared.classes.workflow.Execution;
import org.diskproject.shared.classes.workflow.VariableBinding;
import org.diskproject.shared.classes.workflow.WorkflowInstantiation;
import org.diskproject.shared.classes.workflow.WorkflowSeed;

Expand Down Expand Up @@ -65,8 +62,8 @@ public void executeTLOI (TriggeredLOI tloi, Boolean meta) {
executor.execute(workflowThread);
}

public void monitorTLOI (TriggeredLOI tloi, LineOfInquiry loi, Boolean metamode) {
MonitorThread monitorThread = new MonitorThread(this, tloi, metamode);
public void monitorTLOI (TriggeredLOI tloi, LineOfInquiry loi, Boolean metaMode) {
MonitorThread monitorThread = new MonitorThread(this, tloi, metaMode);
monitor.schedule(monitorThread, 15, TimeUnit.SECONDS);
}

Expand All @@ -80,9 +77,10 @@ public void processFinishedRun (TriggeredLOI tloi, WorkflowSeed wf, Execution ru
}

private boolean addMetaBindings (TriggeredLOI tloi) {
//TODO
List<String> dates = new ArrayList<String>();
Map<String, List<String>> files = new HashMap<String, List<String>>();
System.out.println("[M] Adding data to metaworkflow");
//Map<String, List<String>> files = new HashMap<String, List<String>>();
System.out.println("[M] Adding data to meta-workflow");
boolean allOk = true;
//Get all
String thisParentLoiId = tloi.getParentLoi().getId();
Expand All @@ -94,14 +92,13 @@ private boolean addMetaBindings (TriggeredLOI tloi) {
//TLOIs that match both, LOI & Hypothesis
for (WorkflowInstantiation wf: cur.getWorkflows()) {
for (Execution run: wf.getExecutions()) {
for (VariableBinding out: run.getOutputs()) {
//FIXME: continue here.
//if (!files.containsKey(outputName)) {
// files.put(outputName, new ArrayList<String>());
//}
//List<String> list = files.get(outputName);
//list.add(out.id.replaceAll("^.*#", ""));
}
//for (VariableBinding out: run.getOutputs()) {
// if (!files.containsKey(outputName)) {
// files.put(outputName, new ArrayList<String>());
// }
// List<String> list = files.get(outputName);
// list.add(out.id.replaceAll("^.*#", ""));
//}
dates.add(String.valueOf(run.getEndDate()));
}
}
Expand All @@ -111,7 +108,6 @@ private boolean addMetaBindings (TriggeredLOI tloi) {
/*for (WorkflowSeed wf: tloi.getMetaWorkflowSeeds()) {
MethodAdapter adapter = this.methodAdapters.getMethodAdapterByName(wf.getSource().getName());
List<WorkflowVariable> vars = adapter.getWorkflowVariables(wf.getId());
Check this also TODO
for (VariableBinding vb: wf.getBindings()) {
String binding = vb.getBinding();
if (binding.equals("_RUN_DATE_")) {
Expand All @@ -131,8 +127,8 @@ private boolean addMetaBindings (TriggeredLOI tloi) {
}
System.out.println("type: " + type);
// Upload files:
for (String dataid: files.get(outName)) {
if (!adapter.registerData(dataid, type));
for (String dataId: files.get(outName)) {
if (!adapter.registerData(dataId, type));
allOk = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
public class DataQueryResult extends DataQueryTemplate {
private String query, results;

public DataQueryResult() { }

public DataQueryResult(DataQueryTemplate src) {
super(src);
}
Expand Down

0 comments on commit bfac72b

Please sign in to comment.