mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
update autoprovider
This commit is contained in:
parent
289b065914
commit
cff6f71881
22
src/tethys/dbxml/DMXMLQueryTest.java
Normal file
22
src/tethys/dbxml/DMXMLQueryTest.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package tethys.dbxml;
|
||||||
|
|
||||||
|
import dbxml.JerseyClient;
|
||||||
|
import tethys.output.TethysExportParams;
|
||||||
|
|
||||||
|
public class DMXMLQueryTest {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new DMXMLQueryTest().runTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runTest() {
|
||||||
|
TethysExportParams params = new TethysExportParams();
|
||||||
|
|
||||||
|
JerseyClient jerseyClient = new JerseyClient(params.getFullServerName());
|
||||||
|
|
||||||
|
// web browse to http://localhost:9779/Client
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -32,6 +32,15 @@ import tethys.TethysTimeFuncs;
|
|||||||
import tethys.output.StreamExportParams;
|
import tethys.output.StreamExportParams;
|
||||||
import tethys.output.TethysExportParams;
|
import tethys.output.TethysExportParams;
|
||||||
import whistleClassifier.WhistleContour;
|
import whistleClassifier.WhistleContour;
|
||||||
|
import javax.xml.transform.*;
|
||||||
|
import javax.xml.transform.dom.DOMResult;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import javax.xml.transform.stream.StreamSource;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically provides Tethys data based on the SQL database interface
|
* Automatically provides Tethys data based on the SQL database interface
|
||||||
@ -111,7 +120,10 @@ public class AutoTethysProvider implements TethysDataProvider {
|
|||||||
if (settingsEl == null) {
|
if (settingsEl == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
pamXMLWriter.addNameSpaceToElements(doc, settingsEl, TethysControl.xmlNameSpace);
|
|
||||||
|
settingsEl = addNameSpaceToElements(doc, settingsEl, TethysControl.xmlNameSpace);
|
||||||
|
|
||||||
|
|
||||||
dummyEl.appendChild(settingsEl);
|
dummyEl.appendChild(settingsEl);
|
||||||
NodeList childs = settingsEl.getChildNodes();
|
NodeList childs = settingsEl.getChildNodes();
|
||||||
for (int i = 0; i < childs.getLength(); i++) {
|
for (int i = 0; i < childs.getLength(); i++) {
|
||||||
@ -159,6 +171,73 @@ public class AutoTethysProvider implements TethysDataProvider {
|
|||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Element addNameSpaceToElements(Document doc, Element settingsEl, String xmlNameSpace) {
|
||||||
|
|
||||||
|
|
||||||
|
// String xsltString = "<xsl:stylesheet version=\"1.0\" \r\n"
|
||||||
|
// + " xmlns:xsl=http://www.w3.org/1999/XSL/Transform\r\n"
|
||||||
|
// + " xmlns:ns0=http://mydata.com/H2H/Automation\r\n"
|
||||||
|
// + " exclude-result-prefixes=\"ns0\">\r\n"
|
||||||
|
// + " <xsl:output method=\"xml\" version=\"1.0\" encoding=\"UTF-8\" indent=\"yes\"/>\r\n"
|
||||||
|
// + " <xsl:strip-space elements=\"*\"/>\r\n"
|
||||||
|
// + " \r\n"
|
||||||
|
// + " <xsl:template match=\"*\">\r\n"
|
||||||
|
// + " <xsl:element name=\"{local-name()}\" namespace=http://tethys.sdsu.edu/schema/1.0>\r\n"
|
||||||
|
// + " <xsl:apply-templates/>\r\n"
|
||||||
|
// + " </xsl:element>\r\n"
|
||||||
|
// + " </xsl:template>\r\n"
|
||||||
|
// + " \r\n"
|
||||||
|
// + " <xsl:template match=\"/ns0:Document\">\r\n"
|
||||||
|
// + " <Document xmlns=http://tethys.sdsu.edu/schema/1.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> \r\n"
|
||||||
|
// + " <xsl:apply-templates/>\r\n"
|
||||||
|
// + " </Document>\r\n"
|
||||||
|
// + " </xsl:template>\r\n"
|
||||||
|
// + " \r\n"
|
||||||
|
// + "</xsl:stylesheet>\r\n";
|
||||||
|
String xsltString = "<xsl:stylesheet version=\"1.0\" \n"
|
||||||
|
+ " xmlns:xsl=http://www.w3.org/1999/XSL/Transform\n"
|
||||||
|
+ " xmlns:ns0=http://mydata.com/H2H/Automation\n"
|
||||||
|
+ " exclude-result-prefixes=\"ns0\">\n"
|
||||||
|
+ " <xsl:output method=\"xml\" version=\"1.0\" encoding=\"UTF-8\" indent=\"yes\"/>\n"
|
||||||
|
+ " <xsl:strip-space elements=\"*\"/>\n"
|
||||||
|
+ " \n"
|
||||||
|
+ " <xsl:template match=\"*\">\n"
|
||||||
|
+ " <xsl:element name=\"{local-name()}\" namespace=http://tethys.sdsu.edu/schema/1.0>\n"
|
||||||
|
+ " <xsl:apply-templates/>\n"
|
||||||
|
+ " </xsl:element>\n"
|
||||||
|
+ " </xsl:template>\n"
|
||||||
|
+ " \n"
|
||||||
|
+ " <xsl:template match=\"/ns0:Document\">\n"
|
||||||
|
+ " <Document xmlns=http://tethys.sdsu.edu/schema/1.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> \n"
|
||||||
|
+ " <xsl:apply-templates/>\n"
|
||||||
|
+ " </Document>\n"
|
||||||
|
+ " </xsl:template>\n"
|
||||||
|
+ " \n"
|
||||||
|
+ "</xsl:stylesheet>\n";
|
||||||
|
try {
|
||||||
|
TransformerFactory factory = TransformerFactory.newInstance();
|
||||||
|
// Source xslt = new StreamSource(new File("transform.xslt"));
|
||||||
|
StringReader reader = new StringReader(xmlNameSpace);
|
||||||
|
Source xslt = new StreamSource(reader);
|
||||||
|
|
||||||
|
Transformer transformer = factory.newTransformer(xslt);
|
||||||
|
|
||||||
|
DOMSource source = new DOMSource(doc);
|
||||||
|
|
||||||
|
// Result
|
||||||
|
// Source text = new StreamSource(new File("input.xml"));
|
||||||
|
DOMResult result = new DOMResult();
|
||||||
|
transformer.transform(source, result);
|
||||||
|
|
||||||
|
System.out.println(result.toString());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private PamSettings[] getSettingsObjects() {
|
private PamSettings[] getSettingsObjects() {
|
||||||
if (pamControlledUnit instanceof PamSettings) {
|
if (pamControlledUnit instanceof PamSettings) {
|
||||||
PamSettings[] settings = new PamSettings[1];
|
PamSettings[] settings = new PamSettings[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user