Merge DG branch (#144)

* Refactoring Tethys

A lot of refactoring of Nilus wrappers with more useful Objects for PAMGUard to work with.

* Improved document handling

Abstracted wrapper around nilus documents which allows easyish calling of internal functions in Localize and Detections document without a common base class.

* Fix doc deletion in detector output panel
This commit is contained in:
Douglas Gillespie 2024-08-02 15:26:49 +01:00 committed by GitHub
parent 9eee7434de
commit 82adc06e3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 905 additions and 172 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

@ -1,16 +1,16 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=21 org.eclipse.jdt.core.compiler.compliance=1.3
org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=21 org.eclipse.jdt.core.compiler.source=1.3

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();
} }
@ -595,6 +598,13 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
return detectionsHandler; return detectionsHandler;
} }
/**
* @return the localizationHandler
*/
public LocalizationHandler getLocalizationHandler() {
return localizationHandler;
}
public void showException(TethysException tethysException) { public void showException(TethysException tethysException) {
String title = tethysException.getMessage(); String title = tethysException.getMessage();
StackTraceElement[] stack = tethysException.getStackTrace(); StackTraceElement[] stack = tethysException.getStackTrace();

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

@ -32,6 +32,7 @@ import nilus.Detections;
import nilus.GranularityEnumType; import nilus.GranularityEnumType;
import nilus.GranularityType; import nilus.GranularityType;
import nilus.Helper; import nilus.Helper;
import nilus.Localize;
import tethys.Collection; import tethys.Collection;
import tethys.DocumentInfo; import tethys.DocumentInfo;
import tethys.TethysControl; import tethys.TethysControl;
@ -561,6 +562,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;
}
/** /**
@ -728,6 +786,38 @@ public class DBXMLQueries {
return count; return count;
} }
/**
* Count on effort detections in a Detections document
* @param docName
* @return
*/
public int countLocalizations2(String docName) {
TethysExportParams params = tethysControl.getTethysExportParams();
String queryBase = "count(collection(\"Localizations\")/Localize[Id=\"ReplaceDocumentId\"]/Localizations/Localization)";
String query = queryBase.replace("ReplaceDocumentId", docName);
String result = null;
try {
Queries queries = dbXMLConnect.getTethysQueries();
result = queries.QueryTethys(query);
// System.out.println(result);
}
catch (Exception e) {
System.out.println("Error executing " + query);
// e.printStackTrace();
return -1;
}
int count = 0;
try {
count = Integer.valueOf(result);
}
catch (NumberFormatException e) {
System.out.println("Unable to interpret count data " + result);
return 0;
}
return count;
}
// /** // /**
// * Get a count of the detections in a detections document. // * Get a count of the detections in a detections document.
// * Only looking in onEffort so far. // * Only looking in onEffort so far.
@ -1024,5 +1114,108 @@ public class DBXMLQueries {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return detections; return detections;
} }
/**
* Get the basic information about a Detections document. This is basically everything apart from
* the actual detections themselves.
* @param aDoc
* @return
*/
public Localize getLocalizationDocInfo(String locDocName) {
// String oldqueryBase = "{\"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\",\"Detections/Description\",\"Detections/DataSource\",\"Detections/Algorithm\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Detections/Id\",\"DetectionsDocName\"],\"optype\":\"binary\"}],\"enclose\":1}";
// updated May 23
// String queryBase = "{\"species\":{\"query\":{\"op\":\"lib:completename2tsn\",\"optype\":\"function\",\"operands\":[\"%s\"]},\"return\":{\"op\":\"lib:tsn2completename\",\"optype\":\"function\",\"operands\":[\"%s\"]}},\"return\":[\"Localize/Id\",\"Localize/Description\",\"Localize/DataSource\",\"Localize/Algorithm\",\"Localize/QualityAssurance\",\"Localize/UserId\",\"Localize/MetadataInfo\",\"Localize/Effort\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Localize/Id\",\"LocalizationsDocName\"],\"optype\":\"binary\"}],\"enclose\":1}";
String queryBase = "{\"species\":{\"query\":{\"op\":\"lib:completename2tsn\",\"optype\":\"function\",\"operands\":[\"%s\"]},\"return\":{\"op\":\"lib:tsn2completename\",\"optype\":\"function\",\"operands\":[\"%s\"]}},\"return\":[\"Localize/Id\",\"Localize/Description\",\"Localize/DataSource\",\"Localize/Algorithm\",\"Localize/QualityAssurance\",\"Localize/UserId\",\"Localize/Effort\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Localize/Id\",\"LocalizationsDocName\"],\"optype\":\"binary\"}],\"enclose\":1}";
String query = queryBase.replace("LocalizationsDocName", locDocName);
DBQueryResult queryResult;
try {
queryResult = executeQuery(query);
} catch (TethysQueryException e) {
tethysControl.showException(e);
return null;
}
Document doc;
try {
doc = queryResult.getDocument();
} catch (ParserConfigurationException | SAXException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
// System.out.println(queryResult.queryResult);
Localize localize = new Localize();
try {
Helper.createRequiredElements(localize);
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
e.printStackTrace();
}
NodeList returns = doc.getElementsByTagName("Result");
// System.out.println("N projects = " + returns.getLength());
int n = returns.getLength();
if (n == 0) {
return null;
}
Element result = (Element) returns.item(0);
DescriptionType description = localize.getDescription();
if (description == null) {
description = new DescriptionType();
localize.setDescription(description);
}
localize.setId(getElementData(result, "Id"));
description.setAbstract(getElementData(result, "Description.Abstract"));
description.setMethod(getElementData(result, "Description.Method"));
description.setObjectives(getElementData(result, "Description.Objectives"));
String deployment = getElementData(result, "DataSource.DeploymentId");
if (deployment != null) {
DataSourceType dataSource = localize.getDataSource();
if (dataSource == null) {
dataSource = new DataSourceType();
localize.setDataSource(dataSource);
}
dataSource.setDeploymentId(deployment);
}
// get the effort start an end
String effStart = getElementData(result, "Effort.Start");
String effEnd = getElementData(result, "Effort.End");
localize.getEffort().setStart(TethysTimeFuncs.fromGregorianXML(effStart));
localize.getEffort().setEnd(TethysTimeFuncs.fromGregorianXML(effEnd));
// try to find the granularity.
// String granularityString = getElementData(result, "Effort.Kind.Granularity");
// GranularityEnumType granularity = null;
// if (granularityString != null) {
// granularity = GranularityEnumType.fromValue(granularityString);
// List<DetectionEffortKind> kinds = detections.getEffort().getKind();
// DetectionEffortKind kind = new DetectionEffortKind();
// GranularityType granularityType = new GranularityType();
// granularityType.setValue(granularity);
// kind.setGranularity(granularityType);
// // try to find the rest of the granularity information.
// String binSize_m = getElementAttribute(result, "Effort.Kind.Granularity", "BinSize_m");
// String encounterGap_m = getElementAttribute(result, "Effort.Kind.Granularity", "EncounterGap_m");
// String firstBinStart = getElementAttribute(result, "Effort.Kind.Granularity", "FirstBinStart");
// try {
// granularityType.setBinSizeMin(Double.valueOf(binSize_m));
// }
// catch (NumberFormatException e) {
// }
// try {
// granularityType.setEncounterGapMin(Double.valueOf(encounterGap_m));
// }
// catch (NumberFormatException e) {
// }
//
// kinds.add(kind);
// }
// String
// TODO Auto-generated method stub
return localize;
}
} }

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,11 @@ 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.localization.PLocalization;
import tethys.niluswraps.NilusDataWrapper;
import tethys.niluswraps.PDeployment; import tethys.niluswraps.PDeployment;
import tethys.niluswraps.PDetections; import tethys.niluswraps.PDetections;
import tethys.output.StreamExportParams; import tethys.output.StreamExportParams;
@ -85,7 +95,7 @@ public class DetectionsHandler extends CollectionHandler {
* this data set (not the entire project). * this data set (not the entire project).
* @param dataBlock * @param dataBlock
*/ */
public StreamDetectionsSummary getStreamDetections(PamDataBlock dataBlock) { public StreamDetectionsSummary<NilusDataWrapper<PDetections>> getStreamDetections(PamDataBlock dataBlock) {
ArrayList<PDeployment> deployments = tethysControl.getDeploymentHandler().getMatchedDeployments(); ArrayList<PDeployment> deployments = tethysControl.getDeploymentHandler().getMatchedDeployments();
return getStreamDetections(dataBlock, deployments); return getStreamDetections(dataBlock, deployments);
} }
@ -97,12 +107,12 @@ public class DetectionsHandler extends CollectionHandler {
* @param deployments * @param deployments
* @return * @return
*/ */
public StreamDetectionsSummary getStreamDetections(PamDataBlock dataBlock, ArrayList<PDeployment> deployments) { public StreamDetectionsSummary<NilusDataWrapper<PDetections>> getStreamDetections(PamDataBlock dataBlock, ArrayList<PDeployment> deployments) {
// get the basic data for each document including it's Description. // get the basic data for each document including it's Description.
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 +127,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 +137,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 +213,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;
} }
@ -284,7 +295,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();
@ -353,10 +364,10 @@ public class DetectionsHandler extends CollectionHandler {
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++;
@ -404,8 +415,9 @@ public class DetectionsHandler extends CollectionHandler {
* 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);
@ -432,6 +444,8 @@ public class DetectionsHandler extends CollectionHandler {
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.
List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints(); List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints();
@ -448,12 +462,23 @@ 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()) {
@ -476,10 +501,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 +537,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 +583,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,
@ -551,20 +612,6 @@ public class DetectionsHandler extends CollectionHandler {
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>
* Add all the standard information to the top of the Document * Add all the standard information to the top of the Document
@ -584,7 +631,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 +643,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 +671,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.
@ -634,6 +816,11 @@ public class DetectionsHandler extends CollectionHandler {
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 +865,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 +901,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 +920,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

@ -2,6 +2,7 @@ package tethys.detection;
import java.util.ArrayList; import java.util.ArrayList;
import tethys.niluswraps.NilusDataWrapper;
import tethys.niluswraps.PDetections; import tethys.niluswraps.PDetections;
/** /**
@ -10,11 +11,11 @@ import tethys.niluswraps.PDetections;
* @author dg50 * @author dg50
* *
*/ */
public class StreamDetectionsSummary { public class StreamDetectionsSummary<T extends NilusDataWrapper> {
public ArrayList<PDetections> detectionsDocs; public ArrayList<T> detectionsDocs;
public StreamDetectionsSummary(ArrayList<PDetections> detectionsDocs) { public StreamDetectionsSummary(ArrayList<T> detectionsDocs) {
this.detectionsDocs = detectionsDocs; this.detectionsDocs = detectionsDocs;
} }

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,78 @@
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;
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.NilusDataWrapper;
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() { // public LocalizationType getLoc() {
LocalizationType lt = new LocalizationType(); // LocalizationType lt = new LocalizationType();
CylindricalCoordinateType cct = new CylindricalCoordinateType(); // CylindricalCoordinateType cct = new CylindricalCoordinateType();
// cct.set //// cct.set
CoordinateReferenceSystem cr; // CoordinateReferenceSystem cr;
// return null;
// }
/**
* Get a list of Localization documents associated with a particular data block for all deployments
* documents. Group them by abstract or something
* @param dataBlock
* @return
*/
public StreamDetectionsSummary<NilusDataWrapper<PLocalization>> getStreamLocalizations(PamDataBlock dataBlock) {
ArrayList<PDeployment> deployments = tethysControl.getDeploymentHandler().getMatchedDeployments();
return getStreamLocalizations(dataBlock, deployments);
}
/**
* Get a list of Localization documents associated with a particular data block for the list of deployments
* documents. Group them by abstract or something
* @param dataBlock
* @param deployments can be null for all deployments.
* @return
*/
public StreamDetectionsSummary<NilusDataWrapper<PLocalization>> getStreamLocalizations(PamDataBlock dataBlock, ArrayList<PDeployment> deployments) {
// get the basic data for each document including it's Description.
ArrayList<PLocalization> localizeDocs = 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) {
Localize localize = tethysControl.getDbxmlQueries().getLocalizationDocInfo(aDoc);
int count = tethysControl.getDbxmlQueries().countLocalizations2(aDoc);
PLocalization pLocalize = new PLocalization(localize, dataBlock, aDep, count);
localizeDocs.add(pLocalize);
// PDetections pDetections = new PDetections(detections, dataBlock, aDep, count);
// detectionsDocs.add(pDetections);
}
}
return new StreamDetectionsSummary(localizeDocs);
}
@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,14 @@
package tethys.localization;
import PamguardMVC.PamDataBlock;
import nilus.Localize;
import tethys.niluswraps.NilusDataWrapper;
import tethys.niluswraps.PDeployment;
public class PLocalization extends NilusDataWrapper<Localize> {
public PLocalization(Localize nilusObject, PamDataBlock dataBlock, PDeployment deployment, Integer count) {
super(nilusObject, dataBlock, deployment, count);
}
}

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,56 @@
package tethys.niluswraps;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.xml.datatype.XMLGregorianCalendar;
import PamguardMVC.PamDataBlock;
import nilus.DataSourceType;
import nilus.DescriptionType;
import nilus.QualityAssuranceProcessType;
/**
* 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;
}
public DescriptionType getDescription() {
return (DescriptionType) getGotObject("getDescription");
}
public DataSourceType getDataSource() {
return (DataSourceType) getGotObject("getDataSource");
}
public QualityAssuranceProcessType getQualityAssurance() {
return (QualityAssuranceProcessType) getGotObject("getQualityAssurance");
}
public XMLGregorianCalendar getEffortStart() {
return (XMLGregorianCalendar) getGotObjects("getEffort", "getStart");
}
public XMLGregorianCalendar getEffortEnd() {
return (XMLGregorianCalendar) getGotObjects("getEffort", "getEnd");
}
}

View File

@ -0,0 +1,108 @@
package tethys.niluswraps;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import tethys.Collection;
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);
}
/**
* Get an object out of the nilus object using a series of sequential getter functions
* @param getterName function names (any number to work through class list) .
* @return
*/
public Object getGotObjects(String... getterNames) {
/**
* Be aware that this will probably get called in preference to
* the function below, so need to check to see if the
*/
return getGotObjects(nilusObject, getterNames);
}
/**
* Get an object out of the given object using a series of sequential getter functions
* @param source source object
* @param getterName function names (any number to work through class list) .
* @return
*/
public Object getGotObjects(Object source, String... getterNames) {
Object obj = source;
for (int i = 0; i < getterNames.length; i++) {
obj = getGotObject(obj, getterNames[i]);
if (obj == null) {
break;
}
}
return obj;
}
/**
* Get an object out of the main nilus object using a getter function (no function parameters).
* @param source source object
* @param getterName function name.
* @return
*/
public Object getGotObject(String getterName) {
return getGotObject(nilusObject, getterName);
}
/**
* Get an object out of the given object using a getter function (no function parameters).
* @param source source object
* @param getterName function name.
* @return
*/
public Object getGotObject(Object source, String getterName) {
if (source == null) {
return null;
}
Class sourceClass = source.getClass();
Method getId;
try {
getId = sourceClass.getDeclaredMethod(getterName, null);
Object[] inputs = new Object[0];
Object res = getId.invoke(source, inputs);
return res;
}
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
System.err.printf("Unable to find method %s in object %s\n", getterName, source.toString());
e.printStackTrace();
}
return null;
}
/**
* Get the class of the nilus object.
* @return Java class of nilus object.
*/
public Class getNilusClass() {
return nilusObject.getClass();
}
/**
* Collection for the nilus object.
* @return
*/
public Collection getCollection() {
return Collection.fromClass(getNilusClass());
}
}

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,25 +3,12 @@ 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;
this.detections = detections;
this.deployment = deployment;
this.count = count;
} }
} }

View File

@ -27,14 +27,20 @@ import PamView.dialog.warn.WarnOnce;
import PamView.tables.SwingTableColumnWidths; import PamView.tables.SwingTableColumnWidths;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import nilus.DataSourceType; import nilus.DataSourceType;
import nilus.DescriptionType;
import nilus.DetectionEffort;
import nilus.DetectionEffortKind; import nilus.DetectionEffortKind;
import nilus.Detections; import nilus.Detections;
import nilus.GranularityType; import nilus.GranularityType;
import nilus.Localize.Effort;
import tethys.Collection; import tethys.Collection;
import tethys.TethysControl; import tethys.TethysControl;
import tethys.TethysState; import tethys.TethysState;
import tethys.dbxml.TethysException; import tethys.dbxml.TethysException;
import tethys.detection.StreamDetectionsSummary; import tethys.detection.StreamDetectionsSummary;
import tethys.localization.PLocalization;
import tethys.niluswraps.NilusDataWrapper;
import tethys.niluswraps.NilusDocumentWrapper;
import tethys.niluswraps.PDeployment; import tethys.niluswraps.PDeployment;
import tethys.niluswraps.PDetections; import tethys.niluswraps.PDetections;
@ -57,12 +63,16 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
private PamDataBlock dataBlock; private PamDataBlock dataBlock;
private StreamDetectionsSummary streamDetectionsSummary; // private StreamDetectionsSummary<NilusDataWrapper<PDetections>> streamDetectionsSummary;
//
// private StreamDetectionsSummary<NilusDataWrapper<PLocalization>> streamLocalisationsSummary;
private StreamDetectionsSummary<NilusDataWrapper> combinedSummary;
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();
@ -144,7 +154,16 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
@Override @Override
public String runBackgroundTask(PamWorker<String> pamWorker) { public String runBackgroundTask(PamWorker<String> pamWorker) {
streamDetectionsSummary = getTethysControl().getDetectionsHandler().getStreamDetections(dataBlock); StreamDetectionsSummary<NilusDataWrapper<PDetections>> streamDetectionsSummary = getTethysControl().getDetectionsHandler().getStreamDetections(dataBlock);
StreamDetectionsSummary<NilusDataWrapper<PLocalization>> streamLocalisationsSummary = getTethysControl().getLocalizationHandler().getStreamLocalizations(dataBlock);
ArrayList<NilusDataWrapper> allDocs = new ArrayList();
if (streamDetectionsSummary != null) {
allDocs.addAll(streamDetectionsSummary.detectionsDocs);
}
if (streamLocalisationsSummary != null) {
allDocs.addAll(streamLocalisationsSummary.detectionsDocs);
}
combinedSummary = new StreamDetectionsSummary<>(allDocs);
return null; return null;
} }
@ -183,7 +202,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
} }
int[] rows = table.getSelectedRows(); int[] rows = table.getSelectedRows();
PDetections pDets = detectionsForRow(row); NilusDataWrapper pDets = detectionsForRow(row);
if (pDets == null) { if (pDets == null) {
return; return;
} }
@ -193,7 +212,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 +221,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,11 +231,11 @@ 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) {
deleteDocument(pDets); // deleteDocument(pDets);
} }
}); });
popMenu.add(menuItem); popMenu.add(menuItem);
@ -247,15 +266,15 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
return; return;
} }
ArrayList<Detections> toDelete = new ArrayList(); ArrayList<NilusDataWrapper> toDelete = new ArrayList();
for (int i = 0; i < rows.length; i++) { for (int i = 0; i < rows.length; i++) {
int row = rows[i]; int row = rows[i];
PDetections pDets = detectionsForRow(row); NilusDataWrapper<PDetections> pDets = detectionsForRow(row);
if (pDets == null) { if (pDets == null) {
continue; continue;
} }
toDelete.add(pDets.detections); toDelete.add(pDets);
} }
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");
@ -265,18 +284,18 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
private class DeleteDocs implements PamWorkWrapper<Integer> { private class DeleteDocs implements PamWorkWrapper<Integer> {
private ArrayList<Detections> toDelete; private ArrayList<NilusDataWrapper> toDelete;
public DeleteDocs(ArrayList<Detections> toDelete) { public DeleteDocs(ArrayList<NilusDataWrapper> toDelete) {
this.toDelete = toDelete; this.toDelete = toDelete;
} }
@Override @Override
public Integer runBackgroundTask(PamWorker<Integer> pamWorker) { public Integer runBackgroundTask(PamWorker<Integer> pamWorker) {
for (Detections dets : toDelete) { for (NilusDocumentWrapper dets : toDelete) {
try { try {
getTethysControl().getDbxmlConnect().deleteDocument(dets); getTethysControl().getDbxmlConnect().deleteDocument(dets.nilusObject);
} catch (TethysException e) { } catch (TethysException e) {
getTethysControl().showException(e); getTethysControl().showException(e);
} }
@ -293,13 +312,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);
} }
@ -307,36 +326,35 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
selectDataBlock(dataBlock); // force table update. selectDataBlock(dataBlock); // force table update.
} }
private void displayDocument(PDetections pDets) { private void displayDocument(NilusDataWrapper pDets) {
getTethysControl().displayDocument(Collection.Detections.collectionName(), pDets.detections.getId()); getTethysControl().displayDocument(pDets.getCollection().collectionName(), pDets.getDocumentId());
} }
private void exportDocument(PDetections pDets) { private void exportDocument(NilusDataWrapper pDets) {
getTethysControl().exportDocument(Collection.Detections.toString(), pDets.detections.getId()); getTethysControl().exportDocument(pDets.getCollection().collectionName(), pDets.getDocumentId());
} }
private PDetections detectionsForRow(int iRow) { private NilusDataWrapper detectionsForRow(int iRow) {
if (streamDetectionsSummary == null || streamDetectionsSummary.detectionsDocs == null) { if (combinedSummary == null || combinedSummary.detectionsDocs == null) {
return null; return null;
} }
if (iRow < 0 || iRow >= streamDetectionsSummary.detectionsDocs.size()) { if (iRow < 0 || iRow >= combinedSummary.detectionsDocs.size()) {
return null; return null;
} }
return streamDetectionsSummary.detectionsDocs.get(iRow); return combinedSummary.detectionsDocs.get(iRow);
} }
private class TableModel extends AbstractTableModel { private class TableModel extends AbstractTableModel {
private String[] colNames = {"Document", "Detector", "Deployment", "Effort", "Granularity", "Count", "Abstract"}; private String[] colNames = {"Document", "Detector", "Deployment", "Type", "Effort", "Granularity", "Count", "Abstract"};
@Override @Override
public int getRowCount() { public int getRowCount() {
if (streamDetectionsSummary == null || streamDetectionsSummary.detectionsDocs == null) { if (combinedSummary == null || combinedSummary.detectionsDocs == null) {
return 0; return 0;
} }
return streamDetectionsSummary.detectionsDocs.size(); return combinedSummary.detectionsDocs.size();
} }
@Override @Override
@ -351,28 +369,28 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
@Override @Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
PDetections pDets = detectionsForRow(rowIndex); NilusDataWrapper<PDetections> pDets = detectionsForRow(rowIndex);
return getValueAt(pDets, columnIndex); return getValueAt(pDets, columnIndex);
} }
private Object getValueAt(PDetections pDets, int columnIndex) { private Object getValueAt(NilusDataWrapper<PDetections> pDets, int columnIndex) {
if (pDets == null) { if (pDets == null) {
return null; return null;
} }
Detections dets = pDets.detections; // PDetections dets = pDets.nilusObject;
if (dets == null) { if (pDets == null) {
return "Error in doc"; return "Error in doc";
} }
switch (columnIndex) { switch (columnIndex) {
case 0: case 0:
return dets.getId(); return pDets.getDocumentId();
case 1: case 1:
if (pDets.dataBlock == null) { if (pDets.dataBlock == null) {
return null; return null;
} }
return pDets.dataBlock.getDataName(); return pDets.dataBlock.getDataName();
case 2: case 2:
DataSourceType dataSource = dets.getDataSource(); DataSourceType dataSource = pDets.getDataSource();
if (dataSource == null) { if (dataSource == null) {
return null; return null;
} }
@ -380,28 +398,39 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
return dataSource.getDeploymentId(); return dataSource.getDeploymentId();
} }
case 3: case 3:
XMLGregorianCalendar start = dets.getEffort().getStart(); return pDets.getCollection();
XMLGregorianCalendar stop = dets.getEffort().getEnd();
return start + " to " + stop;
case 4: case 4:
List<DetectionEffortKind> kinds = dets.getEffort().getKind(); // XMLGregorianCalendar start = dets.getEffort().getStart();
if (kinds == null) { // XMLGregorianCalendar stop = dets.getEffort().getEnd();
return null; XMLGregorianCalendar start = pDets.getEffortStart();
} XMLGregorianCalendar stop = pDets.getEffortEnd();
for (DetectionEffortKind kind : kinds) { return start + " to " + stop;
if (kind.getGranularity() != null) { case 5:
GranularityType granularity = kind.getGranularity(); Object effort = pDets.getGotObjects("getEffort");
return PDeployment.formatGranularity(granularity); if (effort instanceof DetectionEffort) {
// if (granularity != null) { DetectionEffort detectionEffort = (DetectionEffort) effort;
// return granularity.getValue(); List<DetectionEffortKind> kinds = detectionEffort.getKind();
// } if (kinds == null) {
return null;
}
for (DetectionEffortKind kind : kinds) {
if (kind.getGranularity() != null) {
GranularityType granularity = kind.getGranularity();
return PDeployment.formatGranularity(granularity);
// if (granularity != null) {
// return granularity.getValue();
// }
}
} }
} }
break; break;
case 5:
return pDets.count;
case 6: case 6:
return dets.getDescription().getAbstract(); return pDets.count;
case 7:
DescriptionType desc = pDets.getDescription();
if (desc != null) {
return desc.getAbstract();
}
} }
return null; return null;
} }

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));