mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 14:42:27 +00:00
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:
parent
9eee7434de
commit
82adc06e3d
@ -6,8 +6,9 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</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>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
|
@ -1,16 +1,16 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
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.compliance=21
|
||||
org.eclipse.jdt.core.compiler.compliance=1.3
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=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.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=21
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.3
|
||||
|
2
pom.xml
2
pom.xml
@ -888,7 +888,7 @@
|
||||
<dependency>
|
||||
<groupId>tethys.org</groupId>
|
||||
<artifactId>nilus</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
4
repo/tethys/org/nilus/3.1/_remote.repositories
Normal file
4
repo/tethys/org/nilus/3.1/_remote.repositories
Normal 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>=
|
BIN
repo/tethys/org/nilus/3.1/nilus-3.1-javadoc.jar
Normal file
BIN
repo/tethys/org/nilus/3.1/nilus-3.1-javadoc.jar
Normal file
Binary file not shown.
BIN
repo/tethys/org/nilus/3.1/nilus-3.1.jar
Normal file
BIN
repo/tethys/org/nilus/3.1/nilus-3.1.jar
Normal file
Binary file not shown.
9
repo/tethys/org/nilus/3.1/nilus-3.1.pom
Normal file
9
repo/tethys/org/nilus/3.1/nilus-3.1.pom
Normal 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>
|
@ -306,6 +306,9 @@ abstract public class PamDialog extends JDialog {
|
||||
* put the dialog near the mouse location.
|
||||
*/
|
||||
public void moveToMouseLocation() {
|
||||
if (MouseInfo.getPointerInfo() == null) {
|
||||
return;
|
||||
}
|
||||
Point mouse = MouseInfo.getPointerInfo().getLocation();
|
||||
moveToLocation(mouse);
|
||||
}
|
||||
|
@ -2929,7 +2929,7 @@ InternalFrameListener, DisplayPanelContainer, SpectrogramParametersUser, PamSett
|
||||
String name = spectrogramDisplay.getDataSelectorName(panelId);
|
||||
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;
|
||||
}
|
||||
directDrawProjector.setDataSelector(dataSelector);
|
||||
|
@ -89,7 +89,7 @@ public enum Collection {
|
||||
return Calibrations;
|
||||
case "nilus.Ensemble":
|
||||
return Ensembles;
|
||||
case "nilus.Localization":
|
||||
case "nilus.Localize":
|
||||
return Localizations;
|
||||
case "nilus.SpeciesAbbreviation":
|
||||
return SpeciesAbbreviations;
|
||||
|
@ -49,6 +49,7 @@ import tethys.dbxml.TethysException;
|
||||
import tethys.dbxml.TethysQueryException;
|
||||
import tethys.deployment.DeploymentHandler;
|
||||
import tethys.detection.DetectionsHandler;
|
||||
import tethys.localization.LocalizationHandler;
|
||||
import tethys.niluswraps.PDeployment;
|
||||
import tethys.output.DatablockSynchInfo;
|
||||
import tethys.output.TethysExportParams;
|
||||
@ -91,6 +92,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
private DeploymentHandler deploymentHandler;
|
||||
private DetectionsHandler detectionsHandler;
|
||||
private CalibrationHandler calibrationHandler;
|
||||
private LocalizationHandler localizationHandler;
|
||||
|
||||
private ITISFunctions itisFunctions;
|
||||
|
||||
@ -102,6 +104,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
deploymentHandler = new DeploymentHandler(this);
|
||||
detectionsHandler = new DetectionsHandler(this);
|
||||
calibrationHandler = new CalibrationHandler(this);
|
||||
localizationHandler = new LocalizationHandler(this);
|
||||
|
||||
serverCheckTimer = new Timer(10000, new ActionListener() {
|
||||
@Override
|
||||
@ -569,8 +572,8 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
int detectionCount = 0;
|
||||
int documentCount = 0;
|
||||
for (PDeployment pDepl : matchedDeployments) {
|
||||
detectionCount += dbxmlQueries.countData(synchInfo.getDataBlock(), pDepl.deployment.getId());
|
||||
ArrayList<String> detectionsNames = getDbxmlQueries().getDetectionsDocuments(synchInfo.getDataBlock(), pDepl.deployment.getId());
|
||||
detectionCount += dbxmlQueries.countData(synchInfo.getDataBlock(), pDepl.getDocumentId());
|
||||
ArrayList<String> detectionsNames = getDbxmlQueries().getDetectionsDocuments(synchInfo.getDataBlock(), pDepl.getDocumentId());
|
||||
if (detectionsNames != null) {
|
||||
documentCount += detectionsNames.size();
|
||||
}
|
||||
@ -595,6 +598,13 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
||||
return detectionsHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the localizationHandler
|
||||
*/
|
||||
public LocalizationHandler getLocalizationHandler() {
|
||||
return localizationHandler;
|
||||
}
|
||||
|
||||
public void showException(TethysException tethysException) {
|
||||
String title = tethysException.getMessage();
|
||||
StackTraceElement[] stack = tethysException.getStackTrace();
|
||||
|
@ -26,14 +26,14 @@ public class TethysMenuActions {
|
||||
}
|
||||
|
||||
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());
|
||||
// for (String detName : detDocNames) {
|
||||
// System.out.println(detName);
|
||||
// }
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
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() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -47,7 +47,7 @@ public class TethysMenuActions {
|
||||
menu.add(menuItem);
|
||||
}
|
||||
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);
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@ -65,6 +65,6 @@ public class TethysMenuActions {
|
||||
}
|
||||
|
||||
protected void deleteDeployment(PDeployment pDeployment) throws TethysException {
|
||||
tethysControl.getDbxmlConnect().deleteDeployment(pDeployment.deployment.getId());
|
||||
tethysControl.getDbxmlConnect().deleteDeployment(pDeployment.nilusObject.getId());
|
||||
}
|
||||
}
|
||||
|
@ -420,10 +420,24 @@ public class CalibrationHandler extends CollectionHandler implements TethysState
|
||||
calibration.setSensitivityDBFS(fullScale);
|
||||
}
|
||||
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> db = frs.getDB();
|
||||
// if (hz == null) {
|
||||
//
|
||||
// }
|
||||
if (hz != null && db != null) {
|
||||
hz.add(Double.valueOf(0));
|
||||
db.add(Double.valueOf(hSens+preampGain));
|
||||
}
|
||||
|
||||
if (NilusChecker.isEmpty(calibration.getResponsibleParty())) {
|
||||
calibration.setResponsibleParty(null);
|
||||
|
@ -515,7 +515,7 @@ C:\Users\dg50\AppData\Local\Temp\PAMGuardTethys\20080311_2DSimplex_0.xmlnot: 0 b
|
||||
* @param nilusObject
|
||||
* @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;
|
||||
Class nilusClass = nilusObject.getClass();
|
||||
Method getId;
|
||||
|
@ -32,6 +32,7 @@ import nilus.Detections;
|
||||
import nilus.GranularityEnumType;
|
||||
import nilus.GranularityType;
|
||||
import nilus.Helper;
|
||||
import nilus.Localize;
|
||||
import tethys.Collection;
|
||||
import tethys.DocumentInfo;
|
||||
import tethys.TethysControl;
|
||||
@ -561,6 +562,63 @@ public class DBXMLQueries {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -727,6 +785,38 @@ public class DBXMLQueries {
|
||||
}
|
||||
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.
|
||||
@ -1024,5 +1114,108 @@ public class DBXMLQueries {
|
||||
// TODO Auto-generated method stub
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ public class DeploymentHandler extends CollectionHandler implements TethysStateO
|
||||
PDeployment exDeploymnet = onePeriod.getMatchedTethysDeployment();
|
||||
try {
|
||||
if (exDeploymnet != null) {
|
||||
deployment.setId(exDeploymnet.deployment.getId());
|
||||
deployment.setId(exDeploymnet.nilusObject.getId());
|
||||
dbxmlConnect.updateDocument(deployment);
|
||||
}
|
||||
else {
|
||||
@ -522,7 +522,7 @@ public class DeploymentHandler extends CollectionHandler implements TethysStateO
|
||||
String id = String.format("%s_%d", exportParams.getDatasetName(), i);
|
||||
if (exDeploymnet != null) {
|
||||
deployment = createDeploymentDocument(freeId, recordPeriod, id);
|
||||
deployment.setId(exDeploymnet.deployment.getId());
|
||||
deployment.setId(exDeploymnet.nilusObject.getId());
|
||||
}
|
||||
if (deployment == null) {
|
||||
deployment = createDeploymentDocument(freeId++, recordPeriod, id);
|
||||
@ -646,7 +646,7 @@ public class DeploymentHandler extends CollectionHandler implements TethysStateO
|
||||
}
|
||||
ArrayList<PInstrument> instruments = new ArrayList<>();
|
||||
for (PDeployment aDepl : projectDeployments) {
|
||||
Instrument intr = aDepl.deployment.getInstrument();
|
||||
Instrument intr = aDepl.nilusObject.getInstrument();
|
||||
if (intr == null) {
|
||||
continue;
|
||||
}
|
||||
@ -764,7 +764,7 @@ public class DeploymentHandler extends CollectionHandler implements TethysStateO
|
||||
int firstFree = 0;
|
||||
if (projectDeployments != null) {
|
||||
for (PDeployment dep : projectDeployments) {
|
||||
firstFree = Math.max(firstFree, dep.deployment.getDeploymentId()+1);
|
||||
firstFree = Math.max(firstFree, dep.nilusObject.getDeploymentId()+1);
|
||||
}
|
||||
}
|
||||
return firstFree;
|
||||
|
@ -12,6 +12,8 @@ import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamController;
|
||||
import PamController.PamguardVersionInfo;
|
||||
import PamDetection.LocContents;
|
||||
import PamDetection.LocalisationInfo;
|
||||
import PamModel.PamPluginInterface;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.dialog.PamDialog;
|
||||
@ -26,6 +28,8 @@ import dataMap.OfflineDataMap;
|
||||
import dataMap.OfflineDataMapPoint;
|
||||
import nilus.AlgorithmType;
|
||||
import nilus.AlgorithmType.SupportSoftware;
|
||||
import nilus.Localize.Effort;
|
||||
import nilus.Localize.Effort.CoordinateReferenceSystem;
|
||||
import nilus.Localize.Localizations;
|
||||
import nilus.DataSourceType;
|
||||
import nilus.Deployment;
|
||||
@ -36,6 +40,7 @@ import nilus.DetectionGroup;
|
||||
import nilus.Detections;
|
||||
import nilus.GranularityEnumType;
|
||||
import nilus.Helper;
|
||||
import nilus.Localize;
|
||||
import tethys.Collection;
|
||||
import tethys.CollectionHandler;
|
||||
import tethys.TethysControl;
|
||||
@ -43,6 +48,11 @@ import tethys.TethysTimeFuncs;
|
||||
import tethys.dbxml.DBXMLConnect;
|
||||
import tethys.dbxml.TethysException;
|
||||
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.PDetections;
|
||||
import tethys.output.StreamExportParams;
|
||||
@ -85,7 +95,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
* this data set (not the entire project).
|
||||
* @param dataBlock
|
||||
*/
|
||||
public StreamDetectionsSummary getStreamDetections(PamDataBlock dataBlock) {
|
||||
public StreamDetectionsSummary<NilusDataWrapper<PDetections>> getStreamDetections(PamDataBlock dataBlock) {
|
||||
ArrayList<PDeployment> deployments = tethysControl.getDeploymentHandler().getMatchedDeployments();
|
||||
return getStreamDetections(dataBlock, deployments);
|
||||
}
|
||||
@ -97,12 +107,12 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
* @param deployments
|
||||
* @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.
|
||||
|
||||
ArrayList<PDetections> detectionsDocs = new ArrayList<>();
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
@ -117,6 +127,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
return new StreamDetectionsSummary(detectionsDocs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Detection Effort part of a Detections document
|
||||
* @param pDeployment
|
||||
@ -126,12 +137,12 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
*/
|
||||
private DetectionEffort getDetectorEffort(PDeployment pDeployment, PamDataBlock dataBlock, StreamExportParams exportParams) {
|
||||
DetectionEffort effort = new DetectionEffort();
|
||||
Deployment deployment = pDeployment.deployment;
|
||||
Deployment deployment = pDeployment.nilusObject;
|
||||
Long effortStart = pDeployment.getAudioStart();
|
||||
Long effortEnd = pDeployment.getAudioEnd();
|
||||
effort.setStart(TethysTimeFuncs.xmlGregCalFromMillis(effortStart));
|
||||
effort.setEnd(TethysTimeFuncs.xmlGregCalFromMillis(effortEnd));
|
||||
// effort.set // no setter for DetectionEffortKind
|
||||
// effort.set // no setter for DetectionEffortKind
|
||||
List<DetectionEffortKind> effortKinds = effort.getKind();
|
||||
|
||||
TethysDataProvider dataProvider = dataBlock.getTethysDataProvider(tethysControl);
|
||||
@ -202,7 +213,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
* @return PAMGuard version
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@ -256,7 +267,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
public void cancelExport() {
|
||||
activeExport = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Round a bin start so that it's aligned correctly with
|
||||
* day starts.
|
||||
@ -284,7 +295,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
TethysExportParams exportParams = tethysControl.getTethysExportParams();
|
||||
DeploymentHandler depHandler = tethysControl.getDeploymentHandler();
|
||||
ArrayList<PDeployment> deployments = depHandler.getMatchedDeployments();
|
||||
// Detections currentDetections = null;
|
||||
// Detections currentDetections = null;
|
||||
OfflineDataMap dataMap = dataBlock.getPrimaryDataMap();
|
||||
DataSelector dataSelector = dataBlock.getDataSelector(tethysControl.getDataSelectName(), false);
|
||||
int totalCount = dataMap.getDataCount();
|
||||
@ -315,7 +326,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
// export everything in that deployment.
|
||||
// need to loop through all map points in this interval.
|
||||
List<OfflineDataMapPoint> mapPoints = dataMap.getMapPoints();
|
||||
|
||||
|
||||
for (OfflineDataMapPoint mapPoint : mapPoints) {
|
||||
if (!activeExport) {
|
||||
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
|
||||
@ -346,24 +357,24 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
if (dets != null) {
|
||||
exportCount+=dets.length;
|
||||
documentCount+=dets.length;
|
||||
|
||||
|
||||
if (exportCount % 100 == 0) {
|
||||
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||
exportObserver.update(prog);
|
||||
}
|
||||
}
|
||||
// Detection det = dataProvider.createDetection(dataUnit, exportParams, streamExportParams);
|
||||
// exportCount++;
|
||||
// documentCount++;
|
||||
// onEffort.getDetection().add(det);
|
||||
// Detection det = dataProvider.createDetection(dataUnit, exportParams, streamExportParams);
|
||||
// exportCount++;
|
||||
// documentCount++;
|
||||
// onEffort.getDetection().add(det);
|
||||
lastUnitTime = dataUnit.getTimeMilliseconds();
|
||||
}
|
||||
doneMapPoints++;
|
||||
prog = new DetectionExportProgress(deployment, null,totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||
exportObserver.update(prog);
|
||||
|
||||
|
||||
if (viewerLoadPolicy == ViewerLoadPolicy.LOAD_ALWAYS_EVERYTHING) {
|
||||
break;
|
||||
}
|
||||
@ -375,14 +386,14 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
if (dets != null) {
|
||||
exportCount += dets.length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return exportCount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export detections and localisations in all deployments for this PAMGuard dataset.
|
||||
* @param dataBlock
|
||||
@ -399,14 +410,15 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
DBXMLConnect dbxmlConnect = tethysControl.getDbxmlConnect();
|
||||
DeploymentHandler depHandler = tethysControl.getDeploymentHandler();
|
||||
ArrayList<PDeployment> deployments = depHandler.getMatchedDeployments();
|
||||
|
||||
|
||||
/*
|
||||
* The main documents for both dets and locs.
|
||||
*/
|
||||
Detections detectionsDocument = null;
|
||||
Localizations localisationsDocument = null;
|
||||
Localize localiseDocument = null;
|
||||
DetectionGroup onEffortDetections = null;
|
||||
|
||||
Localizations localisations = null;
|
||||
|
||||
OfflineDataMap dataMap = dataBlock.getPrimaryDataMap();
|
||||
DataSelector dataSelector = dataBlock.getDataSelector(tethysControl.getDataSelectName(), false);
|
||||
int totalCount = dataMap.getDataCount();
|
||||
@ -431,6 +443,8 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_COUNTING);
|
||||
exportObserver.update(prog);
|
||||
granularityHandler.prepare(deployment.getAudioStart());
|
||||
|
||||
List<Detection> detectionList;
|
||||
|
||||
// export everything in that deployment.
|
||||
// need to loop through all map points in this interval.
|
||||
@ -448,14 +462,25 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
detectionsDocument = startDetectionsDocument(deployment, dataBlock, streamExportParams);
|
||||
detectionsDocument.getEffort().setStart(TethysTimeFuncs.xmlGregCalFromMillis(deployment.getAudioStart()));
|
||||
onEffortDetections = detectionsDocument.getOnEffort();
|
||||
detectionList = onEffortDetections.getDetection();
|
||||
// if {detectionList == null) {
|
||||
// onEffortDetections.
|
||||
// }
|
||||
}
|
||||
else {
|
||||
onEffortDetections = null;
|
||||
detectionList = null;
|
||||
}
|
||||
if (localisationsDocument == null && streamExportParams.exportLocalisations) {
|
||||
localisationsDocument = startLocalisationDocument(deployment, dataBlock, streamExportParams);
|
||||
if (localiseDocument == null && streamExportParams.exportLocalisations) {
|
||||
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()) {
|
||||
continue;
|
||||
}
|
||||
@ -476,10 +501,14 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
exportCount++;
|
||||
documentCount++;
|
||||
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) {
|
||||
prog = new DetectionExportProgress(deployment, detectionsDocument, totalMapPoints, doneMapPoints,
|
||||
lastUnitTime, totalCount, exportCount, skipCount, DetectionExportProgress.STATE_GATHERING);
|
||||
@ -508,6 +537,17 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
}
|
||||
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) {
|
||||
@ -543,6 +583,27 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
}
|
||||
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,
|
||||
@ -550,20 +611,6 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
exportObserver.update(prog);
|
||||
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>
|
||||
@ -584,7 +631,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
}
|
||||
TethysDataProvider dataProvider = dataBlock.getTethysDataProvider(tethysControl);
|
||||
|
||||
String prefix = deployment.deployment.getId() + "_" + dataProvider.getDetectionsName();
|
||||
String prefix = deployment.nilusObject.getId() + "_" + dataProvider.getDetectionsName();
|
||||
String fullId = "";
|
||||
/*
|
||||
* 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.setDescription(dataProvider.getDescription(deployment, tethysExportParams));
|
||||
// detections.setDescription(dataProvider.getDescription(deployment, tethysExportParams));
|
||||
detections.setDescription(exportParams.getNilusDetectionDescription());
|
||||
DataSourceType dataSource = new DataSourceType();
|
||||
dataSource.setDeploymentId(deployment.deployment.getId());
|
||||
// dataSource.setEnsembleId(""); ToDo
|
||||
dataSource.setDeploymentId(deployment.nilusObject.getId());
|
||||
// dataSource.setEnsembleId(""); ToDo
|
||||
detections.setDataSource(dataSource);
|
||||
AlgorithmType algorithm = detections.getAlgorithm();
|
||||
|
||||
if (dataProvider != null) {
|
||||
algorithm = dataProvider.getAlgorithm();
|
||||
// detections.setAlgorithm(algorithm);
|
||||
// detections.setAlgorithm(algorithm);
|
||||
}
|
||||
algorithm.setMethod(getMethodString(dataBlock));
|
||||
algorithm.setSoftware(getSoftwareString(dataBlock));
|
||||
@ -624,6 +671,141 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
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
|
||||
* important in the event that a document got too big and has to be restarted.
|
||||
@ -633,7 +815,12 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
private void closeDetectionsDocument(Detections detections, Long 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>
|
||||
* 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;
|
||||
}
|
||||
|
||||
private boolean checkLocaliseDocument(Localize localiseDocument, GranularityHandler granularityHandler) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Worker thread for exporting detections.
|
||||
* 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 {
|
||||
Integer ans = null;
|
||||
try {
|
||||
// int count = countDetections(dataBlock, exportParams, exportObserver);
|
||||
// if (activeExport == false) {
|
||||
// return 0;
|
||||
// }
|
||||
// String msg = String.format("Do you want to go ahead and output %d %s detections to Tethys?",
|
||||
// count, exportParams.granularity);
|
||||
// int doit = WarnOnce.showWarning("Tethys Detections Export", msg, WarnOnce.OK_CANCEL_OPTION);
|
||||
// if (doit == WarnOnce.OK_OPTION) {
|
||||
ans = exportDetections(dataBlock, exportParams, this);
|
||||
// }
|
||||
// int count = countDetections(dataBlock, exportParams, exportObserver);
|
||||
// if (activeExport == false) {
|
||||
// return 0;
|
||||
// }
|
||||
// String msg = String.format("Do you want to go ahead and output %d %s detections to Tethys?",
|
||||
// count, exportParams.granularity);
|
||||
// int doit = WarnOnce.showWarning("Tethys Detections Export", msg, WarnOnce.OK_CANCEL_OPTION);
|
||||
// if (doit == WarnOnce.OK_OPTION) {
|
||||
ans = exportDetections(dataBlock, exportParams, this);
|
||||
// }
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -728,7 +920,7 @@ public class DetectionsHandler extends CollectionHandler {
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
// this.
|
||||
// this.
|
||||
DetectionExportProgress prog = new DetectionExportProgress(null, null, 0, 0, 0, 0, 0, 0, DetectionExportProgress.STATE_COMPLETE);
|
||||
tethysControl.exportedDetections(dataBlock);
|
||||
exportObserver.update(prog);
|
||||
|
@ -2,6 +2,7 @@ package tethys.detection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import tethys.niluswraps.NilusDataWrapper;
|
||||
import tethys.niluswraps.PDetections;
|
||||
|
||||
/**
|
||||
@ -10,11 +11,11 @@ import tethys.niluswraps.PDetections;
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
11
src/tethys/localization/CoordinateName.java
Normal file
11
src/tethys/localization/CoordinateName.java
Normal 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;
|
||||
}
|
@ -1,17 +1,78 @@
|
||||
package tethys.localization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import nilus.CylindricalCoordinateType;
|
||||
import nilus.LocalizationType;
|
||||
import nilus.Localize;
|
||||
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() {
|
||||
// LocalizationType lt = new LocalizationType();
|
||||
// CylindricalCoordinateType cct = new CylindricalCoordinateType();
|
||||
//// cct.set
|
||||
// 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);
|
||||
}
|
||||
|
||||
public LocalizationType getLoc() {
|
||||
LocalizationType lt = new LocalizationType();
|
||||
CylindricalCoordinateType cct = new CylindricalCoordinateType();
|
||||
// cct.set
|
||||
CoordinateReferenceSystem cr;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
10
src/tethys/localization/LocalizationSubType.java
Normal file
10
src/tethys/localization/LocalizationSubType.java
Normal 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;
|
||||
}
|
11
src/tethys/localization/LocalizationType.java
Normal file
11
src/tethys/localization/LocalizationType.java
Normal 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;
|
||||
}
|
14
src/tethys/localization/PLocalization.java
Normal file
14
src/tethys/localization/PLocalization.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
11
src/tethys/localization/ReferenceFrame.java
Normal file
11
src/tethys/localization/ReferenceFrame.java
Normal 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;
|
||||
}
|
10
src/tethys/localization/TimeReference.java
Normal file
10
src/tethys/localization/TimeReference.java
Normal 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;
|
||||
}
|
56
src/tethys/niluswraps/NilusDataWrapper.java
Normal file
56
src/tethys/niluswraps/NilusDataWrapper.java
Normal 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");
|
||||
}
|
||||
|
||||
}
|
108
src/tethys/niluswraps/NilusDocumentWrapper.java
Normal file
108
src/tethys/niluswraps/NilusDocumentWrapper.java
Normal 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());
|
||||
}
|
||||
|
||||
}
|
@ -12,18 +12,16 @@ import tethys.deployment.RecordingPeriod;
|
||||
* @author dg50
|
||||
*
|
||||
*/
|
||||
public class PDeployment {
|
||||
|
||||
public Deployment deployment;
|
||||
public class PDeployment extends NilusDocumentWrapper<Deployment>{
|
||||
|
||||
private RecordingPeriod matchedPAMGaurdPeriod;
|
||||
|
||||
public PDeployment(Deployment deployment) {
|
||||
super();
|
||||
this.deployment = deployment;
|
||||
super(deployment);
|
||||
}
|
||||
|
||||
public Long getAudioStart() {
|
||||
DeploymentRecoveryDetails detail = deployment.getDeploymentDetails();
|
||||
DeploymentRecoveryDetails detail = nilusObject.getDeploymentDetails();
|
||||
if (detail == null || detail.getAudioTimeStamp() == null) {
|
||||
return null;
|
||||
}
|
||||
@ -31,7 +29,7 @@ public class PDeployment {
|
||||
}
|
||||
|
||||
public Long getAudioEnd() {
|
||||
DeploymentRecoveryDetails detail = deployment.getRecoveryDetails();
|
||||
DeploymentRecoveryDetails detail = nilusObject.getRecoveryDetails();
|
||||
if (detail == null || detail.getAudioTimeStamp() == null) {
|
||||
return null;
|
||||
}
|
||||
@ -40,7 +38,7 @@ public class PDeployment {
|
||||
|
||||
@Override
|
||||
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()));
|
||||
}
|
||||
|
||||
@ -55,10 +53,10 @@ public class PDeployment {
|
||||
public String getShortDescription() {
|
||||
Long audioStart = getAudioStart();
|
||||
if (audioStart == null) {
|
||||
return String.format("%s %s", deployment.getId(), "unknown start");
|
||||
return String.format("%s %s", nilusObject.getId(), "unknown start");
|
||||
}
|
||||
else {
|
||||
return String.format("%s %s", deployment.getId(), PamCalendar.formatDBDate(getAudioStart()));
|
||||
return String.format("%s %s", nilusObject.getId(), PamCalendar.formatDBDate(getAudioStart()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,25 +3,12 @@ package tethys.niluswraps;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import nilus.Detections;
|
||||
|
||||
public class PDetections {
|
||||
|
||||
public Detections detections;
|
||||
|
||||
public Integer count;
|
||||
|
||||
public PDeployment deployment;
|
||||
|
||||
public PamDataBlock dataBlock;
|
||||
public class PDetections extends NilusDataWrapper<Detections> {
|
||||
|
||||
public PDetections(Detections detections, PamDataBlock dataBlock, PDeployment deployment, Integer count) {
|
||||
super();
|
||||
this.dataBlock = dataBlock;
|
||||
this.detections = detections;
|
||||
this.deployment = deployment;
|
||||
this.count = count;
|
||||
super(detections, dataBlock, deployment, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -27,14 +27,20 @@ import PamView.dialog.warn.WarnOnce;
|
||||
import PamView.tables.SwingTableColumnWidths;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import nilus.DataSourceType;
|
||||
import nilus.DescriptionType;
|
||||
import nilus.DetectionEffort;
|
||||
import nilus.DetectionEffortKind;
|
||||
import nilus.Detections;
|
||||
import nilus.GranularityType;
|
||||
import nilus.Localize.Effort;
|
||||
import tethys.Collection;
|
||||
import tethys.TethysControl;
|
||||
import tethys.TethysState;
|
||||
import tethys.dbxml.TethysException;
|
||||
import tethys.detection.StreamDetectionsSummary;
|
||||
import tethys.localization.PLocalization;
|
||||
import tethys.niluswraps.NilusDataWrapper;
|
||||
import tethys.niluswraps.NilusDocumentWrapper;
|
||||
import tethys.niluswraps.PDeployment;
|
||||
import tethys.niluswraps.PDetections;
|
||||
|
||||
@ -57,12 +63,16 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
|
||||
private PamDataBlock dataBlock;
|
||||
|
||||
private StreamDetectionsSummary streamDetectionsSummary;
|
||||
// private StreamDetectionsSummary<NilusDataWrapper<PDetections>> streamDetectionsSummary;
|
||||
//
|
||||
// private StreamDetectionsSummary<NilusDataWrapper<PLocalization>> streamLocalisationsSummary;
|
||||
|
||||
private StreamDetectionsSummary<NilusDataWrapper> combinedSummary;
|
||||
|
||||
public DatablockDetectionsPanel(TethysControl tethysControl) {
|
||||
super(tethysControl);
|
||||
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"));
|
||||
|
||||
tableModel = new TableModel();
|
||||
@ -144,7 +154,16 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@ -183,7 +202,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
}
|
||||
int[] rows = table.getSelectedRows();
|
||||
|
||||
PDetections pDets = detectionsForRow(row);
|
||||
NilusDataWrapper pDets = detectionsForRow(row);
|
||||
if (pDets == null) {
|
||||
return;
|
||||
}
|
||||
@ -193,7 +212,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
JMenuItem menuItem;
|
||||
if (rows.length == 1) {
|
||||
|
||||
menuItem = new JMenuItem("Display document " + pDets.detections.getId());
|
||||
menuItem = new JMenuItem("Display document " + pDets.getDocumentId());
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -202,7 +221,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
});
|
||||
popMenu.add(menuItem);
|
||||
|
||||
menuItem = new JMenuItem("Export document " + pDets.detections.getId());
|
||||
menuItem = new JMenuItem("Export document " + pDets.getDocumentId());
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -212,11 +231,11 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
popMenu.add(menuItem);
|
||||
|
||||
popMenu.addSeparator();
|
||||
menuItem = new JMenuItem("Delete document " + pDets.detections.getId());
|
||||
menuItem = new JMenuItem("Delete document " + pDets.getDocumentId());
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
deleteDocument(pDets);
|
||||
// deleteDocument(pDets);
|
||||
}
|
||||
});
|
||||
popMenu.add(menuItem);
|
||||
@ -247,15 +266,15 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Detections> toDelete = new ArrayList();
|
||||
ArrayList<NilusDataWrapper> toDelete = new ArrayList();
|
||||
|
||||
for (int i = 0; i < rows.length; i++) {
|
||||
int row = rows[i];
|
||||
PDetections pDets = detectionsForRow(row);
|
||||
NilusDataWrapper<PDetections> pDets = detectionsForRow(row);
|
||||
if (pDets == null) {
|
||||
continue;
|
||||
}
|
||||
toDelete.add(pDets.detections);
|
||||
toDelete.add(pDets);
|
||||
}
|
||||
DeleteDocs dd = new DeleteDocs(toDelete);
|
||||
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 ArrayList<Detections> toDelete;
|
||||
private ArrayList<NilusDataWrapper> toDelete;
|
||||
|
||||
public DeleteDocs(ArrayList<Detections> toDelete) {
|
||||
public DeleteDocs(ArrayList<NilusDataWrapper> toDelete) {
|
||||
this.toDelete = toDelete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer runBackgroundTask(PamWorker<Integer> pamWorker) {
|
||||
for (Detections dets : toDelete) {
|
||||
for (NilusDocumentWrapper dets : toDelete) {
|
||||
try {
|
||||
|
||||
getTethysControl().getDbxmlConnect().deleteDocument(dets);
|
||||
getTethysControl().getDbxmlConnect().deleteDocument(dets.nilusObject);
|
||||
} catch (TethysException e) {
|
||||
getTethysControl().showException(e);
|
||||
}
|
||||
@ -293,13 +312,13 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
}
|
||||
|
||||
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);
|
||||
if (ans != WarnOnce.OK_OPTION) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getTethysControl().getDbxmlConnect().deleteDocument(pDets.detections);
|
||||
getTethysControl().getDbxmlConnect().deleteDocument(pDets.nilusObject);
|
||||
} catch (TethysException e) {
|
||||
getTethysControl().showException(e);
|
||||
}
|
||||
@ -307,36 +326,35 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
selectDataBlock(dataBlock); // force table update.
|
||||
}
|
||||
|
||||
private void displayDocument(PDetections pDets) {
|
||||
getTethysControl().displayDocument(Collection.Detections.collectionName(), pDets.detections.getId());
|
||||
private void displayDocument(NilusDataWrapper pDets) {
|
||||
getTethysControl().displayDocument(pDets.getCollection().collectionName(), pDets.getDocumentId());
|
||||
|
||||
}
|
||||
|
||||
private void exportDocument(PDetections pDets) {
|
||||
getTethysControl().exportDocument(Collection.Detections.toString(), pDets.detections.getId());
|
||||
|
||||
private void exportDocument(NilusDataWrapper pDets) {
|
||||
getTethysControl().exportDocument(pDets.getCollection().collectionName(), pDets.getDocumentId());
|
||||
}
|
||||
|
||||
private PDetections detectionsForRow(int iRow) {
|
||||
if (streamDetectionsSummary == null || streamDetectionsSummary.detectionsDocs == null) {
|
||||
private NilusDataWrapper detectionsForRow(int iRow) {
|
||||
if (combinedSummary == null || combinedSummary.detectionsDocs == null) {
|
||||
return null;
|
||||
}
|
||||
if (iRow < 0 || iRow >= streamDetectionsSummary.detectionsDocs.size()) {
|
||||
if (iRow < 0 || iRow >= combinedSummary.detectionsDocs.size()) {
|
||||
return null;
|
||||
}
|
||||
return streamDetectionsSummary.detectionsDocs.get(iRow);
|
||||
return combinedSummary.detectionsDocs.get(iRow);
|
||||
}
|
||||
|
||||
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
|
||||
public int getRowCount() {
|
||||
if (streamDetectionsSummary == null || streamDetectionsSummary.detectionsDocs == null) {
|
||||
if (combinedSummary == null || combinedSummary.detectionsDocs == null) {
|
||||
return 0;
|
||||
}
|
||||
return streamDetectionsSummary.detectionsDocs.size();
|
||||
return combinedSummary.detectionsDocs.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -351,28 +369,28 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
PDetections pDets = detectionsForRow(rowIndex);
|
||||
NilusDataWrapper<PDetections> pDets = detectionsForRow(rowIndex);
|
||||
return getValueAt(pDets, columnIndex);
|
||||
}
|
||||
|
||||
private Object getValueAt(PDetections pDets, int columnIndex) {
|
||||
private Object getValueAt(NilusDataWrapper<PDetections> pDets, int columnIndex) {
|
||||
if (pDets == null) {
|
||||
return null;
|
||||
}
|
||||
Detections dets = pDets.detections;
|
||||
if (dets == null) {
|
||||
// PDetections dets = pDets.nilusObject;
|
||||
if (pDets == null) {
|
||||
return "Error in doc";
|
||||
}
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return dets.getId();
|
||||
return pDets.getDocumentId();
|
||||
case 1:
|
||||
if (pDets.dataBlock == null) {
|
||||
return null;
|
||||
}
|
||||
return pDets.dataBlock.getDataName();
|
||||
case 2:
|
||||
DataSourceType dataSource = dets.getDataSource();
|
||||
DataSourceType dataSource = pDets.getDataSource();
|
||||
if (dataSource == null) {
|
||||
return null;
|
||||
}
|
||||
@ -380,28 +398,39 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
|
||||
return dataSource.getDeploymentId();
|
||||
}
|
||||
case 3:
|
||||
XMLGregorianCalendar start = dets.getEffort().getStart();
|
||||
XMLGregorianCalendar stop = dets.getEffort().getEnd();
|
||||
return start + " to " + stop;
|
||||
return pDets.getCollection();
|
||||
case 4:
|
||||
List<DetectionEffortKind> kinds = dets.getEffort().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();
|
||||
// }
|
||||
// XMLGregorianCalendar start = dets.getEffort().getStart();
|
||||
// XMLGregorianCalendar stop = dets.getEffort().getEnd();
|
||||
XMLGregorianCalendar start = pDets.getEffortStart();
|
||||
XMLGregorianCalendar stop = pDets.getEffortEnd();
|
||||
return start + " to " + stop;
|
||||
case 5:
|
||||
Object effort = pDets.getGotObjects("getEffort");
|
||||
if (effort instanceof DetectionEffort) {
|
||||
DetectionEffort detectionEffort = (DetectionEffort) effort;
|
||||
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;
|
||||
case 5:
|
||||
return pDets.count;
|
||||
case 6:
|
||||
return dets.getDescription().getAbstract();
|
||||
return pDets.count;
|
||||
case 7:
|
||||
DescriptionType desc = pDets.getDescription();
|
||||
if (desc != null) {
|
||||
return desc.getAbstract();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -124,10 +124,10 @@ public class DeploymentExportPanel extends TethysGUIPanel implements DeploymentT
|
||||
return;
|
||||
}
|
||||
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);
|
||||
if (ans == WarnOnce.OK_OPTION) {
|
||||
copyDeploymentData(deployment.deployment);
|
||||
copyDeploymentData(deployment.nilusObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,14 +229,14 @@ private RecordingList masterList;
|
||||
return;
|
||||
}
|
||||
for (PDeployment depl : matchedDeployments) {
|
||||
if (depl.deployment == null) {
|
||||
if (depl.nilusObject == null) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (checkDetections(depl.deployment) == false) {
|
||||
if (checkDetections(depl.nilusObject) == false) {
|
||||
continue;
|
||||
}
|
||||
boolean gone = getTethysControl().getDbxmlConnect().deleteDocument(depl.deployment);
|
||||
boolean gone = getTethysControl().getDbxmlConnect().deleteDocument(depl.nilusObject);
|
||||
} catch (TethysException e) {
|
||||
getTethysControl().showException(e);
|
||||
}
|
||||
@ -279,7 +279,7 @@ private RecordingList masterList;
|
||||
}
|
||||
|
||||
protected void deleteDeployment(PDeployment pDeployment) {
|
||||
Deployment dep = pDeployment.deployment;
|
||||
Deployment dep = pDeployment.nilusObject;
|
||||
if (dep == null) {
|
||||
return;
|
||||
}
|
||||
@ -300,11 +300,11 @@ private RecordingList masterList;
|
||||
}
|
||||
|
||||
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) {
|
||||
getTethysControl().displayDocument(Collection.Deployments.collectionName(), pDeployment.deployment.getId());
|
||||
getTethysControl().displayDocument(Collection.Deployments.collectionName(), pDeployment.nilusObject.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -443,7 +443,7 @@ private RecordingList masterList;
|
||||
if (deployment == null) {
|
||||
return null;
|
||||
}
|
||||
return deployment.deployment.getId();
|
||||
return deployment.nilusObject.getId();
|
||||
// return makeDeplString(period, deployment);
|
||||
case 8:
|
||||
if (deployment == null) {
|
||||
|
@ -226,7 +226,7 @@ public class TethysConnectionPanel extends TethysGUIPanel {
|
||||
*/
|
||||
ArrayList<PDeployment> projectDeployments = getTethysControl().getDeploymentHandler().getProjectDeployments();
|
||||
if (projectDeployments != null && projectDeployments.size() > 0) {
|
||||
Deployment dep = projectDeployments.get(0).deployment;
|
||||
Deployment dep = projectDeployments.get(0).nilusObject;
|
||||
globDeployment.setProject(dep.getProject());
|
||||
globDeployment.setRegion(dep.getRegion());
|
||||
getTethysControl().sendStateUpdate(new TethysState(TethysState.StateType.NEWPROJECTSELECTION));
|
||||
|
Loading…
Reference in New Issue
Block a user