required field update and post to tethys fxn updates

fill in required data for deployments/detections and minor tweaks to post to tethys fxn
This commit is contained in:
kbolaughlin 2023-03-15 16:38:13 -07:00
parent d96ace1ca2
commit 140af14cba
4 changed files with 48 additions and 5 deletions

View File

@ -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";

View File

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

View File

@ -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<Detections> 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<DetectionEffortKind> 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;
}

View File

@ -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;
}