Refactoring Tethys

A lot of refactoring of Nilus wrappers with more useful Objects for PAMGUard to work with.
This commit is contained in:
Douglas Gillespie 2024-07-22 16:07:33 +01:00
parent 3abaff0379
commit 4f87b7b661
30 changed files with 553 additions and 118 deletions

View File

@ -6,8 +6,9 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>

View File

@ -888,7 +888,7 @@
<dependency> <dependency>
<groupId>tethys.org</groupId> <groupId>tethys.org</groupId>
<artifactId>nilus</artifactId> <artifactId>nilus</artifactId>
<version>3.0</version> <version>3.1</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -0,0 +1,4 @@
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Tue Jul 16 19:29:56 BST 2024
nilus-3.1.jar>=
nilus-3.1.pom>=

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>tethys.org</groupId>
<artifactId>nilus</artifactId>
<version>3.1</version>
<description>POM was created from install:install-file</description>
</project>

View File

@ -306,6 +306,9 @@ abstract public class PamDialog extends JDialog {
* put the dialog near the mouse location. * put the dialog near the mouse location.
*/ */
public void moveToMouseLocation() { public void moveToMouseLocation() {
if (MouseInfo.getPointerInfo() == null) {
return;
}
Point mouse = MouseInfo.getPointerInfo().getLocation(); Point mouse = MouseInfo.getPointerInfo().getLocation();
moveToLocation(mouse); moveToLocation(mouse);
} }

View File

@ -2929,7 +2929,7 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
String name = spectrogramDisplay.getDataSelectorName(panelId); String name = spectrogramDisplay.getDataSelectorName(panelId);
DataSelector dataSelector = usedDataBlock.getDataSelector(name, false); DataSelector dataSelector = usedDataBlock.getDataSelector(name, false);
if (dataSelector.getParams().getCombinationFlag() == DataSelectParams.DATA_SELECT_DISABLE) { if (dataSelector != null && dataSelector.getParams().getCombinationFlag() == DataSelectParams.DATA_SELECT_DISABLE) {
dataSelector = null; dataSelector = null;
} }
directDrawProjector.setDataSelector(dataSelector); directDrawProjector.setDataSelector(dataSelector);

View File

@ -89,7 +89,7 @@ public enum Collection {
return Calibrations; return Calibrations;
case "nilus.Ensemble": case "nilus.Ensemble":
return Ensembles; return Ensembles;
case "nilus.Localization": case "nilus.Localize":
return Localizations; return Localizations;
case "nilus.SpeciesAbbreviation": case "nilus.SpeciesAbbreviation":
return SpeciesAbbreviations; return SpeciesAbbreviations;

View File

@ -49,6 +49,7 @@ import tethys.dbxml.TethysException;
import tethys.dbxml.TethysQueryException; import tethys.dbxml.TethysQueryException;
import tethys.deployment.DeploymentHandler; import tethys.deployment.DeploymentHandler;
import tethys.detection.DetectionsHandler; import tethys.detection.DetectionsHandler;
import tethys.localization.LocalizationHandler;
import tethys.niluswraps.PDeployment; import tethys.niluswraps.PDeployment;
import tethys.output.DatablockSynchInfo; import tethys.output.DatablockSynchInfo;
import tethys.output.TethysExportParams; import tethys.output.TethysExportParams;
@ -91,6 +92,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
private DeploymentHandler deploymentHandler; private DeploymentHandler deploymentHandler;
private DetectionsHandler detectionsHandler; private DetectionsHandler detectionsHandler;
private CalibrationHandler calibrationHandler; private CalibrationHandler calibrationHandler;
private LocalizationHandler localizationHandler;
private ITISFunctions itisFunctions; private ITISFunctions itisFunctions;
@ -102,6 +104,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
deploymentHandler = new DeploymentHandler(this); deploymentHandler = new DeploymentHandler(this);
detectionsHandler = new DetectionsHandler(this); detectionsHandler = new DetectionsHandler(this);
calibrationHandler = new CalibrationHandler(this); calibrationHandler = new CalibrationHandler(this);
localizationHandler = new LocalizationHandler(this);
serverCheckTimer = new Timer(10000, new ActionListener() { serverCheckTimer = new Timer(10000, new ActionListener() {
@Override @Override
@ -569,8 +572,8 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
int detectionCount = 0; int detectionCount = 0;
int documentCount = 0; int documentCount = 0;
for (PDeployment pDepl : matchedDeployments) { for (PDeployment pDepl : matchedDeployments) {
detectionCount += dbxmlQueries.countData(synchInfo.getDataBlock(), pDepl.deployment.getId()); detectionCount += dbxmlQueries.countData(synchInfo.getDataBlock(), pDepl.getDocumentId());
ArrayList<String> detectionsNames = getDbxmlQueries().getDetectionsDocuments(synchInfo.getDataBlock(), pDepl.deployment.getId()); ArrayList<String> detectionsNames = getDbxmlQueries().getDetectionsDocuments(synchInfo.getDataBlock(), pDepl.getDocumentId());
if (detectionsNames != null) { if (detectionsNames != null) {
documentCount += detectionsNames.size(); documentCount += detectionsNames.size();
} }

View File

@ -26,14 +26,14 @@ public class TethysMenuActions {
} }
public void deploymentMouseActions(MouseEvent e, PDeployment pDeployment) { public void deploymentMouseActions(MouseEvent e, PDeployment pDeployment) {
ArrayList<String> detDocNames = tethysControl.getDbxmlQueries().getDetectionsDocuments(pDeployment.deployment.getId()); ArrayList<String> detDocNames = tethysControl.getDbxmlQueries().getDetectionsDocuments(pDeployment.nilusObject.getId());
// System.out.println("Detections for deployment " + pDeployment.deployment.getId()); // System.out.println("Detections for deployment " + pDeployment.deployment.getId());
// for (String detName : detDocNames) { // for (String detName : detDocNames) {
// System.out.println(detName); // System.out.println(detName);
// } // }
JPopupMenu menu = new JPopupMenu(); JPopupMenu menu = new JPopupMenu();
if (detDocNames.size() == 0) { if (detDocNames.size() == 0) {
JMenuItem menuItem = new JMenuItem("Delete deployment " + pDeployment.deployment.getId()); JMenuItem menuItem = new JMenuItem("Delete deployment " + pDeployment.nilusObject.getId());
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -47,7 +47,7 @@ public class TethysMenuActions {
menu.add(menuItem); menu.add(menuItem);
} }
else { else {
String str = String.format("Delete deployment %s and %d Detections documents", pDeployment.deployment.getId(), detDocNames.size()); String str = String.format("Delete deployment %s and %d Detections documents", pDeployment.nilusObject.getId(), detDocNames.size());
JMenuItem menuItem = new JMenuItem(str); JMenuItem menuItem = new JMenuItem(str);
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@Override @Override
@ -65,6 +65,6 @@ public class TethysMenuActions {
} }
protected void deleteDeployment(PDeployment pDeployment) throws TethysException { protected void deleteDeployment(PDeployment pDeployment) throws TethysException {
tethysControl.getDbxmlConnect().deleteDeployment(pDeployment.deployment.getId()); tethysControl.getDbxmlConnect().deleteDeployment(pDeployment.nilusObject.getId());
} }
} }

View File

@ -420,10 +420,24 @@ public class CalibrationHandler extends CollectionHandler implements TethysState
calibration.setSensitivityDBFS(fullScale); calibration.setSensitivityDBFS(fullScale);
} }
FrequencyResponse frs = calibration.getFrequencyResponse(); FrequencyResponse frs = calibration.getFrequencyResponse();
if (frs == null) {
frs = new FrequencyResponse();
try {
Helper.createRequiredElements(frs);
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
}
calibration.setFrequencyResponse(frs);
}
List<Double> hz = frs.getHz(); List<Double> hz = frs.getHz();
List<Double> db = frs.getDB(); List<Double> db = frs.getDB();
// if (hz == null) {
//
// }
if (hz != null && db != null) {
hz.add(Double.valueOf(0)); hz.add(Double.valueOf(0));
db.add(Double.valueOf(hSens+preampGain)); db.add(Double.valueOf(hSens+preampGain));
}
if (NilusChecker.isEmpty(calibration.getResponsibleParty())) { if (NilusChecker.isEmpty(calibration.getResponsibleParty())) {
calibration.setResponsibleParty(null); calibration.setResponsibleParty(null);

View File

@ -515,7 +515,7 @@ C:\Users\dg50\AppData\Local\Temp\PAMGuardTethys\20080311_2DSimplex_0.xmlnot: 0 b
* @param nilusObject * @param nilusObject
* @return document Id for any type of document, or null if the document doesn't have a getID function * @return document Id for any type of document, or null if the document doesn't have a getID function
*/ */
private String getDocumentId(Object nilusObject) { public static String getDocumentId(Object nilusObject) {
String tempName = null; String tempName = null;
Class nilusClass = nilusObject.getClass(); Class nilusClass = nilusObject.getClass();
Method getId; Method getId;

View File

@ -561,6 +561,63 @@ public class DBXMLQueries {
} }
return detectionsNames; return detectionsNames;
} }
/**
* Get a list of Localization documents which associate with a datablock and a deploymentId.
* @param dataBlock
* @param deploymentId can be null to get all docs for data block
* @return
*/
public ArrayList<String> getLocalizationDocuments(PamDataBlock dataBlock, String deploymentId) {
/**
* first query for Detections documents associated with this deployment and datablock.
* updated May 23
*/
if (dataBlock == null) {
return null;
}
String queryNoDepl = "{\"species\":{\"query\":{\"op\":\"lib:completename2tsn\",\"optype\":\"function\",\"operands\":[\"%s\"]},\"return\":{\"op\":\"lib:tsn2completename\",\"optype\":\"function\",\"operands\":[\"%s\"]}},\"return\":[\"Localize/Id\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Localize/Algorithm/Software\",\"LongDataName\"],\"optype\":\"binary\"}],\"enclose\":1}";
String queryWithDepl = "{\"species\":{\"query\":{\"op\":\"lib:completename2tsn\",\"optype\":\"function\",\"operands\":[\"%s\"]},\"return\":{\"op\":\"lib:tsn2completename\",\"optype\":\"function\",\"operands\":[\"%s\"]}},\"return\":[\"Localize/Id\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Localize/DataSource/DeploymentId\",\"TheDeploymentId\"],\"optype\":\"binary\"},{\"op\":\"=\",\"operands\":[\"Localize/Algorithm/Software\",\"LongDataName\"],\"optype\":\"binary\"}],\"enclose\":1}";
String query;
if (deploymentId == null) {
query = queryNoDepl;
}
else {
query = queryWithDepl.replace("TheDeploymentId", deploymentId);
}
query = query.replace("LongDataName", dataBlock.getLongDataName());
DBQueryResult queryResult = null;
try {
queryResult = executeQuery(query);
} catch (TethysQueryException e1) {
tethysControl.showException(e1);
return null;
}
if (queryResult ==null) {
return null;
}
Document doc;
try {
doc = queryResult.getDocument();
} catch (ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace();
return null;
}
if (doc == null) {
return null;
}
ArrayList<String> detectionsNames = new ArrayList();
int count = 0;
NodeList returns = doc.getElementsByTagName("Localize");
// 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();
detectionsNames.add(docName);
}
return detectionsNames;
}
/** /**

View File

@ -492,7 +492,7 @@ public class DeploymentHandler extends CollectionHandler implements TethysStateO
PDeployment exDeploymnet = onePeriod.getMatchedTethysDeployment(); PDeployment exDeploymnet = onePeriod.getMatchedTethysDeployment();
try { try {
if (exDeploymnet != null) { if (exDeploymnet != null) {
deployment.setId(exDeploymnet.deployment.getId()); deployment.setId(exDeploymnet.nilusObject.getId());
dbxmlConnect.updateDocument(deployment); dbxmlConnect.updateDocument(deployment);
} }
else { else {
@ -522,7 +522,7 @@ public class DeploymentHandler extends CollectionHandler implements TethysStateO
String id = String.format("%s_%d", exportParams.getDatasetName(), i); String id = String.format("%s_%d", exportParams.getDatasetName(), i);
if (exDeploymnet != null) { if (exDeploymnet != null) {
deployment = createDeploymentDocument(freeId, recordPeriod, id); deployment = createDeploymentDocument(freeId, recordPeriod, id);
deployment.setId(exDeploymnet.deployment.getId()); deployment.setId(exDeploymnet.nilusObject.getId());
} }
if (deployment == null) { if (deployment == null) {
deployment = createDeploymentDocument(freeId++, recordPeriod, id); deployment = createDeploymentDocument(freeId++, recordPeriod, id);
@ -646,7 +646,7 @@ public class DeploymentHandler extends CollectionHandler implements TethysStateO
} }
ArrayList<PInstrument> instruments = new ArrayList<>(); ArrayList<PInstrument> instruments = new ArrayList<>();
for (PDeployment aDepl : projectDeployments) { for (PDeployment aDepl : projectDeployments) {
Instrument intr = aDepl.deployment.getInstrument(); Instrument intr = aDepl.nilusObject.getInstrument();
if (intr == null) { if (intr == null) {
continue; continue;
} }
@ -764,7 +764,7 @@ public class DeploymentHandler extends CollectionHandler implements TethysStateO
int firstFree = 0; int firstFree = 0;
if (projectDeployments != null) { if (projectDeployments != null) {
for (PDeployment dep : projectDeployments) { for (PDeployment dep : projectDeployments) {
firstFree = Math.max(firstFree, dep.deployment.getDeploymentId()+1); firstFree = Math.max(firstFree, dep.nilusObject.getDeploymentId()+1);
} }
} }
return firstFree; return firstFree;

View File

@ -12,6 +12,8 @@ import javax.xml.datatype.XMLGregorianCalendar;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamController; import PamController.PamController;
import PamController.PamguardVersionInfo; import PamController.PamguardVersionInfo;
import PamDetection.LocContents;
import PamDetection.LocalisationInfo;
import PamModel.PamPluginInterface; import PamModel.PamPluginInterface;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamView.dialog.PamDialog; import PamView.dialog.PamDialog;
@ -26,6 +28,8 @@ import dataMap.OfflineDataMap;
import dataMap.OfflineDataMapPoint; import dataMap.OfflineDataMapPoint;
import nilus.AlgorithmType; import nilus.AlgorithmType;
import nilus.AlgorithmType.SupportSoftware; import nilus.AlgorithmType.SupportSoftware;
import nilus.Localize.Effort;
import nilus.Localize.Effort.CoordinateReferenceSystem;
import nilus.Localize.Localizations; import nilus.Localize.Localizations;
import nilus.DataSourceType; import nilus.DataSourceType;
import nilus.Deployment; import nilus.Deployment;
@ -36,6 +40,7 @@ import nilus.DetectionGroup;
import nilus.Detections; import nilus.Detections;
import nilus.GranularityEnumType; import nilus.GranularityEnumType;
import nilus.Helper; import nilus.Helper;
import nilus.Localize;
import tethys.Collection; import tethys.Collection;
import tethys.CollectionHandler; import tethys.CollectionHandler;
import tethys.TethysControl; import tethys.TethysControl;
@ -43,6 +48,9 @@ import tethys.TethysTimeFuncs;
import tethys.dbxml.DBXMLConnect; import tethys.dbxml.DBXMLConnect;
import tethys.dbxml.TethysException; import tethys.dbxml.TethysException;
import tethys.deployment.DeploymentHandler; import tethys.deployment.DeploymentHandler;
import tethys.localization.CoordinateName;
import tethys.localization.LocalizationSubType;
import tethys.localization.LocalizationType;
import tethys.niluswraps.PDeployment; import tethys.niluswraps.PDeployment;
import tethys.niluswraps.PDetections; import tethys.niluswraps.PDetections;
import tethys.output.StreamExportParams; import tethys.output.StreamExportParams;
@ -87,6 +95,7 @@ public class DetectionsHandler extends CollectionHandler {
*/ */
public StreamDetectionsSummary getStreamDetections(PamDataBlock dataBlock) { public StreamDetectionsSummary getStreamDetections(PamDataBlock dataBlock) {
ArrayList<PDeployment> deployments = tethysControl.getDeploymentHandler().getMatchedDeployments(); ArrayList<PDeployment> deployments = tethysControl.getDeploymentHandler().getMatchedDeployments();
// getStreamLocalizations(dataBlock, deployments);
return getStreamDetections(dataBlock, deployments); return getStreamDetections(dataBlock, deployments);
} }
@ -102,7 +111,7 @@ public class DetectionsHandler extends CollectionHandler {
ArrayList<PDetections> detectionsDocs = new ArrayList<>(); ArrayList<PDetections> detectionsDocs = new ArrayList<>();
for (PDeployment aDep : deployments) { for (PDeployment aDep : deployments) {
ArrayList<String> someNames = tethysControl.getDbxmlQueries().getDetectionsDocuments(dataBlock, aDep.deployment.getId()); ArrayList<String> someNames = tethysControl.getDbxmlQueries().getDetectionsDocuments(dataBlock, aDep.nilusObject.getId());
if (someNames == null) { if (someNames == null) {
continue; continue;
} }
@ -117,6 +126,7 @@ public class DetectionsHandler extends CollectionHandler {
return new StreamDetectionsSummary(detectionsDocs); return new StreamDetectionsSummary(detectionsDocs);
} }
/** /**
* Get the Detection Effort part of a Detections document * Get the Detection Effort part of a Detections document
* @param pDeployment * @param pDeployment
@ -126,12 +136,12 @@ public class DetectionsHandler extends CollectionHandler {
*/ */
private DetectionEffort getDetectorEffort(PDeployment pDeployment, PamDataBlock dataBlock, StreamExportParams exportParams) { private DetectionEffort getDetectorEffort(PDeployment pDeployment, PamDataBlock dataBlock, StreamExportParams exportParams) {
DetectionEffort effort = new DetectionEffort(); DetectionEffort effort = new DetectionEffort();
Deployment deployment = pDeployment.deployment; Deployment deployment = pDeployment.nilusObject;
Long effortStart = pDeployment.getAudioStart(); Long effortStart = pDeployment.getAudioStart();
Long effortEnd = pDeployment.getAudioEnd(); Long effortEnd = pDeployment.getAudioEnd();
effort.setStart(TethysTimeFuncs.xmlGregCalFromMillis(effortStart)); effort.setStart(TethysTimeFuncs.xmlGregCalFromMillis(effortStart));
effort.setEnd(TethysTimeFuncs.xmlGregCalFromMillis(effortEnd)); effort.setEnd(TethysTimeFuncs.xmlGregCalFromMillis(effortEnd));
// effort.set // no setter for DetectionEffortKind // effort.set // no setter for DetectionEffortKind
List<DetectionEffortKind> effortKinds = effort.getKind(); List<DetectionEffortKind> effortKinds = effort.getKind();
TethysDataProvider dataProvider = dataBlock.getTethysDataProvider(tethysControl); TethysDataProvider dataProvider = dataBlock.getTethysDataProvider(tethysControl);
@ -202,7 +212,7 @@ public class DetectionsHandler extends CollectionHandler {
* @return PAMGuard version * @return PAMGuard version
*/ */
public String getSupportSoftwareVersion(PamDataBlock dataBlock) { public String getSupportSoftwareVersion(PamDataBlock dataBlock) {
// should try to dig into the binary store and get the version from there. // should try to dig into the binary store and get the version from there.
return PamguardVersionInfo.version; return PamguardVersionInfo.version;
} }
@ -256,7 +266,7 @@ public class DetectionsHandler extends CollectionHandler {
public void cancelExport() { public void cancelExport() {
activeExport = false; activeExport = false;
} }
/** /**
* Round a bin start so that it's aligned correctly with * Round a bin start so that it's aligned correctly with
* day starts. * day starts.
@ -284,7 +294,7 @@ public class DetectionsHandler extends CollectionHandler {
TethysExportParams exportParams = tethysControl.getTethysExportParams(); TethysExportParams exportParams = tethysControl.getTethysExportParams();
DeploymentHandler depHandler = tethysControl.getDeploymentHandler(); DeploymentHandler depHandler = tethysControl.getDeploymentHandler();
ArrayList<PDeployment> deployments = depHandler.getMatchedDeployments(); ArrayList<PDeployment> deployments = depHandler.getMatchedDeployments();
// Detections currentDetections = null; // Detections currentDetections = null;
OfflineDataMap dataMap = dataBlock.getPrimaryDataMap(); OfflineDataMap dataMap = dataBlock.getPrimaryDataMap();
DataSelector dataSelector = dataBlock.getDataSelector(tethysControl.getDataSelectName(), false); DataSelector dataSelector = dataBlock.getDataSelector(tethysControl.getDataSelectName(), false);
int totalCount = dataMap.getDataCount(); int totalCount = dataMap.getDataCount();
@ -315,7 +325,7 @@ public class DetectionsHandler extends CollectionHandler {
// export everything in that deployment. // export everything in that deployment.
// need to loop through all map points in this interval. // need to loop through all map points in this interval.
List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints(); List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints();
for (OfflineDataMapPoint mapPoint : mapPoints) { for (OfflineDataMapPoint mapPoint : mapPoints) {
if (!activeExport) { if (!activeExport) {
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints, prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
@ -346,24 +356,24 @@ public class DetectionsHandler extends CollectionHandler {
if (dets != null) { if (dets != null) {
exportCount+=dets.length; exportCount+=dets.length;
documentCount+=dets.length; documentCount+=dets.length;
if (exportCount % 100 == 0) { if (exportCount % 100 == 0) {
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints, prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
exportObserver.update(prog); exportObserver.update(prog);
} }
} }
// Detection det = dataProvider.createDetection(dataUnit, exportParams, streamExportParams); // Detection det = dataProvider.createDetection(dataUnit, exportParams, streamExportParams);
// exportCount++; // exportCount++;
// documentCount++; // documentCount++;
// onEffort.getDetection().add(det); // onEffort.getDetection().add(det);
lastUnitTime = dataUnit.getTimeMilliseconds(); lastUnitTime = dataUnit.getTimeMilliseconds();
} }
doneMapPoints++; doneMapPoints++;
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints, prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
exportObserver.update(prog); exportObserver.update(prog);
if (viewerLoadPolicy == ViewerLoadPolicy.LOAD_ALWAYS_EVERYTHING) { if (viewerLoadPolicy == ViewerLoadPolicy.LOAD_ALWAYS_EVERYTHING) {
break; break;
} }
@ -375,14 +385,14 @@ public class DetectionsHandler extends CollectionHandler {
if (dets != null) { if (dets != null) {
exportCount += dets.length; exportCount += dets.length;
} }
} }
return exportCount; return exportCount;
} }
/** /**
* Export detections and localisations in all deployments for this PAMGuard dataset. * Export detections and localisations in all deployments for this PAMGuard dataset.
* @param dataBlock * @param dataBlock
@ -399,14 +409,15 @@ public class DetectionsHandler extends CollectionHandler {
DBXMLConnect dbxmlConnect = tethysControl.getDbxmlConnect(); DBXMLConnect dbxmlConnect = tethysControl.getDbxmlConnect();
DeploymentHandler depHandler = tethysControl.getDeploymentHandler(); DeploymentHandler depHandler = tethysControl.getDeploymentHandler();
ArrayList<PDeployment> deployments = depHandler.getMatchedDeployments(); ArrayList<PDeployment> deployments = depHandler.getMatchedDeployments();
/* /*
* The main documents for both dets and locs. * The main documents for both dets and locs.
*/ */
Detections detectionsDocument = null; Detections detectionsDocument = null;
Localizations localisationsDocument = null; Localize localiseDocument = null;
DetectionGroup onEffortDetections = null; DetectionGroup onEffortDetections = null;
Localizations localisations = null;
OfflineDataMap dataMap = dataBlock.getPrimaryDataMap(); OfflineDataMap dataMap = dataBlock.getPrimaryDataMap();
DataSelector dataSelector = dataBlock.getDataSelector(tethysControl.getDataSelectName(), false); DataSelector dataSelector = dataBlock.getDataSelector(tethysControl.getDataSelectName(), false);
int totalCount = dataMap.getDataCount(); int totalCount = dataMap.getDataCount();
@ -431,6 +442,8 @@ public class DetectionsHandler extends CollectionHandler {
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
exportObserver.update(prog); exportObserver.update(prog);
granularityHandler.prepare(deployment.getAudioStart()); granularityHandler.prepare(deployment.getAudioStart());
List<Detection> detectionList;
// export everything in that deployment. // export everything in that deployment.
// need to loop through all map points in this interval. // need to loop through all map points in this interval.
@ -448,14 +461,25 @@ public class DetectionsHandler extends CollectionHandler {
detectionsDocument = startDetectionsDocument(deployment, dataBlock, streamExportParams); detectionsDocument = startDetectionsDocument(deployment, dataBlock, streamExportParams);
detectionsDocument.getEffort().setStart(TethysTimeFuncs.xmlGregCalFromMillis(deployment.getAudioStart())); detectionsDocument.getEffort().setStart(TethysTimeFuncs.xmlGregCalFromMillis(deployment.getAudioStart()));
onEffortDetections = detectionsDocument.getOnEffort(); onEffortDetections = detectionsDocument.getOnEffort();
detectionList = onEffortDetections.getDetection();
// if {detectionList == null) {
// onEffortDetections.
// }
} }
else { else {
onEffortDetections = null; onEffortDetections = null;
detectionList = null;
} }
if (localisationsDocument == null && streamExportParams.exportLocalisations) { if (localiseDocument == null && streamExportParams.exportLocalisations) {
localisationsDocument = startLocalisationDocument(deployment, dataBlock, streamExportParams); localiseDocument = startLocalisationDocument(deployment, dataBlock, streamExportParams);
Effort eff = localiseDocument.getEffort();
localiseDocument.getEffort().setStart(TethysTimeFuncs.xmlGregCalFromMillis(deployment.getAudioStart()));
localisations = localiseDocument.getLocalizations();
} }
else {
localisations = null;
}
if (mapPoint.getEndTime() < deployment.getAudioStart()) { if (mapPoint.getEndTime() < deployment.getAudioStart()) {
continue; continue;
} }
@ -476,10 +500,14 @@ public class DetectionsHandler extends CollectionHandler {
exportCount++; exportCount++;
documentCount++; documentCount++;
if (streamExportParams.exportDetections) { if (streamExportParams.exportDetections) {
onEffortDetections.getDetection().add(dets[dd]); detectionList.add(dets[dd]);
}
if (streamExportParams.exportLocalisations) {
// convert the dets into localisations and add them.
} }
} }
} }
if (exportCount % 100 == 0) { if (exportCount % 100 == 0) {
prog = new DetectionExportProgress(deployment, detectionsDocument, totalMapPoints, doneMapPoints, prog = new DetectionExportProgress(deployment, detectionsDocument, totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING); lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
@ -508,6 +536,17 @@ public class DetectionsHandler extends CollectionHandler {
} }
detectionsDocument = null; detectionsDocument = null;
} }
if (localiseDocument != null) {
closeLocaliseDocument(localiseDocument, mapPoint.getEndTime());
try {
if (checkLocaliseDocument(localiseDocument, granularityHandler)) {
dbxmlConnect.postAndLog(localiseDocument);
}
} catch (TethysException e) {
tethysControl.showException(e);
}
localiseDocument = null;
}
} }
if (viewerLoadPolicy == ViewerLoadPolicy.LOAD_ALWAYS_EVERYTHING) { if (viewerLoadPolicy == ViewerLoadPolicy.LOAD_ALWAYS_EVERYTHING) {
@ -543,6 +582,27 @@ public class DetectionsHandler extends CollectionHandler {
} }
detectionsDocument = null; detectionsDocument = null;
} }
if (localiseDocument != null) {
Detection dets[] = granularityHandler.cleanup(deployment.getAudioEnd());
if (dets != null) {
for (int dd = 0; dd < dets.length; dd++) {
exportCount++;
documentCount++;
// localiseDocument.getOnEffort().getDetection().add(dets[dd]);
}
}
prog = new DetectionExportProgress(deployment, detectionsDocument,totalMapPoints, doneMapPoints,
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_WRITING);
closeLocaliseDocument(localiseDocument, deployment.getAudioEnd());
try {
if (checkLocaliseDocument(localiseDocument, granularityHandler)) {
dbxmlConnect.postAndLog(localiseDocument);
}
} catch (TethysException e) {
tethysControl.showException(e);
}
localiseDocument = null;
}
} }
prog = new DetectionExportProgress(null, null,totalMapPoints, totalMapPoints, prog = new DetectionExportProgress(null, null,totalMapPoints, totalMapPoints,
@ -550,20 +610,6 @@ public class DetectionsHandler extends CollectionHandler {
exportObserver.update(prog); exportObserver.update(prog);
return DetectionExportProgress.STATE_COMPLETE; return DetectionExportProgress.STATE_COMPLETE;
} }
private Localizations startLocalisationDocument(PDeployment deployment, PamDataBlock dataBlock,
StreamExportParams streamExportParams) {
Localizations localisations = new Localizations();
try {
Helper.createRequiredElements(localisations);
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
return null;
}
return localisations;
}
/** /**
* Start a new detections document for the deployment and datablock. <br> * Start a new detections document for the deployment and datablock. <br>
@ -584,7 +630,7 @@ public class DetectionsHandler extends CollectionHandler {
} }
TethysDataProvider dataProvider = dataBlock.getTethysDataProvider(tethysControl); TethysDataProvider dataProvider = dataBlock.getTethysDataProvider(tethysControl);
String prefix = deployment.deployment.getId() + "_" + dataProvider.getDetectionsName(); String prefix = deployment.nilusObject.getId() + "_" + dataProvider.getDetectionsName();
String fullId = ""; String fullId = "";
/* /*
* Check the document name isn't already used and increment id as necessary. * Check the document name isn't already used and increment id as necessary.
@ -596,17 +642,17 @@ public class DetectionsHandler extends CollectionHandler {
} }
} }
detections.setId(fullId); detections.setId(fullId);
// detections.setDescription(dataProvider.getDescription(deployment, tethysExportParams)); // detections.setDescription(dataProvider.getDescription(deployment, tethysExportParams));
detections.setDescription(exportParams.getNilusDetectionDescription()); detections.setDescription(exportParams.getNilusDetectionDescription());
DataSourceType dataSource = new DataSourceType(); DataSourceType dataSource = new DataSourceType();
dataSource.setDeploymentId(deployment.deployment.getId()); dataSource.setDeploymentId(deployment.nilusObject.getId());
// dataSource.setEnsembleId(""); ToDo // dataSource.setEnsembleId(""); ToDo
detections.setDataSource(dataSource); detections.setDataSource(dataSource);
AlgorithmType algorithm = detections.getAlgorithm(); AlgorithmType algorithm = detections.getAlgorithm();
if (dataProvider != null) { if (dataProvider != null) {
algorithm = dataProvider.getAlgorithm(); algorithm = dataProvider.getAlgorithm();
// detections.setAlgorithm(algorithm); // detections.setAlgorithm(algorithm);
} }
algorithm.setMethod(getMethodString(dataBlock)); algorithm.setMethod(getMethodString(dataBlock));
algorithm.setSoftware(getSoftwareString(dataBlock)); algorithm.setSoftware(getSoftwareString(dataBlock));
@ -624,6 +670,141 @@ public class DetectionsHandler extends CollectionHandler {
return detections; return detections;
} }
private Localize startLocalisationDocument(PDeployment deployment, PamDataBlock dataBlock,
StreamExportParams exportParams) {
Localize localisations = new Localize();
try {
Helper.createRequiredElements(localisations);
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
return null;
}
if (localisations.getEffort() == null) {
Effort eff = new Effort();
try {
Helper.createRequiredElements(eff);
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
return null;
}
localisations.setEffort(eff);
}
TethysDataProvider dataProvider = dataBlock.getTethysDataProvider(tethysControl);
String prefix = deployment.nilusObject.getId() + "_" + dataProvider.getDetectionsName();
String fullId = "";
/*
* Check the document name isn't already used and increment id as necessary.
*/
while (true) {
fullId = String.format("%s_%d", prefix, uniqueDetectionsId++);
if (!tethysControl.getDbxmlQueries().documentExists(Collection.Localizations.toString(), fullId)) {
break;
}
}
localisations.setId(fullId);
// detections.setDescription(dataProvider.getDescription(deployment, tethysExportParams));
localisations.setDescription(exportParams.getNilusDetectionDescription());
DataSourceType dataSource = new DataSourceType();
dataSource.setDeploymentId(deployment.nilusObject.getId());
// dataSource.setEnsembleId(""); ToDo
localisations.setDataSource(dataSource);
AlgorithmType algorithm = localisations.getAlgorithm();
if (dataProvider != null) {
algorithm = dataProvider.getAlgorithm();
// detections.setAlgorithm(algorithm);
}
algorithm.setMethod(getMethodString(dataBlock));
algorithm.setSoftware(getSoftwareString(dataBlock));
algorithm.setVersion(getVersionString(dataBlock));
List<SupportSoftware> supSoft = algorithm.getSupportSoftware();
SupportSoftware supportSoft = new SupportSoftware();
supportSoft.setSoftware(getSupportSoftware(dataBlock));
supportSoft.setVersion(getSupportSoftwareVersion(dataBlock));
supSoft.add(supportSoft);
localisations.setAlgorithm(algorithm);
localisations.setUserId("PAMGuard user");
// localisations.setEffort(getLocaliserEffort(deployment, dataBlock, exportParams));
sortLocaliseCoordinates(dataBlock, localisations);
// sort out coordinate system.
return localisations;
}
private boolean sortLocaliseCoordinates(PamDataBlock dataBlock, Localize localisations) {
LocalisationInfo locInfo = dataBlock.getLocalisationContents();
Effort locEffort = localisations.getEffort();
if (locEffort == null) {
locEffort = new Effort();
localisations.setEffort(locEffort);
}
try {
Helper.createRequiredElements(locEffort);
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
return false;
}
locEffort.setTimeReference("relative");
// List<String> locTypes = locEffort.getLocalizationType();
boolean ambiguity = locInfo.hasLocContent(LocContents.HAS_AMBIGUITY);
CoordinateReferenceSystem coordRefs = locEffort.getCoordinateReferenceSystem();
if (locInfo.getLocContent() == 0) {
return false;
}
else if (locInfo.hasLocContent(LocContents.HAS_LATLONG)) {
coordRefs.setName(CoordinateName.WGS84.toString());
coordRefs.setSubtype(LocalizationSubType.Geographic.toString());
locEffort.setLocalizationType(LocalizationType.Point.toString());
// locEffort.set
if (locInfo.hasLocContent(LocContents.HAS_DEPTH)) {
locEffort.setDimension(3);
}
else {
locEffort.setDimension(2);
}
// locEffort.set
}
else if (locInfo.hasLocContent(LocContents.HAS_XYZ)) {
coordRefs.setName(CoordinateName.Cartesian.toString());
coordRefs.setSubtype(LocalizationSubType.Engineering.toString());
locEffort.setLocalizationType(LocalizationType.Point.toString());
locEffort.setDimension(3);
}
else if (locInfo.hasLocContent(LocContents.HAS_XY)) {
coordRefs.setName(CoordinateName.Cartesian.toString());
coordRefs.setSubtype(LocalizationSubType.Engineering.toString());
locEffort.setLocalizationType(LocalizationType.Point.toString());
locEffort.setDimension(2);
}
else if (locInfo.hasLocContent(LocContents.HAS_BEARING)) {
coordRefs.setName(CoordinateName.Polar.toString());
coordRefs.setSubtype(LocalizationSubType.Engineering.toString());
locEffort.setLocalizationType(LocalizationType.Bearing.toString());
if (ambiguity) {
locEffort.setDimension(1);
}
else {
locEffort.setDimension(2);
}
}
else {
return false;
}
return true;
}
private nilus.Localize.Effort getLocaliserEffort(PDeployment deployment, PamDataBlock dataBlock, StreamExportParams exportParams) {
// TODO Auto-generated method stub
return null;
}
/** /**
* Close a detections document. This basically just means rewriting the end time and it's only * Close a detections document. This basically just means rewriting the end time and it's only
* important in the event that a document got too big and has to be restarted. * important in the event that a document got too big and has to be restarted.
@ -633,7 +814,12 @@ public class DetectionsHandler extends CollectionHandler {
private void closeDetectionsDocument(Detections detections, Long audioEnd) { private void closeDetectionsDocument(Detections detections, Long audioEnd) {
detections.getEffort().setEnd(TethysTimeFuncs.xmlGregCalFromMillis(audioEnd)); detections.getEffort().setEnd(TethysTimeFuncs.xmlGregCalFromMillis(audioEnd));
} }
private void closeLocaliseDocument(Localize localiseDocument, long endTime) {
localiseDocument.getEffort().setEnd(TethysTimeFuncs.xmlGregCalFromMillis(endTime));
}
/** /**
* Run some checks on the Detections document prior to submission. <br> * Run some checks on the Detections document prior to submission. <br>
* Currently, is is just a check that the detections are within the effort times. * Currently, is is just a check that the detections are within the effort times.
@ -678,6 +864,11 @@ public class DetectionsHandler extends CollectionHandler {
return true; return true;
} }
private boolean checkLocaliseDocument(Localize localiseDocument, GranularityHandler granularityHandler) {
// TODO Auto-generated method stub
return true;
}
/** /**
* Worker thread for exporting detections. * Worker thread for exporting detections.
* Currently, it counts them first, then checks the user wants to export * Currently, it counts them first, then checks the user wants to export
@ -709,16 +900,16 @@ public class DetectionsHandler extends CollectionHandler {
protected Integer doInBackground() throws Exception { protected Integer doInBackground() throws Exception {
Integer ans = null; Integer ans = null;
try { try {
// int count = countDetections(dataBlock, exportParams, exportObserver); // int count = countDetections(dataBlock, exportParams, exportObserver);
// if (activeExport == false) { // if (activeExport == false) {
// return 0; // return 0;
// } // }
// String msg = String.format("Do you want to go ahead and output %d %s detections to Tethys?", // String msg = String.format("Do you want to go ahead and output %d %s detections to Tethys?",
// count, exportParams.granularity); // count, exportParams.granularity);
// int doit = WarnOnce.showWarning("Tethys Detections Export", msg, WarnOnce.OK_CANCEL_OPTION); // int doit = WarnOnce.showWarning("Tethys Detections Export", msg, WarnOnce.OK_CANCEL_OPTION);
// if (doit == WarnOnce.OK_OPTION) { // if (doit == WarnOnce.OK_OPTION) {
ans = exportDetections(dataBlock, exportParams, this); ans = exportDetections(dataBlock, exportParams, this);
// } // }
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -728,7 +919,7 @@ public class DetectionsHandler extends CollectionHandler {
@Override @Override
protected void done() { protected void done() {
// this. // this.
DetectionExportProgress prog = new DetectionExportProgress(null, null, 0, 0, 0, 0, 0, 0, DetectionExportProgress.STATE_COMPLETE); DetectionExportProgress prog = new DetectionExportProgress(null, null, 0, 0, 0, 0, 0, 0, DetectionExportProgress.STATE_COMPLETE);
tethysControl.exportedDetections(dataBlock); tethysControl.exportedDetections(dataBlock);
exportObserver.update(prog); exportObserver.update(prog);

View File

@ -0,0 +1,11 @@
package tethys.localization;
/**
* Enumeration of the Name field in nilus.Localize.Effort.CoordinateReferenceSystem<br>
* Within Tethys, these are only ever used in their String form.
* @author dg50
*
*/
public enum CoordinateName {
WGS84, UTM, Cartesian, Polar, Spherical, Cylindrical, Range, PerpindicularRange;
}

View File

@ -1,17 +1,63 @@
package tethys.localization; package tethys.localization;
import java.util.ArrayList;
import PamguardMVC.PamDataBlock;
import nilus.CylindricalCoordinateType; import nilus.CylindricalCoordinateType;
import nilus.LocalizationType; import nilus.LocalizationType;
import nilus.Localize.Effort.CoordinateReferenceSystem; import nilus.Localize.Effort.CoordinateReferenceSystem;
import tethys.Collection;
import tethys.CollectionHandler;
import tethys.TethysControl;
import tethys.detection.StreamDetectionsSummary;
import tethys.niluswraps.PDeployment;
public class LocalizationHandler { public class LocalizationHandler extends CollectionHandler {
public LocalizationHandler(TethysControl tethysControl) {
super(tethysControl, Collection.Localizations);
// TODO Auto-generated constructor stub
}
// public LocalizationType getLoc() {
// LocalizationType lt = new LocalizationType();
// CylindricalCoordinateType cct = new CylindricalCoordinateType();
//// cct.set
// CoordinateReferenceSystem cr;
// return null;
// }
public LocalizationType getLoc() { /**
LocalizationType lt = new LocalizationType(); * Get a list of Localization documents associated with a particular data block for the list of deployments
CylindricalCoordinateType cct = new CylindricalCoordinateType(); * documents. Group them by abstract or something
// cct.set * @param dataBlock
CoordinateReferenceSystem cr; * @param deployments
* @return
*/
public StreamDetectionsSummary getStreamLocalizations(PamDataBlock dataBlock, ArrayList<PDeployment> deployments) {
// get the basic data for each document including it's Description.
// ArrayList<PDetections> detectionsDocs = new ArrayList<>();
for (PDeployment aDep : deployments) {
ArrayList<String> someNames = tethysControl.getDbxmlQueries().getLocalizationDocuments(dataBlock, aDep.getDocumentId());
if (someNames == null) {
continue;
}
// // no have a list of all the Detections documents of interest for this datablock.
// for (String aDoc : someNames) {
// Detections detections = tethysControl.getDbxmlQueries().getDetectionsDocInfo(aDoc);
// int count = tethysControl.getDbxmlQueries().countDetections2(aDoc);
// PDetections pDetections = new PDetections(detections, dataBlock, aDep, count);
// detectionsDocs.add(pDetections);
// }
}
// return new StreamDetectionsSummary(detectionsDocs);
return null;
}
@Override
public String getHelpPoint() {
// TODO Auto-generated method stub
return null; return null;
} }
} }

View File

@ -0,0 +1,10 @@
package tethys.localization;
/**
* Enumeration of the ReferenceFrame field in nilus.Localize.Effort.CoordinateReferenceSystem.Subtype <br>
* Within Tethys, these are only ever used in their String form.
* @author dg50
*
*/
public enum LocalizationSubType {
Geographic, Derived, Engineering;
}

View File

@ -0,0 +1,11 @@
package tethys.localization;
/**
* Enumeration of the ReferenceFrame field in nilus.Localize.Effort.CoordinateReferenceSystem.Subtype <br>
* Within Tethys, these are only ever used in their String form.
* @author dg50
*
*/
public enum LocalizationType {
Bearing, PerpindicularRange, Point, Range, Track;
}

View File

@ -0,0 +1,11 @@
package tethys.localization;
/**
* Enumeration of the ReferenceFrame field in nilus.Localize.Effort.CoordinateReferenceSystem <br>
* Within Tethys, these are only ever used in their String form.
* @author dg50
*
*/
public enum ReferenceFrame {
UTMZone, WGS84, instrument;
}

View File

@ -0,0 +1,10 @@
package tethys.localization;
/**
* Enumeration of the ReferenceFrame field in nilus.Localize.Effort.TimeReference <br>
* Within Tethys, these are only ever used in their String form.
* @author dg50
*
*/
public enum TimeReference {
absolute, channel, relative;
}

View File

@ -0,0 +1,27 @@
package tethys.niluswraps;
import PamguardMVC.PamDataBlock;
/**
* Wrapper for Nilus data objects. This means Detections and Localization documents which
* should have an associated datablock, a deployment wrapper and a data count.
* @author dg50
*
* @param <T>
*/
public class NilusDataWrapper<T> extends NilusDocumentWrapper<T> {
public Integer count;
public PDeployment deployment;
public PamDataBlock dataBlock;
public NilusDataWrapper(T nilusObject, PamDataBlock dataBlock, PDeployment deployment, Integer count) {
super(nilusObject);
this.dataBlock = dataBlock;
this.deployment = deployment;
this.count = count;
}
}

View File

@ -0,0 +1,24 @@
package tethys.niluswraps;
import PamguardMVC.PamDataBlock;
import tethys.dbxml.DBXMLConnect;
public class NilusDocumentWrapper<T> {
public T nilusObject;
public String documentName;
public NilusDocumentWrapper(T nilusDocument) {
super();
this.nilusObject = nilusDocument;
}
public String getDocumentId() {
if (nilusObject == null) {
return null;
}
return DBXMLConnect.getDocumentId(nilusObject);
}
}

View File

@ -12,18 +12,16 @@ import tethys.deployment.RecordingPeriod;
* @author dg50 * @author dg50
* *
*/ */
public class PDeployment { public class PDeployment extends NilusDocumentWrapper<Deployment>{
public Deployment deployment;
private RecordingPeriod matchedPAMGaurdPeriod; private RecordingPeriod matchedPAMGaurdPeriod;
public PDeployment(Deployment deployment) { public PDeployment(Deployment deployment) {
super(); super(deployment);
this.deployment = deployment;
} }
public Long getAudioStart() { public Long getAudioStart() {
DeploymentRecoveryDetails detail = deployment.getDeploymentDetails(); DeploymentRecoveryDetails detail = nilusObject.getDeploymentDetails();
if (detail == null || detail.getAudioTimeStamp() == null) { if (detail == null || detail.getAudioTimeStamp() == null) {
return null; return null;
} }
@ -31,7 +29,7 @@ public class PDeployment {
} }
public Long getAudioEnd() { public Long getAudioEnd() {
DeploymentRecoveryDetails detail = deployment.getRecoveryDetails(); DeploymentRecoveryDetails detail = nilusObject.getRecoveryDetails();
if (detail == null || detail.getAudioTimeStamp() == null) { if (detail == null || detail.getAudioTimeStamp() == null) {
return null; return null;
} }
@ -40,7 +38,7 @@ public class PDeployment {
@Override @Override
public String toString() { public String toString() {
return String.format("%s:%d; %s - %s", deployment.getId(), deployment.getDeploymentId(), return String.format("%s:%d; %s - %s", nilusObject.getId(), nilusObject.getDeploymentId(),
PamCalendar.formatDBDateTime(getAudioStart()), PamCalendar.formatDBDateTime(getAudioEnd())); PamCalendar.formatDBDateTime(getAudioStart()), PamCalendar.formatDBDateTime(getAudioEnd()));
} }
@ -55,10 +53,10 @@ public class PDeployment {
public String getShortDescription() { public String getShortDescription() {
Long audioStart = getAudioStart(); Long audioStart = getAudioStart();
if (audioStart == null) { if (audioStart == null) {
return String.format("%s %s", deployment.getId(), "unknown start"); return String.format("%s %s", nilusObject.getId(), "unknown start");
} }
else { else {
return String.format("%s %s", deployment.getId(), PamCalendar.formatDBDate(getAudioStart())); return String.format("%s %s", nilusObject.getId(), PamCalendar.formatDBDate(getAudioStart()));
} }
} }

View File

@ -3,24 +3,29 @@ package tethys.niluswraps;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import nilus.Detections; import nilus.Detections;
public class PDetections { public class PDetections extends NilusDataWrapper<Detections>{
public Detections detections;
public Integer count;
public PDeployment deployment;
public PamDataBlock dataBlock;
public PDetections(Detections detections, PamDataBlock dataBlock, PDeployment deployment, Integer count) { public PDetections(Detections detections, PamDataBlock dataBlock, PDeployment deployment, Integer count) {
super(); super(detections, dataBlock, deployment, count);
this.dataBlock = dataBlock; // TODO Auto-generated constructor stub
this.detections = detections;
this.deployment = deployment;
this.count = count;
} }
// public Detections nilusObject;
//
// public Integer count;
//
// public PDeployment deployment;
//
// public PamDataBlock dataBlock;
//
// public PDetections(Detections detections, PamDataBlock dataBlock, PDeployment deployment, Integer count) {
// super();
// this.dataBlock = dataBlock;
// this.nilusObject = detections;
// this.deployment = deployment;
// this.count = count;
// }

View File

@ -62,7 +62,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
public DatablockDetectionsPanel(TethysControl tethysControl) { public DatablockDetectionsPanel(TethysControl tethysControl) {
super(tethysControl); super(tethysControl);
mainPanel = new JPanel(new BorderLayout()); mainPanel = new JPanel(new BorderLayout());
mainPanel.add(BorderLayout.NORTH, dataBlockName = new JLabel("PAMGUard data stream", JLabel.LEFT)); mainPanel.add(BorderLayout.NORTH, dataBlockName = new JLabel("PAMGuard data stream", JLabel.LEFT));
mainPanel.setBorder(new TitledBorder("Data stream Tethys Detections documents")); mainPanel.setBorder(new TitledBorder("Data stream Tethys Detections documents"));
tableModel = new TableModel(); tableModel = new TableModel();
@ -193,7 +193,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
JMenuItem menuItem; JMenuItem menuItem;
if (rows.length == 1) { if (rows.length == 1) {
menuItem = new JMenuItem("Display document " + pDets.detections.getId()); menuItem = new JMenuItem("Display document " + pDets.getDocumentId());
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -202,7 +202,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
}); });
popMenu.add(menuItem); popMenu.add(menuItem);
menuItem = new JMenuItem("Export document " + pDets.detections.getId()); menuItem = new JMenuItem("Export document " + pDets.getDocumentId());
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -212,7 +212,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
popMenu.add(menuItem); popMenu.add(menuItem);
popMenu.addSeparator(); popMenu.addSeparator();
menuItem = new JMenuItem("Delete document " + pDets.detections.getId()); menuItem = new JMenuItem("Delete document " + pDets.getDocumentId());
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -255,7 +255,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
if (pDets == null) { if (pDets == null) {
continue; continue;
} }
toDelete.add(pDets.detections); toDelete.add(pDets.nilusObject);
} }
DeleteDocs dd = new DeleteDocs(toDelete); DeleteDocs dd = new DeleteDocs(toDelete);
PamWorker<Integer> worker = new PamWorker(dd, getTethysControl().getGuiFrame(), 1, "Deleting Detections documents"); PamWorker<Integer> worker = new PamWorker(dd, getTethysControl().getGuiFrame(), 1, "Deleting Detections documents");
@ -293,13 +293,13 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
} }
protected void deleteDocument(PDetections pDets) { protected void deleteDocument(PDetections pDets) {
String msg = String.format("Are you sure you want to delete the Detections document %s ?", pDets.detections.getId()); String msg = String.format("Are you sure you want to delete the Detections document %s ?", pDets.getDocumentId());
int ans = WarnOnce.showWarning(PamGui.findComponentWindow(mainPanel), "Delete Document", msg, WarnOnce.OK_CANCEL_OPTION); int ans = WarnOnce.showWarning(PamGui.findComponentWindow(mainPanel), "Delete Document", msg, WarnOnce.OK_CANCEL_OPTION);
if (ans != WarnOnce.OK_OPTION) { if (ans != WarnOnce.OK_OPTION) {
return; return;
} }
try { try {
getTethysControl().getDbxmlConnect().deleteDocument(pDets.detections); getTethysControl().getDbxmlConnect().deleteDocument(pDets.nilusObject);
} catch (TethysException e) { } catch (TethysException e) {
getTethysControl().showException(e); getTethysControl().showException(e);
} }
@ -308,12 +308,12 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
} }
private void displayDocument(PDetections pDets) { private void displayDocument(PDetections pDets) {
getTethysControl().displayDocument(Collection.Detections.collectionName(), pDets.detections.getId()); getTethysControl().displayDocument(Collection.Detections.collectionName(), pDets.getDocumentId());
} }
private void exportDocument(PDetections pDets) { private void exportDocument(PDetections pDets) {
getTethysControl().exportDocument(Collection.Detections.toString(), pDets.detections.getId()); getTethysControl().exportDocument(Collection.Detections.toString(), pDets.getDocumentId());
} }
@ -359,7 +359,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
if (pDets == null) { if (pDets == null) {
return null; return null;
} }
Detections dets = pDets.detections; Detections dets = pDets.nilusObject;
if (dets == null) { if (dets == null) {
return "Error in doc"; return "Error in doc";
} }

View File

@ -124,10 +124,10 @@ public class DeploymentExportPanel extends TethysGUIPanel implements DeploymentT
return; return;
} }
PDeployment deployment = tethysDeploys.get(row); PDeployment deployment = tethysDeploys.get(row);
String msg = "Do you want to copy settings from deploymnet document " + deployment.deployment.getId(); String msg = "Do you want to copy settings from deploymnet document " + deployment.nilusObject.getId();
int ans = WarnOnce.showWarning("Deployment data", msg, WarnOnce.OK_CANCEL_OPTION); int ans = WarnOnce.showWarning("Deployment data", msg, WarnOnce.OK_CANCEL_OPTION);
if (ans == WarnOnce.OK_OPTION) { if (ans == WarnOnce.OK_OPTION) {
copyDeploymentData(deployment.deployment); copyDeploymentData(deployment.nilusObject);
} }
} }

View File

@ -229,14 +229,14 @@ private RecordingList masterList;
return; return;
} }
for (PDeployment depl : matchedDeployments) { for (PDeployment depl : matchedDeployments) {
if (depl.deployment == null) { if (depl.nilusObject == null) {
continue; continue;
} }
try { try {
if (checkDetections(depl.deployment) == false) { if (checkDetections(depl.nilusObject) == false) {
continue; continue;
} }
boolean gone = getTethysControl().getDbxmlConnect().deleteDocument(depl.deployment); boolean gone = getTethysControl().getDbxmlConnect().deleteDocument(depl.nilusObject);
} catch (TethysException e) { } catch (TethysException e) {
getTethysControl().showException(e); getTethysControl().showException(e);
} }
@ -279,7 +279,7 @@ private RecordingList masterList;
} }
protected void deleteDeployment(PDeployment pDeployment) { protected void deleteDeployment(PDeployment pDeployment) {
Deployment dep = pDeployment.deployment; Deployment dep = pDeployment.nilusObject;
if (dep == null) { if (dep == null) {
return; return;
} }
@ -300,11 +300,11 @@ private RecordingList masterList;
} }
protected void exportDeployment(PDeployment pDeployment) { protected void exportDeployment(PDeployment pDeployment) {
getTethysControl().exportDocument(Collection.Deployments.collectionName(), pDeployment.deployment.getId()); getTethysControl().exportDocument(Collection.Deployments.collectionName(), pDeployment.nilusObject.getId());
} }
protected void displayDeployment(PDeployment pDeployment) { protected void displayDeployment(PDeployment pDeployment) {
getTethysControl().displayDocument(Collection.Deployments.collectionName(), pDeployment.deployment.getId()); getTethysControl().displayDocument(Collection.Deployments.collectionName(), pDeployment.nilusObject.getId());
} }
@Override @Override
@ -443,7 +443,7 @@ private RecordingList masterList;
if (deployment == null) { if (deployment == null) {
return null; return null;
} }
return deployment.deployment.getId(); return deployment.nilusObject.getId();
// return makeDeplString(period, deployment); // return makeDeplString(period, deployment);
case 8: case 8:
if (deployment == null) { if (deployment == null) {

View File

@ -226,7 +226,7 @@ public class TethysConnectionPanel extends TethysGUIPanel {
*/ */
ArrayList<PDeployment> projectDeployments = getTethysControl().getDeploymentHandler().getProjectDeployments(); ArrayList<PDeployment> projectDeployments = getTethysControl().getDeploymentHandler().getProjectDeployments();
if (projectDeployments != null && projectDeployments.size() > 0) { if (projectDeployments != null && projectDeployments.size() > 0) {
Deployment dep = projectDeployments.get(0).deployment; Deployment dep = projectDeployments.get(0).nilusObject;
globDeployment.setProject(dep.getProject()); globDeployment.setProject(dep.getProject());
globDeployment.setRegion(dep.getRegion()); globDeployment.setRegion(dep.getRegion());
getTethysControl().sendStateUpdate(new TethysState(TethysState.StateType.NEWPROJECTSELECTION)); getTethysControl().sendStateUpdate(new TethysState(TethysState.StateType.NEWPROJECTSELECTION));