mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-10-29 23:30:44 +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;
|
||||
@ -43,8 +43,8 @@ import tethys.swing.TethysTabPanel;
|
||||
|
||||
/**
|
||||
* Quick play with a simple system for outputting data to Tethys. At it's start
|
||||
* this is simply going to offer a dialog and have a few functions which show how
|
||||
* to access data within PAMGuard.
|
||||
* this is simply going to offer a dialog and have a few functions which show how
|
||||
* to access data within PAMGuard.
|
||||
* @author dg50
|
||||
*
|
||||
*/
|
||||
@ -53,23 +53,23 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
public static final String unitType = "Tethys Interface";
|
||||
public static String defaultName = "Tethys";
|
||||
public static String xmlNameSpace = "http://tethys.sdsu.edu/schema/1.0";
|
||||
|
||||
|
||||
private TethysExportParams tethysExportParams = new TethysExportParams();
|
||||
|
||||
|
||||
private DBXMLConnect dbxmlConnect;
|
||||
|
||||
|
||||
private TethysTabPanel tethysTabPanel;
|
||||
|
||||
|
||||
private DBXMLQueries dbxmlQueries;
|
||||
|
||||
|
||||
private ArrayList<TethysStateObserver> stateObservers;
|
||||
|
||||
|
||||
private Timer serverCheckTimer;
|
||||
|
||||
|
||||
private ServerStatus lastServerStatus;
|
||||
|
||||
private ArrayList<DatablockSynchInfo> dataBlockSynchInfos;
|
||||
|
||||
|
||||
private ArrayList<DatablockSynchInfo> dataBlockSynchInfos;
|
||||
|
||||
private DeploymentHandler deploymentHandler;
|
||||
private DetectionsHandler detectionsHandler;
|
||||
|
||||
@ -89,7 +89,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
serverCheckTimer.setInitialDelay(0);
|
||||
PamSettingManager.getInstance().registerSettings(this);
|
||||
addStateObserver(this);
|
||||
|
||||
|
||||
if (PamController.getInstance().isInitializationComplete()) {
|
||||
// must be adding module later on ...
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@ -103,8 +103,8 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
|
||||
/**
|
||||
* Get DBXML Connector. This class contains all the functions that are needed
|
||||
* to talk to the database.
|
||||
* @return DBXML functions.
|
||||
* to talk to the database.
|
||||
* @return DBXML functions.
|
||||
*/
|
||||
public DBXMLConnect getDbxmlConnect() {
|
||||
return dbxmlConnect;
|
||||
@ -139,7 +139,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
tethysMenu.add(showDeps);
|
||||
return tethysMenu;
|
||||
}
|
||||
|
||||
|
||||
public void showProjectDeploymentsDialog() {
|
||||
ProjectDeploymentsDialog.showDialog(getGuiFrame(), this);
|
||||
}
|
||||
@ -154,11 +154,11 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
}
|
||||
return sets;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the synchronisation info for all datablocks.
|
||||
* Get the synchronisation info for all datablocks.
|
||||
* This list should be static, but check it in case something has been
|
||||
* added or removed.
|
||||
* added or removed.
|
||||
* @return
|
||||
*/
|
||||
public ArrayList<DatablockSynchInfo> getSynchronisationInfos() {
|
||||
@ -172,13 +172,13 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
dataBlockSynchInfos.add(new DatablockSynchInfo(this, aBlock));
|
||||
}
|
||||
}
|
||||
// and remove any which are no longer there.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return dataBlockSynchInfos;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* open client in the default web browser
|
||||
*/
|
||||
@ -234,34 +234,34 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
}
|
||||
|
||||
/**
|
||||
* We'll probably want to
|
||||
* We'll probably want to
|
||||
* @param parentFrame
|
||||
*/
|
||||
protected void tethysExport(JFrame parentFrame) {
|
||||
TethysExportParams newExportParams = TethysExportDialog.showDialog(parentFrame, this);
|
||||
if (newExportParams != null) {
|
||||
// dialog returns null if cancel was pressed.
|
||||
// dialog returns null if cancel was pressed.
|
||||
tethysExportParams = newExportParams;
|
||||
exportTethysData(tethysExportParams);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We'll arrive here if the dialog has been opened and we want to export Tethys data.
|
||||
* We'll arrive here if the dialog has been opened and we want to export Tethys data.
|
||||
* @param tethysExportParams2
|
||||
*/
|
||||
private void exportTethysData(TethysExportParams tethysExportParams) {
|
||||
TethysExporter tethysExporter = new TethysExporter(this, tethysExportParams);
|
||||
tethysExporter.doExport();
|
||||
|
||||
tethysExporter.doExport();
|
||||
|
||||
sendStateUpdate(new TethysState(StateType.TRANSFERDATA));
|
||||
countProjectDetections();
|
||||
sendStateUpdate(new TethysState(StateType.NEWPAMGUARDSELECTION));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get global deployment data. This is a bit of a mess, trying to use a separate module
|
||||
* so that the rest of PAMGuard can use it, but creating the
|
||||
* so that the rest of PAMGuard can use it, but creating the
|
||||
* @return
|
||||
*/
|
||||
public DeploymentData getGlobalDeplopymentData() {
|
||||
@ -271,14 +271,14 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
// deployment.setPlatform("Yay a platform");
|
||||
// Instrument instrument = new Instrument();
|
||||
// instrument.setType("machiney");
|
||||
// instrument.setInstrumentId("12345555");
|
||||
// instrument.setInstrumentId("12345555");
|
||||
// deployment.setInstrument(instrument);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
MetaDataContol metaControl = (MetaDataContol) aUnit;
|
||||
DeploymentData deploymentData = metaControl != null ? metaControl.getDeploymentData() : getTethysProjectData();
|
||||
|
||||
DeploymentData deploymentData = metaControl != null ? metaControl.getDeploymentData() : getTethysProjectData();
|
||||
|
||||
// deploymentData.setProject("thisIsAProject");
|
||||
//// deploymentData.setPlatform("Yay a platform");
|
||||
// deploymentData.setCruise("cruisey");
|
||||
@ -286,14 +286,14 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
//// deploymentData.setInstrumentId("super instrument");
|
||||
// deploymentData.setSite("in the ocean somewhere");
|
||||
// deploymentData.setRegion("ocean water");
|
||||
//// deploymentData.setInstrumentType("sensor of sorts");
|
||||
|
||||
//// deploymentData.setInstrumentType("sensor of sorts");
|
||||
|
||||
return deploymentData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a copy of Deployment data stored with other Tethys params when the more
|
||||
* general meta data provider is not present.
|
||||
* general meta data provider is not present.
|
||||
* @return
|
||||
*/
|
||||
private DeploymentData getTethysProjectData() {
|
||||
@ -301,7 +301,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new state observer.
|
||||
* Add a new state observer.
|
||||
* @param stateObserver
|
||||
*/
|
||||
public void addStateObserver(TethysStateObserver stateObserver) {
|
||||
@ -309,16 +309,16 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a state observer.
|
||||
* Remove a state observer.
|
||||
* @param stateObserver
|
||||
* @return true if it existed.
|
||||
* @return true if it existed.
|
||||
*/
|
||||
public boolean removeStateObserver(TethysStateObserver stateObserver) {
|
||||
return stateObservers.remove(stateObserver);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send state updates around to all state observers.
|
||||
* Send state updates around to all state observers.
|
||||
* @param tethysState
|
||||
*/
|
||||
public void sendStateUpdate(TethysState tethysState) {
|
||||
@ -327,7 +327,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A name for any deta selectors.
|
||||
* A name for any deta selectors.
|
||||
* @return
|
||||
*/
|
||||
public String getDataSelectName() {
|
||||
@ -342,15 +342,15 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stuff to do on initial load (initialization complete or addition of
|
||||
* a Tethys module after initialisation).
|
||||
* Stuff to do on initial load (initialization complete or addition of
|
||||
* a Tethys module after initialisation).
|
||||
*/
|
||||
private void initializationStuff() {
|
||||
deploymentHandler.createPamguardOverview();
|
||||
@ -360,9 +360,9 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
|
||||
/**
|
||||
* Check the server. This will send around a notification if the state
|
||||
* has changed since the last call to this function, so it's unlikely you'll
|
||||
* has changed since the last call to this function, so it's unlikely you'll
|
||||
* need to use the return value
|
||||
* @return server status.
|
||||
* @return server status.
|
||||
*/
|
||||
public ServerStatus checkServer() {
|
||||
ServerStatus serverState = dbxmlConnect.pingServer();
|
||||
@ -425,8 +425,8 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
|
||||
/**
|
||||
* One stop place to get Deployment information. Will provide
|
||||
* both information on record periods in PAMGuard and also Deployment docs in Tethys.
|
||||
* @return set of functions for handling deployments.
|
||||
* both information on record periods in PAMGuard and also Deployment docs in Tethys.
|
||||
* @return set of functions for handling deployments.
|
||||
*/
|
||||
public DeploymentHandler getDeploymentHandler() {
|
||||
return deploymentHandler;
|
||||
|
@ -5,18 +5,16 @@ 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;
|
||||
import nilus.DeploymentRecoveryDetails;
|
||||
|
||||
/**
|
||||
* Function(s) to get location information for Tethys in the required format.
|
||||
* Function(s) to get location information for Tethys in the required format.
|
||||
* @author dg50
|
||||
*
|
||||
*/
|
||||
@ -25,10 +23,10 @@ public class TethysLocationFuncs {
|
||||
|
||||
/**
|
||||
* Get everything we need for a deployment document including the track #
|
||||
* and the deployment / recovery information. Basically this means we
|
||||
* have to load the GPS data, then potentially filter it. Slight risk this
|
||||
* may all be too much for memory, but give it a go by loading GPS data for
|
||||
* the deployment times.
|
||||
* and the deployment / recovery information. Basically this means we
|
||||
* have to load the GPS data, then potentially filter it. Slight risk this
|
||||
* may all be too much for memory, but give it a go by loading GPS data for
|
||||
* the deployment times.
|
||||
* @param deployment
|
||||
*/
|
||||
public static void getTrackAndPositionData(Deployment deployment) {
|
||||
@ -41,16 +39,16 @@ public class TethysLocationFuncs {
|
||||
boolean ok = true;
|
||||
ok &= addPositionData(deployment.getDeploymentDetails());
|
||||
ok &= addPositionData(deployment.getRecoveryDetails());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add position data to DeploymentRecoveryDetails.
|
||||
* Add position data to DeploymentRecoveryDetails.
|
||||
* @param drd
|
||||
* @return
|
||||
*/
|
||||
public static boolean addPositionData(DeploymentRecoveryDetails drd) {
|
||||
long timeMillis = TethysTimeFuncs.millisFromGregorianXML(drd.getAudioTimeStamp());
|
||||
long timeMillis = TethysTimeFuncs.millisFromGregorianXML(drd.getAudioTimeStamp());
|
||||
LatLong pos = getLatLongData(timeMillis);
|
||||
if (pos == null) {
|
||||
return false;
|
||||
@ -61,15 +59,15 @@ public class TethysLocationFuncs {
|
||||
drd.setDepthInstrumentM(-pos.getHeight());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static LatLong getLatLongData(long timeMillis) {
|
||||
// check the array time.
|
||||
// check the array time.
|
||||
PamArray array = ArrayManager.getArrayManager().getCurrentArray();
|
||||
Streamer aStreamer = array.getStreamer(0);
|
||||
GPSControl gpsControl = GPSControl.getGpsControl();
|
||||
PamConnection con = DBControlUnit.findConnection();
|
||||
if (gpsControl != null) {
|
||||
// check GPS data are loaded for times around this.
|
||||
// check GPS data are loaded for times around this.
|
||||
GpsDataUnit gpsData = (GpsDataUnit) gpsControl.getGpsDataBlock().getLogging().findClosestDataPoint(con, timeMillis);
|
||||
if (gpsData != null) {
|
||||
return gpsData.getGpsData();
|
||||
|
@ -12,11 +12,11 @@ import javax.swing.JPopupMenu;
|
||||
import tethys.niluswraps.PDeployment;
|
||||
|
||||
/*
|
||||
* Some standard meny dirven functions which we may want to call from
|
||||
* a few different places.
|
||||
* Some standard meny dirven functions which we may want to call from
|
||||
* a few different places.
|
||||
*/
|
||||
public class TethysMenuActions {
|
||||
|
||||
|
||||
private TethysControl tethysControl;
|
||||
|
||||
public TethysMenuActions(TethysControl tethysControl) {
|
||||
|
@ -1,10 +1,8 @@
|
||||
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.
|
||||
* 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.
|
||||
* @author dg50
|
||||
*
|
||||
*/
|
||||
@ -16,8 +14,8 @@ 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;
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package tethys;
|
||||
|
||||
public interface TethysStateObserver {
|
||||
|
||||
|
||||
/**
|
||||
* Receive state updates when Tethys has done something (made a connection, moved some data, etc.)<br>
|
||||
* Note that this is for RECEIVING state updates, not for sending them. To avoid infinite notifications
|
||||
* loops, use tethysControl.sendStateUpdate(TethysState) if this component knows something.
|
||||
* Note that this is for RECEIVING state updates, not for sending them. To avoid infinite notifications
|
||||
* loops, use tethysControl.sendStateUpdate(TethysState) if this component knows something.
|
||||
* @param tethysState
|
||||
*/
|
||||
public void updateState(TethysState tethysState);
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import PamUtils.PamCalendar;
|
||||
|
||||
public class TethysTimeFuncs {
|
||||
|
||||
|
||||
private static TimeZone timeZone = TimeZone.getTimeZone("UTC");
|
||||
|
||||
/*
|
||||
@ -33,9 +33,9 @@ public class TethysTimeFuncs {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a Gregorian calendar value back to milliseconds.
|
||||
* Convert a Gregorian calendar value back to milliseconds.
|
||||
* @param xmlGregorian
|
||||
* @return
|
||||
*/
|
||||
@ -47,9 +47,9 @@ public class TethysTimeFuncs {
|
||||
gc2.setTimeZone(timeZone);
|
||||
return gc2.getTimeInMillis();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make a Gregorian calendar object from a returned XML string.
|
||||
* Make a Gregorian calendar object from a returned XML string.
|
||||
* @param gregorianString
|
||||
* @return
|
||||
*/
|
||||
@ -75,7 +75,7 @@ public class TethysTimeFuncs {
|
||||
//// gCal.se
|
||||
// return gCal;
|
||||
}
|
||||
|
||||
|
||||
public static String formatGregorianTime(XMLGregorianCalendar gregCal) {
|
||||
if (gregCal == null) {
|
||||
return null;
|
||||
|
@ -14,11 +14,11 @@ import org.xml.sax.SAXException;
|
||||
public class DBQueryResult {
|
||||
|
||||
public long queryTimeMillis;
|
||||
|
||||
|
||||
public String queryResult;
|
||||
|
||||
|
||||
public String schemaPlan;
|
||||
|
||||
|
||||
public Exception queryException;
|
||||
|
||||
public DBQueryResult(long queryTimeMillis, String queryResult, String schemaPlan) {
|
||||
@ -33,9 +33,9 @@ public class DBQueryResult {
|
||||
this.queryTimeMillis = queryTimeMillis;
|
||||
this.queryException = queryException;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the result as an XML document.
|
||||
* Get the result as an XML document.
|
||||
* @return XML document
|
||||
* @throws ParserConfigurationException
|
||||
* @throws SAXException
|
||||
@ -58,5 +58,5 @@ public class DBQueryResult {
|
||||
Document doc = builder.parse(new InputSource(new StringReader(queryResult)));
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,28 +4,20 @@ 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,
|
||||
* writing, keeping track of performance, etc.
|
||||
* writing, keeping track of performance, etc.
|
||||
* @author Doug Gillespie, Katie O'Laughlin
|
||||
*
|
||||
*/
|
||||
@ -33,23 +25,23 @@ public class DBXMLConnect {
|
||||
|
||||
private TethysControl tethysControl;
|
||||
private File tempDirectory;
|
||||
|
||||
|
||||
private JerseyClient jerseyClient;
|
||||
|
||||
|
||||
private Queries queries;
|
||||
|
||||
|
||||
private String currentSiteURL;
|
||||
|
||||
|
||||
public DBXMLConnect(TethysControl tethysControl) {
|
||||
this.tethysControl = tethysControl;
|
||||
|
||||
checkTempFolder();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the jersey client and the queries. Need to recreate
|
||||
* if the url has changed.
|
||||
* if the url has changed.
|
||||
* @return
|
||||
*/
|
||||
private boolean checkClient() {
|
||||
@ -57,34 +49,34 @@ public class DBXMLConnect {
|
||||
return false;
|
||||
}
|
||||
TethysExportParams params = tethysControl.getTethysExportParams();
|
||||
if (currentSiteURL.equalsIgnoreCase(params.getFullServerName()) == false) {
|
||||
if (!currentSiteURL.equalsIgnoreCase(params.getFullServerName())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the client. The client will only be recreated if the url changes
|
||||
* @return Jersy client
|
||||
*/
|
||||
public synchronized JerseyClient getJerseyClient() {
|
||||
if (checkClient() == false) {
|
||||
if (!checkClient()) {
|
||||
openConnections();
|
||||
}
|
||||
return jerseyClient;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Queries object. This will only be recreated if the client changes.
|
||||
* Get the Queries object. This will only be recreated if the client changes.
|
||||
* @return
|
||||
*/
|
||||
public synchronized Queries getTethysQueries() {
|
||||
if (checkClient() == false) {
|
||||
if (!checkClient()) {
|
||||
openConnections();
|
||||
}
|
||||
return queries;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update a document within Tethys. We're assuming that a
|
||||
* document with the same name in the same collection already
|
||||
@ -95,13 +87,13 @@ public class DBXMLConnect {
|
||||
*/
|
||||
public String updateDocument(Object nilusDocument) {
|
||||
deleteDocument(nilusDocument);
|
||||
return postToTethys(nilusDocument);
|
||||
return postToTethys(nilusDocument);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a nilus document from the database. The only field which
|
||||
* Delete a nilus document from the database. The only field which
|
||||
* needs to be populated here is the Id. The code also uses the object
|
||||
* class to identify the correct collection.
|
||||
* class to identify the correct collection.
|
||||
* @param nilusDocument
|
||||
* @return
|
||||
*/
|
||||
@ -115,7 +107,7 @@ public class DBXMLConnect {
|
||||
result = jerseyClient.removeDocument(collection, docId );
|
||||
/**
|
||||
* Return from a sucessful delete is something like
|
||||
*
|
||||
*
|
||||
deployment = getTethysControl().getDeploymentHandler().createDeploymentDocument(freeId++, recordPeriod);
|
||||
<DELETE>
|
||||
<ITEM> ['ECoastNARW0'] </ITEM>
|
||||
@ -123,19 +115,19 @@ public class DBXMLConnect {
|
||||
*/
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* take a nilus object loaded with PamGuard data and post it to the Tethys database
|
||||
*
|
||||
*
|
||||
* @param pamGuardObjs a nilus object loaded with PamGuard data
|
||||
* @return error string, null string means there are no errors
|
||||
*/
|
||||
public String postToTethys(Object nilusObject)
|
||||
public String postToTethys(Object nilusObject)
|
||||
{
|
||||
Class objClass = nilusObject.getClass();
|
||||
String collection = getTethysCollection(objClass.getName());
|
||||
@ -146,14 +138,14 @@ public class DBXMLConnect {
|
||||
File tempFile = new File(tempName);
|
||||
try {
|
||||
MarshalXML marshal = new MarshalXML();
|
||||
marshal.createInstance(objClass);
|
||||
marshal.createInstance(objClass);
|
||||
// Path tempFile = Files.createTempFile("pamGuardToTethys", ".xml");
|
||||
marshal.marshal(nilusObject, tempFile.toString());
|
||||
fileError = Importer.ImportFiles(params.getFullServerName(), collection,
|
||||
new String[] { tempFile.toString() }, "", "", false);
|
||||
|
||||
// System.out.println(fileError);
|
||||
|
||||
|
||||
tempFile.deleteOnExit();
|
||||
} catch(IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
@ -164,55 +156,55 @@ public class DBXMLConnect {
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// System.out.println(fileError);
|
||||
return 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// /*
|
||||
// * 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
|
||||
* Get a temp folder to hold xml output. This will be the standard
|
||||
* temp folder + /PAMGuardTethys. Files will be left here until PAMGUard
|
||||
* exits then should delete automatically
|
||||
* exits then should delete automatically
|
||||
*/
|
||||
private void checkTempFolder() {
|
||||
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"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a document Id string. All Document objects should have a getId() function
|
||||
* however they do not have a type hierarchy, so it can't be accessed directly.
|
||||
* instead go via the class.getDeclaredMethod function and it should be possible to find
|
||||
* it.
|
||||
* instead go via the class.getDeclaredMethod function and it should be possible to find
|
||||
* it.
|
||||
* @param nilusObject
|
||||
* @return document Id for any type of document, or null if the document doesn't have a getID function
|
||||
*/
|
||||
@ -235,7 +227,7 @@ public class DBXMLConnect {
|
||||
}
|
||||
|
||||
/**
|
||||
* needs to be based on the document id,
|
||||
* needs to be based on the document id,
|
||||
* @param nilusObject
|
||||
* @return
|
||||
*/
|
||||
@ -256,29 +248,29 @@ public class DBXMLConnect {
|
||||
*/
|
||||
public String getTethysCollection(String className) {
|
||||
switch(className) {
|
||||
case "nilus.Deployment":
|
||||
return "Deployments";
|
||||
case "nilus.Detections":
|
||||
case "nilus.Deployment":
|
||||
return "Deployments";
|
||||
case "nilus.Detections":
|
||||
return "Detections";
|
||||
case "nilus.Calibration":
|
||||
return "Calibrations";
|
||||
case "nilus.Ensemble":
|
||||
return "Ensembles";
|
||||
case "nilus.Localization":
|
||||
return "Localizations";
|
||||
case "nilus.SpeciesAbbreviation":
|
||||
return "SpeciesAbbreviations";
|
||||
case "nilus.SourceMap":
|
||||
return "SourceMaps";
|
||||
case "nilus.ITIS":
|
||||
return "ITIS";
|
||||
case "nilus.ranks":
|
||||
case "nilus.Calibration":
|
||||
return "Calibrations";
|
||||
case "nilus.Ensemble":
|
||||
return "Ensembles";
|
||||
case "nilus.Localization":
|
||||
return "Localizations";
|
||||
case "nilus.SpeciesAbbreviation":
|
||||
return "SpeciesAbbreviations";
|
||||
case "nilus.SourceMap":
|
||||
return "SourceMaps";
|
||||
case "nilus.ITIS":
|
||||
return "ITIS";
|
||||
case "nilus.ranks":
|
||||
return "ITIS_ranks";
|
||||
default:
|
||||
return "";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a Deploymnet and any contained Detections document. Doesn't work !
|
||||
* @param deploymentId
|
||||
@ -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;
|
||||
@ -329,8 +341,8 @@ public class DBXMLConnect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server state via a ping ?
|
||||
* @return Server state ?
|
||||
* Get the server state via a ping ?
|
||||
* @return Server state ?
|
||||
*/
|
||||
public ServerStatus pingServer() {
|
||||
|
||||
@ -344,7 +356,7 @@ public class DBXMLConnect {
|
||||
return new ServerStatus(ok, null);
|
||||
}
|
||||
|
||||
|
||||
// add whatever calls are necessary ...
|
||||
|
||||
// add whatever calls are necessary ...
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import nilus.Detections;
|
||||
import nilus.Helper;
|
||||
import tethys.TethysControl;
|
||||
import tethys.TethysTimeFuncs;
|
||||
import tethys.niluswraps.PDeployment;
|
||||
import tethys.output.TethysExportParams;
|
||||
|
||||
/**
|
||||
@ -42,7 +41,7 @@ public class DBXMLQueries {
|
||||
|
||||
private TethysControl tethysControl;
|
||||
private DBXMLConnect dbXMLConnect;
|
||||
|
||||
|
||||
public DBXMLQueries(TethysControl tethysControl, DBXMLConnect dbXMLConnect) {
|
||||
super();
|
||||
this.tethysControl = tethysControl;
|
||||
@ -75,7 +74,7 @@ public class DBXMLQueries {
|
||||
// String url = jerseyClient.getURL();
|
||||
|
||||
Queries queries = new Queries(jerseyClient);
|
||||
|
||||
|
||||
queryResult = jerseyClient.queryJSON(jsonQueryString, 0);
|
||||
schemaPlan = jerseyClient.queryJSON(jsonQueryString, 1);
|
||||
|
||||
@ -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();
|
||||
if (projName != null) {
|
||||
if (!projectNames.contains(projName)) {
|
||||
projectNames.add(projName);
|
||||
}
|
||||
}
|
||||
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);
|
||||
@ -142,9 +148,9 @@ public class DBXMLQueries {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get some basic (not all) data for deployments associated with a project. Note that
|
||||
* Get some basic (not all) data for deployments associated with a project. Note that
|
||||
* this may include deployments which are NOT part of the current dataset. That requires
|
||||
* a search on Instrument as well.
|
||||
* a search on Instrument as well.
|
||||
* @param projectName
|
||||
* @return
|
||||
*/
|
||||
@ -164,20 +170,25 @@ public class DBXMLQueries {
|
||||
if (doc == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// System.out.println(pamXMLWriter.getAsString(doc));
|
||||
|
||||
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);
|
||||
if (aNode instanceof Element) {
|
||||
Element returnedEl = (Element) aNode;
|
||||
|
||||
|
||||
String Id = getElementData(returnedEl, "Id");
|
||||
String project = getElementData(returnedEl, "Project");
|
||||
String DeploymentId = getElementData(returnedEl, "DeploymentId");
|
||||
@ -218,7 +229,7 @@ public class DBXMLQueries {
|
||||
}
|
||||
return deployments;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of Detections documents which associate with a datablock and a deploymentId.
|
||||
* @param dataBlock
|
||||
@ -227,7 +238,7 @@ public class DBXMLQueries {
|
||||
*/
|
||||
public ArrayList<String> getDetectionsDocuments(PamDataBlock dataBlock, String deploymentId) {
|
||||
/**
|
||||
* first query for Detections documents associated with this deployment and datablock.
|
||||
* first query for Detections documents associated with this deployment and datablock.
|
||||
*/
|
||||
String queryNoDepl = "{\"species\":{\"query\":{\"op\":\"lib:abbrev2tsn\",\"optype\":\"function\",\"operands\":[\"%s\",\"SIO.SWAL.v1\"]},\"return\":{\"op\":\"lib:tsn2abbrev\",\"optype\":\"function\",\"operands\":[\"%s\",\"SIO.SWAL.v1\"]}},\"return\":[\"Detections/Id\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Detections/Algorithm/Software\",\"LongDataName\"],\"optype\":\"binary\"}],\"enclose\":1}";
|
||||
String queryWithDepl = "{\"species\":{\"query\":{\"op\":\"lib:abbrev2tsn\",\"optype\":\"function\",\"operands\":[\"%s\",\"SIO.SWAL.v1\"]},\"return\":{\"op\":\"lib:tsn2abbrev\",\"optype\":\"function\",\"operands\":[\"%s\",\"SIO.SWAL.v1\"]}},\"return\":[\"Detections/Id\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Detections/Algorithm/Software\",\"LongDataName\"],\"optype\":\"binary\"},{\"op\":\"=\",\"operands\":[\"Detections/DataSource/DeploymentId\",\"TheDeploymentId\"],\"optype\":\"binary\"}],\"enclose\":1}";
|
||||
@ -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();
|
||||
@ -260,9 +274,9 @@ public class DBXMLQueries {
|
||||
}
|
||||
return detectionsNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the names of all detection documents for a given deployment for all data streams.
|
||||
* Get the names of all detection documents for a given deployment for all data streams.
|
||||
* @param deploymentId
|
||||
* @return
|
||||
*/
|
||||
@ -273,17 +287,20 @@ public class DBXMLQueries {
|
||||
if (queryResult == null || queryResult.queryException != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// PamguardXMLWriter pamXMLWriter = PamguardXMLWriter.getXMLWriter();
|
||||
|
||||
|
||||
Document doc = convertStringToXMLDocument(queryResult.queryResult);
|
||||
if (doc == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
@ -293,7 +310,7 @@ public class DBXMLQueries {
|
||||
|
||||
public int countData(PamDataBlock dataBlock, String deploymentId) {
|
||||
// /**
|
||||
// * first query for Detections documents associated with this deployment and datablock.
|
||||
// * first query for Detections documents associated with this deployment and datablock.
|
||||
// */
|
||||
// String queryNoDepl = "{\"species\":{\"query\":{\"op\":\"lib:abbrev2tsn\",\"optype\":\"function\",\"operands\":[\"%s\",\"SIO.SWAL.v1\"]},\"return\":{\"op\":\"lib:tsn2abbrev\",\"optype\":\"function\",\"operands\":[\"%s\",\"SIO.SWAL.v1\"]}},\"return\":[\"Detections/Id\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Detections/Algorithm/Software\",\"LongDataName\"],\"optype\":\"binary\"}],\"enclose\":1}";
|
||||
// String queryWithDepl = "{\"species\":{\"query\":{\"op\":\"lib:abbrev2tsn\",\"optype\":\"function\",\"operands\":[\"%s\",\"SIO.SWAL.v1\"]},\"return\":{\"op\":\"lib:tsn2abbrev\",\"optype\":\"function\",\"operands\":[\"%s\",\"SIO.SWAL.v1\"]}},\"return\":[\"Detections/Id\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Detections/Algorithm/Software\",\"LongDataName\"],\"optype\":\"binary\"},{\"op\":\"=\",\"operands\":[\"Detections/DataSource/DeploymentId\",\"TheDeploymentId\"],\"optype\":\"binary\"}],\"enclose\":1}";
|
||||
@ -324,17 +341,15 @@ 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);
|
||||
|
||||
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count on effort detections in a Detections document
|
||||
* @param docName
|
||||
@ -349,7 +364,7 @@ public class DBXMLQueries {
|
||||
try {
|
||||
Queries queries = dbXMLConnect.getTethysQueries();
|
||||
result = queries.QueryTethys(query);
|
||||
// System.out.println(result);
|
||||
// System.out.println(result);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("Error executing " + query);
|
||||
@ -368,11 +383,11 @@ public class DBXMLQueries {
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get a count of the detections in a detections document.
|
||||
// * Only looking in onEffort so far.
|
||||
// * Get a count of the detections in a detections document.
|
||||
// * Only looking in onEffort so far.
|
||||
// * @param deploymentId
|
||||
// * @param detectionDocId
|
||||
// * @param dataBlock
|
||||
// * @param dataBlock
|
||||
// * @return
|
||||
// */
|
||||
// public int getDetectionsDetectionCount(String deploymentId, String detectionDocId, PamDataBlock dataBlock) {
|
||||
@ -391,7 +406,7 @@ public class DBXMLQueries {
|
||||
// if (doc == null) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//// System.out.println(pamXMLWriter.getAsString(doc));
|
||||
//
|
||||
//// ArrayList<String> detectionDocs = new ArrayList<>();
|
||||
@ -404,7 +419,7 @@ public class DBXMLQueries {
|
||||
// /**
|
||||
// * This is the quickest way of counting data in a project, but it will load the start
|
||||
// * times for every detection in a project at once, so might use a lot of memory. Also
|
||||
// * it wll probably get data for all deployments in a project, which may not be what we want.
|
||||
// * it wll probably get data for all deployments in a project, which may not be what we want.
|
||||
// * @param projectName
|
||||
// * @param dataPrefixes
|
||||
// * @return
|
||||
@ -432,7 +447,7 @@ public class DBXMLQueries {
|
||||
/**
|
||||
* Count data within a deployment document which is associated with a set of datablocks
|
||||
* Since the detections all come back in one query, it's easier to count all datablocks at once so
|
||||
* that it can all happen off a single query.
|
||||
* that it can all happen off a single query.
|
||||
* @param id
|
||||
* @param dataBlockPrefixes
|
||||
* @return
|
||||
@ -450,20 +465,20 @@ public class DBXMLQueries {
|
||||
if (doc == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// System.out.println(pamXMLWriter.getAsString(doc));
|
||||
|
||||
NodeList detsDocs = doc.getElementsByTagName("Detections");
|
||||
int[] blockCounts = new int[dataPrefixes.length];
|
||||
|
||||
|
||||
// String detDocPrefix = projectId + "_" + dataBlock.getDataName();
|
||||
|
||||
|
||||
// int totalCalls = 0;
|
||||
int detCount = 0;
|
||||
int dataIndex;
|
||||
for (int i = 0; i < detsDocs.getLength(); i++) {
|
||||
Node detNode = detsDocs.item(i);
|
||||
|
||||
|
||||
NodeList childNodes = detNode.getChildNodes();
|
||||
detCount = childNodes.getLength()-1;
|
||||
dataIndex = -1;
|
||||
@ -531,8 +546,8 @@ public class DBXMLQueries {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the basic information about a Detections document. This is basically everything apart from
|
||||
* the actual detections themselves.
|
||||
* Get the basic information about a Detections document. This is basically everything apart from
|
||||
* the actual detections themselves.
|
||||
* @param aDoc
|
||||
* @return
|
||||
*/
|
||||
@ -549,7 +564,7 @@ public class DBXMLQueries {
|
||||
return null;
|
||||
}
|
||||
// System.out.println(queryResult.queryResult);
|
||||
|
||||
|
||||
Detections detections = new Detections();
|
||||
try {
|
||||
Helper.createRequiredElements(detections);
|
||||
@ -564,7 +579,7 @@ public class DBXMLQueries {
|
||||
return null;
|
||||
}
|
||||
Element result = (Element) returns.item(0);
|
||||
|
||||
|
||||
DescriptionType description = detections.getDescription();
|
||||
if (description == null) {
|
||||
description = new DescriptionType();
|
||||
@ -574,9 +589,9 @@ public class DBXMLQueries {
|
||||
description.setAbstract(getElementData(result, "Description.Abstract"));
|
||||
description.setMethod(getElementData(result, "Description.Method"));
|
||||
description.setObjectives(getElementData(result, "Description.Objectives"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return detections;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
@ -30,23 +20,23 @@ public class DMXMLQueryTest {
|
||||
|
||||
private void runTest() {
|
||||
TethysExportParams params = new TethysExportParams();
|
||||
|
||||
|
||||
JerseyClient jerseyClient = new JerseyClient(params.getFullServerName());
|
||||
|
||||
|
||||
// String testJson = "{\"return\":[\"Deployment/Project\",\"Deployment/DeploymentId\",\"Deployment/Site\",\"Deployment/DeploymentDetails/AudioTimeStamp\",\"Deployment/RecoveryDetails/AudioTimeStamp\"],\"select\":[],\"enclose\":1}";
|
||||
// String testJson = "{\"return\":[\"Deployment/Project\",\"Deployment/Region\",\"Deployment/DeploymentDetails/AudioTimeStamp\",\"Deployment/RecoveryDetails/AudioTimeStamp\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Deployment/DeploymentId\",\"2\"],\"optype\":\"binary\"}],\"enclose\":1}";
|
||||
//String testJson = "{\"return\":[\"Deployment/Project\",\"Deployment/Region\",\"Deployment/DeploymentDetails/AudioTimeStamp\",\"Deployment/RecoveryDetails/AudioTimeStamp\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Deployment/DeploymentId\",\"2\"],\"optype\":\"binary\"},{\"op\":\"=\",\"operands\":[\"Deployment/Project\",\"DCLDE2022\"],\"optype\":\"binary\"}],\"enclose\":1}";
|
||||
// String testJson = "{\"return\":[\"Deployment/Project\",\"Deployment/Region\",\"Deployment/DeploymentDetails/AudioTimeStamp\",\"Deployment/RecoveryDetails/AudioTimeStamp\",\"Deployment/DeploymentId\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Deployment/DeploymentId\",\"2\"],\"optype\":\"binary\"},{\"op\":\"=\",\"operands\":[\"Deployment/Project\",\"DCLDE2022\"],\"optype\":\"binary\"}],\"enclose\":1}";
|
||||
String testJson = "{\"return\":[\"Deployment/Project\"],\"select\":[],\"enclose\":1}";
|
||||
// web browse to http://localhost:9779/Client
|
||||
|
||||
|
||||
String testResult = jerseyClient.queryJSON(testJson);
|
||||
|
||||
Document doc = convertStringToXMLDocument(testResult);
|
||||
|
||||
|
||||
PamguardXMLWriter pamXMLWriter = PamguardXMLWriter.getXMLWriter();
|
||||
String formettedXML = pamXMLWriter.getAsString(doc, true);
|
||||
|
||||
|
||||
System.out.println(testResult);
|
||||
System.out.println(formettedXML);
|
||||
// try {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package tethys.dbxml;
|
||||
|
||||
public class ServerStatus {
|
||||
|
||||
|
||||
public boolean ok;
|
||||
|
||||
|
||||
public Exception error;
|
||||
|
||||
public ServerStatus(boolean ok, Exception error) {
|
||||
@ -11,7 +11,7 @@ public class ServerStatus {
|
||||
this.ok = ok;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
|
||||
public String getFormatted() {
|
||||
if (ok) {
|
||||
return "Server OK";
|
||||
@ -30,6 +30,6 @@ public class ServerStatus {
|
||||
public String toString() {
|
||||
return getFormatted();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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,40 +230,45 @@ 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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
private Object getValueAt(RecordingPeriod period, int rowIndex, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return rowIndex;
|
||||
case 1:
|
||||
return PamCalendar.formatDBDateTime(period.getRecordStart());
|
||||
// return TethysTimeFuncs.formatGregorianTime(deplInfo.deploymentDetails.getAudioTimeStamp());
|
||||
case 2:
|
||||
return PamCalendar.formatDBDateTime(period.getRecordStop());
|
||||
// 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 6:
|
||||
PDeployment deployment = period.getMatchedTethysDeployment();
|
||||
return makeDeplString(period, deployment);
|
||||
case SELECTCOLUMN:
|
||||
// return selectBoxes[rowIndex];
|
||||
return selection[rowIndex];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return columnIndex == 6;
|
||||
}
|
||||
|
||||
private Object getValueAt(RecordingPeriod period, int rowIndex, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return rowIndex;
|
||||
case 1:
|
||||
return PamCalendar.formatDBDateTime(period.getRecordStart());
|
||||
// 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 PamCalendar.formatDuration(period.getRecordStop()-period.getRecordStart());
|
||||
case 5:
|
||||
PDeployment deployment = period.getMatchedTethysDeployment();
|
||||
return makeDeplString(period, deployment);
|
||||
case 6:
|
||||
// return selectBoxes[rowIndex];
|
||||
return selection[rowIndex];
|
||||
}
|
||||
|
||||
return null;
|
||||
return columnIndex == SELECTCOLUMN;
|
||||
}
|
||||
|
||||
private String makeDeplString(RecordingPeriod period, PDeployment deployment) {
|
||||
|
Loading…
Reference in New Issue
Block a user