diff --git a/src/PamguardMVC/PamDataBlock.java b/src/PamguardMVC/PamDataBlock.java index 09f5c94d..d22a8543 100644 --- a/src/PamguardMVC/PamDataBlock.java +++ b/src/PamguardMVC/PamDataBlock.java @@ -3102,6 +3102,16 @@ public class PamDataBlock extends PamObservable { public void setTethysDataProvider(TethysDataProvider tethysDataProvider) { this.tethysDataProvider = tethysDataProvider; } + + + /** + * Get information about species types that may occur within this data + * block. + * @return Types of species information available within this datablock. + */ + public tethys.species.SpeciesTypes getSpeciesTypes() { + return null; + } final public boolean getCanLog() { return (logging != null); diff --git a/src/tethys/dbxml/DBXMLQueries.java b/src/tethys/dbxml/DBXMLQueries.java index 0bf67e9a..6d2e9c47 100644 --- a/src/tethys/dbxml/DBXMLQueries.java +++ b/src/tethys/dbxml/DBXMLQueries.java @@ -129,7 +129,6 @@ public class DBXMLQueries { String queryResult = null; String schemaPlan = null; - TethysExportParams params = tethysControl.getTethysExportParams(); try { JerseyClient jerseyClient = dbxmlConnect.getJerseyClient(); diff --git a/src/tethys/pamdata/TethysDataProvider.java b/src/tethys/pamdata/TethysDataProvider.java index 1a89c505..efbd47e5 100644 --- a/src/tethys/pamdata/TethysDataProvider.java +++ b/src/tethys/pamdata/TethysDataProvider.java @@ -67,4 +67,5 @@ public interface TethysDataProvider { public Parameters getAlgorithmParameters(); + } diff --git a/src/tethys/species/DatablockSpeciesMap.java b/src/tethys/species/DatablockSpeciesMap.java new file mode 100644 index 00000000..07239ab5 --- /dev/null +++ b/src/tethys/species/DatablockSpeciesMap.java @@ -0,0 +1,12 @@ +package tethys.species; + +import java.io.Serializable; + +/** + * Species map for a specified data block + * @author dg50 + * + */ +public class DatablockSpeciesMap implements Serializable { + +} diff --git a/src/tethys/species/SpeciesMapItem.java b/src/tethys/species/SpeciesMapItem.java new file mode 100644 index 00000000..d586ddd1 --- /dev/null +++ b/src/tethys/species/SpeciesMapItem.java @@ -0,0 +1,19 @@ +package tethys.species; + +import java.io.Serializable; + +public class SpeciesMapItem implements Serializable, Cloneable { + + public static final long serialVersionUID = 1L; + + private int itisCode; + + private String pamguardName; + + private String latinName; + + private String commonName; + + private String callType; + +} diff --git a/src/tethys/species/SpeciesMapManager.java b/src/tethys/species/SpeciesMapManager.java new file mode 100644 index 00000000..26d8eda4 --- /dev/null +++ b/src/tethys/species/SpeciesMapManager.java @@ -0,0 +1,5 @@ +package tethys.species; + +public class SpeciesMapManager { + +} diff --git a/src/tethys/species/SpeciesTest.java b/src/tethys/species/SpeciesTest.java new file mode 100644 index 00000000..804abb6c --- /dev/null +++ b/src/tethys/species/SpeciesTest.java @@ -0,0 +1,110 @@ +package tethys.species; + +import dbxml.JerseyClient; +import dbxml.Queries; +import tethys.dbxml.DBQueryResult; +import tethys.dbxml.TethysQueryException; + +public class SpeciesTest extends SpeciesTypes { + + String uri = "http://localhost:9779"; + public static void main(String[] args) { + + SpeciesTest st = new SpeciesTest(); + st.runJson(); + +// int spermWhale = 180488; +// st.getCodeInfo(spermWhale); +// st.runXQuery(); + + } + private void getCodeInfo(int itisCode) { + System.out.println("Running getCodeInfo()"); + String jQBase = "{\"return\":[\"ranks/rank\"],\"select\":[{\"op\":\"=\",\"operands\":[\"ranks/rank/tsn\",\"SPECIESTSN\"],\"optype\":\"binary\"}],\"enclose\":1}"; + String jQ = jQBase.replace("SPECIESTSN", String.format("%d", itisCode)); + + + DBQueryResult result = null; + String queryResult = null; + String schemaPlan = null; + JerseyClient jerseyClient = new JerseyClient(uri); + long t1 = System.nanoTime(); + try { + queryResult = jerseyClient.queryJSON(jQ, 0); +// schemaPlan = jerseyClient.queryJSON(jQ, 1); + } catch (Exception e1) { + e1.printStackTrace(); + + } + long t2 = System.nanoTime(); + System.out.printf("Query time was %3.1fms\n" , (double) (t2-t1)/1e6); + System.out.println(queryResult); + + TethysITISResult itisResult = new TethysITISResult(queryResult); + } + /* + * + + + -10 + Other phenomena + + Other + Autre + Otro + + + + 555654 + Delphinus capensis + + Long-beaked Common Dolphin + + + */ + + private void runXQuery() { + System.out.println("Running runXQuery()"); + String queryBase = "count(collection(\"Detections\")/Detections[Id=\"ReplaceDocumentId\"]/OnEffort/Detection)"; + String xQ = "collection(\"ITIS_ranks\")/ty:ranks/ty:rank[dbxml:contains(ty:completename, \"Physeter\")]"; + + JerseyClient jerseyClient = new JerseyClient(uri); + Queries queries = new Queries(jerseyClient); + + String result = null; + try { + result = queries.QueryTethys(xQ); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println(result); + + } + private void runJson() { +// String jQ = "{\"return\":[\"Deployment\"],\"select\":[{\"op\":\"=\",\"operands\":[\"Deployment/Project\",\"DCLDE2022\"],\"optype\":\"binary\"}],\"enclose\":1}"; +// String jQ = "{\"return\":[\"ranks/rank\"],\"select\":[{\"op\":\"=\",\"operands\":[\"ranks/rank/tsn\",\"624908\"],\"optype\":\"binary\"}],\"enclose\":1}"; +// String jQ = "{\"return\":[\"ranks/rank\"],\"select\":[{\"op\":\"=\",\"operands\":[\"ranks/rank/completename\",\"Mesoplodon\"],\"optype\":\"binary\"}],\"enclose\":1}"; + String jQ = "{\"return\":[\"ranks/rank\"],\"select\":[{\"op\":\"dbxml:contains\",\"operands\":[\"ranks/rank/completename\",\"Mesoplodon\"],\"optype\":\"function\"}],\"enclose\":1}"; + + System.out.println(jQ); + + DBQueryResult result = null; + String queryResult = null; + String schemaPlan = null; + JerseyClient jerseyClient = new JerseyClient(uri); + long t1 = System.nanoTime(); + try { + queryResult = jerseyClient.queryJSON(jQ, 0); +// schemaPlan = jerseyClient.queryJSON(jQ, 1); + } catch (Exception e1) { + System.out.println("epic fail"); + e1.printStackTrace(); + } + long t2 = System.nanoTime(); + System.out.printf("Query time was %3.1fms\n" , (double) (t2-t1)/1e6); + System.out.println(queryResult); + + } + +} diff --git a/src/tethys/species/SpeciesTypes.java b/src/tethys/species/SpeciesTypes.java new file mode 100644 index 00000000..84ca0152 --- /dev/null +++ b/src/tethys/species/SpeciesTypes.java @@ -0,0 +1,20 @@ +package tethys.species; + +import java.util.ArrayList; + +/** + * Class to return lists of species codes or names for a datablock. + * This information will then get incorporated into a more complicated translation table to + * provide PAMGuard data on it's way to Tethys with more rigid species code definitions. + * @author dg50 + * + */ +public class SpeciesTypes { + + + /** + * List of species names / codes associated with this data block. + */ + private ArrayList speciesNames; + +} diff --git a/src/tethys/species/TethysITISResult.java b/src/tethys/species/TethysITISResult.java new file mode 100644 index 00000000..9504d196 --- /dev/null +++ b/src/tethys/species/TethysITISResult.java @@ -0,0 +1,37 @@ +package tethys.species; + +import java.io.StringReader; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +/** + * Class to hold and unpack a XML string returned from the ITIS_ranks document + * in a Tethys database. + * @author dg50 + * + */ +public class TethysITISResult { + + /** + * Construct a ITIS object from XML data + * @param xmlData + */ + public TethysITISResult(String xmlData) { + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + + //API to obtain DOM Document instance + DocumentBuilder builder = null; + +// //Create DocumentBuilder with default configuration +// builder = factory.newDocumentBuilder(); +// +// //Parse the content to Document object +// Document doc = builder.parse(new InputSource(new StringReader(xmlData))); + + } +}