From 140af14cbac345e43123223528a3cc0e7d2d4bb7 Mon Sep 17 00:00:00 2001 From: kbolaughlin Date: Wed, 15 Mar 2023 16:38:13 -0700 Subject: [PATCH] required field update and post to tethys fxn updates fill in required data for deployments/detections and minor tweaks to post to tethys fxn --- src/tethys/dbxml/DBXMLConnect.java | 2 +- src/tethys/deployment/DeploymentHandler.java | 24 +++++++++++++++++-- src/tethys/detection/DetectionsHandler.java | 25 +++++++++++++++++++- src/tethys/pamdata/AutoTethysProvider.java | 2 +- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/tethys/dbxml/DBXMLConnect.java b/src/tethys/dbxml/DBXMLConnect.java index 7b7439a5..88eb042a 100644 --- a/src/tethys/dbxml/DBXMLConnect.java +++ b/src/tethys/dbxml/DBXMLConnect.java @@ -84,7 +84,7 @@ public class DBXMLConnect { switch(className) { case "nilus.Deployment": return "Deployments"; - case "nilus.Detection": + case "nilus.Detections": return "Detections"; case "nilus.Calibration": return "Calibrations"; diff --git a/src/tethys/deployment/DeploymentHandler.java b/src/tethys/deployment/DeploymentHandler.java index 7ed1ab54..fdda96e1 100644 --- a/src/tethys/deployment/DeploymentHandler.java +++ b/src/tethys/deployment/DeploymentHandler.java @@ -22,6 +22,7 @@ import Array.ThreadingHydrophoneLocator; import PamController.PamControlledUnit; import PamController.PamController; import PamguardMVC.PamDataBlock; +import javafx.scene.chart.PieChart.Data; import metadata.MetaDataContol; import metadata.deployment.DeploymentData; import nilus.Audio; @@ -283,13 +284,25 @@ public class DeploymentHandler { public Deployment createDeploymentDocument(int i, DeploymentRecoveryPair drd) { Deployment deployment = new Deployment(); + try { + nilus.Helper.createRequiredElements(deployment); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } String id = String.format("%d", i); deployment.setId(id); deployment.setDeploymentId(i); deployment.setDeploymentDetails(drd.deploymentDetails); deployment.setRecoveryDetails(drd.recoveryDetails); - TethysLocationFuncs.getTrackAndPositionData(deployment); + TethysLocationFuncs.getTrackAndPositionData(deployment); getProjectData(deployment); @@ -317,9 +330,16 @@ public class DeploymentHandler { */ private boolean getProjectData(Deployment deployment) { PamControlledUnit aUnit = PamController.getInstance().findControlledUnit(MetaDataContol.class, null); - if (aUnit instanceof MetaDataContol == false) { + if (aUnit instanceof MetaDataContol == false || true) { + deployment.setProject("thisIsAProject"); + deployment.setPlatform("Yay a platform"); + Instrument instrument = new Instrument(); + instrument.setType("machiney"); + instrument.setInstrumentId("12345555"); + deployment.setInstrument(instrument); return false; } + MetaDataContol metaControl = (MetaDataContol) aUnit; DeploymentData deploymentData = metaControl.getDeploymentData(); deployment.setProject(deploymentData.getProject()); diff --git a/src/tethys/detection/DetectionsHandler.java b/src/tethys/detection/DetectionsHandler.java index e5e9934b..002f920d 100644 --- a/src/tethys/detection/DetectionsHandler.java +++ b/src/tethys/detection/DetectionsHandler.java @@ -1,5 +1,6 @@ package tethys.detection; +import java.math.BigInteger; import java.util.ArrayList; import java.util.List; @@ -166,7 +167,10 @@ public class DetectionsHandler { * We should now have a fully populated Detections object, so write it to the database * using functions in DBXMLConnect */ - //tethysControl.getDbxmlConnect().postToTethys(detectionList); // call whatever you need to call in here to write the Detections. + ArrayList detectionDocuments = new ArrayList(); + detectionDocuments.add(detections); + + tethysControl.getDbxmlConnect().postToTethys(detectionDocuments); // call whatever you need to call in here to write the Detections. return true; @@ -185,6 +189,25 @@ public class DetectionsHandler { effort.setEnd(TethysTimeFuncs.xmlGregCalFromMillis(effortEnd)); // effort.set // no setter for DetectionEffortKind List effortKinds = effort.getKind(); + DetectionEffortKind kind = new DetectionEffortKind(); + try { + nilus.Helper.createRequiredElements(kind); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + kind.getSpeciesId().setValue(BigInteger.valueOf(180537)); + kind.getGranularity().setValue(nilus.GranularityEnumType.CALL); + + effortKinds.add(kind); + return effort; } diff --git a/src/tethys/pamdata/AutoTethysProvider.java b/src/tethys/pamdata/AutoTethysProvider.java index 3f752d55..82952665 100644 --- a/src/tethys/pamdata/AutoTethysProvider.java +++ b/src/tethys/pamdata/AutoTethysProvider.java @@ -246,7 +246,7 @@ public class AutoTethysProvider implements TethysDataProvider { private SpeciesIDType getSpeciesIdType() { SpeciesIDType species = new SpeciesIDType(); -// species.s + species.setValue(BigInteger.valueOf(180537)); return species; }