Commit 12e5aaf1 authored by R.W.M's avatar R.W.M

exchange API example XML documents completed, partial JAXB implementation

parent f14e76be
...@@ -70,6 +70,13 @@ ...@@ -70,6 +70,13 @@
</build> </build>
<dependencies> <dependencies>
<!-- TODO export project as dynamic dependency
<dependency>
<groupId>de.sekmi.histream</groupId>
<artifactId>histream-export</artifactId>
<version>0.8-SNAPSHOT</version>
</dependency>
-->
<!-- unit tests --> <!-- unit tests -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
......
package org.aktin.exchange; package org.aktin.exchange;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/** /**
* Status for a data warehouse node * Status for a data warehouse node
* *
* @author R.W.Majeed * @author R.W.Majeed
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="node-status")
public class NodeStatus { public class NodeStatus {
public NodeStatus(){ public NodeStatus(){
apiVersion = getClass().getPackage().getImplementationVersion();
} }
/** /**
* Version of the dwh-api component * Version of the dwh-api component
*/ */
String apiVersion; Instant timestamp;
Duration uptime;
@XmlElement(name="module")
List<SoftwareModule> modules;
} }
...@@ -6,11 +6,11 @@ import javax.xml.bind.annotation.XmlAccessType; ...@@ -6,11 +6,11 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.w3c.dom.Element; import org.w3c.dom.Element;
/** /**
* Query which can be executed in an i2b2 * Query which can be executed in an i2b2
* data warehouse by the AKTIN remote query * data warehouse by the AKTIN remote query
...@@ -53,10 +53,7 @@ public class Query { ...@@ -53,10 +53,7 @@ public class Query {
@XmlElement(required=true) @XmlElement(required=true)
public QuerySchedule schedule; public QuerySchedule schedule;
@XmlElementWrapper(name="concepts",required=true)
@XmlElement(name="concept",required=true)
public List<AbstractConcept> concepts;
@XmlAnyElement @XmlAnyElement
public Element definition; public List<Element> extensions;
} }
package org.aktin.exchange;
import javax.xml.bind.annotation.XmlType;
@XmlType(name="raw")
public class RawConcept extends AbstractConcept{
}
package org.aktin.exchange; package org.aktin.exchange;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
@XmlSeeAlso({RawConcept.class}) @XmlAccessorType(XmlAccessType.FIELD)
public abstract class AbstractConcept { public class SoftwareModule {
/**
* Unique identifier of the concept.
*/
@XmlAttribute @XmlAttribute
public String id; String id;
String version;
String url;
} }
...@@ -3,6 +3,7 @@ package org.aktin.exchange; ...@@ -3,6 +3,7 @@ package org.aktin.exchange;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.time.Duration;
import javax.xml.bind.JAXB; import javax.xml.bind.JAXB;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
...@@ -19,6 +20,7 @@ import javax.xml.validation.Validator; ...@@ -19,6 +20,7 @@ import javax.xml.validation.Validator;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.w3c.dom.Element;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
...@@ -79,14 +81,9 @@ public class TestUnmarshallDocuments { ...@@ -79,14 +81,9 @@ public class TestUnmarshallDocuments {
//System.out.println("Duration:"+se.duration); //System.out.println("Duration:"+se.duration);
//System.out.println("Reference:"+se.reference); //System.out.println("Reference:"+se.reference);
for( Element el : query.extensions ){
// print XML output System.out.println("Extension name="+el.getLocalName()+", ns="+el.getNamespaceURI());
//se.duration = Period.ofMonths(1); }
//se.reference = Instant.now();
//JAXB.marshal(query, System.out);
System.out.println("Query definition ns: "+query.definition.getNamespaceURI());
System.out.println("Query definition elem: "+query.definition.getLocalName());
} }
@Test @Test
public void validateQueryRequest() throws IOException, SAXException, TransformerException{ public void validateQueryRequest() throws IOException, SAXException, TransformerException{
...@@ -101,4 +98,12 @@ public class TestUnmarshallDocuments { ...@@ -101,4 +98,12 @@ public class TestUnmarshallDocuments {
Assert.assertNotNull(r.deadline); Assert.assertNotNull(r.deadline);
} }
@Test
public void unmarshall_node_status(){
NodeStatus n = JAXB.unmarshal(getResource("/node-status.xml"), NodeStatus.class);
Assert.assertNotNull(n.timestamp);
Assert.assertNotNull(n.uptime);
}
} }
<broker-status>
<timestamp></timestamp>
<uptime></uptime>
<!-- latest software for nodes -->
<node-software>
<module id="dwh">
<version></version>
<url></url>
</module>
<module id="aktin.art-decor.runtime">
<version></version>
<url></url>
</module>
</node-software>
</broker-status>
\ No newline at end of file
<node-status> <node-status xmlns="http://aktin.org/ns/exchange">
<!-- when the status was collected --> <!-- when the status was collected -->
<timestamp>now</timestamp> <timestamp>2016-07-08T00:00:00Z</timestamp>
<!-- duration the (application)server is running --> <!-- duration the (application)server is running -->
<uptime></uptime> <uptime>PT15S</uptime>
<!-- timestamp when the latest data/CDA was imported --> <!-- timestamp when the latest data/CDA was imported -->
<latest-import></latest-import> <latest-import></latest-import>
<!-- version number of the running EAR, all other versions <!-- version number of the running EAR, all other versions
can be deduced from the release POM --> can be deduced from the release POM -->
<!-- get this info via new InitialContext().lookup("java:app/AppName") --> <!-- get this info via new InitialContext().lookup("java:app/AppName") -->
<software>dwh-ear-0.2-SNAPSHOT</software> <module id="dwh">
<version>dwh-ear-0.2-SNAPSHOT</version>
</module>
<module id="aktin.art-decor.runtime">
<version></version>
</module>
</node-status> </node-status>
\ No newline at end of file
<query xmlns="http://aktin.org/ns/exchange" <query xmlns="http://aktin.org/ns/exchange" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwh="http://aktin.org/ns/dwh" xmlns:psm="http://www.i2b2.org/xsd/cell/crc/psm/1.1/">
xmlns:dwh="http://aktin.org/ns/dwh"
xmlns:psm="http://www.i2b2.org/xsd/cell/crc/psm/1.1/">
<id>123</id> <id>123</id>
<description>Lala</description> <description>Lala</description>
<principal> <principal>
...@@ -9,21 +7,38 @@ ...@@ -9,21 +7,38 @@
<organisation>AKTIN</organisation> <organisation>AKTIN</organisation>
<email>it-support@aktin.org</email> <email>it-support@aktin.org</email>
<phone>+49 (441) 798 - 2772</phone> <phone>+49 (441) 798 - 2772</phone>
<!-- optional cryptographic signature at a later release <!-- optional cryptographic signature at a later release <signature></signature> -->
<signature></signature>
-->
</principal> </principal>
<schedule xsi:type="singleExecution"> <schedule xsi:type="singleExecution">
<duration>-P1M</duration> <duration>-P1M</duration>
<reference>2016-04-01T00:00:00Z</reference> <reference>2016-04-01T00:00:00Z</reference>
</schedule> </schedule>
<concepts> <!-- export descriptor -->
<concept id="birthdate" xsi:type="raw"/> <export xmlns="http://sekmi.de/ns/histream/export-v1" xmlns:eav="http://sekmi.de/histream/ns/eav-data">
</concepts> <concepts>
<group class="diag">
<concept wildcard-notation="ICD10:*" />
</group>
<concept notation="T:full" />
<concept wildcard-notation="CEDIS:*" />
</concepts>
<patient-table>
<column header="pid" xpath="@id" />
<column header="dob" xpath="eav:birthdate" />
<column header="sex" xpath="eav:gender" />
<column header="modified" xpath="eav:source/@timestamp" />
</patient-table>
<visit-table>
<column header="vid" xpath="@id" />
<column header="start" xpath="eav:start" />
<column header="f_start" xpath="eav:fact[@concept='T:full']/@start" />
<column header="f_end" xpath="eav:fact[@concept='T:full']/@end" />
<column header="f_loc" xpath="eav:fact[@concept='T:full']/@location" />
<column header="f_val" xpath="eav:fact[@concept='T:full']/eav:value" />
</visit-table>
</export>
<!-- also possible: xsi:type="psm:query_definition" --> <!-- also possible: xsi:type="psm:query_definition" -->
<!-- also possible: xsi:type="dwh:eclectic_query", <!-- also possible: xsi:type="dwh:eclectic_query", see http://methods.schattauer.de/en/contents/archivestandard/issue/2168/manuscript/21349/show.html -->
see http://methods.schattauer.de/en/contents/archivestandard/issue/2168/manuscript/21349/show.html
-->
<dwh:sql xsi:type="dwh:sqlt"> <dwh:sql xsi:type="dwh:sqlt">
SELECT a, b; SELECT a, b;
</dwh:sql> </dwh:sql>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment