From bfac72b24ede2e1d5a1750ec15c45f97d33b840d Mon Sep 17 00:00:00 2001 From: hvarg Date: Sun, 7 Apr 2024 01:43:45 -0400 Subject: [PATCH] Fix data query result constructor --- .../server/{quering => querying}/Match.java | 8 ++--- .../server/repository/DiskRepository.java | 3 +- .../server/threads/MonitorThread.java | 13 ++++---- .../server/threads/ThreadManager.java | 32 ++++++++----------- .../shared/classes/loi/DataQueryResult.java | 2 ++ 5 files changed, 28 insertions(+), 30 deletions(-) rename server/src/main/java/org/diskproject/server/{quering => querying}/Match.java (98%) diff --git a/server/src/main/java/org/diskproject/server/quering/Match.java b/server/src/main/java/org/diskproject/server/querying/Match.java similarity index 98% rename from server/src/main/java/org/diskproject/server/quering/Match.java rename to server/src/main/java/org/diskproject/server/querying/Match.java index da47e39..ec99a29 100644 --- a/server/src/main/java/org/diskproject/server/quering/Match.java +++ b/server/src/main/java/org/diskproject/server/querying/Match.java @@ -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; @@ -311,15 +311,15 @@ private List createWorkflowInstance (WorkflowSeed seed) { private List filterQueryResults (Set allowedVariables) { // If the query results includes variables not used on the workflow, these are removed if the contents are the same. List list = new ArrayList(); - String lastLine = ""; + Set read = new HashSet(); 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); } } diff --git a/server/src/main/java/org/diskproject/server/repository/DiskRepository.java b/server/src/main/java/org/diskproject/server/repository/DiskRepository.java index 95d60f9..b61907a 100644 --- a/server/src/main/java/org/diskproject/server/repository/DiskRepository.java +++ b/server/src/main/java/org/diskproject/server/repository/DiskRepository.java @@ -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; @@ -529,6 +529,7 @@ public List 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) { diff --git a/server/src/main/java/org/diskproject/server/threads/MonitorThread.java b/server/src/main/java/org/diskproject/server/threads/MonitorThread.java index 799369b..68f3e20 100644 --- a/server/src/main/java/org/diskproject/server/threads/MonitorThread.java +++ b/server/src/main/java/org/diskproject/server/threads/MonitorThread.java @@ -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. @@ -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); } diff --git a/server/src/main/java/org/diskproject/server/threads/ThreadManager.java b/server/src/main/java/org/diskproject/server/threads/ThreadManager.java index 9f5b7d8..4ef833f 100644 --- a/server/src/main/java/org/diskproject/server/threads/ThreadManager.java +++ b/server/src/main/java/org/diskproject/server/threads/ThreadManager.java @@ -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; @@ -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; @@ -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); } @@ -80,9 +77,10 @@ public void processFinishedRun (TriggeredLOI tloi, WorkflowSeed wf, Execution ru } private boolean addMetaBindings (TriggeredLOI tloi) { + //TODO List dates = new ArrayList(); - Map> files = new HashMap>(); - System.out.println("[M] Adding data to metaworkflow"); + //Map> files = new HashMap>(); + System.out.println("[M] Adding data to meta-workflow"); boolean allOk = true; //Get all String thisParentLoiId = tloi.getParentLoi().getId(); @@ -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()); - //} - //List list = files.get(outputName); - //list.add(out.id.replaceAll("^.*#", "")); - } + //for (VariableBinding out: run.getOutputs()) { + // if (!files.containsKey(outputName)) { + // files.put(outputName, new ArrayList()); + // } + // List list = files.get(outputName); + // list.add(out.id.replaceAll("^.*#", "")); + //} dates.add(String.valueOf(run.getEndDate())); } } @@ -111,7 +108,6 @@ private boolean addMetaBindings (TriggeredLOI tloi) { /*for (WorkflowSeed wf: tloi.getMetaWorkflowSeeds()) { MethodAdapter adapter = this.methodAdapters.getMethodAdapterByName(wf.getSource().getName()); List vars = adapter.getWorkflowVariables(wf.getId()); - Check this also TODO for (VariableBinding vb: wf.getBindings()) { String binding = vb.getBinding(); if (binding.equals("_RUN_DATE_")) { @@ -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; } } diff --git a/shared/src/main/java/org/diskproject/shared/classes/loi/DataQueryResult.java b/shared/src/main/java/org/diskproject/shared/classes/loi/DataQueryResult.java index 1f0f7b5..343dc84 100644 --- a/shared/src/main/java/org/diskproject/shared/classes/loi/DataQueryResult.java +++ b/shared/src/main/java/org/diskproject/shared/classes/loi/DataQueryResult.java @@ -3,6 +3,8 @@ public class DataQueryResult extends DataQueryTemplate { private String query, results; + public DataQueryResult() { } + public DataQueryResult(DataQueryTemplate src) { super(src); }