mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
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:
parent
faea94205c
commit
35fa8270d2
@ -56,6 +56,7 @@ import PamUtils.PamUtils;
|
||||
import PamView.PamSymbol;
|
||||
import PamView.dialog.PamGridBagContraints;
|
||||
import PamView.symbol.SymbolData;
|
||||
import PamguardMVC.debug.Debug;
|
||||
import clickDetector.ClickClassifiers.basicSweep.CodeHost;
|
||||
import clickDetector.ClickClassifiers.basicSweep.SweepClassifier;
|
||||
import clickDetector.ClickClassifiers.basicSweep.SweepClassifierSet;
|
||||
@ -1707,7 +1708,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane<ClickTypeProperty> {
|
||||
// }
|
||||
// }
|
||||
// else multiChan = true;
|
||||
Debug.out.println("Check multi-channel: " + multiChan);
|
||||
// Debug.out.println("Check multi-channel: " + multiChan);
|
||||
|
||||
return multiChan;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class EffortDialog extends PamDialog {
|
||||
mainPanel.add(new JLabel("Observer name or initials"), c);
|
||||
c.gridx++;
|
||||
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");
|
||||
ButtonGroup bg = new ButtonGroup();
|
||||
bg.add(allActions);
|
||||
|
@ -19,13 +19,13 @@ import javax.swing.Timer;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamController;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamView.PamTabPanel;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import metadata.MetaDataContol;
|
||||
import metadata.deployment.DeploymentData;
|
||||
import pamViewFX.PamSettingsMenuPane;
|
||||
import tethys.TethysState.StateType;
|
||||
import tethys.dbxml.DBXMLConnect;
|
||||
import tethys.dbxml.DBXMLQueries;
|
||||
@ -174,7 +174,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
}
|
||||
// and remove any which are no longer there.
|
||||
for (DatablockSynchInfo synchInfo : dataBlockSynchInfos) {
|
||||
if (dataBlocks.contains(synchInfo.getDataBlock()) == false) {
|
||||
if (!dataBlocks.contains(synchInfo.getDataBlock())) {
|
||||
dataBlockSynchInfos.remove(synchInfo);
|
||||
}
|
||||
}
|
||||
@ -342,7 +342,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
public void notifyModelChanged(int changeType) {
|
||||
super.notifyModelChanged(changeType);
|
||||
switch (changeType) {
|
||||
case PamController.INITIALIZATION_COMPLETE:
|
||||
case PamControllerInterface.INITIALIZATION_COMPLETE:
|
||||
initializationStuff();
|
||||
break;
|
||||
}
|
||||
|
@ -5,11 +5,9 @@ import Array.HydrophoneLocator;
|
||||
import Array.PamArray;
|
||||
import Array.Streamer;
|
||||
import GPS.GPSControl;
|
||||
import GPS.GpsData;
|
||||
import GPS.GpsDataUnit;
|
||||
import PamUtils.LatLong;
|
||||
import PamUtils.PamUtils;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import generalDatabase.DBControlUnit;
|
||||
import generalDatabase.PamConnection;
|
||||
import nilus.Deployment;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package tethys;
|
||||
|
||||
import tethys.detection.DetectionExportProgress;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -16,7 +14,7 @@ public class TethysState {
|
||||
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!)
|
||||
EXPORTING // currently exporting data. may be a while ...
|
||||
};
|
||||
}
|
||||
|
||||
public StateType stateType;
|
||||
private Object stateObject;
|
||||
|
@ -4,24 +4,16 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import dbxml.JerseyClient;
|
||||
import dbxml.Queries;
|
||||
import dbxml.uploader.Importer;
|
||||
import nilus.Deployment;
|
||||
import nilus.MarshalXML;
|
||||
import tethys.TethysControl;
|
||||
import tethys.output.TethysExportParams;
|
||||
import tethys.output.StreamExportParams;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
|
||||
/**
|
||||
* Class containing functions for managing the database connection. Opening, closing,
|
||||
@ -57,7 +49,7 @@ public class DBXMLConnect {
|
||||
return false;
|
||||
}
|
||||
TethysExportParams params = tethysControl.getTethysExportParams();
|
||||
if (currentSiteURL.equalsIgnoreCase(params.getFullServerName()) == false) {
|
||||
if (!currentSiteURL.equalsIgnoreCase(params.getFullServerName())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -68,7 +60,7 @@ public class DBXMLConnect {
|
||||
* @return Jersy client
|
||||
*/
|
||||
public synchronized JerseyClient getJerseyClient() {
|
||||
if (checkClient() == false) {
|
||||
if (!checkClient()) {
|
||||
openConnections();
|
||||
}
|
||||
return jerseyClient;
|
||||
@ -79,7 +71,7 @@ public class DBXMLConnect {
|
||||
* @return
|
||||
*/
|
||||
public synchronized Queries getTethysQueries() {
|
||||
if (checkClient() == false) {
|
||||
if (!checkClient()) {
|
||||
openConnections();
|
||||
}
|
||||
return queries;
|
||||
@ -125,7 +117,7 @@ public class DBXMLConnect {
|
||||
catch (Exception e) {
|
||||
System.out.printf("Error deleting %s %s: %s\n", collection, docId, e.getMessage());
|
||||
}
|
||||
forceFlush();
|
||||
// forceFlush();
|
||||
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 ...
|
||||
*/
|
||||
private void forceFlush() {
|
||||
TethysExportParams params = new TethysExportParams();
|
||||
String fileError = null;
|
||||
try {
|
||||
fileError = Importer.ImportFiles(params.getFullServerName(), "NoCollection",
|
||||
new String[] { "ThereIsNoFileE" }, "", "", false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
// System.out.println(fileError);
|
||||
|
||||
}
|
||||
// /*
|
||||
// * force a fluch by sending a dummy document to th eimporter which will rail, but ...
|
||||
// */
|
||||
// private void forceFlush() {
|
||||
// TethysExportParams params = new TethysExportParams();
|
||||
// String fileError = null;
|
||||
// try {
|
||||
// fileError = Importer.ImportFiles(params.getFullServerName(), "NoCollection",
|
||||
// new String[] { "ThereIsNoFileE" }, "", "", false);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
//// System.out.println(fileError);
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* 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";
|
||||
|
||||
File tempDir = new File(javaTmpDirs);
|
||||
if (tempDir.exists() == false) {
|
||||
if (!tempDir.exists()) {
|
||||
tempDir.mkdirs();
|
||||
}
|
||||
if (tempDir.exists()) {
|
||||
tempDirectory = tempDir;
|
||||
};
|
||||
}
|
||||
if (tempDirectory == null) {
|
||||
tempDirectory = new File(System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
@ -301,7 +293,7 @@ public class DBXMLConnect {
|
||||
// }
|
||||
// }
|
||||
try {
|
||||
String doc = queries.getDocument("Deployments", deploymentId);
|
||||
// String doc = queries.getDocument("Deployments", deploymentId);
|
||||
// queries.
|
||||
result = jerseyClient.removeDocument("Deployments", deploymentId );
|
||||
}
|
||||
@ -319,9 +311,29 @@ public class DBXMLConnect {
|
||||
jerseyClient = new JerseyClient(currentSiteURL);
|
||||
queries = new Queries(jerseyClient);
|
||||
ServerStatus state = pingServer();
|
||||
|
||||
setCache(false);
|
||||
|
||||
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() {
|
||||
jerseyClient = null;
|
||||
queries = null;
|
||||
|
@ -29,7 +29,6 @@ import nilus.Detections;
|
||||
import nilus.Helper;
|
||||
import tethys.TethysControl;
|
||||
import tethys.TethysTimeFuncs;
|
||||
import tethys.niluswraps.PDeployment;
|
||||
import tethys.output.TethysExportParams;
|
||||
|
||||
/**
|
||||
@ -114,26 +113,33 @@ public class DBXMLQueries {
|
||||
if (doc == null) {
|
||||
return null;
|
||||
}
|
||||
NodeList returns = doc.getElementsByTagName("Return");
|
||||
NodeList returns = doc.getElementsByTagName("Project");
|
||||
// System.out.println("N projects = " + returns.getLength());
|
||||
int n = returns.getLength();
|
||||
for (int i = 0; i < n; i++) {
|
||||
Node aNode = returns.item(i);
|
||||
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();
|
||||
String projName = aNode.getTextContent();
|
||||
if (projName != null) {
|
||||
if (!projectNames.contains(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);
|
||||
@ -169,9 +175,14 @@ public class DBXMLQueries {
|
||||
|
||||
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());
|
||||
int n = returns.getLength();
|
||||
|
||||
// Queries queries = new Queries(null)
|
||||
for (int i = 0; i < n; i++) {
|
||||
Node aNode = returns.item(i);
|
||||
@ -252,7 +263,10 @@ public class DBXMLQueries {
|
||||
}
|
||||
ArrayList<String> detectionsNames = new ArrayList();
|
||||
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++) {
|
||||
Node aNode = returns.item(i);
|
||||
String docName = aNode.getTextContent();
|
||||
@ -284,6 +298,9 @@ public class DBXMLQueries {
|
||||
ArrayList<String> detectionDocs = new ArrayList<>();
|
||||
|
||||
NodeList returns = doc.getElementsByTagName("Return");
|
||||
if (returns.getLength() == 0) {
|
||||
returns = doc.getElementsByTagName("Result");
|
||||
}
|
||||
for (int i = 0; i < returns.getLength(); i++) {
|
||||
Node aNode = returns.item(i);
|
||||
detectionDocs.add(aNode.getTextContent());
|
||||
@ -324,9 +341,7 @@ public class DBXMLQueries {
|
||||
return 0;
|
||||
}
|
||||
int count = 0;
|
||||
for (int i = 0; i < documentNames.size(); i++) {
|
||||
// Node aNode = returns.item(i);
|
||||
String docName = documentNames.get(i);
|
||||
for (String docName : documentNames) {
|
||||
// System.out.println(aNode.getTextContent());
|
||||
int count2 = countDetections2(docName);
|
||||
count += count2; //countDetecionsData(docName);
|
||||
|
@ -1,24 +1,14 @@
|
||||
package tethys.dbxml;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.StringReader;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
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.xml.sax.InputSource;
|
||||
|
||||
import PamController.settings.output.xml.PamguardXMLWriter;
|
||||
import PamUtils.XMLUtils;
|
||||
import dbxml.JerseyClient;
|
||||
import tethys.output.TethysExportParams;
|
||||
|
||||
|
@ -29,7 +29,10 @@ public class StreamExportParams implements Serializable {
|
||||
|
||||
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() {
|
||||
if (detectionDescription == null) {
|
||||
|
@ -86,7 +86,7 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
int aRow = table.getSelectedRow();
|
||||
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];
|
||||
for (DeploymentTableObserver obs : observers) {
|
||||
obs.selectionChanged();
|
||||
@ -193,7 +193,9 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
|
||||
|
||||
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
|
||||
public int getRowCount() {
|
||||
@ -217,7 +219,7 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
if (columnIndex == 6) {
|
||||
if (columnIndex == SELECTCOLUMN) {
|
||||
return Boolean.class;
|
||||
// return JCheckBox.class;
|
||||
}
|
||||
@ -228,15 +230,15 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
RecordingPeriod period = deploymentOverview.getRecordingPeriods().get(rowIndex);
|
||||
// DeploymentRecoveryPair deplInfo = deploymentInfo.get(rowIndex);
|
||||
if (columnIndex == 4) {
|
||||
if (columnIndex == 5) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return columnIndex == 6;
|
||||
return getValueAt(period, rowIndex, columnIndex);
|
||||
}
|
||||
|
||||
private Object getValueAt(RecordingPeriod period, int rowIndex, int columnIndex) {
|
||||
@ -245,25 +247,30 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
|
||||
return rowIndex;
|
||||
case 1:
|
||||
return PamCalendar.formatDBDateTime(period.getRecordStart());
|
||||
// return TethysTimeFuncs.formatGregorianTime(deplInfo.deploymentDetails.getAudioTimeStamp());
|
||||
// return TethysTimeFuncs.formatGregorianTime(deplInfo.deploymentDetails.getAudioTimeStamp());
|
||||
case 2:
|
||||
return PamCalendar.formatDBDateTime(period.getRecordStop());
|
||||
// return TethysTimeFuncs.formatGregorianTime(deplInfo.recoveryDetails.getAudioTimeStamp());
|
||||
case 3:
|
||||
// long t1 = TethysTimeFuncs.millisFromGregorianXML(deplInfo.deploymentDetails.getAudioTimeStamp());
|
||||
// long t2 = TethysTimeFuncs.millisFromGregorianXML(deplInfo.recoveryDetails.getAudioTimeStamp());
|
||||
// return TethysTimeFuncs.formatGregorianTime(deplInfo.recoveryDetails.getAudioTimeStamp());
|
||||
case 4:
|
||||
// long t1 = TethysTimeFuncs.millisFromGregorianXML(deplInfo.deploymentDetails.getAudioTimeStamp());
|
||||
// long t2 = TethysTimeFuncs.millisFromGregorianXML(deplInfo.recoveryDetails.getAudioTimeStamp());
|
||||
return PamCalendar.formatDuration(period.getRecordStop()-period.getRecordStart());
|
||||
case 5:
|
||||
case 6:
|
||||
PDeployment deployment = period.getMatchedTethysDeployment();
|
||||
return makeDeplString(period, deployment);
|
||||
case 6:
|
||||
// return selectBoxes[rowIndex];
|
||||
case SELECTCOLUMN:
|
||||
// return selectBoxes[rowIndex];
|
||||
return selection[rowIndex];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return columnIndex == SELECTCOLUMN;
|
||||
}
|
||||
|
||||
private String makeDeplString(RecordingPeriod period, PDeployment deployment) {
|
||||
if (deployment == null) {
|
||||
return "no match";
|
||||
|
Loading…
Reference in New Issue
Block a user