Tethys working again

And a bit more playing around with metadata handling for Deploymnet
documents
This commit is contained in:
Douglas Gillespie 2023-05-01 18:55:35 +01:00
parent 379cd61afa
commit 8a9719b425
18 changed files with 476 additions and 36 deletions

View File

@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Java 17"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -17,7 +17,7 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/TethysJavaClient"/>
<classpathentry combineaccessrules="false" kind="src" path="/nilusxmlgenerator"/> <classpathentry combineaccessrules="false" kind="src" path="/nilusxmlgenerator"/>
<classpathentry combineaccessrules="false" kind="src" path="/TethysJavaClient"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -158,7 +158,7 @@ public class Hydrophone implements Serializable, Cloneable, ManagedParameters {
return sensitivity; return sensitivity;
} }
protected void setSensitivity(double sensitivity) { public void setSensitivity(double sensitivity) {
this.sensitivity = sensitivity; this.sensitivity = sensitivity;
} }
@ -364,7 +364,7 @@ public class Hydrophone implements Serializable, Cloneable, ManagedParameters {
/** /**
* @param preampGain The preampGain to set. * @param preampGain The preampGain to set.
*/ */
protected void setPreampGain(double preampGain) { public void setPreampGain(double preampGain) {
this.preampGain = preampGain; this.preampGain = preampGain;
} }

View File

@ -46,8 +46,6 @@ import fftManager.PamFFTControl;
import group3dlocaliser.Group3DLocaliserControl; import group3dlocaliser.Group3DLocaliserControl;
import metadata.MetaDataContol; import metadata.MetaDataContol;
import meygenturbine.MeygenTurbine; import meygenturbine.MeygenTurbine;
import networkTransfer.receive.BuoyStatusDataUnit;
import networkTransfer.receive.NetworkReceiver;
import printscreen.PrintScreenControl; import printscreen.PrintScreenControl;
import rockBlock.RockBlockControl; import rockBlock.RockBlockControl;
import tethys.TethysControl; import tethys.TethysControl;
@ -1098,6 +1096,7 @@ final public class PamModel implements PamModelInterface, PamSettings {
* PamModel ! * PamModel !
*/ */
// pluginList.add(new MorlaisWP1aPlugin());
// Load up whatever default classloader was used to create this class. Must use the same classloader // Load up whatever default classloader was used to create this class. Must use the same classloader
// for all plugins, or else we will not be able to create proper dependencies between them or be able // for all plugins, or else we will not be able to create proper dependencies between them or be able

View File

@ -10,7 +10,7 @@ import PamUtils.PamCalendar;
public class SqliteSQLTypes extends SQLTypes { public class SqliteSQLTypes extends SQLTypes {
protected static final SQLiteConfig.DateClass dateClass = SQLiteConfig.DateClass.TEXT; public static final SQLiteConfig.DateClass dateClass = SQLiteConfig.DateClass.TEXT;
@Override @Override
public String typeToString(int sqlType, int length, boolean counter) { public String typeToString(int sqlType, int length, boolean counter) {

View File

@ -5,6 +5,7 @@ import java.io.Serializable;
import PamModel.parametermanager.FieldNotFoundException; import PamModel.parametermanager.FieldNotFoundException;
import PamModel.parametermanager.ManagedParameters; import PamModel.parametermanager.ManagedParameters;
import PamModel.parametermanager.PamParameterSet; import PamModel.parametermanager.PamParameterSet;
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
@ -66,6 +67,46 @@ public class DeploymentData implements Serializable, Cloneable, ManagedParameter
*/ */
private String region; private String region;
/**
* time of instrument deployment (different to recording start);
*/
private Long deploymentMillis;
/**
* time of actual recovery (different to recording end);
*/
private Long recoveryMillis;
private LatLong recoverLatLong;
/**
* @return the deploymentMillis
*/
public Long getDeploymentMillis() {
return deploymentMillis;
}
/**
* @param deploymentMillis the deploymentMillis to set
*/
public void setDeploymentMillis(Long deploymentMillis) {
this.deploymentMillis = deploymentMillis;
}
/**
* @return the recoveryMillis
*/
public Long getRecoveryMillis() {
return recoveryMillis;
}
/**
* @param recoveryMillis the recoveryMillis to set
*/
public void setRecoveryMillis(Long recoveryMillis) {
this.recoveryMillis = recoveryMillis;
}
// /** // /**
// * Instrument type, e.g. HARP, EAR, Popup, DMON, etc. // * Instrument type, e.g. HARP, EAR, Popup, DMON, etc.
// */ // */
@ -235,6 +276,22 @@ public class DeploymentData implements Serializable, Cloneable, ManagedParameter
this.region = region; this.region = region;
} }
/**
* Set the recovery position latlong for a static recorder.
* Deployment lat long is in the hydrophone array data.
* @param recoverLatLong
*/
public void setRecoveryLatLong(LatLong recoverLatLong) {
this.recoverLatLong = recoverLatLong;
}
/**
* @return the recoverLatLong (may often be null)
*/
public LatLong getRecoverLatLong() {
return recoverLatLong;
}
// /** // /**
// * @return the instrumentType // * @return the instrumentType
// */ // */

View File

@ -412,7 +412,8 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
public void notifyModelChanged(int changeType) { public void notifyModelChanged(int changeType) {
super.notifyModelChanged(changeType); super.notifyModelChanged(changeType);
switch (changeType) { switch (changeType) {
case PamControllerInterface.INITIALIZATION_COMPLETE: case PamControllerInterface.INITIALIZE_LOADDATA:
// case PamControllerInterface.INITIALIZATION_COMPLETE:
initializationStuff(); initializationStuff();
break; break;
} }

View File

@ -1,9 +1,15 @@
package tethys.dbxml; package tethys.dbxml;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
@ -32,6 +38,8 @@ public class DBXMLConnect {
private String currentSiteURL; private String currentSiteURL;
public static String[] collections = {"Deployments", "Detections", "Localizations", "Calibrations", "SpeciesAbbreviations"};
public DBXMLConnect(TethysControl tethysControl) { public DBXMLConnect(TethysControl tethysControl) {
this.tethysControl = tethysControl; this.tethysControl = tethysControl;
@ -136,13 +144,15 @@ public class DBXMLConnect {
String tempName = getTempFileName(nilusObject); String tempName = getTempFileName(nilusObject);
tempName = tempDirectory.getAbsolutePath() + File.separator + tempName + ".xml"; tempName = tempDirectory.getAbsolutePath() + File.separator + tempName + ".xml";
File tempFile = new File(tempName); File tempFile = new File(tempName);
String bodgeName = tempName;//"C:\\Users\\dg50\\AppData\\Local\\Temp\\PAMGuardTethys\\Meygen2022_10a.xml";
try { try {
MarshalXML marshal = new MarshalXML(); MarshalXML marshal = new MarshalXML();
marshal.createInstance(objClass); marshal.createInstance(objClass);
// Path tempFile = Files.createTempFile("pamGuardToTethys", ".xml"); // Path tempFile = Files.createTempFile("pamGuardToTethys", ".xml");
marshal.marshal(nilusObject, tempFile.toString()); marshal.marshal(nilusObject, tempFile.toString());
// tempFile = stripXMLHeader(tempFile);
fileError = Importer.ImportFiles(params.getFullServerName(), collection, fileError = Importer.ImportFiles(params.getFullServerName(), collection,
new String[] { tempFile.toString() }, "", "", false); new String[] { bodgeName }, "", "", false);
// System.out.println(fileError); // System.out.println(fileError);
@ -157,11 +167,62 @@ public class DBXMLConnect {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
// System.out.println(fileError); System.out.println(fileError);
return fileError; return fileError;
} }
/**
* Seems we have to get rid of the line <?xml version="1.0" encoding="UTF-8"?>
* which is being put there by the marshaller ?
* @param tempFile
*/
private File stripXMLHeader(File tempFile) {
// TODO Auto-generated method stub
File tempTemp = new File(tempFile.getAbsolutePath().replace(".temp.xml", ".xml"));
try {
BufferedReader reader = new BufferedReader(new FileReader(tempFile));
BufferedWriter writer = new BufferedWriter(new FileWriter(tempTemp));
String line = reader.readLine();
while (line != null) {
// see if the line has any unicode in it
int len = line.length();
byte[] bytes = line.getBytes();
if (len == bytes.length) {
System.out.println(line);
}
if (line.startsWith("<?xml version=")) {
}
else {
writer.write(line + "\r\n");
}
line = reader.readLine();
}
writer.close();
reader.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return tempFile;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return tempFile;
}
boolean deleted = tempFile.delete();
if (deleted) {
tempTemp.renameTo(tempFile);
return tempFile;
}
else {
return tempTemp;
}
}
// /* // /*
// * force a fluch by sending a dummy document to th eimporter which will rail, but ... // * force a fluch by sending a dummy document to th eimporter which will rail, but ...
// */ // */

View File

@ -155,6 +155,9 @@ public class DBXMLQueries {
* @return * @return
*/ */
public ArrayList<nilus.Deployment> getProjectDeployments(String projectName) { public ArrayList<nilus.Deployment> getProjectDeployments(String projectName) {
if (projectName == null) {
return null;
}
String qBase = "{\"return\":[\"Deployment\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Deployment/Project\",\"%s\"],\"optype\":\"binary\"}],\"enclose\":1}"; String qBase = "{\"return\":[\"Deployment\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Deployment/Project\",\"%s\"],\"optype\":\"binary\"}],\"enclose\":1}";
String qStr = String.format(qBase, projectName); String qStr = String.format(qBase, projectName);

View File

@ -2,6 +2,8 @@ package tethys.deployment;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
@ -21,6 +23,8 @@ import Array.Streamer;
import Array.ThreadingHydrophoneLocator; import Array.ThreadingHydrophoneLocator;
import PamController.PamControlledUnit; import PamController.PamControlledUnit;
import PamController.PamController; import PamController.PamController;
import PamUtils.LatLong;
import PamUtils.PamCalendar;
import PamUtils.PamUtils; import PamUtils.PamUtils;
import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataBlock;
import SoundRecorder.RecordingInfo; import SoundRecorder.RecordingInfo;
@ -156,6 +160,20 @@ public class DeploymentHandler implements TethysStateObserver {
// just load everything. Probably OK for the acqusition, but will bring down // just load everything. Probably OK for the acqusition, but will bring down
daqInfoDataBlock.loadViewerData(0, Long.MAX_VALUE, null); daqInfoDataBlock.loadViewerData(0, Long.MAX_VALUE, null);
ArrayList<DaqStatusDataUnit> allStatusData = daqInfoDataBlock.getDataCopy(); ArrayList<DaqStatusDataUnit> allStatusData = daqInfoDataBlock.getDataCopy();
/**
* Due to seird file overlaps we need to resort this by id if we can.
*
*/
Collections.sort(allStatusData, new Comparator<DaqStatusDataUnit>() {
@Override
public int compare(DaqStatusDataUnit o1, DaqStatusDataUnit o2) {
if (o1.getDatabaseIndex() == 0) {
return (int) (o1.getTimeMilliseconds()-o2.getTimeMilliseconds());
}
return o1.getDatabaseIndex()-o2.getDatabaseIndex();
}
});
ArrayList<RecordingPeriod> tempPeriods = null; ArrayList<RecordingPeriod> tempPeriods = null;
@ -168,8 +186,15 @@ public class DeploymentHandler implements TethysStateObserver {
} }
if (tempPeriods == null || tempPeriods.size() == 0) { if (tempPeriods == null || tempPeriods.size() == 0) {
System.out.println("Data appear to have no logged recording periods available either from the database or the raw recordings."); System.out.println("Data appear to have no logged recording periods available either from the database or the raw recordings.");
return null;
} }
int nPeriods = tempPeriods.size(); int nPeriods = tempPeriods.size();
// int i = 0;
// for (RecordingPeriod aP : tempPeriods) {
// System.out.printf("Pre merge %d : %s to %s\n", i++, PamCalendar.formatDBDateTime(aP.getRecordStart()),
// PamCalendar.formatDBDateTime(aP.getRecordStop()));
// }
// now go through those and merge into longer periods where there is no gap between files. // now go through those and merge into longer periods where there is no gap between files.
ListIterator<RecordingPeriod> iterator = tempPeriods.listIterator(); ListIterator<RecordingPeriod> iterator = tempPeriods.listIterator();
RecordingPeriod prevPeriod = null; RecordingPeriod prevPeriod = null;
@ -191,6 +216,11 @@ public class DeploymentHandler implements TethysStateObserver {
} }
prevPeriod = nextPeriod; prevPeriod = nextPeriod;
} }
// i = 0;
// for (RecordingPeriod aP : tempPeriods) {
// System.out.printf("Post merge %d : %s to %s\n", i++, PamCalendar.formatDBDateTime(aP.getRecordStart()),
// PamCalendar.formatDBDateTime(aP.getRecordStop()));
// }
// System.out.printf("Data have %d distinct files, but only %d distinct recording periods\n", nPeriods, tempPeriods.size()); // System.out.printf("Data have %d distinct files, but only %d distinct recording periods\n", nPeriods, tempPeriods.size());
DutyCycleInfo dutyCycleinfo = assessDutyCycle(tempPeriods); DutyCycleInfo dutyCycleinfo = assessDutyCycle(tempPeriods);
// if it's duty cycles, then we only want a single entry. // if it's duty cycles, then we only want a single entry.
@ -202,6 +232,17 @@ public class DeploymentHandler implements TethysStateObserver {
deploymentPeriods = new ArrayList<>(); deploymentPeriods = new ArrayList<>();
deploymentPeriods.add(new RecordingPeriod(tempPeriods.get(0).getRecordStart(), tempPeriods.get(tempPeriods.size()-1).getRecordStop())); deploymentPeriods.add(new RecordingPeriod(tempPeriods.get(0).getRecordStart(), tempPeriods.get(tempPeriods.size()-1).getRecordStop()));
} }
/*
* do another sort of the deploymentPeriods. The start stops were in the order they went into the
* database in the hope that pairs were the right way round. Now check all data are/
*/
Collections.sort(deploymentPeriods, new Comparator<RecordingPeriod>() {
@Override
public int compare(RecordingPeriod o1, RecordingPeriod o2) {
return (int) (o1.getRecordStart()-o2.getRecordStart());
}
});
DeploymentOverview deploymentOverview = new DeploymentOverview(dutyCycleinfo, deploymentPeriods); DeploymentOverview deploymentOverview = new DeploymentOverview(dutyCycleinfo, deploymentPeriods);
matchPamguard2Tethys(deploymentOverview, projectDeployments); matchPamguard2Tethys(deploymentOverview, projectDeployments);
this.deploymentOverview = deploymentOverview; this.deploymentOverview = deploymentOverview;
@ -300,7 +341,6 @@ public class DeploymentHandler implements TethysStateObserver {
return cycleInfo; return cycleInfo;
} }
private ArrayList<RecordingPeriod> extractTimesFromStatus(ArrayList<DaqStatusDataUnit> allStatusData) { private ArrayList<RecordingPeriod> extractTimesFromStatus(ArrayList<DaqStatusDataUnit> allStatusData) {
ArrayList<RecordingPeriod> tempPeriods = new ArrayList<>(); ArrayList<RecordingPeriod> tempPeriods = new ArrayList<>();
long dataStart = Long.MAX_VALUE; long dataStart = Long.MAX_VALUE;
@ -315,14 +355,20 @@ public class DeploymentHandler implements TethysStateObserver {
nStart++; nStart++;
dataStart = Math.min(dataStart, daqStatus.getTimeMilliseconds()); dataStart = Math.min(dataStart, daqStatus.getTimeMilliseconds());
lastStart = daqStatus.getTimeMilliseconds(); lastStart = daqStatus.getTimeMilliseconds();
// System.out.println("Start at " + PamCalendar.formatDBDateTime(lastStart));
break; break;
case "Stop": case "Stop":
nStop++; nStop++;
dataEnd = Math.max(dataEnd, daqStatus.getEndTimeInMilliseconds()); dataEnd = Math.max(dataEnd, daqStatus.getEndTimeInMilliseconds());
long lastEnd = daqStatus.getEndTimeInMilliseconds(); long lastEnd = daqStatus.getEndTimeInMilliseconds();
if (lastStart != null) { if (lastStart != null) {
// System.out.printf("Adding period %s to %s\n", PamCalendar.formatDBDateTime(lastStart),
// PamCalendar.formatDBDateTime(lastEnd));
tempPeriods.add(new RecordingPeriod(lastStart, lastEnd)); tempPeriods.add(new RecordingPeriod(lastStart, lastEnd));
} }
else {
// System.out.println("Skipping stop at " + PamCalendar.formatDBDateTime(lastEnd));
}
lastStart = null; lastStart = null;
break; break;
case "NextFile": case "NextFile":
@ -505,17 +551,24 @@ public class DeploymentHandler implements TethysStateObserver {
e.printStackTrace(); e.printStackTrace();
} }
DeploymentData globalDeplData = tethysControl.getGlobalDeplopymentData(); DeploymentData globalDeplData = tethysControl.getGlobalDeplopymentData();
String id = String.format("%s%d", globalDeplData.getProject(), i); String id = String.format("%s_%d", globalDeplData.getProject(), i);
deployment.setId(id); deployment.setId(id);
deployment.setDeploymentId(i); deployment.setDeploymentId(i);
DeploymentRecoveryDetails deploymentDetails = new DeploymentRecoveryDetails(); DeploymentRecoveryDetails deploymentDetails = deployment.getDeploymentDetails();
DeploymentRecoveryDetails recoveryDetails = new DeploymentRecoveryDetails(); if (deploymentDetails == null) {
deploymentDetails.setTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recordingPeriod.getRecordStart())); deploymentDetails = new DeploymentRecoveryDetails();
}
DeploymentRecoveryDetails recoveryDetails = deployment.getRecoveryDetails();
if (recoveryDetails == null) {
recoveryDetails = new DeploymentRecoveryDetails();
}
deploymentDetails.setAudioTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recordingPeriod.getRecordStart())); deploymentDetails.setAudioTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recordingPeriod.getRecordStart()));
recoveryDetails.setTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recordingPeriod.getRecordStop()));
recoveryDetails.setAudioTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recordingPeriod.getRecordStop())); recoveryDetails.setAudioTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recordingPeriod.getRecordStop()));
deploymentDetails.setTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recordingPeriod.getRecordStart()));
recoveryDetails.setTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recordingPeriod.getRecordStop()));
deployment.setDeploymentDetails(deploymentDetails); deployment.setDeploymentDetails(deploymentDetails);
deployment.setRecoveryDetails(recoveryDetails); deployment.setRecoveryDetails(recoveryDetails);
@ -572,6 +625,22 @@ public class DeploymentHandler implements TethysStateObserver {
String geomType = getGeometryType(); String geomType = getGeometryType();
instrument.setGeometryType(geomType); instrument.setGeometryType(geomType);
deployment.setInstrument(instrument); deployment.setInstrument(instrument);
// overwrite the default deployment and recovery times if there is non null data
Long depMillis = deploymentData.getDeploymentMillis();
if (depMillis != null) {
deployment.getDeploymentDetails().setTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(depMillis));
}
Long recMillis = deploymentData.getRecoveryMillis();
if (recMillis != null) {
deployment.getRecoveryDetails().setTimeStamp(TethysTimeFuncs.xmlGregCalFromMillis(recMillis));
}
LatLong recLatLong = deploymentData.getRecoverLatLong();
if (recLatLong != null) {
deployment.getRecoveryDetails().setLatitude(recLatLong.getLatitude());
deployment.getRecoveryDetails().setLongitude(PamUtils.constrainedAngle(recLatLong.getLongitude()));
}
return true; return true;
} }

View File

@ -1,5 +1,7 @@
package tethys.deployment; package tethys.deployment;
import PamUtils.PamCalendar;
public class DutyCycleInfo { public class DutyCycleInfo {
public boolean isDutyCycled; public boolean isDutyCycled;
@ -24,7 +26,8 @@ public class DutyCycleInfo {
return "No duty cycle"; return "No duty cycle";
} }
else { else {
return String.format("%3.1fs on, %3.1fs off, for %d cycles", meanOnTimeS, meanGapS, nCycles); return String.format("%s on, %s off, for %d cycles", PamCalendar.formatDuration((long) (meanOnTimeS*1000)),
PamCalendar.formatDuration((long) (meanGapS*1000)), nCycles);
} }
} }

View File

@ -466,7 +466,7 @@ public class DetectionsHandler {
String prefix = deployment.deployment.getId(); String prefix = deployment.deployment.getId();
detections.setId(String.format("%s_%d", prefix, uniqueDetectionsId++)); detections.setId(String.format("%s_%d", prefix, uniqueDetectionsId++));
// detections.setDescription(dataProvider.getDescription(deployment, tethysExportParams)); // detections.setDescription(dataProvider.getDescription(deployment, tethysExportParams));
detections.setDescription(exportParams.detectionDescription); detections.setDescription(exportParams.getNilusDetectionDescription());
DataSourceType dataSource = new DataSourceType(); DataSourceType dataSource = new DataSourceType();
dataSource.setDeploymentId(deployment.deployment.getId()); dataSource.setDeploymentId(deployment.deployment.getId());
// dataSource.setEnsembleId(""); ToDo // dataSource.setEnsembleId(""); ToDo

View File

@ -0,0 +1,101 @@
package tethys.niluswraps;
import java.io.Serializable;
import nilus.DescriptionType;
/**
* Because we want to save DescriptionType objects in serialised
* psfx files and because Nilus description types are not serialised
* these have to be wrapped in a total bodge way with reasonably convenient
* constructors and getters for converting back and forth from the nilus object.
* @author dg50
*
*/
public class PDescriptionType implements Serializable {
private static final long serialVersionUID = 1L;
protected String objectives;
protected String _abstract;
protected String method;
/**
* Constructor from a set of strings
* @param objectives
* @param _abstract
* @param method
*/
public PDescriptionType(String objectives, String _abstract, String method) {
super();
this.objectives = objectives;
this._abstract = _abstract;
this.method = method;
}
/**
* Construct from a nilus object
* @param descriptionType
*/
public PDescriptionType(DescriptionType descriptionType) {
this.objectives = descriptionType.getObjectives();
this._abstract = descriptionType.getAbstract();
this.method = descriptionType.getMethod();
}
public PDescriptionType() {
}
public String getObjectives() {
return objectives;
}
/**
* @return the _abstract
*/
public String getAbstract() {
return _abstract;
}
/**
* @param _abstract the _abstract to set
*/
public void setAbstract(String _abstract) {
this._abstract = _abstract;
}
/**
* @return the method
*/
public String getMethod() {
return method;
}
/**
* @param method the method to set
*/
public void setMethod(String method) {
this.method = method;
}
/**
* @param objectives the objectives to set
*/
public void setObjectives(String objectives) {
this.objectives = objectives;
}
/**
* convert into a nilus object for output.
* @return
*/
public DescriptionType getDescription() {
DescriptionType descriptionType = new DescriptionType();
descriptionType.setAbstract(_abstract);
descriptionType.setObjectives(objectives);
descriptionType.setMethod(method);
return descriptionType;
}
}

View File

@ -1,9 +1,11 @@
package tethys.output; package tethys.output;
import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import nilus.DescriptionType; import nilus.DescriptionType;
import nilus.GranularityEnumType; import nilus.GranularityEnumType;
import tethys.niluswraps.PDescriptionType;
/** /**
* Parameters controlling export of a single stream. * Parameters controlling export of a single stream.
@ -32,13 +34,21 @@ public class StreamExportParams implements Serializable {
/* /*
* Can't have this here since it isn't serializable. * Can't have this here since it isn't serializable.
*/ */
transient public nilus.DescriptionType detectionDescription; public PDescriptionType detectionDescription;
public DescriptionType getDetectionDescription() { public PDescriptionType getDetectionDescription() {
if (detectionDescription == null) { if (detectionDescription == null) {
detectionDescription = new DescriptionType(); detectionDescription = new PDescriptionType();
} }
return detectionDescription; return detectionDescription;
} }
/**
* Get the nilus detection description
* @return
*/
public DescriptionType getNilusDetectionDescription() {
return getDetectionDescription().getDescription();
}
} }

View File

@ -32,6 +32,7 @@ import nilus.Deployment;
import nilus.Deployment.Data; import nilus.Deployment.Data;
import tethys.TethysControl; import tethys.TethysControl;
import tethys.TethysState; import tethys.TethysState;
import tethys.TethysState.StateType;
import tethys.dbxml.DBXMLConnect; import tethys.dbxml.DBXMLConnect;
import tethys.deployment.RecordingPeriod; import tethys.deployment.RecordingPeriod;
import tethys.niluswraps.PDeployment; import tethys.niluswraps.PDeployment;
@ -149,6 +150,10 @@ public class DeploymentExportPanel extends TethysGUIPanel implements DeploymentT
case NEWPROJECTSELECTION: case NEWPROJECTSELECTION:
updateDeployments(); updateDeployments();
enableControls(); enableControls();
break;
case UPDATEMETADATA:
setInternal();
break;
} }
} }
@ -258,6 +263,7 @@ public class DeploymentExportPanel extends TethysGUIPanel implements DeploymentT
dbxmlConnect.postToTethys(deployment); dbxmlConnect.postToTethys(deployment);
} }
} }
getTethysControl().sendStateUpdate(new TethysState(StateType.UPDATESERVER));
} }
private void enableControls() { private void enableControls() {

View File

@ -0,0 +1,84 @@
package tethys.swing;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import tethys.TethysControl;
import tethys.dbxml.DBXMLConnect;
/**
* Fancy button which has a normal button AND a drop down
* for other web client pages.
* @author dg50
*
*/
public class FancyClientButton extends JPanel {
private JButton clientButton;
private JButton dropButton;
private JPopupMenu collectionsMenu;
private TethysControl tethysControl;
public FancyClientButton(TethysControl tethysControl) {
this.tethysControl = tethysControl;
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.ipadx = c.ipady = 0;
c.insets = new Insets(0,0,0,0);
clientButton = new JButton("Open Client");
clientButton.setToolTipText("Open Tethys web client in default browser");
dropButton = new JButton("v");
dropButton.setToolTipText("Open Tethys collections pages in default browser");
c.gridx = 0;
add(clientButton, c);
c.gridx++;
add(dropButton, c);
String[] collections = DBXMLConnect.collections;
collectionsMenu = new JPopupMenu();
for (int i = 0; i < collections.length; i++) {
JMenuItem menuItem = new JMenuItem(collections[i]);
menuItem.addActionListener(new OpenCollection(collections[i]));
collectionsMenu.add(menuItem);
}
dropButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
collectionsMenu.show(dropButton, 0, 0);
}
});
}
public void addActionListener(ActionListener actionListener) {
clientButton.addActionListener(actionListener);
}
private class OpenCollection implements ActionListener {
private String collection;
public OpenCollection(String collection) {
super();
this.collection = collection;
}
@Override
public void actionPerformed(ActionEvent e) {
tethysControl.openTethysCollection(collection);
}
}
}

View File

@ -2,6 +2,8 @@ package tethys.swing;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
@ -9,7 +11,9 @@ import java.util.Arrays;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
@ -17,10 +21,13 @@ import javax.swing.border.TitledBorder;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
import PamView.dialog.warn.WarnOnce;
import PamView.panel.PamPanel; import PamView.panel.PamPanel;
import PamView.tables.SwingTableColumnWidths; import PamView.tables.SwingTableColumnWidths;
import nilus.Deployment;
import tethys.TethysControl; import tethys.TethysControl;
import tethys.TethysState; import tethys.TethysState;
import tethys.TethysState.StateType;
import tethys.deployment.DeploymentHandler; import tethys.deployment.DeploymentHandler;
import tethys.deployment.DeploymentOverview; import tethys.deployment.DeploymentOverview;
import tethys.deployment.RecordingPeriod; import tethys.deployment.RecordingPeriod;
@ -71,14 +78,14 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) { if (e.isPopupTrigger()) {
showPopup(); showPopup(e);
} }
} }
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) { if (e.isPopupTrigger()) {
showPopup(); showPopup(e);
} }
} }
@ -96,7 +103,7 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
} }
public void showPopup() { public void showPopup(MouseEvent e) {
int aRow = table.getSelectedRow(); int aRow = table.getSelectedRow();
int[] selRows = table.getSelectedRows(); int[] selRows = table.getSelectedRows();
if (selRows == null || selRows.length == 0) { if (selRows == null || selRows.length == 0) {
@ -111,19 +118,54 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
// make a list of RecordingPeriods which don't currently have a Deployment document // make a list of RecordingPeriods which don't currently have a Deployment document
ArrayList<RecordingPeriod> newPeriods = new ArrayList<>(); ArrayList<RecordingPeriod> newPeriods = new ArrayList<>();
ArrayList<RecordingPeriod> allPeriods = deploymentOverview.getRecordingPeriods(); ArrayList<RecordingPeriod> allPeriods = deploymentOverview.getRecordingPeriods();
ArrayList<PDeployment> matchedDeployments = new ArrayList<>();
for (int i = 0; i < selRows.length; i++) { for (int i = 0; i < selRows.length; i++) {
if (allPeriods.get(selRows[i]).getMatchedTethysDeployment() == null) { PDeployment tethysDeployment = allPeriods.get(selRows[i]).getMatchedTethysDeployment();
if (tethysDeployment == null) {
newPeriods.add(allPeriods.get(i)); newPeriods.add(allPeriods.get(i));
} }
else {
if (matchedDeployments.contains(tethysDeployment) == false) {
matchedDeployments.add(tethysDeployment);
}
}
} }
if (newPeriods.size() == 0) { if (matchedDeployments.size() == 1) {
JPopupMenu popMenu = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("Remove deployment document " + matchedDeployments.get(0));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteDeployment(matchedDeployments.get(0));
}
});
popMenu.add(menuItem);
popMenu.show(e.getComponent(), e.getX(), e.getY());
}
// if (newPeriods.size() == 0) {
// return;
// }
// /*
// * if we get here, we've one or more rows without a Tethys output, so can have
// * a menu to create them.
// */
}
protected void deleteDeployment(PDeployment pDeployment) {
Deployment dep = pDeployment.deployment;
if (dep == null) {
return; return;
} }
/* int ans = WarnOnce.showWarning(getTethysControl().getGuiFrame(), "Delete Deployment document",
* if we get here, we've one or more rows without a Tethys output, so can have "Are you sure you want to delete the deployment document " + dep.getId(), WarnOnce.OK_CANCEL_OPTION);
* a menu to create them. if (ans == WarnOnce.CANCEL_OPTION) {
*/ return;
}
boolean gone = getTethysControl().getDbxmlConnect().deleteDocument(dep);
getTethysControl().sendStateUpdate(new TethysState(StateType.UPDATESERVER));
} }
/** /**
@ -172,6 +214,9 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
private void updateDeployments() { private void updateDeployments() {
DeploymentHandler deploymentHandler = getTethysControl().getDeploymentHandler(); DeploymentHandler deploymentHandler = getTethysControl().getDeploymentHandler();
deploymentOverview = deploymentHandler.getDeploymentOverview(); deploymentOverview = deploymentHandler.getDeploymentOverview();
if (deploymentOverview == null) {
return;
}
int n = deploymentOverview.getRecordingPeriods().size(); int n = deploymentOverview.getRecordingPeriods().size();
if (selection.length < n) { if (selection.length < n) {
selection = Arrays.copyOf(selection, n); selection = Arrays.copyOf(selection, n);

View File

@ -62,7 +62,7 @@ public class TethysConnectionPanel extends TethysGUIPanel {
private JButton newInstrument; private JButton newInstrument;
private JButton openClient; private FancyClientButton openClient;
public TethysConnectionPanel(TethysControl tethysControl) { public TethysConnectionPanel(TethysControl tethysControl) {
super(tethysControl); super(tethysControl);
@ -73,8 +73,8 @@ public class TethysConnectionPanel extends TethysGUIPanel {
serverSelButton.setToolTipText("Select server"); serverSelButton.setToolTipText("Select server");
serverStatus = new ScrollingPamLabel(SERVERSTATUSLENGTH); serverStatus = new ScrollingPamLabel(SERVERSTATUSLENGTH);
serverName.setEditable(false); serverName.setEditable(false);
openClient = new JButton("Open Client"); openClient = new FancyClientButton(tethysControl);
openClient.setToolTipText("Open Tethys client in web browser"); // openClient.setToolTipText("Open Tethys client in web browser");
// serverStatus.setEditable(false); // serverStatus.setEditable(false);
serverSelButton.addActionListener(new ActionListener() { serverSelButton.addActionListener(new ActionListener() {
@Override @Override

View File

@ -12,6 +12,7 @@ import javax.swing.border.TitledBorder;
import PamView.dialog.PamDialog; import PamView.dialog.PamDialog;
import nilus.DescriptionType; import nilus.DescriptionType;
import tethys.niluswraps.PDescriptionType;
/** /**
* Panel containing the three test entry fields for nilus.DescriptionType * Panel containing the three test entry fields for nilus.DescriptionType
@ -65,7 +66,7 @@ public class DescriptionTypePanel {
return mainPanel; return mainPanel;
} }
public void setParams(DescriptionType description) { public void setParams(PDescriptionType description) {
if (description == null) { if (description == null) {
tObjectives.setText(null); tObjectives.setText(null);
tAbstract.setText(null); tAbstract.setText(null);
@ -73,7 +74,7 @@ public class DescriptionTypePanel {
} }
} }
public boolean getParams(DescriptionType description) { public boolean getParams(PDescriptionType description) {
if (checkField(requireObjective, tObjectives) == false) { if (checkField(requireObjective, tObjectives) == false) {
return PamDialog.showWarning(null, "Objectives", "The objectives field must be competed"); return PamDialog.showWarning(null, "Objectives", "The objectives field must be competed");
} }