From 1ab00f3f21ecdd899110738c086385c1ed000cd7 Mon Sep 17 00:00:00 2001 From: "Jeremy R. Easton-Marks" Date: Mon, 9 Nov 2015 13:16:39 -0500 Subject: [PATCH] Updates to licensing Added new resource interfaces --- MPL2.0.txt | 373 ++++++++++++ pom.xml | 4 +- src/main/.gitignore | 1 + .../dbmi/bd2k/irct/ri/exac/EXACDataType.java | 58 ++ .../ri/exac/EXACOntologyRelationship.java | 25 + .../dbmi/bd2k/irct/ri/exac/EXACResource.java | 17 + .../ri/exac/EXACResourceImplementation.java | 556 ++++++++++++++++++ .../exception/ResourceInterfaceException.java | 54 -- .../ri/i2b2/I2B2OntologyRelationship.java | 3 + .../dbmi/bd2k/irct/ri/i2b2/I2B2Resource.java | 19 +- .../i2b2/I2B2XMLResourceImplementation.java | 159 +++-- .../I2B2TranSMARTResourceImplementation.java | 154 ++++- .../i2b2transmart/I2B2tranSMARTResource.java | 19 +- ...ranSMARTVariantResourceImplementation.java | 342 +++++++++++ .../I2B2tranSMARTVariantResource.java | 16 + .../bd2k/irct/ri/openCPU/OpenCPUResource.java | 19 +- .../OpenCPUResourceImplementation.java | 18 +- 17 files changed, 1675 insertions(+), 162 deletions(-) create mode 100644 MPL2.0.txt create mode 100644 src/main/.gitignore create mode 100644 src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACDataType.java create mode 100644 src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACOntologyRelationship.java create mode 100644 src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACResource.java create mode 100644 src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACResourceImplementation.java delete mode 100644 src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exception/ResourceInterfaceException.java create mode 100644 src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmartvariant/I2B2TranSMARTVariantResourceImplementation.java create mode 100644 src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmartvariant/I2B2tranSMARTVariantResource.java diff --git a/MPL2.0.txt b/MPL2.0.txt new file mode 100644 index 0000000..14e2f77 --- /dev/null +++ b/MPL2.0.txt @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/pom.xml b/pom.xml index 13973d9..2ede7be 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 edu.harvard.hms.dbmi.bd2k.irct IRCT-RI - 0.1 + 0.2 INTER-RESOURCE COMMUNICATION TOOL : Resource Interface @@ -29,7 +29,7 @@ edu.harvard.hms.dbmi.i2b2 i2b2-Java-API - 0.1 + 0.2 \ No newline at end of file diff --git a/src/main/.gitignore b/src/main/.gitignore new file mode 100644 index 0000000..cb6eb2c --- /dev/null +++ b/src/main/.gitignore @@ -0,0 +1 @@ +/resources/ diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACDataType.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACDataType.java new file mode 100644 index 0000000..f1000bc --- /dev/null +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACDataType.java @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +package edu.harvard.hms.dbmi.bd2k.irct.ri.exac; + +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.DataType; + +public enum EXACDataType implements DataType { + VARIANT { + @Override + public byte[] toBytes(Object value) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object fromBytes(byte[] bytes) { + // TODO Auto-generated method stub + return null; + } + }, GENE { + @Override + public byte[] toBytes(Object value) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object fromBytes(byte[] bytes) { + // TODO Auto-generated method stub + return null; + } + }, TRANSCRIPT { + @Override + public byte[] toBytes(Object value) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object fromBytes(byte[] bytes) { + // TODO Auto-generated method stub + return null; + } + }, REGION { + @Override + public byte[] toBytes(Object value) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object fromBytes(byte[] bytes) { + // TODO Auto-generated method stub + return null; + } + }; +} diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACOntologyRelationship.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACOntologyRelationship.java new file mode 100644 index 0000000..003ba84 --- /dev/null +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACOntologyRelationship.java @@ -0,0 +1,25 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +package edu.harvard.hms.dbmi.bd2k.irct.ri.exac; + +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.OntologyRelationship; + +/** + * A list of relationships that the i2b2 implementation can use + * + * @author Jeremy R. Easton-Marks + * + */ +public enum EXACOntologyRelationship implements OntologyRelationship { + PARENT { + public OntologyRelationship getInverse() { + return CHILD; + } + }, + CHILD { + public OntologyRelationship getInverse() { + return PARENT; + } + } +} diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACResource.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACResource.java new file mode 100644 index 0000000..047bd4a --- /dev/null +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACResource.java @@ -0,0 +1,17 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +package edu.harvard.hms.dbmi.bd2k.irct.ri.exac; + +import edu.harvard.hms.dbmi.bd2k.irct.model.resource.Resource; + +/** + * A Base exAC Resource that can be implemented as a separate resource + * + * @author Jeremy R. Easton-Marks + * + */ + +public class EXACResource extends Resource { + +} diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACResourceImplementation.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACResourceImplementation.java new file mode 100644 index 0000000..c6d403d --- /dev/null +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exac/EXACResourceImplementation.java @@ -0,0 +1,556 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +package edu.harvard.hms.dbmi.bd2k.irct.ri.exac; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; +import javax.json.JsonReader; +import javax.json.JsonValue; +import javax.json.JsonValue.ValueType; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.LaxRedirectStrategy; + +import edu.harvard.hms.dbmi.bd2k.irct.exception.ResourceInterfaceException; +import edu.harvard.hms.dbmi.bd2k.irct.model.action.ActionState; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.OntologyRelationship; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.OntologyType; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.Path; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.PrimitiveDataType; +import edu.harvard.hms.dbmi.bd2k.irct.model.process.IRCTProcess; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.Query; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.WhereClause; +import edu.harvard.hms.dbmi.bd2k.irct.model.resource.PathResourceImplementationInterface; +import edu.harvard.hms.dbmi.bd2k.irct.model.resource.ProcessResourceImplementationInterface; +import edu.harvard.hms.dbmi.bd2k.irct.model.resource.QueryResourceImplementationInterface; +import edu.harvard.hms.dbmi.bd2k.irct.model.resource.ResourceState; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.Column; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.FileResultSet; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.ResultSet; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.exception.PersistableException; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.exception.ResultSetException; + +public class EXACResourceImplementation implements + QueryResourceImplementationInterface, + PathResourceImplementationInterface, + ProcessResourceImplementationInterface { + private String serverURL; + private HttpClient client; + + @Override + public void setup(Map parameters) { + setClient(HttpClientBuilder.create() + .setRedirectStrategy(new LaxRedirectStrategy()).build()); + setServerURL(parameters.get("serverURL")); + } + + @Override + public String getType() { + return "exAC"; + } + + @Override + public JsonObject toJson() { + return toJson(1); + } + + @Override + public JsonObject toJson(int depth) { + depth--; + JsonObjectBuilder returnJSON = Json.createObjectBuilder(); + returnJSON.add("type", this.getType()); + + JsonArrayBuilder returnEntityArray = Json.createArrayBuilder(); + for (Path rePath : getReturnEntity()) { + returnEntityArray.add(rePath.toJson(depth)); + } + returnJSON.add("returnEntity", returnEntityArray.build()); + returnJSON.add("editableReturnEntity", this.editableReturnEntity()); + + return returnJSON.build(); + } + + @Override + public List getPathRoot() { + List roots = new ArrayList(); + + Path variant = new Path(); + variant.setName("Variant"); + variant.setPui("variant"); + variant.setDataType(EXACDataType.VARIANT); + roots.add(variant); + + Path gene = new Path(); + gene.setName("Gene"); + gene.setPui("gene"); + gene.setDataType(EXACDataType.GENE); + roots.add(gene); + + Path transcript = new Path(); + transcript.setName("Transcript"); + transcript.setPui("transcript"); + transcript.setDataType(EXACDataType.TRANSCRIPT); + roots.add(transcript); + + Path region = new Path(); + region.setName("Region"); + region.setPui("region"); + region.setDataType(EXACDataType.REGION); + roots.add(region); + + return roots; + } + + @Override + public List relationships() { + List relationships = new ArrayList(); + relationships.add(EXACOntologyRelationship.CHILD); + relationships.add(EXACOntologyRelationship.PARENT); + return relationships; + } + + @Override + public OntologyRelationship getRelationshipFromString(String relationship) { + return EXACOntologyRelationship.valueOf(relationship); + } + + @Override + public List getPathRelationship(Path path, + OntologyRelationship relationship) + throws ResourceInterfaceException { + List returns = new ArrayList(); + + if (path.getPui().equals("variant")) { + +// /rest/variant/variant/ + Path variant = new Path(); + variant.setName("Variant"); + variant.setPui("variant/variant"); + variant.setDataType(EXACDataType.VARIANT); + returns.add(variant); + +// /rest/variant/base_coverage/ + Path baseCoverage = new Path(); + baseCoverage.setName("Base Coverage"); + baseCoverage.setPui("variant/base_coverage"); + baseCoverage.setDataType(EXACDataType.VARIANT); + returns.add(baseCoverage); + +// /rest/variant/consequences/ + Path consequences = new Path(); + consequences.setName("Consequences"); + consequences.setPui("variant/consequences"); + consequences.setDataType(EXACDataType.VARIANT); + returns.add(consequences); + +// /rest/variant/any_covered/ + Path anyCovered = new Path(); + anyCovered.setName("Any Covered"); + anyCovered.setPui("variant/any_covered"); + anyCovered.setDataType(EXACDataType.VARIANT); + returns.add(anyCovered); + +// /rest/variant/ordered_csqs/ + Path orderedCSQS = new Path(); + orderedCSQS.setName("Ordered CSQS"); + orderedCSQS.setPui("variant/ordered_csqs"); + orderedCSQS.setDataType(EXACDataType.VARIANT); + returns.add(orderedCSQS); + +// /rest/variant/metrics/ + Path metrics = new Path(); + metrics.setName("Metrics"); + metrics.setPui("variant/metrics"); + metrics.setDataType(EXACDataType.VARIANT); + returns.add(metrics); + + } else if (path.getPui().equals("gene")) { + Path transcript = new Path(); + transcript.setName("Transcripts"); + transcript.setPui("gene/transcript"); + transcript.setDataType(EXACDataType.GENE); + returns.add(transcript); + + Path geneVariants = new Path(); + geneVariants.setName("Variants in Gene"); + geneVariants.setPui("gene/variants_in_gene"); + geneVariants.setDataType(EXACDataType.GENE); + returns.add(geneVariants); + + Path transcriptVariants = new Path(); + transcriptVariants.setName("Variants in Transcript"); + transcriptVariants.setPui("gene/variants_in_transcript"); + transcriptVariants.setDataType(EXACDataType.GENE); + returns.add(transcriptVariants); + + Path transcriptGenes = new Path(); + transcriptGenes.setName("Transcripts in Gene"); + transcriptGenes.setPui("gene/transcripts_in_gene"); + transcriptGenes.setDataType(EXACDataType.GENE); + returns.add(transcriptGenes); + + Path coverageStats = new Path(); + coverageStats.setName("Coverage Stats"); + coverageStats.setPui("gene/coverage_stats"); + coverageStats.setDataType(EXACDataType.GENE); + returns.add(coverageStats); + } else if (path.getPui().equals("transcript")) { +// /rest/transcript/transcript/ + Path transcript = new Path(); + transcript.setName("Transcript"); + transcript.setPui("transcript/transcript"); + transcript.setDataType(EXACDataType.TRANSCRIPT); + returns.add(transcript); + +// /rest/transcript/variants_in_transcript/ + Path variantsInTranscript = new Path(); + variantsInTranscript.setName("Variants in Transcript"); + variantsInTranscript.setPui("transcript/variants_in_transcript"); + variantsInTranscript.setDataType(EXACDataType.TRANSCRIPT); + returns.add(variantsInTranscript); + +// /rest/transcript/coverage_stats/ + Path coverageStats = new Path(); + coverageStats.setName("Coverage Stats"); + coverageStats.setPui("transcript/coverage_stats"); + coverageStats.setDataType(EXACDataType.TRANSCRIPT); + returns.add(coverageStats); + +// /rest/transcript/gene/ + Path gene = new Path(); + gene.setName("Gene"); + gene.setPui("transcript/gene"); + gene.setDataType(EXACDataType.VARIANT); + returns.add(gene); + } else if (path.getPui().equals("region")) { +// /rest/region/genes_in_region/ + Path genesInRegion = new Path(); + genesInRegion.setName("Genes in region"); + genesInRegion.setPui("region/genes_in_region"); + genesInRegion.setDataType(EXACDataType.REGION); + returns.add(genesInRegion); + +// /rest/region/variants_in_region/ + Path variantsInRegion = new Path(); + variantsInRegion.setName("Variants in region"); + variantsInRegion.setPui("region/variants_in_region"); + variantsInRegion.setDataType(EXACDataType.REGION); + returns.add(variantsInRegion); + +// /rest/region/coverage_array/ + Path coverageArray = new Path(); + coverageArray.setName("Coverage Array"); + coverageArray.setPui("region/coverage_array"); + coverageArray.setDataType(EXACDataType.REGION); + returns.add(coverageArray); + } + + return returns; + } + + @Override + public OntologyType getOntologyType() { + return OntologyType.TREE; + } + + @Override + public Path getPathFromString(String path) { + Path pathObj = new Path(); + pathObj.setPui(path); + return pathObj; + } + + @Override + public ActionState runQuery(Query qep) throws ResourceInterfaceException { + ActionState actionState = new ActionState(); + + + WhereClause whereClause = (WhereClause) qep.getClauses() + .values().iterator().next(); + + if (whereClause.getPredicateType().getName().equals("BYQUERY")) { + String service = whereClause.getField().getPui().split("/")[1]; + HttpGet get = new HttpGet(getServerURL() + "/rest/awesome?query=" + + whereClause.getValues().get("query") + "&service=" + + service); + + try { + HttpResponse response = client.execute(get); + JsonReader reader = Json.createReader(response.getEntity() + .getContent()); + JsonArray results = reader.readArray(); + + actionState.setResults(convertJsonToResultSet(results)); + actionState.setComplete(true); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else if (whereClause.getPredicateType().getName().equals("BYENSEMBL")) { + HttpGet get = new HttpGet(getServerURL() + "/rest/" + whereClause.getField().getPui() + "/" + whereClause.getValues().get("ensembl")); + + try { + HttpResponse response = client.execute(get); + JsonReader reader = Json.createReader(response.getEntity() + .getContent()); + JsonArray results = reader.readArray(); + + actionState.setResults(convertJsonToResultSet(results)); + actionState.setComplete(true); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else if (whereClause.getPredicateType().getName().equals("BYREGION")) { + + } + + return actionState; + } + + @Override + public ActionState runProcess(IRCTProcess pep) { + ActionState actionState = new ActionState(); + + ResultSet rs = pep.getResultSets().get("ResultSet"); + String chromColumn = pep.getValues().get("Chromosome"); + String startColumn = pep.getValues().get("Start"); + String refColumn = pep.getValues().get("Reference"); + String altColumn = pep.getValues().get("Alternative"); + + + + try { + Set columns = new HashSet(); + for(Column col : rs.getColumns()) { + columns.add(col.getName()); + } + + List> rawData = new ArrayList>(); + + rs.beforeFirst(); + while(rs.next()) { + Map entry = new HashMap(); + + String chrom = rs.getString(chromColumn); + String start = rs.getString(startColumn); + String ref = rs.getString(refColumn); + String alt = rs.getString(altColumn); + + + for(Column column : rs.getColumns()) { + entry.put(column.getName(), rs.getString(column.getName())); + } + + if(!alt.equals("-") && !ref.equals("-")) { + String url = getServerURL() + "/rest/variant/variant/" + chrom + "-" + start + "-" + ref + "-" + alt; + System.out.println(url); + + HttpGet get = new HttpGet(url); + + HttpResponse response = client.execute(get); + JsonReader reader = Json.createReader(response.getEntity().getContent()); + JsonObject varObj = reader.readObject(); + + List fields = getNames("", varObj); + columns.addAll(fields); + + + for(String field : fields) { + entry.put(field, getValue(varObj, field)); + } + rawData.add(entry); + + reader.close(); + } + } + + FileResultSet mrs = new FileResultSet(); + for(String field : columns) { + Column column = new Column(); + column.setName(field); + column.setDataType(PrimitiveDataType.STRING); + mrs.appendColumn(column); + } + + for(Map entry : rawData) { + mrs.appendRow(); + for(String field : columns) { + String value = entry.get(field); + if(value == null) { + value = ""; + } + mrs.updateString(field, value); + } + } + actionState.setResults(mrs); + actionState.setComplete(true); + + } catch (ResultSetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClientProtocolException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (PersistableException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return actionState; + } + + @Override + public ResultSet getResults(ActionState actionState) throws ResourceInterfaceException { + return null; + } + + private ResultSet convertJsonToResultSet(JsonArray results) { + FileResultSet mrs = new FileResultSet(); + + try { + if (results.size() == 0) { + return mrs; + } + // Setup columns + JsonObject columnObject = (JsonObject) results.get(0); + + List fields = getNames("", columnObject); + for(String field : fields) { + Column column = new Column(); + column.setName(field); + column.setDataType(PrimitiveDataType.STRING); + mrs.appendColumn(column); + } + + // Add data + for(JsonValue val : results) { + JsonObject obj = (JsonObject) val; + mrs.appendRow(); + for(String field : fields) { +// JsonValue jv = getValue(obj, field); +// if(jv == null) { +// mrs.updateString(field, ""); +// } else if(jv.getValueType() == ValueType.NUMBER) { +// mrs.updateLong(field, ((JsonNumber) jv).longValue()); +// } else if(jv.getValueType() == ValueType.STRING) { +// mrs.updateString(field, ((JsonString) jv).getString()); +// } else { +// mrs.updateString(field, jv.toString()); +// } + mrs.updateString(field, getValue(obj, field)); + } + } + } catch (ResultSetException | PersistableException e) { + e.printStackTrace(); + } + + return mrs; + } + + private String getValue(JsonObject obj, String field) { + if(field.contains(".")) { + String thisField = field.split("\\.")[0]; + String remaining = field.replaceFirst(thisField + ".", ""); + return getValue(obj.getJsonObject(thisField), remaining); + } + if(obj.containsKey(field)) { + ValueType vt = obj.get(field).getValueType(); + if(vt == ValueType.NUMBER) { + return obj.getJsonNumber(field).toString(); + } + return obj.getString(field); +// return obj.get(field); + } + return ""; + } + + private List getNames(String prefix, JsonObject obj) { + List returns = new ArrayList(); + for(String field : obj.keySet()) { + if(obj.get(field).getValueType() == ValueType.OBJECT) { + if(prefix.equals("")) { + returns.addAll(getNames(field, obj.getJsonObject(field))); + } else { + returns.addAll(getNames(prefix + "." + field, obj.getJsonObject(field))); + } + } else if(obj.get(field).getValueType() != ValueType.ARRAY){ + if(prefix.equals("")) { + returns.add(field); + } else { + returns.add(prefix + "." + field); + } + } + } + + return returns; + } + + @Override + public ResourceState getState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getReturnEntity() { + return new ArrayList(); + } + + @Override + public Boolean editableReturnEntity() { + return false; + } + + /** + * @return the client + */ + public HttpClient getClient() { + return client; + } + + /** + * @param client + * the client to set + */ + public void setClient(HttpClient client) { + this.client = client; + } + + /** + * @return the serverURL + */ + public String getServerURL() { + return serverURL; + } + + /** + * @param serverURL + * the serverURL to set + */ + public void setServerURL(String serverURL) { + this.serverURL = serverURL; + } + + + +} diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exception/ResourceInterfaceException.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exception/ResourceInterfaceException.java deleted file mode 100644 index b7b3bc2..0000000 --- a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/exception/ResourceInterfaceException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of Inter-Resource Communication Tool (IRCT). - * - * IRCT is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * IRCT is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with IRCT. If not, see . - */ -package edu.harvard.hms.dbmi.bd2k.irct.ri.exception; -/** - * Indicates a Resource Interface Exception occurred of some type - * - * @author Jeremy R. Easton-Marks - * - */ -public class ResourceInterfaceException extends Exception { - private static final long serialVersionUID = -4688536480746747740L; - - /** - * Create a Resource Interface Exception with the given message - * - * @param message Messsage - */ - public ResourceInterfaceException(String message) { - super(message); - } - - /** - * Create a Resource Interface Exception - * - * @param exception Exception - */ - public ResourceInterfaceException(Exception exception) { - super(exception); - } - - /** - * Create a Resource Interface Exception with the given message - * - * @param message Message - * @param exception Exception - */ - public ResourceInterfaceException(String message, Exception exception) { - super(message, exception); - } -} diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2OntologyRelationship.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2OntologyRelationship.java index a981495..56c18b5 100644 --- a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2OntologyRelationship.java +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2OntologyRelationship.java @@ -1,3 +1,6 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2; import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.OntologyRelationship; diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2Resource.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2Resource.java index ddf98c0..b158cd1 100644 --- a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2Resource.java +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2Resource.java @@ -1,19 +1,6 @@ -/* - * This file is part of Inter-Resource Communication Tool (IRCT). - * - * IRCT is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * IRCT is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with IRCT. If not, see . - */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2; import edu.harvard.hms.dbmi.bd2k.irct.model.resource.Resource; diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2XMLResourceImplementation.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2XMLResourceImplementation.java index 9ae8ddf..62d5585 100644 --- a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2XMLResourceImplementation.java +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2/I2B2XMLResourceImplementation.java @@ -1,19 +1,6 @@ -/* - * This file is part of Inter-Resource Communication Tool (IRCT). - * - * IRCT is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * IRCT is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with IRCT. If not, see . - */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2; import java.io.IOException; @@ -23,6 +10,7 @@ import java.util.Map; import javax.json.Json; +import javax.json.JsonArrayBuilder; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; import javax.xml.bind.JAXBException; @@ -32,7 +20,9 @@ import org.apache.http.client.HttpClient; import org.apache.http.impl.client.HttpClients; -import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.DataType; +import edu.harvard.hms.dbmi.bd2k.irct.exception.ResourceInterfaceException; +import edu.harvard.hms.dbmi.bd2k.irct.model.action.ActionState; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.PrimitiveDataType; import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.OntologyRelationship; import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.OntologyType; import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.Path; @@ -48,7 +38,6 @@ import edu.harvard.hms.dbmi.bd2k.irct.model.result.ResultSet; import edu.harvard.hms.dbmi.bd2k.irct.model.result.exception.PersistableException; import edu.harvard.hms.dbmi.bd2k.irct.model.result.exception.ResultSetException; -import edu.harvard.hms.dbmi.bd2k.irct.ri.exception.ResourceInterfaceException; import edu.harvard.hms.dbmi.i2b2.api.exception.I2B2InterfaceException; import edu.harvard.hms.dbmi.i2b2.api.crc.CRCCell; import edu.harvard.hms.dbmi.i2b2.api.crc.xml.pdo.OutputOptionSelectType; @@ -227,7 +216,7 @@ public Path getPathFromString(String path) { return pathObj; } - public Long runQuery(Query qep) throws ResourceInterfaceException { + public ActionState runQuery(Query qep) throws ResourceInterfaceException { int panelCount = 1; ArrayList panels = new ArrayList(); @@ -267,19 +256,22 @@ public Long runQuery(Query qep) throws ResourceInterfaceException { root.setName("PATIENTSET"); roolt.getResultOutput().add(root); - Long queryId = 0L; + String queryId = null; try { MasterInstanceResultResponseType mirrt = crcCell .runQueryInstanceFromQueryDefinition(client, null, null, - "IRCT", null, "SAMEVISIT", 0, roolt, + "IRCT", null, "ANY", 0, roolt, panels.toArray(new PanelType[panels.size()])); - queryId = Long.parseLong(mirrt.getQueryResultInstance().get(0).getResultInstanceId()); + queryId = mirrt.getQueryResultInstance().get(0).getResultInstanceId(); } catch (JAXBException | IOException | I2B2InterfaceException e) { throw new ResourceInterfaceException( "Error traversing relationship", e); } - return queryId; + + ActionState as = new ActionState(); + as.setResourceId(queryId); + return as; } private PanelType createPanel(int panelItem) { @@ -295,14 +287,13 @@ private PanelType createPanel(int panelItem) { return panel; } - public ResultSet getResults(Long queryId) throws ResourceInterfaceException { + public ResultSet getResults(ActionState actionState) throws ResourceInterfaceException { try { - - String resultInstanceId = queryId.toString(); + String resultInstanceId = actionState.getResourceId(); PatientDataResponseType pdrt = crcCell.getPDOfromInputList(client, resultInstanceId, 0, 100000, false, false, false, OutputOptionSelectType.USING_INPUT_LIST); - + actionState.setComplete(true); return convertPatientSetToResultSet(pdrt.getPatientData() .getPatientSet()); @@ -324,12 +315,103 @@ public JsonObject toJson(int depth) { depth--; JsonObjectBuilder returnJSON = Json.createObjectBuilder(); returnJSON.add("type", this.getType()); + + JsonArrayBuilder returnEntityArray = Json.createArrayBuilder(); + for(Path rePath : getReturnEntity()) { + returnEntityArray.add(rePath.toJson(depth)); + } + returnJSON.add("returnEntity", returnEntityArray.build()); + returnJSON.add("editableReturnEntity", this.editableReturnEntity()); + return returnJSON.build(); } - public Path getReturnEntity() { - // TODO Auto-generated method stub - return null; + public List getReturnEntity() { + List returnEntity = new ArrayList(); +// Patient Id + Path patientId = new Path(); + patientId.setName("Patient Id"); + patientId.setPui("Patient Id"); + patientId.setDataType(PrimitiveDataType.STRING); + returnEntity.add(patientId); + +// vital_status_cd + Path vitalStatusCd = new Path(); + vitalStatusCd.setName("Vital Status"); + vitalStatusCd.setPui("vital_status_cd"); + vitalStatusCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(vitalStatusCd); + +// language_cd + Path languageCd = new Path(); + languageCd.setName("Language"); + languageCd.setPui("language_cd"); + languageCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(languageCd); + +// birth_date + Path birthDate = new Path(); + birthDate.setName("Birth Date"); + birthDate.setPui("birth_date"); + birthDate.setDataType(PrimitiveDataType.STRING); + returnEntity.add(birthDate); + +// race_cd + Path raceCd = new Path(); + raceCd.setName("Race"); + raceCd.setPui("race_cd"); + raceCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(raceCd); + +// religion_cd + Path religionCd = new Path(); + religionCd.setName("Religion"); + religionCd.setPui("Religion"); + religionCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(religionCd); + +// income_cd + Path incomeCd = new Path(); + incomeCd.setName("Income"); + incomeCd.setPui("income_cd"); + incomeCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(incomeCd); + +// statecityzip_path + Path stateCityCd = new Path(); + stateCityCd.setName("State, City Zip"); + stateCityCd.setPui("statecityzip_path"); + stateCityCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(stateCityCd); + +// zip_cd + Path zipCd = new Path(); + zipCd.setName("Zip"); + zipCd.setPui("zip_cd"); + zipCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(zipCd); + +// marital_status_cd + Path maritalCd = new Path(); + maritalCd.setName("marital_status_cd"); + maritalCd.setPui("marital_status_cd"); + maritalCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(maritalCd); + +// age_in_years_num + Path ageCd = new Path(); + ageCd.setName("Age"); + ageCd.setPui("age_in_years_num"); + ageCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(ageCd); + +// sex_cd + Path sexCd = new Path(); + sexCd.setName("Sex"); + sexCd.setPui("sex_cd"); + sexCd.setDataType(PrimitiveDataType.STRING); + returnEntity.add(sexCd); + return returnEntity; } // ------------------------------------------------------------------------- @@ -346,12 +428,12 @@ private ResultSet convertPatientSetToResultSet(PatientSet patientSet) { PatientType columnPT = patientSet.getPatient().get(0); Column idColumn = new Column(); idColumn.setName("Patient Id"); - idColumn.setDataType(DataType.STRING); + idColumn.setDataType(PrimitiveDataType.STRING); mrs.appendColumn(idColumn); for (ParamType paramType : columnPT.getParam()) { Column column = new Column(); column.setName(paramType.getColumn()); - column.setDataType(DataType.STRING); + column.setDataType(PrimitiveDataType.STRING); mrs.appendColumn(column); } @@ -372,15 +454,13 @@ private ResultSet convertPatientSetToResultSet(PatientSet patientSet) { private ItemType createItemTypeFromWhereClause(WhereClause whereClause) { ItemType item = new ItemType(); - item.setHlevel(3);//???? - item.setClazz("ENC");//??? item.setItemKey(whereClause.getField().getPui() .replaceAll(getServerName() + "/", "").replace('/', '\\')); item.setItemName(item.getItemKey()); + item.setItemIsSynonym(false); if (whereClause.getPredicateType() != null) { if (whereClause.getPredicateType().getName() .equals("CONSTRAIN_MODIFIER")) { - item.setConstrainByModifier(createConstrainByModifier(whereClause)); } else if (whereClause.getPredicateType().getName() .equals("CONSTRAIN_VALUE")) { @@ -464,7 +544,7 @@ private List convertModifiersTypeToPath(ModifiersType modifiersType, childPath.setPui(getServerName() + "/" + modifier.getKey().replace('\\', '/')); if (modifier.getColumndatatype().equals("T")) { - childPath.setDataType(DataType.STRING); + childPath.setDataType(PrimitiveDataType.STRING); } Map attributes = new HashMap(); @@ -506,7 +586,7 @@ private List convertConceptsTypeToPath(ConceptsType conceptsType) { childPath.setPui(getServerName() + "/" + concept.getKey().replace('\\', '/')); if (concept.getVisualattributes().startsWith("L")) { - childPath.setDataType(DataType.STRING); + childPath.setDataType(PrimitiveDataType.STRING); } Map attributes = new HashMap(); attributes.put("level", Integer.toString(concept.getLevel())); @@ -631,4 +711,9 @@ public String getServerName() { public void setServerName(String serverName) { this.serverName = serverName; } + + @Override + public Boolean editableReturnEntity() { + return false; + } } diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmart/I2B2TranSMARTResourceImplementation.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmart/I2B2TranSMARTResourceImplementation.java index 3031df4..f6520f2 100644 --- a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmart/I2B2TranSMARTResourceImplementation.java +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmart/I2B2TranSMARTResourceImplementation.java @@ -1,15 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2transmart; import java.io.IOException; +import java.net.URLEncoder; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import javax.json.Json; +import javax.json.JsonArray; import javax.json.JsonObject; import javax.json.JsonReader; +import javax.json.JsonValue; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; @@ -20,6 +29,7 @@ import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; @@ -32,11 +42,20 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.message.BasicNameValuePair; +import edu.harvard.hms.dbmi.bd2k.irct.exception.ResourceInterfaceException; +import edu.harvard.hms.dbmi.bd2k.irct.model.action.ActionState; import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.OntologyRelationship; import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.Path; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.PrimitiveDataType; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.ClauseAbstract; import edu.harvard.hms.dbmi.bd2k.irct.model.query.Query; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.SelectClause; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.WhereClause; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.Column; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.FileResultSet; import edu.harvard.hms.dbmi.bd2k.irct.model.result.ResultSet; -import edu.harvard.hms.dbmi.bd2k.irct.ri.exception.ResourceInterfaceException; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.exception.PersistableException; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.exception.ResultSetException; import edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2.I2B2XMLResourceImplementation; /** @@ -112,23 +131,67 @@ public List getPathRelationship(Path path, } @Override - public ResultSet getResults(Long queryId) throws ResourceInterfaceException { - + public ResultSet getResults(ActionState as) + throws ResourceInterfaceException { return null; } -// private ResultSet getColumns(Long queryId, String columnName, -// String... paths) { -// return null; -// } - @Override - public Long runQuery(Query query) throws ResourceInterfaceException { + public ActionState runQuery(Query query) throws ResourceInterfaceException { + String gatherAllEncounterFacts = "false"; try { super.setClient(login()); - Long runId = super.runQuery(query); + ActionState actionState = super.runQuery(query); + // Get results and save them locally + Map selects = new HashMap(); + String parameters = ""; + for (ClauseAbstract clause : query.getClauses().values()) { + if (clause instanceof SelectClause) { + SelectClause selectClaues = (SelectClause) clause; + String pui = selectClaues.getParameter().getPui() + .replaceAll(getServerName() + "/", ""); + pui = pui.substring(pui.indexOf("/", 3)); + if (!parameters.equals("")) { + parameters += "|"; + } + parameters += pui; + selects.put(pui, selectClaues.getParameter().getName()); + } + if (clause instanceof WhereClause) { + WhereClause whereClause = (WhereClause) clause; + String encounter = whereClause.getValues().get("encounter"); + if((encounter != null) && (encounter.equalsIgnoreCase("yes"))) { + gatherAllEncounterFacts = "true"; + } + } + } - return runId; + if (parameters.equals("")) { + actionState.setResults(super.getResults(actionState)); + actionState.setComplete(true); + } else { + System.out.println(this.baseURL + + "/ClinicalData/retrieveClinicalData?rid=" + + actionState.getResourceId() + "&conceptPaths=" + + URLEncoder.encode(parameters, "UTF-8") + "&gatherAllEncounterFacts=" + gatherAllEncounterFacts); + HttpGet get = new HttpGet(this.baseURL + + "/ClinicalData/retrieveClinicalData?rid=" + + actionState.getResourceId() + "&conceptPaths=" + + URLEncoder.encode(parameters, "UTF-8") + "&gatherAllEncounterFacts=" + gatherAllEncounterFacts); + HttpResponse response = super.getClient().execute(get); + JsonReader reader = Json.createReader(response.getEntity() + .getContent()); + JsonArray results = reader.readArray(); + if(gatherAllEncounterFacts.equalsIgnoreCase("true")) { + actionState.setResults(convertJsonToPivotResultSetonEncounter(results, true)); + } else { + actionState.setResults(convertJsonToPivotResultSetonEncounter(results, false)); + } + + actionState.setComplete(true); + } + + return actionState; } catch (KeyManagementException | NoSuchAlgorithmException | IOException e) { throw new ResourceInterfaceException( @@ -136,6 +199,70 @@ public Long runQuery(Query query) throws ResourceInterfaceException { } } + private ResultSet convertJsonToPivotResultSetonEncounter(JsonArray results, boolean onEncounter) { + FileResultSet mrs = new FileResultSet(); + + Set columns = new HashSet(); + columns.add("PATIENT_NUM"); + if(onEncounter) { + columns.add("ENCOUNTER_NUM"); + } + + Map> rawData = new HashMap>(); + + if (results.size() == 0) { + return mrs; + } + + for (JsonValue val : results) { + JsonObject obj = (JsonObject) val; + String pivotString = obj.getString("PATIENT_NUM"); + if(onEncounter) { + pivotString = obj.getString("ENCOUNTER_NUM"); + } + if(!rawData.containsKey(pivotString)) { + Map entryMap = new HashMap(); + entryMap.put("PATIENT_NUM", obj.getString("PATIENT_NUM")); + if(onEncounter) { + entryMap.put("ENCOUNTER_NUM", obj.getString("ENCOUNTER_NUM")); + } + rawData.put(pivotString, entryMap); + } + + rawData.get(pivotString).put(obj.getString("CONCEPT_PATH"), obj.getString("VALUE")); + columns.add(obj.getString("CONCEPT_PATH")); + } + + try { + + for(String column : columns) { + Column field = new Column(); + field.setName(column); + field.setDataType(PrimitiveDataType.STRING); + mrs.appendColumn(field); + } + + for(String encounterId : rawData.keySet()) { + mrs.appendRow(); + Map pivotTable = rawData.get(encounterId); + + for(String column : columns) { + String value = ""; + if(pivotTable.containsKey(column)) { + value = pivotTable.get(column); + } + mrs.updateString(column, value); + } + } + + } catch (ResultSetException | PersistableException e) { + e.printStackTrace(); + } + + + return mrs; + } + private HttpClient login() throws NoSuchAlgorithmException, KeyManagementException, ClientProtocolException, IOException { // SSL WRAPAROUND @@ -189,4 +316,9 @@ public void checkServerTrusted( return client; } + + @Override + public Boolean editableReturnEntity() { + return true; + } } diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmart/I2B2tranSMARTResource.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmart/I2B2tranSMARTResource.java index ff64646..9d1fb0e 100644 --- a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmart/I2B2tranSMARTResource.java +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmart/I2B2tranSMARTResource.java @@ -1,19 +1,6 @@ -/* - * This file is part of Inter-Resource Communication Tool (IRCT). - * - * IRCT is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * IRCT is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with IRCT. If not, see . - */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2transmart; import edu.harvard.hms.dbmi.bd2k.irct.model.resource.Resource; diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmartvariant/I2B2TranSMARTVariantResourceImplementation.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmartvariant/I2B2TranSMARTVariantResourceImplementation.java new file mode 100644 index 0000000..f0ccb53 --- /dev/null +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmartvariant/I2B2TranSMARTVariantResourceImplementation.java @@ -0,0 +1,342 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +package edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2transmartvariant; + +import java.io.IOException; +import java.net.URLEncoder; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonReader; +import javax.json.JsonValue; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.HttpClientConnectionManager; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.message.BasicNameValuePair; + +import edu.harvard.hms.dbmi.bd2k.irct.exception.ResourceInterfaceException; +import edu.harvard.hms.dbmi.bd2k.irct.model.action.ActionState; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.OntologyRelationship; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.Path; +import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.PrimitiveDataType; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.ClauseAbstract; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.Query; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.SelectClause; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.WhereClause; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.Column; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.FileResultSet; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.ResultSet; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.exception.PersistableException; +import edu.harvard.hms.dbmi.bd2k.irct.model.result.exception.ResultSetException; +import edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2.I2B2XMLResourceImplementation; + +/** + * An implementation of a resource that communicates with the tranSMART + * instance. It extends the i2b2 XML resource implementation. + * + */ +public class I2B2TranSMARTVariantResourceImplementation extends + I2B2XMLResourceImplementation { + private String tranSMARTuserName; + private String tranSMARTpassword; + private String baseURL; + + @Override + public void setup(Map parameters) { + this.tranSMARTuserName = parameters.get("tranSMARTusername"); + this.tranSMARTpassword = parameters.get("tranSMARTpassword"); + this.baseURL = parameters.get("baseURL"); + + super.setup(parameters); + + } + + @Override + public String getType() { + return "i2b2/tranSMART"; + } + + @Override + public List getPathRelationship(Path path, + OntologyRelationship relationship) + throws ResourceInterfaceException { + try { + HttpClient client = login(); + super.setClient(client); + List paths = super.getPathRelationship(path, relationship); + String self = path.getPui() + .replaceAll(super.getServerName() + "/", "") + .replace('/', '\\'); + if (!self.equals(getServerName())) { + HttpPost post = new HttpPost(this.baseURL + + "/chart/childConceptPatientCounts"); + List formParameters = new ArrayList(); + formParameters.add(new BasicNameValuePair("charttype", + "childconceptpatientcounts")); + formParameters.add(new BasicNameValuePair("concept_key", self)); + formParameters.add(new BasicNameValuePair("concept_level", "")); + post.setEntity(new UrlEncodedFormEntity(formParameters)); + HttpResponse response = client.execute(post); + + JsonReader jsonReader = Json.createReader(response.getEntity() + .getContent()); + JsonObject counts = jsonReader.readObject().getJsonObject( + "counts"); + + for (Path singlePath : paths) { + String i2b2Path = singlePath.getPui() + .replaceAll(getServerName() + "/", "") + .replace('/', '\\').substring(2); + i2b2Path = i2b2Path.substring(i2b2Path.indexOf("\\")); + if (counts.containsKey(i2b2Path)) { + singlePath.getCounts().put("count", + counts.getInt(i2b2Path)); + } + } + } + return paths; + } catch (KeyManagementException | NoSuchAlgorithmException + | IOException e) { + throw new ResourceInterfaceException( + "Error logging into tranSMART server"); + } + } + + @Override + public ResultSet getResults(ActionState as) + throws ResourceInterfaceException { + return null; + } + + @Override + public ActionState runQuery(Query query) throws ResourceInterfaceException { + String gatherAllEncounterFacts = "false"; + try { + super.setClient(login()); + ActionState actionState = super.runQuery(query); + // Get results and save them locally + Map selects = new HashMap(); + String parameters = ""; + for (ClauseAbstract clause : query.getClauses().values()) { + if (clause instanceof SelectClause) { + SelectClause selectClaues = (SelectClause) clause; + String pui = selectClaues.getParameter().getPui() + .replaceAll(getServerName() + "/", ""); + pui = pui.substring(pui.indexOf("/", 3)); + if (!parameters.equals("")) { + parameters += "|"; + } + parameters += pui; + selects.put(pui, selectClaues.getParameter().getName()); + } + if (clause instanceof WhereClause) { + WhereClause whereClause = (WhereClause) clause; + String encounter = whereClause.getValues().get("encounter"); + if((encounter != null) && (encounter.equalsIgnoreCase("yes"))) { + gatherAllEncounterFacts = "true"; + } + } + } + + if (parameters.equals("")) { + actionState.setResults(super.getResults(actionState)); + actionState.setComplete(true); + } else { + System.out.println(this.baseURL + + "/ClinicalData/retrieveClinicalData?rid=" + + actionState.getResourceId() + "&conceptPaths=" + + URLEncoder.encode(parameters, "UTF-8") + "&gatherAllEncounterFacts=" + gatherAllEncounterFacts); + HttpGet get = new HttpGet(this.baseURL + + "/ClinicalData/retrieveClinicalData?rid=" + + actionState.getResourceId() + "&conceptPaths=" + + URLEncoder.encode(parameters, "UTF-8") + "&gatherAllEncounterFacts=" + gatherAllEncounterFacts); + HttpResponse response = super.getClient().execute(get); + JsonReader reader = Json.createReader(response.getEntity() + .getContent()); + JsonArray results = reader.readArray(); + if(gatherAllEncounterFacts.equalsIgnoreCase("true")) { + actionState.setResults(convertJsonToPivotResultSetonEncounter(results, true)); + } else { + actionState.setResults(convertJsonToPivotResultSetonEncounter(results, false)); + } + reader.close(); + actionState.setComplete(true); + } + + return actionState; + } catch (KeyManagementException | NoSuchAlgorithmException + | IOException e) { + throw new ResourceInterfaceException( + "Error logging into tranSMART server"); + } + } + + private ResultSet convertJsonToPivotResultSetonEncounter(JsonArray results, boolean onEncounter) { + FileResultSet mrs = new FileResultSet(); + + Pattern pattern = Pattern.compile("\\\\[0-9][0-9]_(?!.*\\\\[0-9][0-9]_*)"); + + Set columns = new HashSet(); + columns.add("PATIENT_NUM"); + if(onEncounter) { + columns.add("ENCOUNTER_NUM"); + } + + Map> rawData = new HashMap>(); + + if (results.size() == 0) { + return mrs; + } + + for (JsonValue val : results) { + JsonObject obj = (JsonObject) val; + String pivotString = obj.getString("PATIENT_NUM"); + if(onEncounter) { + pivotString = obj.getString("ENCOUNTER_NUM"); + } + + if(!rawData.containsKey(pivotString)) { + Map entryMap = new HashMap(); + entryMap.put("PATIENT_NUM", obj.getString("PATIENT_NUM")); + if(onEncounter) { + entryMap.put("ENCOUNTER_NUM", obj.getString("ENCOUNTER_NUM")); + if(obj.containsKey("RACE_CD")) { + entryMap.put("RACE_CD", obj.getString("RACE_CD")); + columns.add("RACE_CD"); + } + } + rawData.put(pivotString, entryMap); + } + + String columnString = obj.getString("CONCEPT_PATH"); + if(onEncounter) { + Matcher matcher = pattern.matcher(columnString); + if(matcher.find()) { + int end = columnString.indexOf("\\", matcher.end()); + columnString = columnString.substring(0, end); + } + } + columns.add(columnString); + + rawData.get(pivotString).put(columnString, obj.getString("VALUE")); + } + + try { + + for(String column : columns) { + Column field = new Column(); + field.setName(column); + field.setDataType(PrimitiveDataType.STRING); + mrs.appendColumn(field); + } + + for(String encounterId : rawData.keySet()) { + mrs.appendRow(); + Map pivotTable = rawData.get(encounterId); + + for(String column : columns) { + String value = ""; + if(pivotTable.containsKey(column)) { + value = pivotTable.get(column); + } + mrs.updateString(column, value); + } + } + + } catch (ResultSetException | PersistableException e) { + e.printStackTrace(); + } + + + return mrs; + } + + private HttpClient login() throws NoSuchAlgorithmException, + KeyManagementException, ClientProtocolException, IOException { + // SSL WRAPAROUND + System.setProperty("jsse.enableSNIExtension", "false"); + + TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { + + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + } }; + + SSLContext sslContext = SSLContext.getInstance("SSL"); + sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sslContext + .getSocketFactory()); + + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( + sslContext, NoopHostnameVerifier.INSTANCE); + + Registry r = RegistryBuilder + . create().register("https", sslsf) + .build(); + + HttpClientConnectionManager cm = new PoolingHttpClientConnectionManager( + r); + + // CLIENT CONNECTION + BasicCookieStore cookieStore = new BasicCookieStore(); + HttpClient client = HttpClients.custom().setConnectionManager(cm) + .setDefaultCookieStore(cookieStore).build(); + + HttpPost loginHost = new HttpPost(baseURL + "/j_spring_security_check"); + + List urlParameters = new ArrayList(); + urlParameters.add(new BasicNameValuePair("j_username", + this.tranSMARTuserName)); + urlParameters.add(new BasicNameValuePair("j_password", + this.tranSMARTpassword)); + loginHost.setEntity(new UrlEncodedFormEntity(urlParameters)); + + client.execute(loginHost); + + return client; + } + + @Override + public Boolean editableReturnEntity() { + return true; + } +} diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmartvariant/I2B2tranSMARTVariantResource.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmartvariant/I2B2tranSMARTVariantResource.java new file mode 100644 index 0000000..11beebb --- /dev/null +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/i2b2transmartvariant/I2B2tranSMARTVariantResource.java @@ -0,0 +1,16 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +package edu.harvard.hms.dbmi.bd2k.irct.ri.i2b2transmartvariant; + +import edu.harvard.hms.dbmi.bd2k.irct.model.resource.Resource; + +/** + * A Base tranSMART Resource that can be implemented as a separate resource + * + * @author Jeremy R. Easton-Marks + * + */ +public class I2B2tranSMARTVariantResource extends Resource { + +} diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/openCPU/OpenCPUResource.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/openCPU/OpenCPUResource.java index 19eb813..7fc1c88 100644 --- a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/openCPU/OpenCPUResource.java +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/openCPU/OpenCPUResource.java @@ -1,19 +1,6 @@ -/* - * This file is part of Inter-Resource Communication Tool (IRCT). - * - * IRCT is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * IRCT is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with IRCT. If not, see . - */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package edu.harvard.hms.dbmi.bd2k.irct.ri.openCPU; import edu.harvard.hms.dbmi.bd2k.irct.model.resource.Resource; diff --git a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/openCPU/OpenCPUResourceImplementation.java b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/openCPU/OpenCPUResourceImplementation.java index 4ece5d0..97f2f2d 100644 --- a/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/openCPU/OpenCPUResourceImplementation.java +++ b/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/ri/openCPU/OpenCPUResourceImplementation.java @@ -1,3 +1,6 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package edu.harvard.hms.dbmi.bd2k.irct.ri.openCPU; import java.util.List; @@ -5,6 +8,8 @@ import javax.json.JsonObject; +import edu.harvard.hms.dbmi.bd2k.irct.exception.ResourceInterfaceException; +import edu.harvard.hms.dbmi.bd2k.irct.model.action.ActionState; import edu.harvard.hms.dbmi.bd2k.irct.model.ontology.Path; import edu.harvard.hms.dbmi.bd2k.irct.model.process.IRCTProcess; import edu.harvard.hms.dbmi.bd2k.irct.model.resource.ProcessResourceImplementationInterface; @@ -34,25 +39,19 @@ public String getType() { } @Override - public List availableProcesses() { + public List getReturnEntity() { // TODO Auto-generated method stub return null; } @Override - public Path getReturnEntity() { + public ActionState runProcess(IRCTProcess pep) { // TODO Auto-generated method stub return null; } @Override - public Long run(IRCTProcess pep) { - // TODO Auto-generated method stub - return null; - } - - @Override - public ResultSet getResults(Long processId) { + public ResultSet getResults(ActionState actionState) throws ResourceInterfaceException { // TODO Auto-generated method stub return null; } @@ -74,5 +73,4 @@ public JsonObject toJson(int depth) { // TODO Auto-generated method stub return null; } - }