diff --git a/histream-i2b2/src/main/java/de/sekmi/histream/i2b2/services/HiveServer.java b/histream-i2b2/src/main/java/de/sekmi/histream/i2b2/services/HiveServer.java deleted file mode 100644 index 93dec081d9fb10941b4f0281486c4e7534de7623..0000000000000000000000000000000000000000 --- a/histream-i2b2/src/main/java/de/sekmi/histream/i2b2/services/HiveServer.java +++ /dev/null @@ -1,160 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardWatchEventKinds; -import java.nio.file.WatchEvent; -import java.nio.file.WatchKey; -import java.nio.file.WatchService; - -import javax.annotation.Resource; -import javax.script.Invocable; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.ws.Endpoint; -import javax.xml.ws.Provider; -import javax.xml.ws.WebServiceContext; -import javax.xml.ws.handler.MessageContext; -import javax.xml.ws.http.HTTPBinding; - - -/** - * Provides REST interfaces to emulate an i2b2 server. - * @author Raphael - * - */ -//@WebServiceProvider() -//@ServiceMode(value = Service.Mode.MESSAGE) -//@BindingType(HTTPBinding.HTTP_BINDING) -public class HiveServer implements Provider{ - private ScriptEngineManager scriptManager; - private ScriptEngine scriptEngine; - private Path scriptDir; - private WatchService watcher; - - @Resource - protected WebServiceContext context; - - - public HiveServer() { - scriptManager = new ScriptEngineManager(); - // set bindings for callbacks to java code - //scriptManager.setBindings(bindings); - //scriptEngine = scriptManager.getEngineByName("nashorn"); - // load scripts - } - public void loadMainScript() throws IOException, ScriptException{ - scriptEngine = scriptManager.getEngineByName("nashorn"); - try( Reader scriptFile = new FileReader(scriptDir.resolve("main.js").toFile()) ) { - scriptEngine.eval(scriptFile); - Object o = scriptEngine.eval("typeof httpRequest === 'function'"); - if( o == null || !(o instanceof Boolean) || ((Boolean)o) != true ){ - throw new ScriptException("global function 'httpRequest(?,?,?,?)' needed"); - } - } - } - - public void reloadChangesLoop(){ - while( true ){ - WatchKey key; - try { - key = watcher.take(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - break; - } - System.out.println("Reloading scripts.."); - try { - loadMainScript(); - } catch (IOException | ScriptException e1) { - System.err.println("Error loading script"); - e1.printStackTrace(); - } - // pollEvents() is needed for the key to reset properly - for( WatchEvent e : key.pollEvents() ){ - if( e == null )continue;// noop - //System.out.println("Event: "+e.kind().toString() + ", "+e.toString()); - } - if( !key.reset() ){ - System.err.println("Key closed"); - break; - } - } - } - @SuppressWarnings("resource") // cannot close default filesystem - public void loadScipts()throws IOException, ScriptException{ - - FileSystem fs = FileSystems.getDefault(); - scriptDir = fs.getPath("src", "main", "scripts", "i2b2-ws"); - if( !Files.isDirectory(scriptDir) )throw new FileNotFoundException("Script dir not found: "+scriptDir); - loadMainScript(); - // TODO: watch directory and reload script if changes - watcher = fs.newWatchService(); - scriptDir.register(watcher, StandardWatchEventKinds.ENTRY_MODIFY); - - /* - try( DirectoryStream dir = Files.newDirectoryStream(scriptDir, "*.js") ){ - for( Path script : dir ){ - System.out.println("Script: "+script.normalize().toString()); - ScriptEngine se = scriptManager.getEngineByName("nashorn"); - try { - se.eval(new FileReader(script.toFile())); - System.out.println("cell.name="+se.eval("this.cell.id").toString()); - } catch (ScriptException e) { - e.printStackTrace(); - } - } - }*/ - } - public static void main(String args[]) throws IOException, ScriptException{ - HiveServer hs = new HiveServer(); - hs.loadScipts(); - Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, hs); - // use executor for more control over parallel executions - //e.setExecutor(/*...*/); - String address = "http://localhost:9000/i2b2/services"; - e.publish(address); - - hs.reloadChangesLoop(); - - } - - @Override - public StreamSource invoke(Source request) { - // TODO Auto-generated method stub - MessageContext mc = context.getMessageContext(); - String path = (String)mc.get(MessageContext.PATH_INFO); - String query = (String)mc.get(MessageContext.QUERY_STRING); - String httpMethod = (String)mc.get(MessageContext.HTTP_REQUEST_METHOD); - if( request != null ){ - System.out.println("Source: "+request.getClass()); - } - if( scriptEngine != null )try { - Object ret = ((Invocable)scriptEngine).invokeFunction("httpRequest", httpMethod, path, query, request); - return new StreamSource(new StringReader(ret.toString())); - } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ScriptException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - /* - @SuppressWarnings("unchecked") - java.util.Map> headers = - (Map>) context.getMessageContext().get(MessageContext.HTTP_RESPONSE_HEADERS); - headers.put("Content-Type", Arrays.asList("text/html"));*/ - return new StreamSource(new StringReader("ERROR")); - } -} diff --git a/li2b2/li2b2-api/.gitignore b/li2b2/li2b2-api/.gitignore deleted file mode 100644 index 8360da6d69893ae285a79a9d8ee7645b3951a524..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.settings/ -.classpath -.project -target/ diff --git a/li2b2/li2b2-api/README.md b/li2b2/li2b2-api/README.md deleted file mode 100644 index f2c40beaef112679ba5236ab6921d2edddee4a0a..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/README.md +++ /dev/null @@ -1,7 +0,0 @@ - -i2b2 client implementation --------------------------- - -Lightweight client implementation to authenticate with -an i2b2 hive, manage users/roles and run queries. - \ No newline at end of file diff --git a/li2b2/li2b2-api/pom.xml b/li2b2/li2b2-api/pom.xml deleted file mode 100644 index 5be449151459b777bb73c3253db9db456db0c647..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - 4.0.0 - HIStream : li2b2 : API - jar - - - li2b2 server backend API. Implement this - to run a custom i2b2 server. - - - de.sekmi.histream.li2b2 - li2b2-api - 0.8-SNAPSHOT - - - de.sekmi.histream.li2b2 - pom - 0.8-SNAPSHOT - - - - - - junit - junit - - - \ No newline at end of file diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryInstance.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryInstance.java deleted file mode 100644 index dc0143594e0a6402a5d0ede3336bf80bdf425720..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryInstance.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.sekmi.histream.i2b2.api.crc; - -import java.util.List; - -public interface QueryInstance { - String getId(); // instance id - QueryStatus getStatus(); - List getResults(); - -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryManager.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryManager.java deleted file mode 100644 index 11fc699830c115fb114752741122f762427b6150..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryManager.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.sekmi.histream.i2b2.api.crc; - -import java.util.List; - -import org.w3c.dom.Element; - -public interface QueryManager { - - QueryMaster runQuery(Element definition, List results); - - QueryMaster getQuery(String queryId); - - /** - * List queries for user - * @param userId user id - * @return queries - */ - Iterable listQueries(String userId); - - /** - * Return supported result types - * @return result types - */ - Iterable getResultTypes(); -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryMaster.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryMaster.java deleted file mode 100644 index 0c2b9f30c6614e80211b2e0c53ea191a1f91c504..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryMaster.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.sekmi.histream.i2b2.api.crc; - -import java.time.Instant; - -import org.w3c.dom.Element; - -public interface QueryMaster { - String getId(); - String getDisplayName(); - String getUser(); - Element getDefinition(); - Instant getCreateDate(); - /** - * Get the instance/execution for the query. - * XXX maybe add support for multiple executions later - * @return execution instance - */ - QueryInstance getInstance(); -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryResult.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryResult.java deleted file mode 100644 index 31e3447b5afacfd2349d1aa506508e57c5fafecf..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryResult.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.sekmi.histream.i2b2.api.crc; - -import java.time.Instant; - -public interface QueryResult { - String getId(); // result id - String getDescription(); - ResultType getResultType(); - Integer getSetSize(); - Instant getStartDate(); - Instant getEndDate(); - QueryStatus getStatus(); -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryStatus.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryStatus.java deleted file mode 100644 index f5d50587e78585394a2131f4424fe763f05d8885..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/QueryStatus.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.sekmi.histream.i2b2.api.crc; - -public enum QueryStatus { - ERROR, COMPLETED(6), FINISHED(3), INCOMPLETE, WAITTOPROCESS, PROCESSING; - - int typeId; - private QueryStatus(int typeId){ - this.typeId = typeId; - } - private QueryStatus(){ - this.typeId = 0; - } -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/ResultType.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/ResultType.java deleted file mode 100644 index 656ca4600942414a2ff5a37ee53fce66531018e4..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/crc/ResultType.java +++ /dev/null @@ -1,7 +0,0 @@ -package de.sekmi.histream.i2b2.api.crc; - -public interface ResultType { - Integer getId(); - String getName(); - String getDescription(); -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Concept.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Concept.java deleted file mode 100644 index 855e3d6686d6fff6bb9148d81634c1b635cb17d8..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Concept.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.sekmi.histream.i2b2.api.ont; - -public interface Concept { - String getKey(); - String getDisplayName(); - - default Integer getTotalNum(){return null;} - default Concept getSynonymTarget(){return null;} - - boolean hasNarrower(); - Iterable getNarrower(); - - boolean hasModifiers(); - Iterable getModifiers(); - - /* TODO implement concept_cd - concept_dimension - concept_path - T - LIKE - \i2b2\Diagnoses\Conditions in the perinatal period (760-779)\ - */ -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Modifier.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Modifier.java deleted file mode 100644 index e8be386b1028116aa2931213dee2af54d2b01cd8..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Modifier.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.sekmi.histream.i2b2.api.ont; - -public interface Modifier { - -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Ontology.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Ontology.java deleted file mode 100644 index 02502ca81ec5ceb418f7bda74448543bcbd5b195..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/ont/Ontology.java +++ /dev/null @@ -1,7 +0,0 @@ -package de.sekmi.histream.i2b2.api.ont; - -public interface Ontology { - Iterable getCategories(); - - Concept getConceptByKey(String key); -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/package-info.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/package-info.java deleted file mode 100644 index 1085b272c820d8a6443d36969e8bedd1884ef23b..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * This package and its sub packages contain interfaces - * to implement backend functionality for the i2b2 server - * emulation. - *

- *

- */ -package de.sekmi.histream.i2b2.api; - diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/Project.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/Project.java deleted file mode 100644 index 2e7aa0a7425227a3b1cc08770a21a01c7c62a3aa..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/Project.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.sekmi.histream.i2b2.api.pm; - -public interface Project { - - /** - * Unique id - * @return id - */ - String getId(); - /** - * Short human readable name for the project. - * @return name - */ - String getName(); - - void addUserRole(User user, String role); - Iterable getUserRoles(User user); - // TODO removeUser (removes all roles), removeUserRole -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/ProjectManager.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/ProjectManager.java deleted file mode 100644 index 21cfd239b9d6dd584eefe6ebdda2555b233b13db..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/ProjectManager.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.sekmi.histream.i2b2.api.pm; - -/** - * User authorisation and association of projects - * - * @author R.W.Majeed - * - */ -public interface ProjectManager { - - User getUserById(String userId); - Project getProjectById(String projectId); -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/SessionManager.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/SessionManager.java deleted file mode 100644 index d5a51a516f41fcceb2546bbc4628d21131de02bc..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/SessionManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package de.sekmi.histream.i2b2.api.pm; - -public interface SessionManager { - - - public interface Session{ - String getId(); - String getUserId(); - String getProjectId(); - // XXX set project id? or set at creation? - long getCreationTime(); - long getLastAccess(); - } - - /** - * Access an existing session by its session id. - * This operation will also update the {@link Session#getLastAccess()} - * time stamp. - * - * @param sessionId session id - * @return session or {@code null} if not available or expired. - */ - public Session accessSession(String sessionId); - - public Session createSession(String userId); - public void deleteSession(String sessionId); - - - /** - * Get the timeout duration in milliseconds. Sessions - * last accessed longer than this will be discarded. - * @return timeout in milliseconds - */ - public long getTimeoutMillis(); - /** - * Iterate over all sessions. The remove() operation should - * be supported by the iterators. - * @return all sessions - */ - Iterable allSessions(); -} diff --git a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/User.java b/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/User.java deleted file mode 100644 index 782b1fbabb04a7bcddde8483a03c867d8ec27f64..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-api/src/main/java/de/sekmi/histream/i2b2/api/pm/User.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.sekmi.histream.i2b2.api.pm; - -import java.security.Principal; - -public interface User extends Principal{ - String getFullName(); - boolean isAdmin(); - - Iterable getProjects(); - // check password - boolean hasPassword(char[] password); - void setPassword(char[] newPassword); -} diff --git a/li2b2/li2b2-client/.gitignore b/li2b2/li2b2-client/.gitignore deleted file mode 100644 index 8360da6d69893ae285a79a9d8ee7645b3951a524..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-client/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.settings/ -.classpath -.project -target/ diff --git a/li2b2/li2b2-client/README.md b/li2b2/li2b2-client/README.md deleted file mode 100644 index f2c40beaef112679ba5236ab6921d2edddee4a0a..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-client/README.md +++ /dev/null @@ -1,7 +0,0 @@ - -i2b2 client implementation --------------------------- - -Lightweight client implementation to authenticate with -an i2b2 hive, manage users/roles and run queries. - \ No newline at end of file diff --git a/li2b2/li2b2-client/pom.xml b/li2b2/li2b2-client/pom.xml deleted file mode 100644 index d85d2487b11d1800af95710e3c19b4251fe9eb72..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-client/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - 4.0.0 - HIStream : li2b2 : client - jar - - - Lightweight client implementation to authenticate with - an i2b2 hive, manage users/roles and run queries. - - - de.sekmi.histream.li2b2 - li2b2-client - 0.8-SNAPSHOT - - - de.sekmi.histream.li2b2 - pom - 0.8-SNAPSHOT - - - - - - junit - junit - - - \ No newline at end of file diff --git a/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/CellClient.java b/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/CellClient.java deleted file mode 100644 index 2091b7501c35691212c4b6c95514b171b019d991..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/CellClient.java +++ /dev/null @@ -1,136 +0,0 @@ -package de.sekmi.histream.li2b2.client; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.StringReader; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.Objects; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.transform.TransformerException; -import javax.xml.xpath.XPathExpressionException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -public class CellClient { - private static final Logger log = Logger.getLogger(CellClient.class.getName()); - - protected Client client; - protected URL serviceUrl; - - public CellClient(Client client, URL serviceUrl){ - this.client = client; - this.serviceUrl = serviceUrl; - } - protected String getOutputCharset(){ - return client.getOutputEncoding(); - } - - protected URL createRequest(String path) throws MalformedURLException{ - return new URL(serviceUrl, path); - } - protected DocumentBuilder newBuilder(){ - return client.newBuilder(); - } - - /** - * Create a new request message. Will also set the security - * credentials. - * - * @param builder document builder - * @return request message - */ - protected Request createRequestMessage(DocumentBuilder builder){ - Request req = client.createRequest(builder); - req.setSecurity(client.credentials); - req.setProjectId(client.getProjectId()); - // TODO set message id - return req; - } - protected Request createRequestMessage(){ - return createRequestMessage(newBuilder()); - } - protected Request createRequestMessage(String bodyXML) throws SAXException, IOException{ - DocumentBuilder b = newBuilder(); - Request req = createRequestMessage(b); - // parse body XML - Document dom = b.parse(new InputSource(new StringReader(bodyXML))); - Element body = req.getMessageBody(); - Objects.requireNonNull(body, "no message_body"); - // move parsed DOM into message_body - body.appendChild(body.getOwnerDocument().adoptNode(dom.getDocumentElement())); - return req; - } - /** - * Create the HTTP connection. Will use the proxy specified by - * the client and fill the redirect URL in the message header. - *

- * This method will also prepare the returned connection for - * the {@link URLConnection#connect()} call. Specifically, - * the request method will be set to {@code POST}, and the - * {@code Content-Type} header will be set to {@code application/xml} - * with output charset. - *

- * @param request request - * @param requestUrl URL - * @throws IOException io error - */ - protected HttpURLConnection createConnection(Request request, URL requestUrl) throws IOException{ - HttpURLConnection c; - if( client.getProxy() != null ){ - request.setRedirectUrl(requestUrl); - c = (HttpURLConnection)client.getProxy().openConnection(); - }else{ - // clear redirect URL - request.setRedirectUrl(null); - c = (HttpURLConnection)requestUrl.openConnection(); - } - c.setRequestMethod("POST"); - c.setDoOutput(true); - c.setRequestProperty("Content-Type", "application/xml; charset="+getOutputCharset()); - return c; - } - protected Response submitRequest(Request request, String method) throws MalformedURLException, IOException{ - return submitRequest(newBuilder(), request, createRequest(method)); - } - protected Response submitRequest(DocumentBuilder b, Request request, URL requestUrl) throws IOException{ - HttpURLConnection c = createConnection(request, requestUrl); - c.connect(); - OutputStream out = c.getOutputStream(); - - try { - log.info("Submitting to "+requestUrl); - DOMUtils.printDOM(request.dom, System.out); - DOMUtils.printDOM(request.dom, out, getOutputCharset()); - } catch (TransformerException e) { - throw new IOException(e); - } - out.close(); - int status = c.getResponseCode(); - // check status code for failure - if( status != 200 ){ - throw new IOException("Unexpected HTTP response code "+status); - } -// System.out.println("Response:"+status); - InputStream in = c.getInputStream(); - Document resp; - try { - resp = b.parse(in); - DOMUtils.stripWhitespace(resp.getDocumentElement()); - } catch (SAXException | XPathExpressionException e) { - throw new IOException("Unable to parse response XML",e); - } - log.info("Received response:"); - DOMUtils.printDOM(resp, System.out); - return new Response(resp); - } - -} diff --git a/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/Client.java b/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/Client.java deleted file mode 100644 index fd4a9ef306651ebc551ec2e45c0547d36b365364..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/Client.java +++ /dev/null @@ -1,123 +0,0 @@ -package de.sekmi.histream.li2b2.client; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPathExpressionException; - -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import de.sekmi.histream.li2b2.client.pm.UserConfiguration; -import de.sekmi.histream.li2b2.client.ont.OntologyClient; -import de.sekmi.histream.li2b2.client.pm.Cell; -import de.sekmi.histream.li2b2.client.pm.PMClient; - -public class Client { - private static final Logger log = Logger.getLogger(Client.class.getName()); - - // configuration for connection - private URL proxy; - // information from server - UserConfiguration info; - Credentials credentials; - String projectId; - - private PMClient pm; - private OntologyClient ont; - - private Document requestTemplate; - private DocumentBuilderFactory factory; - - private String outputEncoding; - - public Client() throws IOException{ - factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - this.outputEncoding = "UTF-8"; - DocumentBuilder b; - try { - b = factory.newDocumentBuilder(); - requestTemplate = b.parse(getClass().getResourceAsStream("/request_template.xml")); - DOMUtils.stripWhitespace(requestTemplate.getDocumentElement()); - } catch (ParserConfigurationException | SAXException | XPathExpressionException e) { - throw new IOException(e); - } - } - - public void setProjectId(String projectId){ - this.projectId = projectId; - } - public String getProjectId(){ - return this.projectId; - } - public void setProxy(URL proxy){ - this.proxy = proxy; - } - public URL getProxy(){ - return this.proxy; - } - public String getOutputEncoding(){ - return outputEncoding; - } - - public void setAuthorisation(String user, String password, String domain, boolean isToken){ - setAuthorisation(new Credentials(domain, user, password, isToken)); - } - public void setAuthorisation(Credentials credentials){ - this.credentials = credentials; - } - DocumentBuilder newBuilder(){ - try { - return factory.newDocumentBuilder(); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } - } - - - public void setPM(URL pmService){ - this.pm = new PMClient(this, pmService); - } - public void setONT(URL url){ - this.ont = new OntologyClient(this, url); - } - - public PMClient PM(){ - return this.pm; - } - public OntologyClient ONT(){ - return this.ont; - } - public Request createRequest(DocumentBuilder builder){ - Document req = builder.newDocument(); - req.appendChild(req.importNode(requestTemplate.getDocumentElement(), true)); - Request r = new Request(req); - // TODO random message id - r.setMessageId("asdf", "0"); - return r; - } - - public void setServices(Cell[] cells){ - for( int i=0; i - Element el = req.addBodyElement(XMLNS, "get_categories"); - el.setAttribute("synonyms", "true"); - el.setAttribute("hiddens", "false"); - el.setAttribute("type", "core"); - // submit - Response resp = submitRequest(req, "getCategories"); - ResultStatus rs = resp.getResultStatus(); - if( !rs.getCode().equals("DONE") ){ - throw new HiveException(rs); - } - // parse concepts - // TODO move to private method since we will need this more often - NodeList nl = resp.getMessageBody().getElementsByTagName("concept"); - Concept[] concepts = new Concept[nl.getLength()]; - try { - Unmarshaller um = JAXBContext.newInstance(Concept.class).createUnmarshaller(); - for( int i=0; iundefined - // - Element el = req.addBodyElement(XMLNS, "get_user_configuration"); - el.appendChild(el.getOwnerDocument().createElement("project")).setTextContent("undefinded"); - // submit - Response resp = submitRequest(req, "getServices"); - ResultStatus rs = resp.getResultStatus(); - if( !rs.getCode().equals("DONE") ){ - throw new HiveException(rs); - } - Element body = resp.getMessageBody(); - Node n = body.getFirstChild(); - if( n == null || n.getNodeType() != Node.ELEMENT_NODE - || n.getNamespaceURI() == null || !n.getNamespaceURI().equals(I2b2Constants.PM_NS) - || !n.getLocalName().equals("configure") ) - { - throw new IOException("pm:configure element expected in response message_body instead of "+n); - } - UserConfiguration config = UserConfiguration.parse((Element)n); - // if we have a session key, use it for future calls - if( config.getSessionKey() != null ){ - log.info("Using session key for future calls: "+config.getSessionKey()); - client.setAuthorisation( - new Credentials( - config.getUserDomain(), - config.getUserName(), - config.getSessionKey(), - true) - ); - } - return config; - } - -} diff --git a/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/pm/Project.java b/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/pm/Project.java deleted file mode 100644 index 71bfdc812d20957907df8ec21aeeb89adbd567ee..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/pm/Project.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.sekmi.histream.li2b2.client.pm; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="project") -@XmlAccessorType(XmlAccessType.FIELD) -public class Project { - - @XmlAttribute - public String id; - public String name; - public String wiki; - public String description; - public String path; - public String[] role; -} diff --git a/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/pm/UserConfiguration.java b/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/pm/UserConfiguration.java deleted file mode 100644 index 6a3d480242519617b93ca3e416c7ca9f1df4ca6b..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-client/src/main/java/de/sekmi/histream/li2b2/client/pm/UserConfiguration.java +++ /dev/null @@ -1,79 +0,0 @@ -package de.sekmi.histream.li2b2.client.pm; - -import javax.xml.bind.JAXB; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.dom.DOMSource; - -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import de.sekmi.histream.li2b2.client.ont.Concept; - -public class UserConfiguration { - - private boolean isAdmin; - private String fullName; - private String sessionKey; - private String userName; - private String userDomain; - - - Project[] projects; - Cell[] cells; - - - public String getSessionKey(){ - return sessionKey; - } - public String getUserName(){ - return userName; - } - public String getUserDomain(){ - return userDomain; - } - public boolean isAdmin(){ - return isAdmin; - } - private void parseElement(Element configure){ - Element user = (Element)configure.getElementsByTagName("user").item(0); - fullName = user.getElementsByTagName("full_name").item(0).getTextContent(); - userName = user.getElementsByTagName("user_name").item(0).getTextContent(); - userDomain = user.getElementsByTagName("domain").item(0).getTextContent(); - sessionKey = user.getElementsByTagName("password").item(0).getTextContent(); - // TODO verify that @is_token==true - isAdmin = Boolean.parseBoolean(user.getElementsByTagName("is_admin").item(0).getTextContent()); - try { - Unmarshaller um; - um = JAXBContext.newInstance(Cell.class, Project.class).createUnmarshaller(); - - NodeList nl = user.getElementsByTagName("project"); - projects = new Project[nl.getLength()]; - for( int i=0; i - - - - http://services.i2b2.org/i2b2/services/PMService/getServices - - - 1.1 - 2.4 - - i2b2 Project Management - 1.6 - - - i2b2 Hive - - - Project Management Cell - 1.6 - - - i2b2 Hive - - 2016-07-20T12:22:50+02:00 - - i2b2demo - demo - - - - 8b5M3z5lb2nU1g6Zq2QSm - 0 - - - P - I - - AL - AL - US - undefined - - - 180000 - - - - \ No newline at end of file diff --git a/li2b2/li2b2-client/src/test/java/de/sekmi/histream/li2b2/client/TestClient.java b/li2b2/li2b2-client/src/test/java/de/sekmi/histream/li2b2/client/TestClient.java deleted file mode 100644 index 58e5a6f4ed2b811cb11d28eda38d50e316d45203..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-client/src/test/java/de/sekmi/histream/li2b2/client/TestClient.java +++ /dev/null @@ -1,42 +0,0 @@ -package de.sekmi.histream.li2b2.client; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Arrays; - -import org.junit.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import de.sekmi.histream.li2b2.client.Response.ResultStatus; -import de.sekmi.histream.li2b2.client.ont.Concept; -import de.sekmi.histream.li2b2.client.pm.Project; -import de.sekmi.histream.li2b2.client.pm.UserConfiguration; - -public class TestClient { - - - @Test - public void testWithHarvard() throws Exception{ - Client c = new Client(); - c.setProxy(new URL("https://www.i2b2.org/webclient/index.php")); - c.setPM(new URL("http://services.i2b2.org/i2b2/services/PMService/")); - c.setAuthorisation("demo", "demouser", "i2b2demo", false); - UserConfiguration uc = c.PM().requestUserConfiguration(); - Project[] projects = uc.getProjects(); - if( projects != null ){ - // use first project - c.setProjectId(projects[0].id); - - System.out.println("Project:"+projects[0].id); - System.out.println("Roles:"+Arrays.toString(projects[0].role)); - } - // initialise other cells - c.setServices(uc.getCells()); - Concept[] cats = c.ONT().getCategories(); - System.out.println("Found "+cats.length+" concepts"); - for( int i=0; i - 4.0.0 - HIStream : li2b2 : server - war - - - This project emulates the core components - of an i2b2 server backend. Basic functionality - of PM, CRC, ONT and WORK cells allows the - official i2b2 webclient to connect ot this - emulated server. - - - de.sekmi.histream.li2b2 - li2b2-server - 0.8-SNAPSHOT - - - de.sekmi.histream.li2b2 - pom - 0.8-SNAPSHOT - - - - - jetty - - - - - org.eclipse.jetty - jetty-maven-plugin - - 9.3.8.v20160314 - - true - true - 5 - ${project.basedir}/src/main/webapp/WEB-INF/jetty-context.xml - - ${project.basedir}/src/main/webapp/WEB-INF/jetty-defaults-web.xml - ${project.basedir}/src/main/webapp/WEB-INF/jetty-env.xml - - - - - - org.glassfish.jersey.media - jersey-media-json-jackson - 2.14 - - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.10 - - - unpack - generate-resources - - unpack - - - - - - org.i2b2 - webclient - 1.7.07c - zip - - - ${project.build.directory}/classes - - - - - - - - - - - org.glassfish.jersey.containers - jersey-container-servlet - 2.14 - provided - - - org.glassfish.jersey.containers.glassfish - jersey-gf-cdi - 2.14 - provided - - - org.glassfish.jersey.containers.glassfish - jersey-gf-cdi-ban-custom-hk2-binding - 2.14 - provided - - - - org.jboss.weld.servlet - weld-servlet-core - 2.2.5.Final - provided - - - - - - - - - src/main/resources - - - target/generated-resources - - - - - - - - - - de.sekmi.histream.li2b2 - li2b2-api - 0.8-SNAPSHOT - - - javax.ws.rs - javax.ws.rs-api - 2.0.1 - provided - - - javax.inject - javax.inject - 1 - provided - - - javax.annotation - javax.annotation-api - 1.2 - provided - - - - - - org.freemarker - freemarker - 2.3.23 - - - - junit - junit - - - - org.jboss.resteasy - resteasy-undertow - 3.0.18.Final - test - - - - org.jboss.resteasy - resteasy-cdi - 3.0.18.Final - test - - - - javax.enterprise - cdi-api - 1.2 - test - - - - org.jboss.weld.servlet - weld-servlet - 2.3.5.Final - test - - - - io.undertow - undertow-servlet - 1.3.23.Final - test - - - - -
\ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/AbstractService.java b/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/AbstractService.java deleted file mode 100644 index 884e1fdfa6281a86cc9e9e0ef9c2e244674aa650..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/AbstractService.java +++ /dev/null @@ -1,112 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.IOException; -import java.io.InputStream; -import java.time.Instant; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -public abstract class AbstractService { - private static final Logger log = Logger.getLogger(AbstractService.class.getName()); - public static final String HIVE_NS="http://www.i2b2.org/xsd/hive/msg/1.1/"; - - /** - * Service name (for communication to client). - *

- * The default implementation returns {@link Class#getSimpleName()}. - *

- * @return service name, e.g. Workplace Cell - */ - public String getName(){ - return getClass().getSimpleName(); - } - /** - * Service version (for communication to client) - *

- * The default implementation returns {@link Package#getImplementationVersion()} - * for the implementing class. - *

- * @return service version, e.g. 1.700 - */ - public String getVersion(){ - return getClass().getPackage().getImplementationVersion(); - } - - DocumentBuilder newDocumentBuilder() throws ParserConfigurationException{ - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - // use schema? - //factory.setSchema(schema); - factory.setNamespaceAware(true); - return factory.newDocumentBuilder(); - } - Document parseRequest(DocumentBuilder builder, InputStream requestBody) throws SAXException, IOException{ - Document dom = builder.parse(requestBody); - // remove whitespace nodes from message header - Element root = dom.getDocumentElement(); - try { - stripWhitespace(root); - } catch (XPathExpressionException e) { - log.log(Level.WARNING, "Unable to strip whitespace from request", e); - } - return dom; - } - HiveRequest parseRequest(Document request){ - return HiveRequest.parse(request.getDocumentElement()); - } - private void stripWhitespace(Element node) throws XPathExpressionException{ - XPathFactory xf = XPathFactory.newInstance(); - // XPath to find empty text nodes. - XPathExpression xe = xf.newXPath().compile("//text()[normalize-space(.) = '']"); - NodeList nl = (NodeList)xe.evaluate(node, XPathConstants.NODESET); - - // Remove each empty text node from document. - for (int i = 0; i < nl.getLength(); i++) { - Node empty = nl.item(i); - empty.getParentNode().removeChild(empty); - } - } - -// private void appendTextNode(Element el, String name, String value){ -// Element sub = (Element)el.appendChild(el.getOwnerDocument().createElement(name)); -// if( value != null ){ -// sub.appendChild(el.getOwnerDocument().createTextNode(value)); -// } -// } - Document createResponse(DocumentBuilder builder, Element request_header){ - Document dom = builder.newDocument(); - Element re = (Element)dom.appendChild(dom.createElementNS(HIVE_NS, "response")); - NodeList nl; - try { - Document rh = builder.parse(getClass().getResourceAsStream("/templates/response_header.xml")); - stripWhitespace(rh.getDocumentElement()); - // sending application - nl = rh.getElementsByTagName("sending_application").item(0).getChildNodes(); - nl.item(0).setTextContent(getName()); - nl.item(1).setTextContent(getVersion()); - // timestamp - rh.getElementsByTagName("datetime_of_message").item(0).setTextContent(Instant.now().toString()); - // security - nl = rh.getElementsByTagName("security").item(0).getChildNodes(); - // TODO message_id, project, session - re.appendChild(dom.adoptNode(rh.getDocumentElement())); - } catch (SAXException | IOException | XPathExpressionException e) { - log.log(Level.WARNING, "unable to process response header template", e); - } - - return dom; - } -} diff --git a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/HiveRequest.java b/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/HiveRequest.java deleted file mode 100644 index 55d8da0c29ccc8686e597991bec1608e22a86378..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/HiveRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class HiveRequest { - // message header - String clientName; - String clientVersion; - String secDomain; - String secUser; - String secPassword; - boolean secToken; - String messageId; - String projectId; - // request header - // message body - Element messageBody; - - public static HiveRequest parse(Element request){ - HiveRequest me = new HiveRequest(); - Node n = request.getFirstChild(); - if( n.getNodeType() != Node.ELEMENT_NODE || !n.getNodeName().equals("message_header") ){ - throw new RuntimeException("request should have message_header as first node instead of "+n.getNodeName()); - } - Element mh = (Element)n; - NodeList nl = mh.getElementsByTagName("sending_application").item(0).getChildNodes(); - me.clientName = nl.item(0).getTextContent(); - me.clientVersion = nl.item(1).getTextContent(); - nl = mh.getElementsByTagName("security").item(0).getChildNodes(); - me.secDomain = nl.item(0).getTextContent(); - me.secUser = nl.item(1).getTextContent(); - me.secPassword = nl.item(2).getTextContent(); - me.secToken = ((Element)nl.item(2)).getAttribute("is_token").equals("true"); - me.messageId = mh.getElementsByTagName("message_control_id").item(0).getFirstChild().getTextContent(); - n = request.getLastChild(); - if( n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equals("message_body") ){ - me.messageBody = (Element)n; - } - return me; - } -} diff --git a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/OntologyService.java b/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/OntologyService.java deleted file mode 100644 index a2108af2832b937b7e987a9ccb3d89f3d56f871c..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/OntologyService.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.util.logging.Logger; - -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.Response; - -@Path("/i2b2/services/OntologyService") -public class OntologyService { - private static final Logger log = Logger.getLogger(OntologyService.class.getName()); - - @POST - @Path("getSchemes") - public Response getSchemes(){ - log.info("schemes"); - return Response.ok(getClass().getResourceAsStream("/templates/ont/getSchemes.xml")).build(); - } - @POST - @Path("getCategories") - public Response getCategories(){ - log.info("categories"); - return Response.ok(getClass().getResourceAsStream("/templates/ont/getCategories.xml")).build(); - } - @POST - @Path("getTermInfo") - public Response getTermInfo(){ - log.info("termInfo"); - return Response.ok(getClass().getResourceAsStream("/templates/ont/terminfo.xml")).build(); - } -} diff --git a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/PMService.java b/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/PMService.java deleted file mode 100644 index cfa48c5b5e79c06ba559559478f59e74f7ce7c9a..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/PMService.java +++ /dev/null @@ -1,64 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.IOException; -import java.io.StringWriter; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.Response; - -import freemarker.template.Template; -import freemarker.template.TemplateException; - -@Singleton -@Path("/i2b2/services/PMService") -public class PMService extends AbstractService{ - private static final Logger log = Logger.getLogger(PMService.class.getName()); - - @Inject - Settings config; - - @POST - @Path("getServices") - public Response getServices(){ - StringWriter w = new StringWriter(2048); - Map map = new HashMap<>(); - map.put("timestamp", Instant.now().toString()); - try { - Template t = config.getFreemarkerConfiguration().getTemplate("getServices.xml"); - t.process(map, w); - } catch (IOException | TemplateException e) { - log.log(Level.SEVERE, "Template error", e); - } - - return Response.ok(w.toString()).build(); - } - @GET - @Path("test") - public Response test(){ - StringWriter w = new StringWriter(2048); - Map map = new HashMap<>(); - map.put("timestamp", Instant.now().toString()); - try { - Template t = config.getFreemarkerConfiguration().getTemplate("getServices.xml"); - t.process(map, w); - } catch (IOException | TemplateException e) { - log.log(Level.SEVERE, "Template error", e); - } - - return Response.ok(w.toString()).build(); - } - @Override - public String getVersion() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/QueryToolService.java b/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/QueryToolService.java deleted file mode 100644 index 25874c940601c2ec443de53041a42c244e4559f1..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/QueryToolService.java +++ /dev/null @@ -1,88 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.IOException; -import java.io.InputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -@Path("/i2b2/services/QueryToolService") -public class QueryToolService { - private static final Logger log = Logger.getLogger(QueryToolService.class.getName()); - - @POST - @Path("request") - public Response request(InputStream body){ - Document dom = null; - try { - DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance(); - fac.setIgnoringElementContentWhitespace(true); - fac.setNamespaceAware(true); - DocumentBuilder b = fac.newDocumentBuilder(); - dom = b.parse(body); - dom.normalizeDocument(); - body.close(); - } catch (ParserConfigurationException | SAXException | IOException e) { - log.log(Level.SEVERE,"XML error",e); - return Response.status(500).build(); - } - // get request type - NodeList nl = dom.getElementsByTagName("request_type"); - String type = null; - if( nl.getLength() != 0 ){ - type = nl.item(0).getTextContent(); - } - // find request body - Node sib = nl.item(0).getParentNode().getNextSibling(); - while( sib != null && sib.getNodeType() == Node.TEXT_NODE && sib.getTextContent().trim().length() == 0 ){ - sib = sib.getNextSibling(); - } - Element req = null; - if( sib != null && sib.getNodeType() == Node.ELEMENT_NODE ){ - req = (Element)sib; - } - - return request(type, req); - } - - private Response request(String type, Element request){ - String rtype = null; - if( request != null ){ - rtype = request.getAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type"); - } - log.info("Request:"+type+" type="+rtype); - if( type.equals("CRC_QRY_getResultType") ){ - InputStream xml = getClass().getResourceAsStream("/templates/crc/resulttype.xml"); - if( xml == null ){ - log.warning("resulttype.xml not found"); - } - return Response.ok(xml).build(); - }else if( type.equals("CRC_QRY_getQueryMasterList_fromUserId") ){ - return Response.ok(getClass().getResourceAsStream("/templates/crc/masterlist.xml")).build(); - }else if( type.equals("CRC_QRY_runQueryInstance_fromQueryDefinition") ){ - // XXX - return Response.ok(getClass().getResourceAsStream("/templates/crc/master_instance_result.xml")).build(); - }else if( type.equals("CRC_QRY_deleteQueryMaster") ){ - // XXX - return Response.noContent().build(); - }else{ - // XXX - return Response.noContent().build(); - } - } -} diff --git a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/Settings.java b/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/Settings.java deleted file mode 100644 index 821f262de710b7138ae66de54f58195e5cc603be..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/Settings.java +++ /dev/null @@ -1,46 +0,0 @@ -package de.sekmi.histream.i2b2.services; - - -import java.util.logging.Logger; - -import javax.inject.Singleton; - -import freemarker.cache.ClassTemplateLoader; -import freemarker.template.Configuration; -import freemarker.template.TemplateExceptionHandler; - -@Singleton -public class Settings { - private static final Logger log = Logger.getLogger(Settings.class.getName()); - - private Configuration fmConfig; - - public Settings(){ - log.info("Creating freemarker config"); - // Create your Configuration instance, and specify if up to what FreeMarker - // version (here 2.3.25) do you want to apply the fixes that are not 100% - // backward-compatible. See the Configuration JavaDoc for details. - Configuration cfg = new Configuration(Configuration.VERSION_2_3_23); - - // Specify the source where the template files come from. Here I set a - // plain directory for it, but non-file-system sources are possible too: - cfg.setTemplateLoader(new ClassTemplateLoader(Settings.class, "/")); - - // Set the preferred charset template files are stored in. UTF-8 is - // a good choice in most applications: - cfg.setDefaultEncoding("UTF-8"); - - // Sets how errors will appear. - // During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER is better. - cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); - - // Don't log exceptions inside FreeMarker that it will thrown at you anyway: - cfg.setLogTemplateExceptions(false); - this.fmConfig = cfg; - } - - - public Configuration getFreemarkerConfiguration(){ - return fmConfig; - } -} diff --git a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/WorkplaceService.java b/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/WorkplaceService.java deleted file mode 100644 index 87fe76308fc6f7ffe2cb879d376a234e0ae02172..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/java/de/sekmi/histream/i2b2/services/WorkplaceService.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.InputStream; -import java.util.logging.Logger; - -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.Response; - -@Path("/i2b2/services/WorkplaceService") -public class WorkplaceService { - private static final Logger log = Logger.getLogger(WorkplaceService.class.getName()); - - @POST - @Path("getFoldersByUserId") - public Response getFoldersByUserId(){ - InputStream xml = getClass().getResourceAsStream("/templates/work/folders.xml"); - if( xml == null ){ - log.warning("folders.xml not found"); - }else{ - log.info("folders"); - } - return Response.ok(xml).build(); - } -} diff --git a/li2b2/li2b2-server/src/main/resources/META-INF/beans.xml b/li2b2/li2b2-server/src/main/resources/META-INF/beans.xml deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/li2b2/li2b2-server/src/main/resources/getServices.xml b/li2b2/li2b2-server/src/main/resources/getServices.xml deleted file mode 100644 index 3b644d87aaac6a97f81fe6063d6e44e22de86445..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/resources/getServices.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - 1.1 - 2.4 - - PM Cell - 1.700 - - - i2b2 Hive - - - PM Cell - 1.700 - - - i2b2 Hive - - ${timestamp} - - we3u0XWlAXI2e5jl61JDx - 1 - - - P - I - - AL - AL - US - undefined - - - - PM processing completed - - - - - DEVELOPMENT - http://www.i2b2.org - - i2b2 User - demo - SessionKey:mI8pk4Q4vDFoydDL1h14 - i2b2demo - true - - i2b2 Demo - http://www.i2b2.org - none - /Demo - DATA_LDS - DATA_PROT - USER - DATA_AGG - DATA_DEID - DATA_OBFSC - EDITOR - IRBTEST - - - i2b2demo - i2b2 - true - - - Data Repository - /i2b2/services/QueryToolService/ - / - REST - true - - - Ontology Cell - /i2b2/services/OntologyService/ - / - REST - true - - - Workplace Cell - /i2b2/services/WorkplaceService/ - / - REST - true - - - - - - diff --git a/li2b2/li2b2-server/src/main/resources/templates/crc/master_instance_result.xml b/li2b2/li2b2-server/src/main/resources/templates/crc/master_instance_result.xml deleted file mode 100644 index 9f9d701d41ea74177e7b1394379b56ac7eb8ccde..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/resources/templates/crc/master_instance_result.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - 1.1 - 2.4 - - CRC Cell - 1.7 - - - i2b2 Hive - - - i2b2_QueryTool - 1.6 - - - i2b2 Hive - - - 1 - - Demo - - - Log information - - DONE - - - - - - - DONE - - - 22825 - Diagnoses@01:49:02 - demo - Demo - 2016-07-19T23:49:15.000Z - - - - 22845 - 22825 - demo - Demo - 2016-07-19T23:49:15.000Z - 2016-07-19T23:49:18.000Z - - 6 - COMPLETED - COMPLETED - - - - 48131 - 22845 - Number of patients for "Diagnoses@01:49:02" - - 4 - PATIENT_COUNT_XML - CATNUM - LA - Number of patients - - 133 - 2016-07-19T23:49:15.000Z - 2016-07-19T23:49:17.000Z - - 3 - FINISHED - FINISHED - - - - 48132 - 22845 - Vital Status patient breakdown for "Diagnoses@01:49:02" - - 6 - PATIENT_VITALSTATUS_COUNT_XML - CATNUM - LA - Vital Status patient breakdown - - 133 - 2016-07-19T23:49:15.000Z - 2016-07-19T23:49:18.000Z - - 3 - FINISHED - FINISHED - - - - 48133 - 22845 - Age patient breakdown for "Diagnoses@01:49:02" - - 8 - PATIENT_AGE_COUNT_XML - CATNUM - LA - Age patient breakdown - - 133 - 2016-07-19T23:49:15.000Z - 2016-07-19T23:49:18.000Z - - 3 - FINISHED - FINISHED - - - - - - - 1.1 - 2.4 - - CRC Cell - 1.7 - - - i2b2 Hive - - - i2b2_QueryTool - 1.6 - - - i2b2 Hive - - - 1 - - Demo - - - Log information - - DONE - - - - - - - DONE - - - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/resources/templates/crc/resulttype.xml b/li2b2/li2b2-server/src/main/resources/templates/crc/resulttype.xml deleted file mode 100644 index e5e58002b45947c11c8aa4a549c8e1ae5b10f7bf..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/resources/templates/crc/resulttype.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - 1.1 - 2.4 - - CRC Cell - 1.7 - - - i2b2 Hive - - - i2b2_QueryTool - 1.6 - - - i2b2 Hive - - - 1 - - Demo - - - Log information - - DONE - - - - - - - DONE - - - 1 - DISTRIBUTED_PATIENT_COUNT_XML - CATNUM - LA - Distributed patient count - - - - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/resources/templates/ont/getCategories.xml b/li2b2/li2b2-server/src/main/resources/templates/ont/getCategories.xml deleted file mode 100644 index 2d8fc80a2900f7309ad9aa711f8f8158b74185b4..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/resources/templates/ont/getCategories.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 1.1 - 2.4 - - Ontology Cell - 1.700 - - - i2b2 Hive - - - i2b2 Ontology - 1.6 - - - i2b2 Hive - - 2016-07-19T22:18:49.808Z - - i2b2demo - demo - SessionKey:R8ytkZuQNUGmNANxV5QU - - - 7Ll75pXG9woHvoiio8jX4 - 1 - - - P - I - - AL - AL - US - Demo - - - - Ontology processing completed - - - - - - 1 - \\i2b2_DIAG\i2b2\Diagnoses\ - Diagnoses - N - FA - - concept_cd - concept_dimension - concept_path - T - LIKE - \i2b2\Diagnoses\ - Diagnoses - - - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/resources/templates/ont/getSchemes.xml b/li2b2/li2b2-server/src/main/resources/templates/ont/getSchemes.xml deleted file mode 100644 index 02b5f8570669f3fbcbc1a802ba5a0925a37a7524..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/resources/templates/ont/getSchemes.xml +++ /dev/null @@ -1,149 +0,0 @@ - - - 1.1 - 2.4 - - Ontology Cell - 1.700 - - - i2b2 Hive - - - i2b2 Ontology - 1.6 - - - i2b2 Hive - - 2016-07-19T22:18:49.801Z - - i2b2demo - demo - SessionKey:R8ytkZuQNUGmNANxV5QU - - - M50E0n7lrzevp981Vtg0Q - 1 - - - P - I - - AL - AL - US - Demo - - - - Ontology processing completed - - - - - - 0 - DEM|AGE: - DEM|AGE - - - - 0 - DEM|DATE: - DEM|DATE - - - - 0 - DEM|LANGUAGE: - DEM|LANGUAGE - - - - 0 - DEM|MARITAL: - DEM|MARITAL - - - - 0 - DEM|RACE: - DEM|RACE - - - - 0 - DEM|RELIGION: - DEM|RELIGION - - - - 0 - DEM|SEX: - DEM|SEX - - - - 0 - DEM|VITAL: - DEM|VITAL - - - - 0 - DEM|ZIPCODE: - DEM|ZIPCODE - - - - 0 - DSG-NLP: - DSG-NLP - - - - 0 - ICD10: - ICD10 - - - - 0 - ICD9: - ICD9 - - - - 0 - LCS-I2B2: - LCS-I2B2 - - - - 0 - LOINC: - LOINC - - - - 0 - NDC: - NDC - - - - 0 - - None - - - - 0 - UMLS: - UMLS - - - - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/resources/templates/ont/terminfo.xml b/li2b2/li2b2-server/src/main/resources/templates/ont/terminfo.xml deleted file mode 100644 index a04b3ab0748c162c2f1b9fa6a6be84f86b896599..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/resources/templates/ont/terminfo.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 1.1 - 2.4 - - Ontology Cell - 1.700 - - - i2b2 Hive - - - i2b2 Ontology - 1.6 - - - i2b2 Hive - - 2016-07-19T22:52:11.588Z - - i2b2demo - demo - SessionKey:R8ytkZuQNUGmNANxV5QU - - - OrXn3doqMa2j80t2z4dS9 - 1 - - - P - I - - AL - AL - US - Demo - - - - Ontology processing completed - - - - - - 1 - \\i2b2_DIAG\i2b2\Diagnoses\ - Diagnoses - N - FA - - concept_cd - concept_dimension - concept_path - T - LIKE - \i2b2\Diagnoses\ - Diagnoses - - - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/resources/templates/response_header.xml b/li2b2/li2b2-server/src/main/resources/templates/response_header.xml deleted file mode 100644 index 06be0deca12647a128a0219bb236ae359c09f73e..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/resources/templates/response_header.xml +++ /dev/null @@ -1,36 +0,0 @@ - - 1.1 - 2.4 - - ${service_name} - ${service_version} - - - i2b2 Hive - - - ${client_name} - ${client_version} - - - i2b2 Hive - - ${timestamp} - - ${domain} - ${user} - ${session} - - - ${message_id} - 1 - - - P - I - - AL - AL - DE - ${project} - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/resources/templates/work/folders.xml b/li2b2/li2b2-server/src/main/resources/templates/work/folders.xml deleted file mode 100644 index f12d1076df41706741f51a6e5b32ccf62d3f4377..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/resources/templates/work/folders.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - 1.1 - 2.4 - - Workplace Cell - 1.700 - - - i2b2 Hive - - - i2b2 Ontology - 1.6 - - - i2b2 Hive - - 2016-07-19T22:18:53.417Z - - i2b2demo - demo - SessionKey:R8ytkZuQNUGmNANxV5QU - - - vK2le8W6PP7Wt6XBc7uzg - 1 - - - P - I - - AL - AL - US - Demo - - - - Workplace processing completed - - - - - - SHARED - shared - demo - N - Y - \\demo\100 - CA - demo - SHARED -SHARED - - - demo - demo - Demo - N - N - \\demo\SXRTJ9XfJTkj8AIKt4su - CA - Demo - demo - - - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/webapp/WEB-INF/beans.xml b/li2b2/li2b2-server/src/main/webapp/WEB-INF/beans.xml deleted file mode 100644 index 62d79077bb9f7bb39da10d739e368696b3c0a339..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/webapp/WEB-INF/beans.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-context.xml b/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-context.xml deleted file mode 100644 index 0c05c1eecb53956e738c2f4e2ae5b528ab10d48c..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-context.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - -org.eclipse.jetty.servlet.ServletContextHandler.Decorator - - - - - - *** JETTY-CONTEXT loaded - - - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-defaults-web.xml b/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-defaults-web.xml deleted file mode 100644 index 44b8715c211a04ed245e31a31dc302ebbbe0d6f3..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-defaults-web.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - CDA import web application - - javax.ws.rs.core.Application - org.glassfish.jersey.servlet.ServletContainer - - jersey.config.server.provider.packages - de.sekmi.histream.i2b2.services - - 1 - - - javax.ws.rs.core.Application - /* - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-env.xml b/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-env.xml deleted file mode 100644 index d7c8af891952678ea7375de841356eb800994959..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/webapp/WEB-INF/jetty-env.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - BeanManager - - - javax.enterprise.inject.spi.BeanManager - org.jboss.weld.resources.ManagerObjectFactory - - - - - - - - *** JETTY-ENV loaded - - - diff --git a/li2b2/li2b2-server/src/main/webapp/WEB-INF/web.xml b/li2b2/li2b2-server/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 7961d6daffbac918d1cb3a74fe802c5e9bd0485d..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,11 +0,0 @@ - - HIStream i2b2 emulation - - javax.ws.rs.core.Application - /* - - - \ No newline at end of file diff --git a/li2b2/li2b2-server/src/main/webapp/index.html b/li2b2/li2b2-server/src/main/webapp/index.html deleted file mode 100644 index 0b2b5cc4ced430eaa82efb1816c09a061f23563f..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/main/webapp/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - -ok - - diff --git a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestAbstractService.java b/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestAbstractService.java deleted file mode 100644 index e53c1812e0404363eb5acf8570f96111ade9e78e..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestAbstractService.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.IOException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.ParserConfigurationException; - -import org.junit.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; -import static org.junit.Assert.*; - -public class TestAbstractService extends AbstractService{ - - - @Test - public void parseRequestGenerateResponse() throws ParserConfigurationException, SAXException, IOException{ - DocumentBuilder b = newDocumentBuilder(); - Document dom = parseRequest(b, getClass().getResourceAsStream("/pm_request_test.xml")); - // check header present - Node n = dom.getDocumentElement().getFirstChild(); - assertEquals(Node.ELEMENT_NODE, n.getNodeType()); - Element el = (Element)n; - assertEquals("message_header", el.getNodeName()); - //assertEquals(HIVE_NS, el.getNamespaceURI()); - assertEquals("proxy", el.getFirstChild().getNodeName()); - - Document resp = createResponse(b, el); - XMLUtils.printDOM(resp, System.out); - } - - @Test - public void parse_PM_request() throws Exception{ - DocumentBuilder b = newDocumentBuilder(); - Document dom = parseRequest(b, getClass().getResourceAsStream("/pm_request_test.xml")); - HiveRequest hr = parseRequest(dom); - assertEquals("i2b2 Project Management", hr.clientName); - assertEquals("1.6", hr.clientVersion); - assertEquals("8b5M3z5lb2nU1g6Zq2QSm", hr.messageId); - } - - @Override - public String getName() { - return "Test Cell"; - } - - @Override - public String getVersion() { - return "1.700"; - } -} diff --git a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestPMService.java b/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestPMService.java deleted file mode 100644 index 47201dac2dece8f622a8e627b9940e9af8484f3e..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestPMService.java +++ /dev/null @@ -1,67 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -import org.jboss.resteasy.cdi.CdiInjectorFactory; -import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer; -import org.jboss.resteasy.spi.ResteasyDeployment; -import org.jboss.resteasy.test.TestPortProvider; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import io.undertow.servlet.Servlets; -import io.undertow.servlet.api.DeploymentInfo; - -public class TestPMService{ - - private UndertowJaxrsServer server; - - @Before - public void startServer() throws Exception { - server = new UndertowJaxrsServer().start(); - ResteasyDeployment rd = new ResteasyDeployment(); -// rd.getActualResourceClasses().add(WorkplaceService.class); - rd.getActualResourceClasses().add(PMService.class); - rd.setInjectorFactoryClass(CdiInjectorFactory.class.getName()); - DeploymentInfo di = server.undertowDeployment(rd); - di.setClassLoader(getClass().getClassLoader()); - di.setDeploymentName("TestPM"); - di.setContextPath("/"); - di.addListeners(Servlets.listener(org.jboss.weld.environment.servlet.Listener.class)); - server.deploy(di); - } - - public URL createURL(String name) throws MalformedURLException{ - return TestPortProvider.createURL("/i2b2/services/PMService"+name); - } - - @Test - public void testPost() throws MalformedURLException, IOException{ - URL url = createURL("/getServices"); - System.out.println(url); - HttpURLConnection c = (HttpURLConnection)url.openConnection(); - c.setRequestMethod("POST"); - c.connect(); - Assert.assertEquals(200, c.getResponseCode()); - InputStream in = c.getInputStream(); - in.close(); - } - - @Test - public void invalidLoginCredentialsShouldFail(){ - - } - - @After - public void stopServer() { - server.stop(); - } - - -} diff --git a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestTemplates.java b/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestTemplates.java deleted file mode 100644 index 90dde280006f6d23a9d3da1bf53067f69fcc87f0..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/TestTemplates.java +++ /dev/null @@ -1,42 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.junit.Test; - -import freemarker.core.ParseException; -import freemarker.template.MalformedTemplateNameException; -import freemarker.template.Template; -import freemarker.template.TemplateException; -import freemarker.template.TemplateHashModel; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateModelException; -import freemarker.template.TemplateNotFoundException; -import freemarker.template.TemplateScalarModel; - -public class TestTemplates { - - @Test - public void test() throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{ - Settings s = new Settings(); - Template t = s.getFreemarkerConfiguration().getTemplate("templates/response_header.xml"); - t.process(new TemplateHashModel() { - @Override - public boolean isEmpty() throws TemplateModelException { - return false; - } - - @Override - public TemplateModel get(String key) throws TemplateModelException { - return new TemplateScalarModel() { - @Override - public String getAsString() throws TemplateModelException { - return "dummy"; - } - }; - } - }, new PrintWriter(System.out)); - } -} diff --git a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/Webclient.java b/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/Webclient.java deleted file mode 100644 index 0ac42747f02c9a4140f50f8b5f1fb694ecd1bd5d..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/Webclient.java +++ /dev/null @@ -1,37 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.InputStream; -import java.util.logging.Logger; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; - - -import javax.ws.rs.core.UriInfo; - -@Path("/webclient") -public class Webclient { - private static final Logger log = Logger.getLogger(Webclient.class.getName()); - - @GET - @Path("{path: .*}") - public Response test(@PathParam("path") String path){ - if( path.equals("i2b2_config_data.js") ){ - // send test config data - return Response.ok(getClass().getResourceAsStream("/i2b2_config_data.js")).build(); - } - - InputStream in = getClass().getResourceAsStream("/webclient/"+path); - if( in == null ){ - // not found - log.warning(path+" not found"); - return Response.status(Status.NOT_FOUND).build(); - }else{ - return Response.ok(in).build(); - } - } -} diff --git a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/XMLUtils.java b/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/XMLUtils.java deleted file mode 100644 index be9149ea526320c7fa31a6282f584f6bb9c2eddf..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/test/java/de/sekmi/histream/i2b2/services/XMLUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package de.sekmi.histream.i2b2.services; - -import java.io.OutputStream; - -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Node; - -public class XMLUtils { - public static void printDOM(Node node, OutputStream out){ - try { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer; - transformer = tf.newTransformer(); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); - - transformer.transform(new DOMSource(node), - new StreamResult(out)); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - } -} diff --git a/li2b2/li2b2-server/src/test/resources/i2b2_config_data.js b/li2b2/li2b2-server/src/test/resources/i2b2_config_data.js deleted file mode 100644 index 9724f81f3d19e26c6a9a91d7df9f4f9a700aa8a5..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/test/resources/i2b2_config_data.js +++ /dev/null @@ -1,16 +0,0 @@ -{ - //urlProxy: "index.php", - urlFramework: "js-i2b2/", - //------------------------------------------------------------------------------------------- - // THESE ARE ALL THE DOMAINS A USER CAN LOGIN TO - lstDomains: [ - { domain: "i2b2demo", - name: "HIStream test emulator", - urlCellPM: "/i2b2/services/PMService/", - allowAnalysis: true, - installer: "/webclient/plugin_installer/", - debug: true - } - ] - //------------------------------------------------------------------------------------------- -} diff --git a/li2b2/li2b2-server/src/test/resources/pm_request_test.xml b/li2b2/li2b2-server/src/test/resources/pm_request_test.xml deleted file mode 100644 index 04d304872471a61ca7a0fce5ba9e28f5eab35874..0000000000000000000000000000000000000000 --- a/li2b2/li2b2-server/src/test/resources/pm_request_test.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - http://services.i2b2.org/i2b2/services/PMService/getServices - - - 1.1 - 2.4 - - i2b2 Project Management - 1.6 - - - i2b2 Hive - - - Project Management Cell - 1.6 - - - i2b2 Hive - - 2016-07-20T12:22:50+02:00 - - i2b2demo - demo - - - - 8b5M3z5lb2nU1g6Zq2QSm - 0 - - - P - I - - AL - AL - US - undefined - - - 180000 - - - - undefined - - - \ No newline at end of file diff --git a/li2b2/pom.xml b/li2b2/pom.xml deleted file mode 100644 index bd0f19ae4b2efd845c9068273db100f67ce1766e..0000000000000000000000000000000000000000 --- a/li2b2/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - pom - - de.sekmi.histream.li2b2 - pom - 0.8-SNAPSHOT - - - de.sekmi.histream - histream - 0.8-SNAPSHOT - - - HIStream : li2b2 - lightweight i2b2 implementation - - - li2b2-client - li2b2-api - li2b2-server - - \ No newline at end of file