Changes to match server updates

Deleting now working. am automatically calling a windows curl command to
disable the cache on the server.
This commit is contained in:
Douglas Gillespie 2023-04-04 20:53:14 +01:00
parent faea94205c
commit 35fa8270d2
15 changed files with 310 additions and 286 deletions

View File

@ -56,6 +56,7 @@ import PamUtils.PamUtils;
import PamView.PamSymbol; import PamView.PamSymbol;
import PamView.dialog.PamGridBagContraints; import PamView.dialog.PamGridBagContraints;
import PamView.symbol.SymbolData; import PamView.symbol.SymbolData;
import PamguardMVC.debug.Debug;
import clickDetector.ClickClassifiers.basicSweep.CodeHost; import clickDetector.ClickClassifiers.basicSweep.CodeHost;
import clickDetector.ClickClassifiers.basicSweep.SweepClassifier; import clickDetector.ClickClassifiers.basicSweep.SweepClassifier;
import clickDetector.ClickClassifiers.basicSweep.SweepClassifierSet; import clickDetector.ClickClassifiers.basicSweep.SweepClassifierSet;
@ -1707,7 +1708,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane<ClickTypeProperty> {
// } // }
// } // }
// else multiChan = true; // else multiChan = true;
Debug.out.println("Check multi-channel: " + multiChan); // Debug.out.println("Check multi-channel: " + multiChan);
return multiChan; return multiChan;
} }

View File

@ -43,7 +43,7 @@ public class EffortDialog extends PamDialog {
mainPanel.add(new JLabel("Observer name or initials"), c); mainPanel.add(new JLabel("Observer name or initials"), c);
c.gridx++; c.gridx++;
mainPanel.add(observer = new JComboBox<String>(), c); mainPanel.add(observer = new JComboBox<String>(), c);
outerOnly = new JRadioButton("Log uter scroll only"); outerOnly = new JRadioButton("Log outer scroll only");
allActions = new JRadioButton("Log all scroll actions"); allActions = new JRadioButton("Log all scroll actions");
ButtonGroup bg = new ButtonGroup(); ButtonGroup bg = new ButtonGroup();
bg.add(allActions); bg.add(allActions);

View File

@ -19,13 +19,13 @@ import javax.swing.Timer;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings; import PamController.PamControlledUnitSettings;
import PamController.PamController; import PamController.PamController;
import PamController.PamControllerInterface;
import PamController.PamSettingManager; import PamController.PamSettingManager;
import PamController.PamSettings; import PamController.PamSettings;
import PamView.PamTabPanel; import PamView.PamTabPanel;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import metadata.MetaDataContol; import metadata.MetaDataContol;
import metadata.deployment.DeploymentData; import metadata.deployment.DeploymentData;
import pamViewFX.PamSettingsMenuPane;
import tethys.TethysState.StateType; import tethys.TethysState.StateType;
import tethys.dbxml.DBXMLConnect; import tethys.dbxml.DBXMLConnect;
import tethys.dbxml.DBXMLQueries; import tethys.dbxml.DBXMLQueries;
@ -174,7 +174,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
} }
// and remove any which are no longer there. // and remove any which are no longer there.
for (DatablockSynchInfo synchInfo : dataBlockSynchInfos) { for (DatablockSynchInfo synchInfo : dataBlockSynchInfos) {
if (dataBlocks.contains(synchInfo.getDataBlock()) == false) { if (!dataBlocks.contains(synchInfo.getDataBlock())) {
dataBlockSynchInfos.remove(synchInfo); dataBlockSynchInfos.remove(synchInfo);
} }
} }
@ -342,7 +342,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
public void notifyModelChanged(int changeType) { public void notifyModelChanged(int changeType) {
super.notifyModelChanged(changeType); super.notifyModelChanged(changeType);
switch (changeType) { switch (changeType) {
case PamController.INITIALIZATION_COMPLETE: case PamControllerInterface.INITIALIZATION_COMPLETE:
initializationStuff(); initializationStuff();
break; break;
} }

View File

@ -5,11 +5,9 @@ import Array.HydrophoneLocator;
import Array.PamArray; import Array.PamArray;
import Array.Streamer; import Array.Streamer;
import GPS.GPSControl; import GPS.GPSControl;
import GPS.GpsData;
import GPS.GpsDataUnit; import GPS.GpsDataUnit;
import PamUtils.LatLong; import PamUtils.LatLong;
import PamUtils.PamUtils; import PamUtils.PamUtils;
import PamguardMVC.PamDataUnit;
import generalDatabase.DBControlUnit; import generalDatabase.DBControlUnit;
import generalDatabase.PamConnection; import generalDatabase.PamConnection;
import nilus.Deployment; import nilus.Deployment;

View File

@ -1,7 +1,5 @@
package tethys; package tethys;
import tethys.detection.DetectionExportProgress;
/** /**
* Basis for a message system which will get passed around whenever something happens in * Basis for a message system which will get passed around whenever something happens in
* Tethys, whether it be a new connection, progress during data output, etc. * Tethys, whether it be a new connection, progress during data output, etc.
@ -16,7 +14,7 @@ public class TethysState {
NEWPAMGUARDSELECTION, // new PAMGuard data are available (called once on first load) NEWPAMGUARDSELECTION, // new PAMGuard data are available (called once on first load)
UPDATEMETADATA, // META Data being prepared for output have changed (so may be able to enable output!) UPDATEMETADATA, // META Data being prepared for output have changed (so may be able to enable output!)
EXPORTING // currently exporting data. may be a while ... EXPORTING // currently exporting data. may be a while ...
}; }
public StateType stateType; public StateType stateType;
private Object stateObject; private Object stateObject;

View File

@ -4,24 +4,16 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import java.nio.file.Files;
import java.nio.file.Path;
import dbxml.JerseyClient; import dbxml.JerseyClient;
import dbxml.Queries; import dbxml.Queries;
import dbxml.uploader.Importer; import dbxml.uploader.Importer;
import nilus.Deployment;
import nilus.MarshalXML; import nilus.MarshalXML;
import tethys.TethysControl; import tethys.TethysControl;
import tethys.output.TethysExportParams; import tethys.output.TethysExportParams;
import tethys.output.StreamExportParams;
import PamguardMVC.PamDataBlock;
/** /**
* Class containing functions for managing the database connection. Opening, closing, * Class containing functions for managing the database connection. Opening, closing,
@ -57,7 +49,7 @@ public class DBXMLConnect {
return false; return false;
} }
TethysExportParams params = tethysControl.getTethysExportParams(); TethysExportParams params = tethysControl.getTethysExportParams();
if (currentSiteURL.equalsIgnoreCase(params.getFullServerName()) == false) { if (!currentSiteURL.equalsIgnoreCase(params.getFullServerName())) {
return false; return false;
} }
return true; return true;
@ -68,7 +60,7 @@ public class DBXMLConnect {
* @return Jersy client * @return Jersy client
*/ */
public synchronized JerseyClient getJerseyClient() { public synchronized JerseyClient getJerseyClient() {
if (checkClient() == false) { if (!checkClient()) {
openConnections(); openConnections();
} }
return jerseyClient; return jerseyClient;
@ -79,7 +71,7 @@ public class DBXMLConnect {
* @return * @return
*/ */
public synchronized Queries getTethysQueries() { public synchronized Queries getTethysQueries() {
if (checkClient() == false) { if (!checkClient()) {
openConnections(); openConnections();
} }
return queries; return queries;
@ -125,7 +117,7 @@ public class DBXMLConnect {
catch (Exception e) { catch (Exception e) {
System.out.printf("Error deleting %s %s: %s\n", collection, docId, e.getMessage()); System.out.printf("Error deleting %s %s: %s\n", collection, docId, e.getMessage());
} }
forceFlush(); // forceFlush();
return result == null; return result == null;
} }
@ -170,22 +162,22 @@ public class DBXMLConnect {
} }
/* // /*
* force a fluch by sending a dummy document to th eimporter which will rail, but ... // * force a fluch by sending a dummy document to th eimporter which will rail, but ...
*/ // */
private void forceFlush() { // private void forceFlush() {
TethysExportParams params = new TethysExportParams(); // TethysExportParams params = new TethysExportParams();
String fileError = null; // String fileError = null;
try { // try {
fileError = Importer.ImportFiles(params.getFullServerName(), "NoCollection", // fileError = Importer.ImportFiles(params.getFullServerName(), "NoCollection",
new String[] { "ThereIsNoFileE" }, "", "", false); // new String[] { "ThereIsNoFileE" }, "", "", false);
} // }
catch (Exception e) { // catch (Exception e) {
//
} // }
// System.out.println(fileError); //// System.out.println(fileError);
//
} // }
/** /**
* Get a temp folder to hold xml output. This will be the standard * Get a temp folder to hold xml output. This will be the standard
@ -196,12 +188,12 @@ public class DBXMLConnect {
String javaTmpDirs = System.getProperty("java.io.tmpdir") + File.separator + "PAMGuardTethys"; String javaTmpDirs = System.getProperty("java.io.tmpdir") + File.separator + "PAMGuardTethys";
File tempDir = new File(javaTmpDirs); File tempDir = new File(javaTmpDirs);
if (tempDir.exists() == false) { if (!tempDir.exists()) {
tempDir.mkdirs(); tempDir.mkdirs();
} }
if (tempDir.exists()) { if (tempDir.exists()) {
tempDirectory = tempDir; tempDirectory = tempDir;
}; }
if (tempDirectory == null) { if (tempDirectory == null) {
tempDirectory = new File(System.getProperty("java.io.tmpdir")); tempDirectory = new File(System.getProperty("java.io.tmpdir"));
} }
@ -301,7 +293,7 @@ public class DBXMLConnect {
// } // }
// } // }
try { try {
String doc = queries.getDocument("Deployments", deploymentId); // String doc = queries.getDocument("Deployments", deploymentId);
// queries. // queries.
result = jerseyClient.removeDocument("Deployments", deploymentId ); result = jerseyClient.removeDocument("Deployments", deploymentId );
} }
@ -319,9 +311,29 @@ public class DBXMLConnect {
jerseyClient = new JerseyClient(currentSiteURL); jerseyClient = new JerseyClient(currentSiteURL);
queries = new Queries(jerseyClient); queries = new Queries(jerseyClient);
ServerStatus state = pingServer(); ServerStatus state = pingServer();
setCache(false);
return state.ok; return state.ok;
} }
private void setCache(boolean cacheOn) {
// from Marie. 4/4/2022: Basically it is a PUT to http://localhost:9979/Tethys/cache/off (or on).
TethysExportParams params = tethysControl.getTethysExportParams();
String cmd = String.format("curl -X PUT -data \"\" %s/Tethys/cache/%s", params.getFullServerName(), cacheOn ? "on" : "off");
System.out.println(cmd);
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// CUrl curl = new CUrl(cmd);
}
public synchronized void closeConnections() { public synchronized void closeConnections() {
jerseyClient = null; jerseyClient = null;
queries = null; queries = null;

View File

@ -29,7 +29,6 @@ import nilus.Detections;
import nilus.Helper; import nilus.Helper;
import tethys.TethysControl; import tethys.TethysControl;
import tethys.TethysTimeFuncs; import tethys.TethysTimeFuncs;
import tethys.niluswraps.PDeployment;
import tethys.output.TethysExportParams; import tethys.output.TethysExportParams;
/** /**
@ -114,26 +113,33 @@ public class DBXMLQueries {
if (doc == null) { if (doc == null) {
return null; return null;
} }
NodeList returns = doc.getElementsByTagName("Return"); NodeList returns = doc.getElementsByTagName("Project");
// System.out.println("N projects = " + returns.getLength()); // System.out.println("N projects = " + returns.getLength());
int n = returns.getLength(); int n = returns.getLength();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Node aNode = returns.item(i); Node aNode = returns.item(i);
if (aNode instanceof Element) { String projName = aNode.getTextContent();
Node depEl = ((Element) aNode).getFirstChild();
if (depEl == null) {
continue;
}
if (depEl instanceof Element) {
Element projEl = (Element) ((Element) depEl).getFirstChild();
String projName = projEl.getTextContent();
if (projName != null) { if (projName != null) {
if (!projectNames.contains(projName)) { if (!projectNames.contains(projName)) {
projectNames.add(projName); projectNames.add(projName);
} }
} }
} // }
} // if (aNode instanceof Element) {
// Node depEl = ((Element) aNode).getFirstChild();
// if (depEl == null) {
// continue;
// }
// if (depEl instanceof Element) {
// Element projEl = (Element) ((Element) depEl).getFirstChild();
// String projName = projEl.getTextContent();
// if (projName != null) {
// if (!projectNames.contains(projName)) {
// projectNames.add(projName);
// }
// }
// }
// }
} }
Collections.sort(projectNames); Collections.sort(projectNames);
@ -169,9 +175,14 @@ public class DBXMLQueries {
ArrayList<Deployment> deployments = new ArrayList<>(); ArrayList<Deployment> deployments = new ArrayList<>();
NodeList returns = doc.getElementsByTagName("Return"); NodeList returns = doc.getElementsByTagName("Deployment");
// if (returns.getLength() == 0) {
// // try REsult instead !
// returns = doc.getElementsByTagName("Result");
// }
// System.out.println("N projects = " + returns.getLength()); // System.out.println("N projects = " + returns.getLength());
int n = returns.getLength(); int n = returns.getLength();
// Queries queries = new Queries(null) // Queries queries = new Queries(null)
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Node aNode = returns.item(i); Node aNode = returns.item(i);
@ -252,7 +263,10 @@ public class DBXMLQueries {
} }
ArrayList<String> detectionsNames = new ArrayList(); ArrayList<String> detectionsNames = new ArrayList();
int count = 0; int count = 0;
NodeList returns = doc.getElementsByTagName("Return"); NodeList returns = doc.getElementsByTagName("Detections");
// if (returns.getLength() == 0) {
// returns = doc.getElementsByTagName("Result");
// }
for (int i = 0; i < returns.getLength(); i++) { for (int i = 0; i < returns.getLength(); i++) {
Node aNode = returns.item(i); Node aNode = returns.item(i);
String docName = aNode.getTextContent(); String docName = aNode.getTextContent();
@ -284,6 +298,9 @@ public class DBXMLQueries {
ArrayList<String> detectionDocs = new ArrayList<>(); ArrayList<String> detectionDocs = new ArrayList<>();
NodeList returns = doc.getElementsByTagName("Return"); NodeList returns = doc.getElementsByTagName("Return");
if (returns.getLength() == 0) {
returns = doc.getElementsByTagName("Result");
}
for (int i = 0; i < returns.getLength(); i++) { for (int i = 0; i < returns.getLength(); i++) {
Node aNode = returns.item(i); Node aNode = returns.item(i);
detectionDocs.add(aNode.getTextContent()); detectionDocs.add(aNode.getTextContent());
@ -324,9 +341,7 @@ public class DBXMLQueries {
return 0; return 0;
} }
int count = 0; int count = 0;
for (int i = 0; i < documentNames.size(); i++) { for (String docName : documentNames) {
// Node aNode = returns.item(i);
String docName = documentNames.get(i);
// System.out.println(aNode.getTextContent()); // System.out.println(aNode.getTextContent());
int count2 = countDetections2(docName); int count2 = countDetections2(docName);
count += count2; //countDetecionsData(docName); count += count2; //countDetecionsData(docName);

View File

@ -1,24 +1,14 @@
package tethys.dbxml; package tethys.dbxml;
import java.io.ByteArrayOutputStream;
import java.io.StringReader; import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import PamController.settings.output.xml.PamguardXMLWriter; import PamController.settings.output.xml.PamguardXMLWriter;
import PamUtils.XMLUtils;
import dbxml.JerseyClient; import dbxml.JerseyClient;
import tethys.output.TethysExportParams; import tethys.output.TethysExportParams;

View File

@ -29,7 +29,10 @@ public class StreamExportParams implements Serializable {
public GranularityEnumType granularity = GranularityEnumType.CALL; public GranularityEnumType granularity = GranularityEnumType.CALL;
public nilus.DescriptionType detectionDescription; /*
* Can't have this here since it isn't serializable.
*/
transient public nilus.DescriptionType detectionDescription;
public DescriptionType getDetectionDescription() { public DescriptionType getDetectionDescription() {
if (detectionDescription == null) { if (detectionDescription == null) {

View File

@ -86,7 +86,7 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int aRow = table.getSelectedRow(); int aRow = table.getSelectedRow();
int col = table.getSelectedColumn(); int col = table.getSelectedColumn();
if (aRow >= 0 && aRow < selection.length && col == 6) { if (aRow >= 0 && aRow < selection.length && col == TableModel.SELECTCOLUMN) {
selection[aRow] = !selection[aRow]; selection[aRow] = !selection[aRow];
for (DeploymentTableObserver obs : observers) { for (DeploymentTableObserver obs : observers) {
obs.selectionChanged(); obs.selectionChanged();
@ -193,7 +193,9 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
private class TableModel extends AbstractTableModel { private class TableModel extends AbstractTableModel {
private String[] columnNames = {"Id", "Start", "Stop", "Duration", "Cycle", "Tethys Deployment", "Select"}; private String[] columnNames = {"Id", "Start", "Stop", "Gap", "Duration", "Cycle", "Tethys Deployment", "Select"};
private static final int SELECTCOLUMN = 7;
@Override @Override
public int getRowCount() { public int getRowCount() {
@ -217,7 +219,7 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
@Override @Override
public Class<?> getColumnClass(int columnIndex) { public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == 6) { if (columnIndex == SELECTCOLUMN) {
return Boolean.class; return Boolean.class;
// return JCheckBox.class; // return JCheckBox.class;
} }
@ -228,15 +230,15 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
RecordingPeriod period = deploymentOverview.getRecordingPeriods().get(rowIndex); RecordingPeriod period = deploymentOverview.getRecordingPeriods().get(rowIndex);
// DeploymentRecoveryPair deplInfo = deploymentInfo.get(rowIndex); // DeploymentRecoveryPair deplInfo = deploymentInfo.get(rowIndex);
if (columnIndex == 4) { if (columnIndex == 5) {
return deploymentOverview.getDutyCycleInfo(); return deploymentOverview.getDutyCycleInfo();
} }
return getValueAt(period, rowIndex, columnIndex); if (columnIndex == 3 && rowIndex > 0) {
RecordingPeriod prevPeriod = deploymentOverview.getRecordingPeriods().get(rowIndex-1);
long gap = period.getRecordStart() - prevPeriod.getRecordStop();
return PamCalendar.formatDuration(gap);
} }
return getValueAt(period, rowIndex, columnIndex);
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return columnIndex == 6;
} }
private Object getValueAt(RecordingPeriod period, int rowIndex, int columnIndex) { private Object getValueAt(RecordingPeriod period, int rowIndex, int columnIndex) {
@ -245,25 +247,30 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
return rowIndex; return rowIndex;
case 1: case 1:
return PamCalendar.formatDBDateTime(period.getRecordStart()); return PamCalendar.formatDBDateTime(period.getRecordStart());
// return TethysTimeFuncs.formatGregorianTime(deplInfo.deploymentDetails.getAudioTimeStamp()); // return TethysTimeFuncs.formatGregorianTime(deplInfo.deploymentDetails.getAudioTimeStamp());
case 2: case 2:
return PamCalendar.formatDBDateTime(period.getRecordStop()); return PamCalendar.formatDBDateTime(period.getRecordStop());
// return TethysTimeFuncs.formatGregorianTime(deplInfo.recoveryDetails.getAudioTimeStamp()); // return TethysTimeFuncs.formatGregorianTime(deplInfo.recoveryDetails.getAudioTimeStamp());
case 3: case 4:
// long t1 = TethysTimeFuncs.millisFromGregorianXML(deplInfo.deploymentDetails.getAudioTimeStamp()); // long t1 = TethysTimeFuncs.millisFromGregorianXML(deplInfo.deploymentDetails.getAudioTimeStamp());
// long t2 = TethysTimeFuncs.millisFromGregorianXML(deplInfo.recoveryDetails.getAudioTimeStamp()); // long t2 = TethysTimeFuncs.millisFromGregorianXML(deplInfo.recoveryDetails.getAudioTimeStamp());
return PamCalendar.formatDuration(period.getRecordStop()-period.getRecordStart()); return PamCalendar.formatDuration(period.getRecordStop()-period.getRecordStart());
case 5: case 6:
PDeployment deployment = period.getMatchedTethysDeployment(); PDeployment deployment = period.getMatchedTethysDeployment();
return makeDeplString(period, deployment); return makeDeplString(period, deployment);
case 6: case SELECTCOLUMN:
// return selectBoxes[rowIndex]; // return selectBoxes[rowIndex];
return selection[rowIndex]; return selection[rowIndex];
} }
return null; return null;
} }
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return columnIndex == SELECTCOLUMN;
}
private String makeDeplString(RecordingPeriod period, PDeployment deployment) { private String makeDeplString(RecordingPeriod period, PDeployment deployment) {
if (deployment == null) { if (deployment == null) {
return "no match"; return "no match";