mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
Global metadata
Reorganised how global meta data for a PAMGuard dataset is managed by wrapping a nilus deployment object so that PAMGuard settings can serialise and unpack the xml version of a nilus Deployment object.
This commit is contained in:
parent
bafe93e7f5
commit
7721d7f1c0
@ -54,6 +54,7 @@ import fftManager.FFTDataUnit;
|
|||||||
import generalDatabase.DBControlUnit;
|
import generalDatabase.DBControlUnit;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import metadata.MetaDataContol;
|
||||||
import Array.ArrayManager;
|
import Array.ArrayManager;
|
||||||
import PamController.command.MulticastController;
|
import PamController.command.MulticastController;
|
||||||
import PamController.command.NetworkController;
|
import PamController.command.NetworkController;
|
||||||
@ -450,6 +451,7 @@ public class PamController implements PamControllerInterface, PamSettings {
|
|||||||
System.out.println("");
|
System.out.println("");
|
||||||
System.out.println("Note - ignore the following SLF4J warn/error messages, they are not applicable to this application");
|
System.out.println("Note - ignore the following SLF4J warn/error messages, they are not applicable to this application");
|
||||||
ArrayManager.getArrayManager(); // create the array manager so that it get's it's settings
|
ArrayManager.getArrayManager(); // create the array manager so that it get's it's settings
|
||||||
|
MetaDataContol.getMetaDataControl();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for archived files and unpack automatically.
|
* Check for archived files and unpack automatically.
|
||||||
|
@ -461,10 +461,10 @@ final public class PamModel implements PamModelInterface, PamSettings {
|
|||||||
mi.setMaxNumber(1);
|
mi.setMaxNumber(1);
|
||||||
|
|
||||||
|
|
||||||
mi = PamModuleInfo.registerControlledUnit(MetaDataContol.class.getName(), MetaDataContol.unitType);
|
// mi = PamModuleInfo.registerControlledUnit(MetaDataContol.class.getName(), MetaDataContol.unitType);
|
||||||
mi.setToolTipText("Project Meta Data");
|
// mi.setToolTipText("Project Meta Data");
|
||||||
mi.setModulesMenuGroup(utilitiesGroup);
|
// mi.setModulesMenuGroup(utilitiesGroup);
|
||||||
mi.setMaxNumber(1);
|
// mi.setMaxNumber(1);
|
||||||
|
|
||||||
if (isViewer) {
|
if (isViewer) {
|
||||||
mi = PamModuleInfo.registerControlledUnit(TethysControl.class.getName(), TethysControl.defaultName);
|
mi = PamModuleInfo.registerControlledUnit(TethysControl.class.getName(), TethysControl.defaultName);
|
||||||
|
@ -1,44 +1,99 @@
|
|||||||
package metadata;
|
package metadata;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
import PamController.PamControlledUnit;
|
import PamController.PamControlledUnit;
|
||||||
|
import PamController.PamControlledUnitSettings;
|
||||||
|
import PamController.PamController;
|
||||||
|
import PamController.PamSettingManager;
|
||||||
|
import PamController.PamSettings;
|
||||||
import PamModel.parametermanager.ParameterSetManager;
|
import PamModel.parametermanager.ParameterSetManager;
|
||||||
import generalDatabase.parameterstore.ParameterDatabaseStore;
|
import generalDatabase.parameterstore.ParameterDatabaseStore;
|
||||||
import metadata.deployment.DeploymentData;
|
import metadata.deployment.DeploymentData;
|
||||||
|
|
||||||
public class MetaDataContol extends PamControlledUnit {
|
/**
|
||||||
|
* Class to handle Project MetaData. Am making this a PAMControlledUnit, but may never
|
||||||
|
* register it with the model ? Will see what advantages and disadvantages there are.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MetaDataContol extends PamControlledUnit implements PamSettings {
|
||||||
|
|
||||||
public static final String unitType = "Meta Data";
|
public static final String unitType = "Meta Data";
|
||||||
|
|
||||||
private DeploymentData deploymentData = new DeploymentData();
|
private static MetaDataContol singleInstance;
|
||||||
|
|
||||||
private ParameterSetManager<DeploymentData> deploymentSetManager;
|
private PamguardMetaData pamguardMetaData = new PamguardMetaData();
|
||||||
|
|
||||||
|
// private ParameterSetManager<DeploymentData> deploymentSetManager;
|
||||||
|
|
||||||
|
|
||||||
public MetaDataContol(String unitName) {
|
private MetaDataContol(String unitName) {
|
||||||
super(unitType, unitName);
|
super(unitType, unitName);
|
||||||
deploymentSetManager = new ParameterSetManager<DeploymentData>(deploymentData, "Deployment Data");
|
// deploymentSetManager = new ParameterSetManager<DeploymentData>(deploymentData, "Deployment Data");
|
||||||
|
PamSettingManager.getInstance().registerSettings(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Easy getter for singleton MetaData controller.
|
||||||
|
* @return meta data controller
|
||||||
|
*/
|
||||||
|
public static MetaDataContol getMetaDataControl() {
|
||||||
|
if (singleInstance == null) {
|
||||||
|
singleInstance = new MetaDataContol(unitType);
|
||||||
|
// add this line to add it to the main modules list. Then it will get menu's, etc.
|
||||||
|
PamController.getInstance().addControlledUnit(singleInstance);
|
||||||
|
}
|
||||||
|
return singleInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get PAMGuard Metadata. This contains a nilus Deployment object wrapped up
|
||||||
|
* so that it can be serialised into other PAMGuard settings.
|
||||||
|
* @return PAMGuard meta data
|
||||||
|
*/
|
||||||
|
public PamguardMetaData getMetaData() {
|
||||||
|
return pamguardMetaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the meta data object.
|
||||||
|
* @param metaData
|
||||||
|
*/
|
||||||
|
public void setMetaData(PamguardMetaData metaData) {
|
||||||
|
this.pamguardMetaData = metaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JMenuItem createFileMenu(JFrame parentFrame) {
|
public Serializable getSettingsReference() {
|
||||||
return deploymentSetManager.getMenuItem(parentFrame);
|
pamguardMetaData.checkSerialisation();
|
||||||
|
return pamguardMetaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the deploymentData
|
public long getSettingsVersion() {
|
||||||
*/
|
return PamguardMetaData.serialVersionUID;
|
||||||
public DeploymentData getDeploymentData() {
|
|
||||||
return deploymentData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @param deploymentData the deploymentData to set
|
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||||
*/
|
Object obj = pamControlledUnitSettings.getSettings();
|
||||||
public void setDeploymentData(DeploymentData deploymentData) {
|
if (obj instanceof PamguardMetaData) {
|
||||||
this.deploymentData = deploymentData;
|
pamguardMetaData = (PamguardMetaData) obj;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public JMenuItem createFileMenu(JFrame parentFrame) {
|
||||||
|
// return deploymentSetManager.getMenuItem(parentFrame);
|
||||||
|
//// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
79
src/metadata/PamguardMetaData.java
Normal file
79
src/metadata/PamguardMetaData.java
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
package metadata;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import PamUtils.LatLong;
|
||||||
|
import nilus.Deployment;
|
||||||
|
import nilus.Helper;
|
||||||
|
import tethys.niluswraps.NilusSettingsWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meta data for a PAMGuard data set. This is based around serialisable versions of
|
||||||
|
* nilus classes to be compliant with both Tethys and PAMGuard settings files. May only
|
||||||
|
* need a Deployment object, but scope for adding others / other fields if it's useful.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PamguardMetaData implements Serializable {
|
||||||
|
|
||||||
|
public static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private NilusSettingsWrapper<Deployment> deploymentWrapper;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Deployment time (used if different
|
||||||
|
// */
|
||||||
|
// private Long deploymentMillis;
|
||||||
|
//
|
||||||
|
// private Long recoverMillis;
|
||||||
|
//
|
||||||
|
// private LatLong recoverLatLong;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the deployment data
|
||||||
|
* @return nilus deployment
|
||||||
|
*/
|
||||||
|
public Deployment getDeployment() {
|
||||||
|
if (deploymentWrapper == null) {
|
||||||
|
deploymentWrapper = new NilusSettingsWrapper<>();
|
||||||
|
}
|
||||||
|
Deployment deployment = deploymentWrapper.getNilusObject(Deployment.class);
|
||||||
|
if (deployment == null) {
|
||||||
|
deployment = new Deployment();
|
||||||
|
try {
|
||||||
|
Helper.createRequiredElements(deployment);
|
||||||
|
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
deploymentWrapper.setNilusObject(deployment);
|
||||||
|
}
|
||||||
|
return deploymentWrapper.getNilusObject(Deployment.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the deployment data.
|
||||||
|
* @param deployment nilus deployment
|
||||||
|
*/
|
||||||
|
public void setDeployment(Deployment deployment) {
|
||||||
|
if (deploymentWrapper == null) {
|
||||||
|
deploymentWrapper = new NilusSettingsWrapper<>();
|
||||||
|
}
|
||||||
|
deploymentWrapper.setNilusObject(deployment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the deploymentWrapper
|
||||||
|
*/
|
||||||
|
public NilusSettingsWrapper<Deployment> getDeploymentWrapper() {
|
||||||
|
return deploymentWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkSerialisation() {
|
||||||
|
// check that all wrappers have their xml up to date.
|
||||||
|
deploymentWrapper.reSerialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -11,7 +11,8 @@ import PamUtils.LatLong;
|
|||||||
/**
|
/**
|
||||||
* Class to hold Deployment data in a form consistent with the ANSI PAM
|
* Class to hold Deployment data in a form consistent with the ANSI PAM
|
||||||
* Standard. This has been keep separate from the Tethys Interface to keep it
|
* Standard. This has been keep separate from the Tethys Interface to keep it
|
||||||
* easy to benefit from these data without using Tethys itself.
|
* easy to benefit from these data without using Tethys itself. Is also serilaisable
|
||||||
|
* which is important for storage into PAMGuard settings.
|
||||||
*
|
*
|
||||||
* @author dg50
|
* @author dg50
|
||||||
*
|
*
|
||||||
@ -108,15 +109,17 @@ public class DeploymentData implements Serializable, Cloneable, ManagedParameter
|
|||||||
this.recoveryMillis = recoveryMillis;
|
this.recoveryMillis = recoveryMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Instrument type, e.g. HARP, EAR, Popup, DMON, etc.
|
* Set data from a nilus deployment class
|
||||||
// */
|
* @param nilusDeployment
|
||||||
// private String instrumentType;
|
*/
|
||||||
//
|
public void setData(nilus.Deployment nilusDeployment) {
|
||||||
// /**
|
|
||||||
// * Instrument identifier, e.g. serial number
|
}
|
||||||
// */
|
|
||||||
// private String instrumentId;
|
public void getData(nilus.Deployment nilusDeployment) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public DeploymentData() {
|
public DeploymentData() {
|
||||||
}
|
}
|
||||||
@ -151,103 +154,103 @@ public class DeploymentData implements Serializable, Cloneable, ManagedParameter
|
|||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* @return the id
|
// * @return the id
|
||||||
*/
|
// */
|
||||||
public String getId() {
|
// public String getId() {
|
||||||
return id;
|
// return id;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @param id the id to set
|
// * @param id the id to set
|
||||||
*/
|
// */
|
||||||
public void setId(String id) {
|
// public void setId(String id) {
|
||||||
this.id = id;
|
// this.id = id;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @return the project
|
// * @return the project
|
||||||
*/
|
// */
|
||||||
public String getProject() {
|
// public String getProject() {
|
||||||
return project;
|
// return project;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @param project the project to set
|
// * @param project the project to set
|
||||||
*/
|
// */
|
||||||
public void setProject(String project) {
|
// public void setProject(String project) {
|
||||||
this.project = project;
|
// this.project = project;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @return the deploymentId
|
// * @return the deploymentId
|
||||||
*/
|
// */
|
||||||
public int getDeploymentId() {
|
// public int getDeploymentId() {
|
||||||
return deploymentId;
|
// return deploymentId;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @param deploymentId the deploymentId to set
|
// * @param deploymentId the deploymentId to set
|
||||||
*/
|
// */
|
||||||
public void setDeploymentId(int deploymentId) {
|
// public void setDeploymentId(int deploymentId) {
|
||||||
this.deploymentId = deploymentId;
|
// this.deploymentId = deploymentId;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @return the deplomentAlias
|
// * @return the deplomentAlias
|
||||||
*/
|
// */
|
||||||
public String getDeploymentAlias() {
|
// public String getDeploymentAlias() {
|
||||||
return deploymentAlias;
|
// return deploymentAlias;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @param deplomentAlias the deplomentAlias to set
|
// * @param deplomentAlias the deplomentAlias to set
|
||||||
*/
|
// */
|
||||||
public void setDeploymentAlias(String deplomentAlias) {
|
// public void setDeploymentAlias(String deplomentAlias) {
|
||||||
this.deploymentAlias = deplomentAlias;
|
// this.deploymentAlias = deplomentAlias;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @return the site
|
// * @return the site
|
||||||
*/
|
// */
|
||||||
public String getSite() {
|
// public String getSite() {
|
||||||
return site;
|
// return site;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @param site the site to set
|
// * @param site the site to set
|
||||||
*/
|
// */
|
||||||
public void setSite(String site) {
|
// public void setSite(String site) {
|
||||||
this.site = site;
|
// this.site = site;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @return the siteAliases
|
// * @return the siteAliases
|
||||||
*/
|
// */
|
||||||
public String getSiteAliases() {
|
// public String getSiteAliases() {
|
||||||
return siteAliases;
|
// return siteAliases;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @param siteAliases the siteAliases to set
|
// * @param siteAliases the siteAliases to set
|
||||||
*/
|
// */
|
||||||
public void setSiteAliases(String siteAliases) {
|
// public void setSiteAliases(String siteAliases) {
|
||||||
this.siteAliases = siteAliases;
|
// this.siteAliases = siteAliases;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @return the cruise
|
// * @return the cruise
|
||||||
*/
|
// */
|
||||||
public String getCruise() {
|
// public String getCruise() {
|
||||||
return cruise;
|
// return cruise;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @param cruise the cruise to set
|
// * @param cruise the cruise to set
|
||||||
*/
|
// */
|
||||||
public void setCruise(String cruise) {
|
// public void setCruise(String cruise) {
|
||||||
this.cruise = cruise;
|
// this.cruise = cruise;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @return the platform
|
// * @return the platform
|
||||||
|
@ -36,7 +36,9 @@ import PamView.PamTabPanel;
|
|||||||
import PamView.dialog.warn.WarnOnce;
|
import PamView.dialog.warn.WarnOnce;
|
||||||
import PamguardMVC.PamDataBlock;
|
import PamguardMVC.PamDataBlock;
|
||||||
import metadata.MetaDataContol;
|
import metadata.MetaDataContol;
|
||||||
|
import metadata.PamguardMetaData;
|
||||||
import metadata.deployment.DeploymentData;
|
import metadata.deployment.DeploymentData;
|
||||||
|
import nilus.Deployment;
|
||||||
import tethys.TethysState.StateType;
|
import tethys.TethysState.StateType;
|
||||||
import tethys.calibration.CalibrationHandler;
|
import tethys.calibration.CalibrationHandler;
|
||||||
import tethys.dbxml.DBXMLConnect;
|
import tethys.dbxml.DBXMLConnect;
|
||||||
@ -406,31 +408,23 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
|||||||
* so that the rest of PAMGuard can use it, but creating the
|
* so that the rest of PAMGuard can use it, but creating the
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DeploymentData getGlobalDeplopymentData() {
|
public Deployment getGlobalDeplopymentData() {
|
||||||
PamControlledUnit aUnit = PamController.getInstance().findControlledUnit(MetaDataContol.class, null);
|
|
||||||
// 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;
|
MetaDataContol metaControl = MetaDataContol.getMetaDataControl();
|
||||||
DeploymentData deploymentData = metaControl != null ? metaControl.getDeploymentData() : getTethysProjectData();
|
PamguardMetaData metaData = metaControl.getMetaData();
|
||||||
|
return metaData.getDeployment();
|
||||||
// deploymentData.setProject("thisIsAProject");
|
// Deployment deploymentData = metaControl != null ? metaData.getDeployment() : getTethysProjectData();
|
||||||
//// deploymentData.setPlatform("Yay a platform");
|
//
|
||||||
// deploymentData.setCruise("cruisey");
|
//// deploymentData.setProject("thisIsAProject");
|
||||||
// deploymentData.setDeploymentId(142536);
|
////// deploymentData.setPlatform("Yay a platform");
|
||||||
//// deploymentData.setInstrumentId("super instrument");
|
//// deploymentData.setCruise("cruisey");
|
||||||
// deploymentData.setSite("in the ocean somewhere");
|
//// deploymentData.setDeploymentId(142536);
|
||||||
// deploymentData.setRegion("ocean water");
|
////// deploymentData.setInstrumentId("super instrument");
|
||||||
//// deploymentData.setInstrumentType("sensor of sorts");
|
//// deploymentData.setSite("in the ocean somewhere");
|
||||||
|
//// deploymentData.setRegion("ocean water");
|
||||||
return deploymentData;
|
////// deploymentData.setInstrumentType("sensor of sorts");
|
||||||
|
//
|
||||||
|
// return deploymentData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -545,7 +539,7 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
|
|||||||
if (dataBlockSynchInfos == null) {
|
if (dataBlockSynchInfos == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DeploymentData deplData = getGlobalDeplopymentData();
|
Deployment deplData = getGlobalDeplopymentData();
|
||||||
String[] dataPrefixes = new String[dataBlockSynchInfos.size()];
|
String[] dataPrefixes = new String[dataBlockSynchInfos.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
ArrayList<PDeployment> matchedDeployments = deploymentHandler.getMatchedDeployments();
|
ArrayList<PDeployment> matchedDeployments = deploymentHandler.getMatchedDeployments();
|
||||||
|
@ -4,7 +4,6 @@ import java.text.DateFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -116,9 +115,14 @@ public class CalibrationHandler implements TethysStateObserver {
|
|||||||
* Update the list of documents associated with the selected instrument.
|
* Update the list of documents associated with the selected instrument.
|
||||||
*/
|
*/
|
||||||
private void updateDocumentsList() {
|
private void updateDocumentsList() {
|
||||||
|
|
||||||
|
calibrationsList.clear();
|
||||||
|
|
||||||
ArrayList<DocumentInfo> docsList = getArrayCalibrations();
|
ArrayList<DocumentInfo> docsList = getArrayCalibrations();
|
||||||
// now immediately read the calibrations in again.
|
// now immediately read the calibrations in again.
|
||||||
calibrationsList.clear();;
|
if (docsList == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
NilusUnpacker unpacker = new NilusUnpacker();
|
NilusUnpacker unpacker = new NilusUnpacker();
|
||||||
for (DocumentInfo aDoc : docsList) {
|
for (DocumentInfo aDoc : docsList) {
|
||||||
Queries queries = tethysControl.getDbxmlConnect().getTethysQueries();
|
Queries queries = tethysControl.getDbxmlConnect().getTethysQueries();
|
||||||
@ -182,11 +186,7 @@ public class CalibrationHandler implements TethysStateObserver {
|
|||||||
// String docName = getHydrophoneId(i);
|
// String docName = getHydrophoneId(i);
|
||||||
Calibration calDoc = createCalibrationDocument(i);
|
Calibration calDoc = createCalibrationDocument(i);
|
||||||
if (sampleCal != null) {
|
if (sampleCal != null) {
|
||||||
calDoc.setMetadataInfo(sampleCal.getMetadataInfo());
|
calDoc.setMetadataInfo(sampleCal.getMetadataInfo());
|
||||||
MetadataInfo oldMeta = calDoc.getMetadataInfo();
|
|
||||||
MetadataInfo newMeta = sampleCal.getMetadataInfo();
|
|
||||||
|
|
||||||
|
|
||||||
calDoc.setProcess(sampleCal.getProcess());
|
calDoc.setProcess(sampleCal.getProcess());
|
||||||
calDoc.setQualityAssurance(sampleCal.getQualityAssurance());
|
calDoc.setQualityAssurance(sampleCal.getQualityAssurance());
|
||||||
calDoc.setResponsibleParty(sampleCal.getResponsibleParty());
|
calDoc.setResponsibleParty(sampleCal.getResponsibleParty());
|
||||||
@ -234,7 +234,7 @@ public class CalibrationHandler implements TethysStateObserver {
|
|||||||
* Add the separate pamguard parameters to the document which are used
|
* Add the separate pamguard parameters to the document which are used
|
||||||
* to make up the overall calibration.
|
* to make up the overall calibration.
|
||||||
* @param calDoc
|
* @param calDoc
|
||||||
* @param i
|
* @param i hydrophone number
|
||||||
*/
|
*/
|
||||||
private void addParameterDetails(Calibration calDoc, int i) {
|
private void addParameterDetails(Calibration calDoc, int i) {
|
||||||
Parameters params = calDoc.getProcess().getParameters();
|
Parameters params = calDoc.getProcess().getParameters();
|
||||||
@ -518,8 +518,10 @@ public class CalibrationHandler implements TethysStateObserver {
|
|||||||
*/
|
*/
|
||||||
private ArrayList<DocumentInfo> getArrayCalibrations() {
|
private ArrayList<DocumentInfo> getArrayCalibrations() {
|
||||||
ArrayList<DocumentInfo> allCals = tethysControl.getDbxmlQueries().getCollectionDocumentList(Collection.Calibrations);
|
ArrayList<DocumentInfo> allCals = tethysControl.getDbxmlQueries().getCollectionDocumentList(Collection.Calibrations);
|
||||||
String prefix = createCalibrationDocumentRoot();
|
if (allCals == null) {
|
||||||
// find doc names that have that root.
|
return null;
|
||||||
|
}
|
||||||
|
String prefix = createCalibrationDocumentRoot(); // find doc names that have that root.
|
||||||
ArrayList<DocumentInfo> theseCals = new ArrayList<>();
|
ArrayList<DocumentInfo> theseCals = new ArrayList<>();
|
||||||
for (DocumentInfo aDoc : allCals) {
|
for (DocumentInfo aDoc : allCals) {
|
||||||
if (aDoc.getDocumentName().startsWith(prefix)) {
|
if (aDoc.getDocumentName().startsWith(prefix)) {
|
||||||
|
@ -78,9 +78,11 @@ public class CalibrationProcessCard extends CalibrationsCard {
|
|||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
processPanel.add(new JLabel("Serial number ", JLabel.RIGHT), c);
|
processPanel.add(new JLabel("Serial number ", JLabel.RIGHT), c);
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
|
c.gridwidth = 2;
|
||||||
processPanel.add(version, c);
|
processPanel.add(version, c);
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy++;
|
c.gridy++;
|
||||||
|
c.gridwidth = 1;
|
||||||
processPanel.add(new JLabel("Quality ", JLabel.RIGHT), c);
|
processPanel.add(new JLabel("Quality ", JLabel.RIGHT), c);
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
processPanel.add(qaQuality, c);
|
processPanel.add(qaQuality, c);
|
||||||
@ -88,6 +90,7 @@ public class CalibrationProcessCard extends CalibrationsCard {
|
|||||||
c.gridy++;
|
c.gridy++;
|
||||||
processPanel.add(new JLabel("QA Comment ", JLabel.RIGHT), c);
|
processPanel.add(new JLabel("QA Comment ", JLabel.RIGHT), c);
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
|
c.gridwidth = 2;
|
||||||
processPanel.add(qaComment, c);
|
processPanel.add(qaComment, c);
|
||||||
|
|
||||||
this.add(BorderLayout.CENTER, makeScrollablePanel(software, "Calibration method"));
|
this.add(BorderLayout.CENTER, makeScrollablePanel(software, "Calibration method"));
|
||||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
|
|
||||||
import org.apache.commons.beanutils.converters.BigIntegerConverter;
|
import org.apache.commons.beanutils.converters.BigIntegerConverter;
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ import binaryFileStorage.BinaryStore;
|
|||||||
import dataMap.OfflineDataMap;
|
import dataMap.OfflineDataMap;
|
||||||
import dataMap.OfflineDataMapPoint;
|
import dataMap.OfflineDataMapPoint;
|
||||||
import generalDatabase.DBControlUnit;
|
import generalDatabase.DBControlUnit;
|
||||||
|
import metadata.MetaDataContol;
|
||||||
|
import metadata.PamguardMetaData;
|
||||||
import metadata.deployment.DeploymentData;
|
import metadata.deployment.DeploymentData;
|
||||||
import nilus.Audio;
|
import nilus.Audio;
|
||||||
import nilus.ChannelInfo;
|
import nilus.ChannelInfo;
|
||||||
@ -125,7 +128,7 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
* @return true if OK
|
* @return true if OK
|
||||||
*/
|
*/
|
||||||
public boolean updateProjectDeployments() {
|
public boolean updateProjectDeployments() {
|
||||||
DeploymentData projData = tethysControl.getGlobalDeplopymentData();
|
Deployment projData = tethysControl.getGlobalDeplopymentData();
|
||||||
ArrayList<Deployment> tethysDocs = tethysControl.getDbxmlQueries().getProjectDeployments(projData.getProject(), getInstrumentId());
|
ArrayList<Deployment> tethysDocs = tethysControl.getDbxmlQueries().getProjectDeployments(projData.getProject(), getInstrumentId());
|
||||||
if (tethysDocs == null) {
|
if (tethysDocs == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -310,7 +313,7 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
selectedDeployments.get(selectedDeployments.size()-1).getRecordStop());
|
selectedDeployments.get(selectedDeployments.size()-1).getRecordStop());
|
||||||
Deployment deployment = createDeploymentDocument(freeId, onePeriod);
|
Deployment deployment = createDeploymentDocument(freeId, onePeriod);
|
||||||
// fill in a few things from here
|
// fill in a few things from here
|
||||||
DeploymentData globalMeta = getTethysControl().getGlobalDeplopymentData();
|
Deployment globalMeta = getTethysControl().getGlobalDeplopymentData();
|
||||||
deployment.setCruise(globalMeta.getCruise());
|
deployment.setCruise(globalMeta.getCruise());
|
||||||
deployment.setSite(globalMeta.getSite());
|
deployment.setSite(globalMeta.getSite());
|
||||||
if (selectedDeployments.size() > 1) {
|
if (selectedDeployments.size() > 1) {
|
||||||
@ -344,6 +347,8 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
private void exportSeparateDeployments(ArrayList<RecordingPeriod> selectedDeployments) {
|
private void exportSeparateDeployments(ArrayList<RecordingPeriod> selectedDeployments) {
|
||||||
|
|
||||||
int freeId = getTethysControl().getDeploymentHandler().getFirstFreeDeploymentId();
|
int freeId = getTethysControl().getDeploymentHandler().getFirstFreeDeploymentId();
|
||||||
|
// fill in a few things from here
|
||||||
|
Deployment globalMeta = getTethysControl().getGlobalDeplopymentData();
|
||||||
for (int i = 0; i < selectedDeployments.size(); i++) {
|
for (int i = 0; i < selectedDeployments.size(); i++) {
|
||||||
RecordingPeriod recordPeriod = selectedDeployments.get(i);
|
RecordingPeriod recordPeriod = selectedDeployments.get(i);
|
||||||
PDeployment exDeploymnet = recordPeriod.getMatchedTethysDeployment();
|
PDeployment exDeploymnet = recordPeriod.getMatchedTethysDeployment();
|
||||||
@ -355,8 +360,6 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
if (deployment == null) {
|
if (deployment == null) {
|
||||||
deployment = createDeploymentDocument(freeId++, recordPeriod);
|
deployment = createDeploymentDocument(freeId++, recordPeriod);
|
||||||
}
|
}
|
||||||
// fill in a few things from here
|
|
||||||
DeploymentData globalMeta = getTethysControl().getGlobalDeplopymentData();
|
|
||||||
deployment.setCruise(globalMeta.getCruise());
|
deployment.setCruise(globalMeta.getCruise());
|
||||||
deployment.setSite(globalMeta.getSite());
|
deployment.setSite(globalMeta.getSite());
|
||||||
// also need to sort out track data here, etc.
|
// also need to sort out track data here, etc.
|
||||||
@ -740,7 +743,7 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
DeploymentData globalDeplData = tethysControl.getGlobalDeplopymentData();
|
// Deployment globalDeplData = tethysControl.getGlobalDeplopymentData();
|
||||||
TethysExportParams exportParams = tethysControl.getTethysExportParams();
|
TethysExportParams exportParams = tethysControl.getTethysExportParams();
|
||||||
String id = String.format("%s_%d", exportParams.getDatasetName(), i);
|
String id = String.format("%s_%d", exportParams.getDatasetName(), i);
|
||||||
deployment.setId(id);
|
deployment.setId(id);
|
||||||
@ -903,7 +906,8 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// MetaDataContol metaControl = (MetaDataContol) aUnit;
|
// MetaDataContol metaControl = (MetaDataContol) aUnit;
|
||||||
DeploymentData deploymentData = tethysControl.getGlobalDeplopymentData();
|
PamguardMetaData metaData = MetaDataContol.getMetaDataControl().getMetaData();
|
||||||
|
Deployment deploymentData = tethysControl.getGlobalDeplopymentData();
|
||||||
deployment.setProject(deploymentData.getProject());
|
deployment.setProject(deploymentData.getProject());
|
||||||
deployment.setDeploymentAlias(deploymentData.getDeploymentAlias());
|
deployment.setDeploymentAlias(deploymentData.getDeploymentAlias());
|
||||||
deployment.setSite(deploymentData.getSite());
|
deployment.setSite(deploymentData.getSite());
|
||||||
@ -919,18 +923,19 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
deployment.setInstrument(instrument);
|
deployment.setInstrument(instrument);
|
||||||
|
|
||||||
// overwrite the default deployment and recovery times if there is non null data
|
// overwrite the default deployment and recovery times if there is non null data
|
||||||
Long depMillis = deploymentData.getDeploymentMillis();
|
XMLGregorianCalendar depTime = deploymentData.getDeploymentDetails().getTimeStamp();
|
||||||
if (depMillis != null) {
|
if (depTime != null) {
|
||||||
deployment.getDeploymentDetails().setTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(depMillis));
|
deployment.getDeploymentDetails().setTimeStamp(depTime);
|
||||||
}
|
}
|
||||||
Long recMillis = deploymentData.getRecoveryMillis();
|
XMLGregorianCalendar recMillis = deploymentData.getRecoveryDetails().getTimeStamp();
|
||||||
if (recMillis != null) {
|
if (recMillis != null) {
|
||||||
deployment.getRecoveryDetails().setTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recMillis));
|
deployment.getRecoveryDetails().setTimeStamp(recMillis);
|
||||||
}
|
}
|
||||||
LatLong recLatLong = deploymentData.getRecoverLatLong();
|
double recLat = deploymentData.getRecoveryDetails().getLatitude();
|
||||||
if (recLatLong != null) {
|
double recLong = deploymentData.getRecoveryDetails().getLongitude();
|
||||||
deployment.getRecoveryDetails().setLatitude(recLatLong.getLatitude());
|
if (recLat != 0 & recLong != 0.) {
|
||||||
deployment.getRecoveryDetails().setLongitude(PamUtils.constrainedAngle(recLatLong.getLongitude()));
|
deployment.getRecoveryDetails().setLatitude(recLat);
|
||||||
|
deployment.getRecoveryDetails().setLongitude(PamUtils.constrainedAngle(recLong));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -951,7 +956,7 @@ public class DeploymentHandler implements TethysStateObserver {
|
|||||||
*/
|
*/
|
||||||
public String canExportDeployments() {
|
public String canExportDeployments() {
|
||||||
|
|
||||||
DeploymentData globalDeplData = tethysControl.getGlobalDeplopymentData();
|
Deployment globalDeplData = tethysControl.getGlobalDeplopymentData();
|
||||||
if (globalDeplData.getProject() == null) {
|
if (globalDeplData.getProject() == null) {
|
||||||
return "You must set a project name";
|
return "You must set a project name";
|
||||||
}
|
}
|
||||||
|
196
src/tethys/niluswraps/NilusSettingsWrapper.java
Normal file
196
src/tethys/niluswraps/NilusSettingsWrapper.java
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
package tethys.niluswraps;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.io.StringReader;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
|
import nilus.MarshalXML;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to wrap up a nilus object so that it can be saved using Java serialization.
|
||||||
|
* This is basically saving the xml as a String, since all nilus objects are NOT
|
||||||
|
* serializable, but should make it (relatively) straight forward to save nilus
|
||||||
|
* objects into PAMGuard settings files.
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NilusSettingsWrapper<T extends Object> implements Serializable, Cloneable {
|
||||||
|
|
||||||
|
public static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String xmlString;
|
||||||
|
|
||||||
|
private transient T nilusObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a nilus object. Have to pass the class type in as
|
||||||
|
* an argument, since Class isn't serializable, so can't be stored
|
||||||
|
* with the object - which contains nothing but a String, which can be safely serialised.
|
||||||
|
* @param nilusClass
|
||||||
|
* @return nilus object.
|
||||||
|
*/
|
||||||
|
public T getNilusObject(Class nilusClass) {
|
||||||
|
if (nilusObject == null) {
|
||||||
|
nilusObject = unpackNilusObject(nilusClass);
|
||||||
|
}
|
||||||
|
return nilusObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
private T unpackNilusObject(Class nilusClass) {
|
||||||
|
Document doc = getDocument();
|
||||||
|
if (doc == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Try to turn the string into a document.
|
||||||
|
*/
|
||||||
|
NilusUnpacker unpacker = new NilusUnpacker();
|
||||||
|
T unpacked = (T) unpacker.unpackDocument(doc, nilusClass);
|
||||||
|
|
||||||
|
return unpacked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the nilus object. This marshals the nilus object
|
||||||
|
* into xml and saves the data as an intetnal xml string which
|
||||||
|
* can be safely serialized.
|
||||||
|
* @param nilusObject nilus object.
|
||||||
|
* @return true if it was marshalled OK.
|
||||||
|
*/
|
||||||
|
public boolean setNilusObject(T nilusObject) {
|
||||||
|
// use the marshaller to create a Tethys type document, then
|
||||||
|
// get it as a string.
|
||||||
|
this.nilusObject = nilusObject;
|
||||||
|
// and convert immediately to the XML string.
|
||||||
|
return packNilusObject(nilusObject);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the nilus object. This marshals the nilus object
|
||||||
|
* into xml and saves the data as an intetnal xml string which
|
||||||
|
* can be safely serialized.
|
||||||
|
* @param nilusObject nilus object.
|
||||||
|
* @return true if it was marshalled OK.
|
||||||
|
*/
|
||||||
|
private boolean packNilusObject(T nilusObject) {
|
||||||
|
// use the marshaller to create a Tethys type document, then
|
||||||
|
// get it as a string.
|
||||||
|
// and convert immediately to XML string.
|
||||||
|
if (nilusObject == null) {
|
||||||
|
xmlString = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
PrintWriter printWriter = new PrintWriter(bos);
|
||||||
|
MarshalXML marshaler;
|
||||||
|
try {
|
||||||
|
marshaler = new MarshalXML();
|
||||||
|
marshaler.marshal(nilusObject, bos);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
xmlString = bos.toString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repack the object. May want to do this before serializing.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean repackNilusObject() {
|
||||||
|
return packNilusObject(nilusObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a document from the internal xml String representation.
|
||||||
|
* @return xml document
|
||||||
|
*/
|
||||||
|
public Document getDocument() {
|
||||||
|
if(xmlString == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
//API to obtain DOM Document instance
|
||||||
|
DocumentBuilder builder = null;
|
||||||
|
try {
|
||||||
|
//Create DocumentBuilder with default configuration
|
||||||
|
builder = factory.newDocumentBuilder();
|
||||||
|
//Parse the content to Document object
|
||||||
|
Document doc = builder.parse(new InputSource(new StringReader(xmlString)));
|
||||||
|
return doc;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the xmlString
|
||||||
|
*/
|
||||||
|
public String getXmlString() {
|
||||||
|
return xmlString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repack the nilus object. Call this just before settings are
|
||||||
|
* saved to ensure everything is up to date since this probably won't
|
||||||
|
* have happened if changes were made within existing nilus objects
|
||||||
|
* and setNilusObject was never called.
|
||||||
|
*/
|
||||||
|
public void reSerialise() {
|
||||||
|
packNilusObject(nilusObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private Class<?> getNilusClass() throws NoSuchMethodException, SecurityException {
|
||||||
|
// Method method = this.getClass().getMethod("getNilusObject", null);
|
||||||
|
// Class<?> retClass = GenericTypeResolver.resolveReturnType(method, this.getClass());
|
||||||
|
//
|
||||||
|
// return retClass;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
//
|
||||||
|
// Deployment deployment = new Deployment();
|
||||||
|
// try {
|
||||||
|
// Helper.createRequiredElements(deployment);
|
||||||
|
// } catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// deployment.setCruise("Test cruise");
|
||||||
|
// deployment.setDeploymentId(111);
|
||||||
|
// deployment.setProject("Tethys Development");
|
||||||
|
// DescriptionType desc = deployment.getDescription();
|
||||||
|
// if (desc == null) {
|
||||||
|
// desc = new DescriptionType();
|
||||||
|
// deployment.setDescription(desc);
|
||||||
|
// }
|
||||||
|
// desc.setAbstract("Deployment Abstract");
|
||||||
|
//
|
||||||
|
// NilusSettingsWrapper<Deployment> wrapper = new NilusSettingsWrapper<>();
|
||||||
|
//
|
||||||
|
// wrapper.setNilusObject(deployment);
|
||||||
|
//
|
||||||
|
// System.out.println(wrapper.xmlString);
|
||||||
|
//
|
||||||
|
// Deployment newDeployment = wrapper.getNilusObject(Deployment.class);
|
||||||
|
//
|
||||||
|
// // now warp the new object again and print that.
|
||||||
|
// newDeployment.setDeploymentId(newDeployment.getDeploymentId()*2);
|
||||||
|
// wrapper.setNilusObject(newDeployment);
|
||||||
|
// System.out.println("********************************************");
|
||||||
|
// System.out.println(wrapper.xmlString);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
@ -210,26 +210,26 @@ public class TethysExporter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* find Deployment data. This is stored in a separate PAMGuard module, which may
|
// * find Deployment data. This is stored in a separate PAMGuard module, which may
|
||||||
* not be present.
|
// * not be present.
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public DeploymentData findDeploymentData() {
|
// public DeploymentData findDeploymentData() {
|
||||||
/**
|
// /**
|
||||||
* What to do if this isn't present or is incomplete ? Should we be showing this
|
// * What to do if this isn't present or is incomplete ? Should we be showing this
|
||||||
* in the main export dialog at some point ? More a Q for when we make a nicer
|
// * in the main export dialog at some point ? More a Q for when we make a nicer
|
||||||
* UI later in the project.
|
// * UI later in the project.
|
||||||
*/
|
// */
|
||||||
MetaDataContol metaControl = (MetaDataContol) PamController.getInstance()
|
// MetaDataContol metaControl = (MetaDataContol) PamController.getInstance()
|
||||||
.findControlledUnit(MetaDataContol.unitType);
|
// .findControlledUnit(MetaDataContol.unitType);
|
||||||
if (metaControl == null) {
|
// if (metaControl == null) {
|
||||||
return null;
|
// return null;
|
||||||
} else {
|
// } else {
|
||||||
return metaControl.getDeploymentData();
|
// return metaControl.getDeploymentData();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public SnapshotGeometry findArrayGeometrey() {
|
public SnapshotGeometry findArrayGeometrey() {
|
||||||
/*
|
/*
|
||||||
|
@ -132,7 +132,7 @@ public class DeploymentExportPanel extends TethysGUIPanel implements DeploymentT
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void copyDeploymentData(Deployment deployment) {
|
private void copyDeploymentData(Deployment deployment) {
|
||||||
DeploymentData globalMeta = getTethysControl().getGlobalDeplopymentData();
|
Deployment globalMeta = getTethysControl().getGlobalDeplopymentData();
|
||||||
globalMeta.setSite(deployment.getSite());
|
globalMeta.setSite(deployment.getSite());
|
||||||
globalMeta.setCruise(deployment.getCruise());
|
globalMeta.setCruise(deployment.getCruise());
|
||||||
globalMeta.setRegion(deployment.getRegion());
|
globalMeta.setRegion(deployment.getRegion());
|
||||||
@ -189,7 +189,7 @@ public class DeploymentExportPanel extends TethysGUIPanel implements DeploymentT
|
|||||||
* Set the parms from internally stored data.
|
* Set the parms from internally stored data.
|
||||||
*/
|
*/
|
||||||
private void setInternal() {
|
private void setInternal() {
|
||||||
DeploymentData globalMeta = getTethysControl().getGlobalDeplopymentData();
|
Deployment globalMeta = getTethysControl().getGlobalDeplopymentData();
|
||||||
site.setText(globalMeta.getSite());
|
site.setText(globalMeta.getSite());
|
||||||
cruise.setText(globalMeta.getCruise());
|
cruise.setText(globalMeta.getCruise());
|
||||||
// region.setText(globalMeta.getRegion());
|
// region.setText(globalMeta.getRegion());
|
||||||
|
@ -10,7 +10,9 @@ import javax.swing.JTextField;
|
|||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
import PamView.dialog.PamGridBagContraints;
|
import PamView.dialog.PamGridBagContraints;
|
||||||
|
import metadata.PamguardMetaData;
|
||||||
import metadata.deployment.DeploymentData;
|
import metadata.deployment.DeploymentData;
|
||||||
|
import nilus.Deployment;
|
||||||
import tethys.TethysControl;
|
import tethys.TethysControl;
|
||||||
|
|
||||||
public class NewProjectDialog extends PamView.dialog.PamDialog {
|
public class NewProjectDialog extends PamView.dialog.PamDialog {
|
||||||
@ -23,7 +25,7 @@ public class NewProjectDialog extends PamView.dialog.PamDialog {
|
|||||||
|
|
||||||
private JTextField projectRegion;
|
private JTextField projectRegion;
|
||||||
|
|
||||||
private DeploymentData deploymentData;
|
private PamguardMetaData metaData;
|
||||||
|
|
||||||
private NewProjectDialog(Window parentFrame, TethysControl tethysControl) {
|
private NewProjectDialog(Window parentFrame, TethysControl tethysControl) {
|
||||||
super(parentFrame, "New Project", false);
|
super(parentFrame, "New Project", false);
|
||||||
@ -45,32 +47,33 @@ public class NewProjectDialog extends PamView.dialog.PamDialog {
|
|||||||
setDialogComponent(mainPanel);
|
setDialogComponent(mainPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DeploymentData showDialog(Window parent, TethysControl tethysControl, DeploymentData deploymentData) {
|
public static PamguardMetaData showDialog(Window parent, TethysControl tethysControl, PamguardMetaData metaData) {
|
||||||
if (singleInstance == null) {
|
if (singleInstance == null) {
|
||||||
singleInstance = new NewProjectDialog(parent, tethysControl);
|
singleInstance = new NewProjectDialog(parent, tethysControl);
|
||||||
}
|
}
|
||||||
singleInstance.setParams(deploymentData);
|
singleInstance.setParams(metaData);
|
||||||
singleInstance.setVisible(true);
|
singleInstance.setVisible(true);
|
||||||
return singleInstance.deploymentData;
|
return singleInstance.metaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setParams(DeploymentData deploymentData) {
|
private void setParams(PamguardMetaData deploymentData) {
|
||||||
if (deploymentData == null) {
|
if (deploymentData == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.deploymentData = deploymentData;
|
this.metaData = deploymentData;
|
||||||
projectName.setText(deploymentData.getProject());
|
projectName.setText(deploymentData.getDeployment().getProject());
|
||||||
projectRegion.setText(deploymentData.getRegion());
|
projectRegion.setText(deploymentData.getDeployment().getRegion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getParams() {
|
public boolean getParams() {
|
||||||
if (deploymentData == null) {
|
if (metaData == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
deploymentData.setProject(projectName.getText());
|
Deployment deployment = metaData.getDeployment();
|
||||||
deploymentData.setRegion(projectRegion.getText());
|
deployment.setProject(projectName.getText());
|
||||||
if (deploymentData.getProject() == null || deploymentData.getProject().length() == 0) {
|
deployment.setRegion(projectRegion.getText());
|
||||||
|
if (deployment.getProject() == null || deployment.getProject().length() == 0) {
|
||||||
return showWarning("you must specify a project name");
|
return showWarning("you must specify a project name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ public class NewProjectDialog extends PamView.dialog.PamDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelButtonPressed() {
|
public void cancelButtonPressed() {
|
||||||
deploymentData = null;
|
metaData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,6 +22,8 @@ import PamView.dialog.ScrollingPamLabel;
|
|||||||
import PamView.dialog.SettingsButton;
|
import PamView.dialog.SettingsButton;
|
||||||
import PamView.panel.PamPanel;
|
import PamView.panel.PamPanel;
|
||||||
import PamView.panel.WestAlignedPanel;
|
import PamView.panel.WestAlignedPanel;
|
||||||
|
import metadata.MetaDataContol;
|
||||||
|
import metadata.PamguardMetaData;
|
||||||
import metadata.deployment.DeploymentData;
|
import metadata.deployment.DeploymentData;
|
||||||
import nilus.Deployment;
|
import nilus.Deployment;
|
||||||
import pamViewFX.fxNodes.PamComboBox;
|
import pamViewFX.fxNodes.PamComboBox;
|
||||||
@ -185,9 +187,10 @@ public class TethysConnectionPanel extends TethysGUIPanel {
|
|||||||
* Action from new project button
|
* Action from new project button
|
||||||
*/
|
*/
|
||||||
protected void createNewProject() {
|
protected void createNewProject() {
|
||||||
DeploymentData pamDeploymentData = getTethysControl().getGlobalDeplopymentData();
|
PamguardMetaData pamDeploymentData = MetaDataContol.getMetaDataControl().getMetaData();
|
||||||
pamDeploymentData = NewProjectDialog.showDialog(getTethysControl().getGuiFrame(), getTethysControl(), pamDeploymentData);
|
pamDeploymentData = NewProjectDialog.showDialog(getTethysControl().getGuiFrame(), getTethysControl(), pamDeploymentData);
|
||||||
if (pamDeploymentData != null) {
|
if (pamDeploymentData != null) {
|
||||||
|
MetaDataContol.getMetaDataControl().setMetaData(pamDeploymentData);
|
||||||
updateProjectList();
|
updateProjectList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,8 +200,10 @@ public class TethysConnectionPanel extends TethysGUIPanel {
|
|||||||
if (project == null) {
|
if (project == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DeploymentData globData = getTethysControl().getGlobalDeplopymentData();
|
PamguardMetaData pamMetaData = MetaDataContol.getMetaDataControl().getMetaData();
|
||||||
globData.setProject(project);
|
Deployment globDeployment = pamMetaData.getDeployment();
|
||||||
|
// DeploymentData globData = getTethysControl().getGlobalDeplopymentData();
|
||||||
|
globDeployment.setProject(project);
|
||||||
getTethysControl().getDeploymentHandler().updateProjectDeployments();
|
getTethysControl().getDeploymentHandler().updateProjectDeployments();
|
||||||
/*
|
/*
|
||||||
* if there are existing deployment data, then copy the info to the
|
* if there are existing deployment data, then copy the info to the
|
||||||
@ -207,8 +212,8 @@ 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).deployment;
|
||||||
globData.setProject(dep.getProject());
|
globDeployment.setProject(dep.getProject());
|
||||||
globData.setRegion(dep.getRegion());
|
globDeployment.setRegion(dep.getRegion());
|
||||||
getTethysControl().sendStateUpdate(new TethysState(TethysState.StateType.NEWPROJECTSELECTION));
|
getTethysControl().sendStateUpdate(new TethysState(TethysState.StateType.NEWPROJECTSELECTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,9 +276,10 @@ public class TethysConnectionPanel extends TethysGUIPanel {
|
|||||||
* list.
|
* list.
|
||||||
*/
|
*/
|
||||||
String localProjName = null;
|
String localProjName = null;
|
||||||
DeploymentData pamDeploymentData = getTethysControl().getGlobalDeplopymentData();
|
PamguardMetaData pamMetaData = MetaDataContol.getMetaDataControl().getMetaData();
|
||||||
if (pamDeploymentData != null && pamDeploymentData.getProject() != null) {
|
Deployment globDeployment = pamMetaData.getDeployment();
|
||||||
localProjName = pamDeploymentData.getProject();
|
if (globDeployment != null && globDeployment.getProject() != null) {
|
||||||
|
localProjName = globDeployment.getProject();
|
||||||
if (localProjName.length() == 0) {
|
if (localProjName.length() == 0) {
|
||||||
localProjName = null;
|
localProjName = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user