diff --git a/.gitignore b/.gitignore index fe260563c..2865edb07 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ log src/main/bin/NCIT_HISTORY/ report.html gradle.lockfile +/.apt_generated/ +/.apt_generated_tests/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 1acc16067..d708d3d52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [2.2.0.RELEASE] - 2025-06-10 +### Changed +- FHIR improvements (improved param support, improved swagger, improved metadata, more tests) +- Improvements to computed childhood neoplasm subsets +- Improved handling of complex defintions +- Improved handling of NCI Thesaurus cumulative history + ## [2.1.1.RELEASE] - 2025-04-30 ### Changed - Load childhood neoplasm data from a renamed file and include subsetLink data diff --git a/ELASTICSEARCH.md b/ELASTICSEARCH.md deleted file mode 100644 index f2eba6d48..000000000 --- a/ELASTICSEARCH.md +++ /dev/null @@ -1,16 +0,0 @@ -# EVSRESTAPI - ELASTICSEARCH SETUP - -Information on downloading and using ELASTICSEARCH with EVSRESTAPI. - -Verify the $ES_DIR variable points to the correct path set up in previous steps. If not, set it now:
`export set -ES_DIR=c:$dir/elasticsearch/data` - -## Running Elasticsearch Locally - -In a terminal, run the following to have an elasticsearch instance running. Keep this window open to keep the server running. - - docker run -d --name=es_evs --rm -p $ES_PORT:9200 \ - -v "$ES_DIR":/usr/share/elasticsearch/data -e "xpack.security.enabled=false" \ - -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms1g -Xmx5g" \ - docker.elastic.co/elasticsearch/elasticsearch:7.12.1 - diff --git a/JENA.md b/JENA.md index 97861e3aa..c5375ce11 100644 --- a/JENA.md +++ b/JENA.md @@ -8,7 +8,7 @@ Run the following command to build the Jena image: ```bash cd docker/fuseki -docker build -t evsrestapi/fuseki:5.1.0 . +docker build -t evsrestapi/fuseki:5.3.0 . ``` ### Running a Jena/Fuseki Container @@ -18,7 +18,7 @@ Note: you need the mount path to a local directory ($dir) of your choice to pers ```bash dir=c:/Users/carlsenbr/eclipse-workspace/data/fuseki -docker run -d --name=jena_evs --rm -p "3030:3030" -v "$dir":/opt/fuseki/run/databases evsrestapi/fuseki:5.1.0 +docker run -d --name=jena_evs --rm -p "3030:3030" -v "$dir":/opt/fuseki/run/databases evsrestapi/fuseki:5.3.0 ``` ### Running a sparql query (assumes jena/fuseki running on localhost and curl and jq are installed) diff --git a/Makefile b/Makefile index 82a1ed41f..82d6a5fb8 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ clean: # Build the library without tests # On Windows use: git config core.eol lf build: - ./gradlew clean spotlessApply build -x test + ./gradlew clean spotlessApply build -x test -x zipFile test: ./gradlew spotlessCheck -x test diff --git a/OPENSEARCH.md b/OPENSEARCH.md index 0af48a4e4..33e6d80dd 100644 --- a/OPENSEARCH.md +++ b/OPENSEARCH.md @@ -27,7 +27,35 @@ In a terminal, run the following to have an opensearch instance running on the b -v "$OS_DIR":/usr/share/opensearch/data \ -e DISABLE_SECURITY_PLUGIN=true \ --name opensearch-node -d opensearchproject/opensearch:2.18.0 - + +## Configure refresh interval globally + +To prevent "too many requests" issue from happening while loader is running, it may be useful +to set the refresh interval higher. Making it higher than 5s requires review of loader +code to ensure it is not trying to read back data earlier than 5s after a required prior +indexing operation completes (Review `Thread.sleep` calls in the code). + +``` +curl -X PUT $ES/_cluster/settings -H "Content-type: application/json" \ + -d '{ "persistent": { "index.refresh_interval": "60s" } } +``` + +A call like this in AWS needs to be done from a machine with an IAM role l + +``` +{ + "Effect": "Allow", + "Principal": { + "AWS": "arn:aws:iam:::user/" + }, + "Action": [ + "es:ESHttpPut", + "es:admin/cluster/settings/update" + ], + "Resource": "arn:aws:es:::domain//*" +} +``` + ## References * Documentation - https://opensearch.org/docs/latest/ diff --git a/build.gradle b/build.gradle index 8b04cf91c..0a8d24e8c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { ext { - springBootVersion = '3.3.5' + springBootVersion = '3.3.11' // Remove this line to see what version is favored by springBootVersion // and the version brought in by spring-data-elasticsearch set('elasticsearch.version', '7.12.1') @@ -56,7 +56,7 @@ ext { /* Version info */ group = "gov.nih.nci.evs.api" -version = "2.1.1.RELEASE" +version = "2.2.0.RELEASE" sourceCompatibility = 17 targetCompatibility = 17 @@ -72,6 +72,7 @@ java { toolchain { languageVersion = JavaLanguageVersion.of(17) } + } dependencies { @@ -89,7 +90,7 @@ dependencies { implementation "org.springframework:spring-aop" // For vulnerabilities - implementation "org.apache.tomcat.embed:tomcat-embed-core:10.1.40" + implementation "org.apache.tomcat.embed:tomcat-embed-core:10.1.42" //implementation "org.springframework.data:spring-data-elasticsearch:4.2.12" implementation "org.opensearch.client:spring-data-opensearch-starter:1.5.3" @@ -120,11 +121,11 @@ dependencies { implementation 'com.google.protobuf:protobuf-java:3.25.5' // fhir dependencies - implementation "ca.uhn.hapi.fhir:hapi-fhir-base:7.4.5"; - implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r4:7.4.5" - implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r5:7.4.5" - implementation "ca.uhn.hapi.fhir:hapi-fhir-server:7.4.5" - implementation("ca.uhn.hapi.fhir:hapi-fhir-jpaserver-base:7.4.5") { + implementation "ca.uhn.hapi.fhir:hapi-fhir-base:7.6.1"; + implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r4:7.6.1" + implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r5:7.6.1" + implementation "ca.uhn.hapi.fhir:hapi-fhir-server:7.6.1" + implementation("ca.uhn.hapi.fhir:hapi-fhir-jpaserver-base:7.6.1") { exclude group: "net.minidev", module: "json-smart" exclude group: "ca.uhn.hapi.fhir", module: "hapi-fhir-sql-migrate" exclude group: "org.elasticsearch.client", module: "elasticsearch-rest-high-level-client" @@ -136,19 +137,19 @@ dependencies { exclude group: "org.glassfish", module: "javax.el" exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j" } - implementation "ca.uhn.hapi.fhir:hapi-fhir-server-openapi:7.4.5" + implementation "ca.uhn.hapi.fhir:hapi-fhir-server-openapi:7.6.1" // For the moment, these require explicit 6.4.0 to resolve vulnerabilities (as 7.4.5 above is current) implementation "org.fhir:ucum:1.0.9" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.convertors:6.4.0" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.dstu2:6.4.0" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.dstu2016may:6.4.0" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.dstu3:6.4.0" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.r4:6.4.0" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.r4b:6.4.0" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.r5:6.4.0" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.utilities:6.4.0" - implementation "ca.uhn.hapi.fhir:org.hl7.fhir.validation:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.convertors:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.dstu2:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.dstu2016may:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.dstu3:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.r4:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.r4b:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.r5:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.utilities:6.4.0" + //implementation "ca.uhn.hapi.fhir:org.hl7.fhir.validation:6.4.0" // Lombok dependencies (avoid using lombok for now) //implementation "org.projectlombok:lombok:1.18.32" diff --git a/docker/fuseki/Dockerfile b/docker/fuseki/Dockerfile index 08e8deb22..d94b1164f 100644 --- a/docker/fuseki/Dockerfile +++ b/docker/fuseki/Dockerfile @@ -1,7 +1,7 @@ FROM bellsoft/liberica-openjre-alpine:17.0.13 # Set environment variables -ENV FUSEKI_VERSION=5.1.0 +ENV FUSEKI_VERSION=5.3.0 ENV JENA_HOME=/opt/jena ENV FUSEKI_HOME=/opt/fuseki ENV FUSEKI_BASE=/opt/fuseki/run diff --git a/software/NCIT.md b/software/NCIT.md deleted file mode 100644 index e386d8932..000000000 --- a/software/NCIT.md +++ /dev/null @@ -1,29 +0,0 @@ -# EVSRESTAPI - NCIT Maintenance Tasks - -Information on using evsrestapi-util for maintenance tasks. - -## Computing SPARQL queries for roles/subclasses - -The roles and subclasses queries in sparql-queries.properties -may need to change from time to time as patterns within NCIt OWL -change over time. Periodically (e.g. quarterly/bi-annually), -it is desirable to recompute the roles and subclasses sparql queries -to understand whether new patterns need to be supported. - -### Steps - -1. Build software/evsapi-util to create the evsrestapi-util.jar file (requires `ant` installation) - - -2. Generate roles - -java -d64 -Xms512m -Xmx4g -classpath evsrestapi-util.jar gov.nih.nci.evs.restapi.util.SPARQLQueryGenerator /path/to//ThesaurusInferred.owl roles - -Use the output to update all "roles" entries in `sparql-queries.properties`) - -3. Generate subclasses - -java -d64 -Xms512m -Xmx4g -classpath evsrestapi-util.jar gov.nih.nci.evs.restapi.util.SPARQLQueryGenerator /path/to//ThesaurusInferred.owl subclasses - -Use the output to update all "hierarchy" entries in `sparql-queries.properties`) - diff --git a/software/evsrestapi-client/build.properties b/software/evsrestapi-client/build.properties deleted file mode 100644 index a6942a212..000000000 --- a/software/evsrestapi-client/build.properties +++ /dev/null @@ -1,30 +0,0 @@ -# The project name will be the name of the jar file. -project.name = evsrestapi-client - -# CVS settings -cvs.root = -export.command = export -DNOW src - -# Where source files are found -src.dir = ./src - -# Classpath - -# Intermediate directory for building class files. -build.dir = ./build - -# Compiler options. -debug = on -optimize = on -deprecation = off -packagename = evsrestapi-client - -# Javadoc options. -javadoc.dir = ./api -#javadoc.style = -javadoc.author = true -javadoc.private = false -javadoc.use = true -javadoc.version = true -javadoc.window.title = evsrestapi-client -javadoc.doc.title = evsrestapi-client diff --git a/software/evsrestapi-client/build.xml b/software/evsrestapi-client/build.xml deleted file mode 100644 index 367e2991c..000000000 --- a/software/evsrestapi-client/build.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JAVA_HOME: ${java.home} - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/software/evsrestapi-client/cmd.exe b/software/evsrestapi-client/cmd.exe deleted file mode 100644 index dca94f437..000000000 Binary files a/software/evsrestapi-client/cmd.exe and /dev/null differ diff --git a/software/evsrestapi-client/evsrestapi-client.jar b/software/evsrestapi-client/evsrestapi-client.jar deleted file mode 100644 index 9867b1acb..000000000 Binary files a/software/evsrestapi-client/evsrestapi-client.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/evsrestapi-util.jar b/software/evsrestapi-client/lib/evsrestapi-util.jar deleted file mode 100644 index 758e707ad..000000000 Binary files a/software/evsrestapi-client/lib/evsrestapi-util.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/gson-2.6.2.jar b/software/evsrestapi-client/lib/gson-2.6.2.jar deleted file mode 100644 index 9d78626d8..000000000 Binary files a/software/evsrestapi-client/lib/gson-2.6.2.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/jackson-annotations-2.9.0.jar b/software/evsrestapi-client/lib/jackson-annotations-2.9.0.jar deleted file mode 100644 index 624db9882..000000000 Binary files a/software/evsrestapi-client/lib/jackson-annotations-2.9.0.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/jackson-core-2.9.7.jar b/software/evsrestapi-client/lib/jackson-core-2.9.7.jar deleted file mode 100644 index 8211c6442..000000000 Binary files a/software/evsrestapi-client/lib/jackson-core-2.9.7.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/jackson-databind-2.9.7.jar b/software/evsrestapi-client/lib/jackson-databind-2.9.7.jar deleted file mode 100644 index 89b059975..000000000 Binary files a/software/evsrestapi-client/lib/jackson-databind-2.9.7.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/jackson-dataformat-yaml-2.9.7.jar b/software/evsrestapi-client/lib/jackson-dataformat-yaml-2.9.7.jar deleted file mode 100644 index 0bfba2eb3..000000000 Binary files a/software/evsrestapi-client/lib/jackson-dataformat-yaml-2.9.7.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/jackson-datatype-jdk8-2.9.7.jar b/software/evsrestapi-client/lib/jackson-datatype-jdk8-2.9.7.jar deleted file mode 100644 index 7e8c24e48..000000000 Binary files a/software/evsrestapi-client/lib/jackson-datatype-jdk8-2.9.7.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/jackson-datatype-jsr310-2.9.7.jar b/software/evsrestapi-client/lib/jackson-datatype-jsr310-2.9.7.jar deleted file mode 100644 index 1357a6a09..000000000 Binary files a/software/evsrestapi-client/lib/jackson-datatype-jsr310-2.9.7.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/jackson-module-parameter-names-2.9.7.jar b/software/evsrestapi-client/lib/jackson-module-parameter-names-2.9.7.jar deleted file mode 100644 index 8bd6a449d..000000000 Binary files a/software/evsrestapi-client/lib/jackson-module-parameter-names-2.9.7.jar and /dev/null differ diff --git a/software/evsrestapi-client/lib/xstream-1.2.2.jar b/software/evsrestapi-client/lib/xstream-1.2.2.jar deleted file mode 100644 index 2d813c229..000000000 Binary files a/software/evsrestapi-client/lib/xstream-1.2.2.jar and /dev/null differ diff --git a/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/client/bean/Association.java b/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/client/bean/Association.java deleted file mode 100644 index 0a747e778..000000000 --- a/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/client/bean/Association.java +++ /dev/null @@ -1,93 +0,0 @@ -package gov.nih.nci.evs.restapi.client.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class Association -{ - -// Variable declaration - private String type; - private String relatedCode; - private String relatedName; - -// Default constructor - public Association() { - } - -// Constructor - public Association( - String type, - String relatedCode, - String relatedName) { - - this.type = type; - this.relatedCode = relatedCode; - this.relatedName = relatedName; - } - -// Set methods - public void setType(String type) { - this.type = type; - } - - public void setRelatedCode(String relatedCode) { - this.relatedCode = relatedCode; - } - - public void setRelatedName(String relatedName) { - this.relatedName = relatedName; - } - - -// Get methods - public String getType() { - return this.type; - } - - public String getRelatedCode() { - return this.relatedCode; - } - - public String getRelatedName() { - return this.relatedName; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i synonyms; - private List definitions; - private List properties; - private List parents; - private List children; - private List associations; - private List inverseAssociations; - private List roles; - private List inverseRoles; - private List maps; - -// Default constructor - public ConceptDetails() { - } - -// Constructor - public ConceptDetails( - String code, - String name, - String terminology, - String version, - boolean leaf, - List synonyms, - List definitions, - List properties, - List parents, - List children, - List associations, - List inverseAssociations, - List roles, - List inverseRoles, - List maps) { - - this.code = code; - this.name = name; - this.terminology = terminology; - this.version = version; - this.leaf = leaf; - this.synonyms = synonyms; - this.definitions = definitions; - this.properties = properties; - this.parents = parents; - this.children = children; - this.associations = associations; - this.inverseAssociations = inverseAssociations; - this.roles = roles; - this.inverseRoles = inverseRoles; - this.maps = maps; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setName(String name) { - this.name = name; - } - - public void setTerminology(String terminology) { - this.terminology = terminology; - } - - public void setVersion(String version) { - this.version = version; - } - - public void setLeaf(boolean leaf) { - this.leaf = leaf; - } - - public void setSynonyms(List synonyms) { - this.synonyms = synonyms; - } - - public void setDefinitions(List definitions) { - this.definitions = definitions; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public void setParents(List parents) { - this.parents = parents; - } - - public void setChildren(List children) { - this.children = children; - } - - public void setAssociations(List associations) { - this.associations = associations; - } - - public void setInverseAssociations(List inverseAssociations) { - this.inverseAssociations = inverseAssociations; - } - - public void setRoles(List roles) { - this.roles = roles; - } - - public void setInverseRoles(List inverseRoles) { - this.inverseRoles = inverseRoles; - } - - public void setMaps(List maps) { - this.maps = maps; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getName() { - return this.name; - } - - public String getTerminology() { - return this.terminology; - } - - public String getVersion() { - return this.version; - } - - public boolean getLeaf() { - return this.leaf; - } - - public List getSynonyms() { - return this.synonyms; - } - - public List getDefinitions() { - return this.definitions; - } - - public List getProperties() { - return this.properties; - } - - public List getParents() { - return this.parents; - } - - public List getChildren() { - return this.children; - } - - public List getAssociations() { - return this.associations; - } - - public List getInverseAssociations() { - return this.inverseAssociations; - } - - public List getRoles() { - return this.roles; - } - - public List getInverseRoles() { - return this.inverseRoles; - } - - public List getMaps() { - return this.maps; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i qualifiers; - -// Default constructor - public Definition() { - } - -// Constructor - public Definition( - String type, - String definition, - String source, - List qualifiers) { - - this.type = type; - this.definition = definition; - this.source = source; - this.qualifiers = qualifiers; - } - -// Set methods - public void setType(String type) { - this.type = type; - } - - public void setDefinition(String definition) { - this.definition = definition; - } - - public void setSource(String source) { - this.source = source; - } - - public void setQualifiers(List qualifiers) { - this.qualifiers = qualifiers; - } - - -// Get methods - public String getType() { - return this.type; - } - - public String getDefinition() { - return this.definition; - } - - public String getSource() { - return this.source; - } - - public List getQualifiers() { - return this.qualifiers; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i property; - List synonymType; - private List terminology; - -// Default constructor - public Parameter() { - } - -// Constructor - public Parameter( - String term, - String type, - String include, - int fromRecord, - int pageSize, - List property, - List synonymType, - List terminology) { - - this.term = term; - this.type = type; - this.include = include; - this.fromRecord = fromRecord; - this.pageSize = pageSize; - this.property = property; - this.synonymType = synonymType; - this.terminology = terminology; - } - -// Set methods - public void setTerm(String term) { - this.term = term; - } - - public void setType(String type) { - this.type = type; - } - - public void setInclude(String include) { - this.include = include; - } - - public void setFromRecord(int fromRecord) { - this.fromRecord = fromRecord; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public void setProperty(List property) { - this.property = property; - } - - public void setSynonymType(List synonymType) { - this.synonymType = synonymType; - } - - public void setTerminology(List terminology) { - this.terminology = terminology; - } - - -// Get methods - public String getTerm() { - return this.term; - } - - public String getType() { - return this.type; - } - - public String getInclude() { - return this.include; - } - - public int getFromRecord() { - return this.fromRecord; - } - - public int getPageSize() { - return this.pageSize; - } - - public List getProperty() { - return this.property; - } - - public List getSynonymType() { - return this.synonymType; - } - - public List getTerminology() { - return this.terminology; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i path; - -// Default constructor - public Path() { - } - -// Constructor - public Path( - List path) { - - this.path = path; - } - -// Set methods - public void setPath(List path) { - this.path = path; - } - - -// Get methods - public List getPath() { - return this.path; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i paths; - -// Default constructor - public Paths() { - } - -// Constructor - public Paths( - List paths) { - - this.paths = paths; - } - -// Set methods - public void setPaths(List paths) { - this.paths = paths; - } - - -// Get methods - public List getPaths() { - return this.paths; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i qualifiers; - -// Default constructor - public Property() { - } - -// Constructor - public Property( - String type, - String value, - List qualifiers) { - - this.type = type; - this.value = value; - this.qualifiers = qualifiers; - } - -// Set methods - public void setType(String type) { - this.type = type; - } - - public void setValue(String value) { - this.value = value; - } - - public void setQualifiers(List qualifiers) { - this.qualifiers = qualifiers; - } - - -// Get methods - public String getType() { - return this.type; - } - - public String getValue() { - return this.value; - } - - public List getQualifiers() { - return this.qualifiers; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i concepts; - -// Default constructor - public SearchResult() { - } - -// Constructor - public SearchResult( - int total, - int timeTaken, - Parameter parameters, - List concepts) { - - this.total = total; - this.timeTaken = timeTaken; - this.parameters = parameters; - this.concepts = concepts; - } - -// Set methods - public void setTotal(int total) { - this.total = total; - } - - public void setTimeTaken(int timeTaken) { - this.timeTaken = timeTaken; - } - - public void setParameters(Parameter parameters) { - this.parameters = parameters; - } - - public void setConcepts(List concepts) { - this.concepts = concepts; - } - - -// Get methods - public int getTotal() { - return this.total; - } - - public int getTimeTaken() { - return this.timeTaken; - } - - public Parameter getParameters() { - return this.parameters; - } - - public List getConcepts() { - return this.concepts; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i concepts; - -// Default constructor - public SearchResultDetails() { - } - -// Constructor - public SearchResultDetails( - int total, - int timeTaken, - Parameter parameters, - List concepts) { - - this.total = total; - this.timeTaken = timeTaken; - this.parameters = parameters; - this.concepts = concepts; - } - -// Set methods - public void setTotal(int total) { - this.total = total; - } - - public void setTimeTaken(int timeTaken) { - this.timeTaken = timeTaken; - } - - public void setParameters(Parameter parameters) { - this.parameters = parameters; - } - - public void setConcepts(List concepts) { - this.concepts = concepts; - } - - -// Get methods - public int getTotal() { - return this.total; - } - - public int getTimeTaken() { - return this.timeTaken; - } - - public Parameter getParameters() { - return this.parameters; - } - - public List getConcepts() { - return this.concepts; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i children; - -// Default constructor - public TreeNode() { - } - -// Constructor - public TreeNode( - String code, - String label, - boolean leaf, - boolean expanded, - List children) { - - this.code = code; - this.label = label; - this.leaf = leaf; - this.expanded = expanded; - this.children = children; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setLabel(String label) { - this.label = label; - } - - public void setLeaf(boolean leaf) { - this.leaf = leaf; - } - - public void setExpanded(boolean expanded) { - this.expanded = expanded; - } - - public void setChildren(List children) { - this.children = children; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getLabel() { - return this.label; - } - - public boolean getLeaf() { - return this.leaf; - } - - public boolean getExpanded() { - return this.expanded; - } - - public List getChildren() { - return this.children; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println("" + title + ""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - } - - public void writeBody(PrintWriter out, String title, gov.nih.nci.evs.restapi.model.ConceptDetails c) { - out.println(""); - out.println("
"); - out.println("
"); - out.println(" "); - out.println("

" + title + "

"); - out.println("

"); - out.println("  Synonyms: none"); - } else { - out.println("
  Synonyms:
"); - out.println(" "); - out.println(" "); - - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - - for (int i=0; i"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - } - - out.println(" "); - out.println("
NameTypeTerm GroupSourceSubsourceSource Code
 " + synonym.getName() + "" + synonym.getType() + "" + termgroup + "" + source + "" + subsource + "" + sourcecode + "
"); - } - out.println("

"); - - out.println("
"); - List defs = c.getDefinitions(); - if (defs == null || defs.size() == 0) { - out.println("
  Definitions: none
"); - } else { - out.println("
  Definitions:
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - for (int i=0; i"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - } - out.println(" "); - out.println("
TypeDescriptionSource
 " + type + "" + a.getDefinition() + "" + a.getSource() + "
"); - } - out.println("
"); - out.println("

"); - - out.println("
"); - List properties = c.getProperties(); - if (properties == null || properties.size() == 0) { - out.println("
  Properties: none
"); - } else { - out.println("
  Properties:
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - for (int i=0; i"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - } - out.println(" "); - out.println("
TypeValue
 " + a.getType() + "" + a.getValue() + "
"); - } - out.println("
"); - out.println("

"); - - out.println("
"); - - List superconcepts = c.getParents(); - if (superconcepts == null || superconcepts.size() == 0) { - out.println("
  Superconcepts: none
"); - } else { - out.println("
  Superconcepts:
"); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - - for (int i=0; i"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - } - out.println(" "); - out.println("
 CodeName
 " + superconcept.getCode() + "" + superconcept.getName() + "
"); - } - out.println("

"); - out.println("
"); - out.println("
"); - List subconcepts = c.getChildren(); - if (subconcepts == null || subconcepts.size() == 0) { - out.println("
  Subconcepts: none
"); - } else { - out.println("
  Subconcepts:
"); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - for (int i=0; i"); - - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - } - out.println(" "); - out.println("
 CodeName
 " + subconcept.getCode() + "" + subconcept.getName() + "
"); - } - out.println("
"); - out.println("

"); - - out.println("
"); - ///////////////////////////////////////////////////////////////////////////////// - List associations = c.getAssociations(); - if (associations == null || associations.size() == 0) { - out.println("
  Associations: none
"); - } else { - out.println("
  Associations:
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - for (int i=0; i"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - } - out.println(" "); - out.println("
NameRelated NameRelated Code
 " + a.getType() + "" + a.getRelatedName() + "" + a.getRelatedCode() + "
"); - } - out.println("
"); - out.println("

"); - - out.println("
"); - List inv_associations = c.getInverseAssociations(); - if (inv_associations == null || inv_associations.size() == 0) { - out.println("
  Inverse Associations: none
"); - } else { - out.println("
  Inverse Associations:
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - for (int i=0; i"); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - - out.println(" "); - } - out.println(" "); - out.println("
Related NameRelated CodeName
  " + a.getRelatedName() + "" + a.getRelatedCode() + "" + a.getType() + "
"); - } - - - out.println("
"); - out.println("

"); - List roles = c.getRoles(); - if (roles == null || roles.size() == 0) { - out.println("
  Roles: none
"); - } else { - out.println("
  Roles:
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - for (int i=0; i"); - - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - } - out.println(" "); - out.println("
NameRelated NameRelated Code
 " + a.getType() + "" + a.getRelatedName() + "" + a.getRelatedCode() + "
"); - } - out.println("

"); - out.println("
"); - List inv_roles = c.getInverseRoles(); - if (inv_roles == null || inv_roles.size() == 0) { - out.println("
  Inverse Roles: none
"); - } else { - out.println("
  Inverse Roles:
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - for (int i=0; i"); - - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - } - out.println(" "); - out.println("
Related NameRelated CodeName
 " + a.getRelatedName() + "" + a.getRelatedCode() + "" + a.getType() + "
"); - } - out.println("

"); - - out.println("
"); - List maps = c.getMaps(); - if (maps == null || maps.size() == 0) { - out.println("
  MapsTo: none
"); - } else { - out.println("
  MapsTo:
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - for (int i=0; i"); - - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(" "); - } - out.println(" "); - out.println("
TypeTarget NameTarget Term GroupTarget CodeTarget TermonologyTarget Termonology Version
 " + a.getType() + "" + a.getTargetName() + "" + a.getTargetTermGroup() + "" + a.getTargetCode() + "" + a.getTargetTerminology() + "" +version + "
"); - } - - out.println("
"); - out.println(""); - } - - public void writeFooter(PrintWriter out) { - out.println(""); - } - - public void generate(PrintWriter out, String title, gov.nih.nci.evs.restapi.model.ConceptDetails c) { - writeHeader(out, title); - writeBody(out, title, c); - writeFooter(out); - } - - public void generate(String outputfile, String title, gov.nih.nci.evs.restapi.model.ConceptDetails c) { - long ms = System.currentTimeMillis(); - PrintWriter pw = null; - try { - pw = new PrintWriter(outputfile, "UTF-8"); - generate(pw, title, c); - - } catch (Exception ex) { - - } finally { - try { - pw.close(); - System.out.println("Output file " + outputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void main(String[] args) { - Vector v = null; - try { - //String terminology = "ncit"; - //String code = "C3224"; - String terminology = args[0]; - String code = args[1]; - - gov.nih.nci.evs.restapi.model.ConceptDetails c = EVSRESTAPIClient.getConceptDetails(terminology, code); - /* - String json = c.toJson(); - //System.out.println(c.toJson()); - String flattened_json = EVSRESTAPIClient.flattenJSON(json); - System.out.println(flattened_json); - gov.nih.nci.evs.restapi.model.ConceptDetails c2 = (gov.nih.nci.evs.restapi.model.ConceptDetails) EVSRESTAPIClient.deserialize("ConceptDetails", flattened_json); - System.out.println(c2.toJson()); - */ - - ConceptDetailsPageGenerator generator = new ConceptDetailsPageGenerator(); - String outputfile = "concept_details_" + code + ".html"; - String title = c.getName() + " (" + code + ")"; - generator.generate(outputfile, title, c); - - } catch (Exception ex) { - ex.printStackTrace(); - } - } -} - - -/* - private String code; - private String name; - private String terminology; - private String version; - private List synonyms; - private List definitions; - private List properties; - private List parents; - private List children; - private List associations; - private List inverseAssociations; - private List roles; - private List inverseRoles; - private List maps; -*/ \ No newline at end of file diff --git a/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/util/EVSRESTAPIClient.java b/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/util/EVSRESTAPIClient.java deleted file mode 100644 index 8228d08fc..000000000 --- a/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/util/EVSRESTAPIClient.java +++ /dev/null @@ -1,478 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import gov.nih.nci.evs.restapi.model.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import java.nio.charset.Charset; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.DeserializationFeature; - -public class EVSRESTAPIClient { - public static String ENDPOINT_PREFIX = "https://api-evsrest.nci.nih.gov"; - public static String ENDPOINT_CONCEPT = "/api/v1/concept/{terminology}/{code}"; - public static String[] TYPES = new String[]{"roles", "inverseRoles", "associations", "inverseAssociations", "parents"}; - public static HashMap EVSRESTAPI_URL_MAP = new HashMap(); - - static { - EVSRESTAPI_URL_MAP = new HashMap(); - EVSRESTAPI_URL_MAP.put("associations", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/associations"); - EVSRESTAPI_URL_MAP.put("inverseAssociations", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/inverseAssociations"); - EVSRESTAPI_URL_MAP.put("code", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}"); - EVSRESTAPI_URL_MAP.put("maps", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/maps"); - EVSRESTAPI_URL_MAP.put("pathsToAncestor_ancestorCode", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/pathsToAncestor/{ancestorCode}"); - EVSRESTAPI_URL_MAP.put("roles", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/roles"); - EVSRESTAPI_URL_MAP.put("roots", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/roots"); - EVSRESTAPI_URL_MAP.put("descendants", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/descendants"); - EVSRESTAPI_URL_MAP.put("pathsToRoot", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/pathsToRoot"); - EVSRESTAPI_URL_MAP.put("subtree", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/subtree"); - EVSRESTAPI_URL_MAP.put("inverseAssociations", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/inverseAssociations"); - EVSRESTAPI_URL_MAP.put("inverseRoles", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/inverseRoles"); - EVSRESTAPI_URL_MAP.put("concept_terminology", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}"); - EVSRESTAPI_URL_MAP.put("children", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/subtree/children"); - EVSRESTAPI_URL_MAP.put("disjointWith", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/disjointWith"); - EVSRESTAPI_URL_MAP.put("pathsFromRoot", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/pathsFromRoot"); - EVSRESTAPI_URL_MAP.put("parents", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}/parents"); - EVSRESTAPI_URL_MAP.put("concept", "https://api-evsrest.nci.nih.gov/api/v1/concept/{terminology}/{code}?include=full"); - - - EVSRESTAPI_URL_MAP.put("metadata_associations", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/associations"); - EVSRESTAPI_URL_MAP.put("metadata_terminologies", "https://api-evsrest.nci.nih.gov/api/v1/metadata/terminologies"); - EVSRESTAPI_URL_MAP.put("metadata_values", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/qualifier/{codeOrLabel}/values"); - EVSRESTAPI_URL_MAP.put("metadata_roles", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/roles"); - EVSRESTAPI_URL_MAP.put("metadata_role_codeOrLabel", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/role/{codeOrLabel}"); - EVSRESTAPI_URL_MAP.put("metadata_qualifiers", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/qualifiers"); - EVSRESTAPI_URL_MAP.put("metadata_definitionSources", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/definitionSources"); - EVSRESTAPI_URL_MAP.put("metadata_termTypes", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/termTypes"); - EVSRESTAPI_URL_MAP.put("metadata_synonymSources", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/synonymSources"); - EVSRESTAPI_URL_MAP.put("metadata_association_codeOrLabel", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/association/{codeOrLabel}"); - EVSRESTAPI_URL_MAP.put("metadata_property_codeOrLabel", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/property/{codeOrLabel}"); - EVSRESTAPI_URL_MAP.put("metadata_conceptStatuses", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/conceptStatuses"); - EVSRESTAPI_URL_MAP.put("metadata_properties", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/properties"); - EVSRESTAPI_URL_MAP.put("metadata_qualifier_codeOrLabel", "https://api-evsrest.nci.nih.gov/api/v1/metadata/{terminology}/qualifier/{codeOrLabel}"); - } - - - public EVSRESTAPIClient() { - - } - - public static HashMap get_evsrestapi_endpoint_map(String filename) { - HashMap hmap = new HashMap(); - String end_point_prefix = EVSRESTAPIClient.ENDPOINT_PREFIX; - Vector v = Utils.readFile(filename); - Vector w = new Vector(); - for (int i=0; i list = Arrays.asList(TYPES); - Vector end_points = get_evsrestapi_endpoints( filename, code); - Vector v = new Vector(); - int k = 0; - for (int i=0; i 0) { - Utils.saveToFile("failed_urls.txt", failed_urls); - } - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - return w; - } - - public static String getURL(String t, String terminology, String code) { - if (terminology != null) t = t.replace("{terminology}", terminology); - if (code != null) t = t.replace("{code}", code); - return t; - } - - public String code2Label(String code) { - return code2Label("ncit", code); - } - - public String code2Label(String terminology, String code) { - String t = (String) EVSRESTAPI_URL_MAP.get("code"); - String url = getURL(t, terminology, code); - String json = getJson(url); - if (json == null) return null; - try { - gov.nih.nci.evs.restapi.model.Concept c = (gov.nih.nci.evs.restapi.model.Concept) deserialize("Concept", json); - return c.getName(); - } catch (Exception ex) { - ex.printStackTrace(); - } - return null; - } - - public Vector extractHierarchyData(String parentCode, String parntLabel , gov.nih.nci.evs.restapi.model.TreeNode node) { - if (node == null) return null; - Vector w = new Vector(); - w.add(parntLabel + "|" + parentCode + "|" + node.getName() + "|" + node.getCode()); - List list = node.getChildren(); - if (list != null) { - for (int k=0; k codes = vs.getCodes(); - for (int i=0; i definitions) { - int hashcode = 0; - if (definitions == null || definitions.size() == 0) return 0; - for (int i=0; i superclasses) { - int hashcode = 0; - if (superclasses == null || superclasses.size() == 0) return 0; - for (int i=0; i subclasses) { - int hashcode = 0; - if (subclasses == null || subclasses.size() == 0) return 0; - for (int i=0; i maps) { - int hashcode = 0; - if (maps == null || maps.size() == 0) return 0; - for (int i=0; i synonyms) { - int hashcode = 0; - if (synonyms == null || synonyms.size() == 0) return 0; - for (int i=0; i roles) { - int hashcode = 0; - if (roles == null || roles.size() == 0) return 0; - for (int i=0; i inverseroles) { - int hashcode = 0; - if (inverseroles == null || inverseroles.size() == 0) return 0; - for (int i=0; i associations) { - int hashcode = 0; - if (associations == null || associations.size() == 0) return 0; - for (int i=0; i inverseassociation) { - int hashcode = 0; - if (inverseassociation == null || inverseassociation.size() == 0) return 0; - for (int i=0; i superclasses = cd.getParents(); - if (superclasses == null || superclasses.size() == 0) return null; - for (int i=0; i suberclasses = cd.getChildren(); - if (suberclasses == null || suberclasses.size() == 0) return null; - for (int i=0; i maps = cd.getMaps(); - if (maps == null || maps.size() == 0) return null; - for (int i=0; i properties = cd.getProperties(); - if (properties == null || properties.size() == 0) return null; - for (int i=0; i definitions = cd.getDefinitions(); - if (definitions == null || definitions.size() == 0) return null; - for (int i=0; i roles = cd.getRoles(); - if (roles == null || roles.size() == 0) return null; - for (int i=0; i roles = cd.getInverseRoles(); - if (roles == null || roles.size() == 0) return null; - for (int i=0; i roles = cd.getAssociations(); - if (roles == null || roles.size() == 0) return null; - for (int i=0; i roles = cd.getInverseAssociations(); - if (roles == null || roles.size() == 0) return null; - for (int i=0; i synonyms = cd.getSynonyms(); - if (synonyms == null || synonyms.size() == 0) return null; - for (int i=0; i properties) { - int hashcode = 0; - if (properties == null || properties.size() == 0) return 0; - for (int i=0; i 0) { - v1.add(t); - } - } - Vector v2 = new Vector(); - for (int i=0; i 0) { - v2.add(t); - } - } - Vector cd1 = new Vector(); - Vector cd2 = new Vector(); - Vector w1 = new Vector(); - Vector w2 = new Vector(); - Vector hashcd_1 = new Vector(); - Vector hashcd_2 = new Vector(); - HashMap code2CDMap1 = new HashMap(); - HashMap code2CDMap2 = new HashMap(); - - HashMap code2Label1 = new HashMap(); - HashMap code2Label2 = new HashMap(); - - Vector edit_history = new Vector(); - - for (int i=0; i loadEditHistory(String filename) { - Vector lines = Utils.readFile(filename); - return toEditActionList(lines); - } - - public static List toEditActionList(Vector lines) { - List list = new ArrayList(); - for (int i=0; i list = loadEditHistory("edit_history.txt"); - */ - List list = toEditActionList(edit_history); - for (int i=0; i"); - out.println(""); - out.println(" "); - out.println(" " + title + ""); - out.println(" "); - out.println(""); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(""); - out.println(" "); - out.println(""); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("

" + title + "

"); - out.println(" "); - out.println("

"); - out.println(" Options:"); - out.println(" "); - //out.println(" "); - out.println("

"); - //out.println(" "); - out.println(" "); - out.println("
");
-		out.println("  ");
-		out.println("");
-    }
-
-    public static void generate_html(String json, String title) {
-		long ms = System.currentTimeMillis();
-		String outputfile = title + ".html";
-		outputfile = outputfile.replace(" ","_");
-		System.out.println("Generating " + outputfile + " ...");
-		PrintWriter pw = null;
-		try {
-			pw = new PrintWriter(outputfile, "UTF-8");
-			generate(pw, title, json);
-
-		} catch (Exception ex) {
-
-		} finally {
-			try {
-				pw.close();
-				System.out.println("Output file " + outputfile + " generated.");
-			} catch (Exception ex) {
-				ex.printStackTrace();
-			}
-		}
-		System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms));
-	}
-
-
-    public static void generateHTML(String jsonfile) {
-		long ms = System.currentTimeMillis();
-		String json = readJSONFromFile(jsonfile);
-		int n = jsonfile.lastIndexOf(".");
-		String title = jsonfile.substring(0, n);
-		int m = title.lastIndexOf("\\");
-		if (m == -1) {
-			m = title.lastIndexOf("/");
-		}
-		if (m != -1) {
-			title = title.substring(m+1, title.length());
-		}
-		String outputfile = jsonfile.substring(0, n) + ".html";
-		System.out.println("Generating " + outputfile + " ...");
-		PrintWriter pw = null;
-		try {
-			pw = new PrintWriter(outputfile, "UTF-8");
-			generate(pw, title, json);
-
-		} catch (Exception ex) {
-
-		} finally {
-			try {
-				pw.close();
-				System.out.println("Output file " + outputfile + " generated.");
-			} catch (Exception ex) {
-				ex.printStackTrace();
-			}
-		}
-		System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms));
-	}
-
-    public static void main(String[] args) {
-		long ms = System.currentTimeMillis();
-		String jsonfile = args[0];
-		generateHTML(jsonfile);
-	}
-}
\ No newline at end of file
diff --git a/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/util/ObjectMappingUtils.java b/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/util/ObjectMappingUtils.java
deleted file mode 100644
index f9fdfa0df..000000000
--- a/software/evsrestapi-client/src/gov/nih/nci/evs/restapi/util/ObjectMappingUtils.java
+++ /dev/null
@@ -1,429 +0,0 @@
-package gov.nih.nci.evs.restapi.util;
-
-import gov.nih.nci.evs.restapi.client.bean.*;
-import java.io.*;
-import java.io.IOException;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.*;
-
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-
-public class ObjectMappingUtils {
-
-	static String BASE_URL = "https://api-evsrest.nci.nih.gov/api/v1/";
-
-	public static String ASSOCIATIONS = "associations";
-	public static String CHILDREN = "children";
-	public static String DESCENDANTS = "descendants";
-	public static String DISJOINTWITH = "disjointWith";
-	public static String INVERSEASSOCIATIONS = "inverseAssociations";
-	public static String INVERSEROLES = "inverseRoles";
-	public static String MAPS = "maps";
-	public static String PARENTS = "parents";
-	public static String ROLES = "roles";
-
-	public static String[] HIERARCHICAL_RELATIONSHIPS = new String[] {CHILDREN, PARENTS};
-
-	public static String[] RELATIONSHIPS = new String[] {ASSOCIATIONS, DISJOINTWITH, INVERSEASSOCIATIONS,
-	                                                    INVERSEROLES, MAPS, ROLES};
-
-    public static void setBASE_URL(String url) {
-		BASE_URL = url;
-	}
-
-	public static void run(String[] args) {
-		String inputfile = args[0];
-		run(inputfile);
-	}
-
-	public static Vector readFile(String filename)
-	{
-		Vector v = new Vector();
-		try {
-			BufferedReader in = new BufferedReader(
-			   new InputStreamReader(
-						  new FileInputStream(filename), "UTF8"));
-			String str;
-			while ((str = in.readLine()) != null) {
-				v.add(str);
-			}
-            in.close();
-		} catch (Exception ex) {
-            ex.printStackTrace();
-		}
-		return v;
-	}
-
-	 public static String replaceFilename(String filename) {
-	    return filename.replaceAll("[^a-zA-Z0-9\\.\\-]", "_");
-	 }
-
-	 public static void saveToFile(String outputfile, Vector v) {
-		outputfile = replaceFilename(outputfile);
-		PrintWriter pw = null;
-		try {
-			pw = new PrintWriter(outputfile, "UTF-8");
-			if (v != null && v.size() > 0) {
-				for (int i=0; i 0) {
-			for (int i=0; i
-    
- 
-    
-  
-    
-    
-    
-    
-      
-    
-        
-            
-        
-       
-
-    
-        
-            
-        
-        
-            
-                
-     
-      
-    
-        
-    
-    
-        JAVA_HOME: ${java.home}
-        
-    
-  
-    
-        
-            
-            
-        
-    
-
-    
-        
-    
-
-    
-        
-            
-                
-                
-            
-        
-    
-  
-  
-  
-
diff --git a/software/evsrestapi-util/evsrestapi-util.jar b/software/evsrestapi-util/evsrestapi-util.jar
deleted file mode 100644
index 758e707ad..000000000
Binary files a/software/evsrestapi-util/evsrestapi-util.jar and /dev/null differ
diff --git a/software/evsrestapi-util/jar/ncitqa.jar b/software/evsrestapi-util/jar/ncitqa.jar
deleted file mode 100644
index 037117d68..000000000
Binary files a/software/evsrestapi-util/jar/ncitqa.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/application-thesaurus.yml b/software/evsrestapi-util/lib/application-thesaurus.yml
deleted file mode 100644
index 5a1077495..000000000
--- a/software/evsrestapi-util/lib/application-thesaurus.yml
+++ /dev/null
@@ -1,424 +0,0 @@
-thesaurus:
-       owl:
-        returnFields: { code: 'Code',
-                        nhc0: 'Code',
-                        label: 'Label',
-                        displayname: 'Display_Name',
-                        display_name: 'Display_Name',
-                        p107: 'Display_Name',
-                        preferredname: 'Preferred_Name',
-                        preferred_name: 'Preferred_Name',
-                        p108: 'Preferred_Name',
-                        definitions: 'DEFINITION',
-                        definition: 'DEFINITION',
-                        p97: 'DEFINITION',
-                        alt_definition: 'ALT_DEFINITION',
-                        alt_definitions: 'ALT_DEFINITION',
-                        p325: 'ALT_DEFINITION',
-                        semantictypes: 'Semantic_Type',
-                        semantictype: 'Semantic_Type',
-                        semantic_type: 'Semantic_Type',
-                        p106: 'Semantic_Type',
-                        synonyms: 'FULL_SYN',
-                        synonym: 'FULL_SYN',
-                        full_syn: 'FULL_SYN',
-                        p90: 'FULL_SYN',
-                        superconcepts: 'Superconcept',
-                        superconcept: 'Superconcept',
-                        subconcepts: 'Subconcept',
-                        subconcept: 'Subconcept',
-                        roles: 'Role',
-                        role: 'Role',
-                        inverseroles: 'InverseRole',
-                        inverserole: 'InverseRole',
-                        associations: 'Association',
-                        association: 'Association',
-                        inverseassociations: 'InverseAssociation',
-                        inverseassociation: 'InverseAssociation',
-                        conceptstatus: 'Concept_Status',
-                        concept_status: 'Concept_Status',
-                        p310: 'Concept_Status',
-                        neoplastic_status: 'Neoplastic_Status',
-                        p363: 'Neoplastic_Status',
-                        umls_cui: 'UMLS_CUI',
-                        p207: 'UMLS_CUI',
-                        nci_meta_cui: 'NCI_META_CUI',
-                        p208: 'NCI_META_CUI',
-                        cas_registry: 'CAS_Registry',
-                        p210: 'CAS_Registry',
-                        kegg_id:  'KEGG_ID',
-                        p215:  'KEGG_ID',
-                        biocarta_id:  'BioCarta_ID',
-                        p216:  'BioCarta_ID',
-                        accepted_therapeutic_use_for: 'Accepted_Therapeutic_Use_For',
-                        p302: 'Accepted_Therapeutic_Use_For',
-                        snp_id: 'SNP_ID',
-                        p315: 'SNP_ID',
-                        relative_enzyme_activity: 'Relative_Enzyme_Activity',
-                        p316: 'Relative_Enzyme_Activity',
-                        fda_table:  'FDA_Table',
-                        p317:  'FDA_Table',
-                        fda_unii_code:  'FDA_UNII_Code',
-                        p319:  'FDA_UNII_Code',
-                        oid:  'OID',
-                        p320:  'OID',
-                        legacy_concept_name:  'Legacy_Concept_Name',
-                        p366:  'Legacy_Concept_Name',
-                        nichd_hierarchy_term: 'NICHD_Hierarchy_Term',
-                        p371: 'NICHD_Hierarchy_Term',
-                        term_browser_value_set_description: 'Term_Browser_Value_Set_Description',
-                        p376: 'Term_Browser_Value_Set_Description',
-                        gene_encodes_product: 'Gene_Encodes_Product',
-                        p96: 'Gene_Encodes_Product',
-                        swiss_prot: 'Swiss_Prot',
-                        p93: 'Swiss_Prot',
-                        icd-o-3_code: 'ICD-O-3_Code',
-                        p334: 'ICD-O-3_Code',
-                        chemical_formula: 'Chemical_Formula',
-                        p350: 'Chemical_Formula',
-                        infoods:  'INFOODS',
-                        p353:  'INFOODS',
-                        usda_id:  'USDA_ID',
-                        p354:  'USDA_ID',
-                        essential_amino_acid: 'Essential_Amino_Acid',
-                        p356: 'Essential_Amino_Acid',
-                        essential_fatty_acid: 'Essential_Fatty_Acid',
-                        p357: 'Essential_Fatty_Acid',
-                        nutrient: 'Nutrient',
-                        p358: 'Nutrient',
-                        micronutrient:  'Micronutrient',
-                        p359:  'Micronutrient',
-                        macronutrient:  'Macronutrient',
-                        p360:  'Macronutrient',
-                        extensible_list:  'Extensible_List',
-                        p361:  'Extensible_List',
-                        mirbase_id: 'miRBase_ID',
-                        p362: 'miRBase_ID',
-                        hgnc_id:  'HGNC_ID',
-                        p369:  'HGNC_ID',
-                        pid_id: 'PID_ID',
-                        p367: 'PID_ID',
-                        chebi_id: 'CHEBI_ID',
-                        p368: 'CHEBI_ID',
-                        pdq_open_trial_search_id: 'PDQ_Open_Trial_Search_ID',
-                        p329: 'PDQ_Open_Trial_Search_ID',
-                        pdq_closed_trial_search_id: 'PDQ_Closed_Trial_Search_ID',
-                        p330: 'PDQ_Closed_Trial_Search_ID',
-                        ncbi_taxon_id:  'NCBI_Taxon_ID',
-                        p331:  'NCBI_Taxon_ID',
-                        mgi_accession_id: 'MGI_Accession_ID',
-                        p332: 'MGI_Accession_ID',
-                        contributing_source:  'Contributing_Source',
-                        p322:  'Contributing_Source',
-                        pubmedid_primary_reference: 'PubMedID_Primary_Reference',
-                        p171: 'PubMedID_Primary_Reference',
-                        nsc_code: 'NSC_Code',
-                        p175: 'NSC_Code',
-                        entrezgene_id:  'EntrezGene_ID',
-                        p321:  'EntrezGene_ID',
-                        omim_number:  'OMIM_Number',
-                        p100:  'OMIM_Number',
-                        homologous_gene:  'Homologous_Gene',
-                        p101:  'Homologous_Gene',
-                        genbank_accession_number: 'GenBank_Accession_Number',
-                        p102: 'GenBank_Accession_Number',
-                        maps_to:  'Maps_To',
-                        p375:  'Maps_To',
-                        go_annotation:  'GO_Annotation',
-                        p211:  'GO_Annotation'
-                       }
-        propertyNotConsidered:
-                       {
-                       NHC4: 'Split_From',
-                       P167: 'Image_Link',
-                       P200: 'OLD_PARENT',
-                       P201: 'OLD_CHILD',
-                       P203: 'OLD_KIND',
-                       P204: 'OLD_ROLE',
-                       P205: 'OLD_STATE',
-                       P333: 'Use_For',
-                       P351: 'US_Recommended_Intake',
-                       P352: 'Tolerable_Level',
-                       P355: 'Unit',
-                       P364: 'OLD_ASSOCIATION',
-                       P365: 'OLD_SOURCE_ASSOCIATION',
-                       P377: 'def-definition',
-                       P378: 'Definition_Source',
-                       P379: 'Definition_Reviewer_Name',
-                       P380: 'Definition_Review_Date',
-                       P381: 'attribution',
-                       P382: 'term-name',
-                       P383: 'Term_Type',
-                       P384: 'Term_Source',
-                       P385: 'Source_Code',
-                       P386: 'Subsource_Name',
-                       P387: 'go-id',
-                       P388: 'go-term',
-                       P389: 'go-evi',
-                       P390: 'go-source',
-                       P391: 'source-date',
-                       P392: 'Target_Term',
-                       P393: 'Relationship_to_Target',
-                       P394: 'Target_Term_Type',
-                       P395: 'Target_Code',
-                       P396: 'Target_Terminology',
-                       P92: 'Subsource',
-                       P98: 'DesignNote'
-                       }
-        conceptStatuses: {concept_pending_approval: 'Concept_Pending_Approval',
-                          deprecated_concept: 'Deprecated_Concept',
-                          header_concept: 'Header_Concept',
-                          obsolete_concept: 'Obsolete_Concept',
-                          provisional_concept: 'Provisional_Concept',
-                          retired_concept: 'Retired_Concept'
-                          }
-        contributingSources: {
-                            acc: 'ACC',
-                            bridg: 'BRIDG',
-                            carelex: 'CareLex',
-                            cdisc: 'CDISC',
-                            cdisc-gloss: 'CDISC-GLOSS',
-                            crch: 'CRCH',
-                            ctcae: 'CTCAE',
-                            ctep: 'CTEP',
-                            ctrp: 'CTRP',
-                            edqm-hc: 'EDQM-HC',
-                            fda: 'FDA',
-                            gaia: 'GAIA',
-                            hl7: 'HL7',
-                            ich: 'ICH',
-                            inc: 'INC',
-                            meddra: 'MedDRA',
-                            nccn: 'NCCN',
-                            ncpdp: 'NCPDP',
-                            ndc: 'NDC',
-                            nichd: 'NICHD',
-                            pi-rads: 'PI-RADS',
-                            ucum: 'UCUM'
-                         }
-        sourcesToBeRemoved: ['cadsr', 'CADSR', 'CAdsr','caDSR'
-                        ]
-        associations:  {a1: 'Role_Has_Domain',
-                        a10: 'Has_CDRH_Parent',
-                        a11: 'Has_NICHD_Parent',
-                        a12: 'Has_Data_Element',
-                        a13: 'Related_To_Genetic_Biomarker',
-                        a14: 'Neoplasm_Has_Special_Category',
-                        a15: 'Has_CTCAE_5_Parent',
-                        a2: 'Role_Has_Range',
-                        a3: 'Role_Has_Parent',
-                        a4: 'Qualifier_Applies_To',
-                        a5: 'Has_Salt_Form',
-                        a6: 'Has_Free_Acid_Or_Base_Form',
-                        a7: 'Has_Target',
-                        a8: 'Concept_In_Subset',
-                        a9: 'Is_Related_To_Endogenous_Product',
-                        role_has_domain: 'Role_Has_Domain',
-                        has_cdrh_parent: 'Has_CDRH_Parent',
-                        has_nichd_parent: 'Has_NICHD_Parent',
-                        has_data_element: 'Has_Data_Element',
-                        related_to_genetic_biomarker: 'Related_To_Genetic_Biomarker',
-                        neoplasm_has_special_category: 'Neoplasm_Has_Special_Category',
-                        has_ctcae_5_parent: 'Has_CTCAE_5_Parent',
-                        role_has_range: 'Role_Has_Range',
-                        role_has_parent: 'Role_Has_Parent',
-                        qualifier_applies_To: 'Qualifier_Applies_To',
-                        has_salt_form: 'Has_Salt_Form',
-                        has_free_acid_or_base_form: 'Has_Free_Acid_Or_Base_Form',
-                        has_target: 'Has_Target',
-                        concept_in_subset: 'Concept_In_Subset',
-                        is_related_to_endogenous_product: 'Is_Related_To_Endogenous_Product'}
-        roles: {r156: 'Allele_Absent_From_Wild-type_Chromosomal_Location',
-                r153: 'Allele_Has_Abnormality',
-                r159: 'Allele_Has_Activity',
-                r155: 'Allele_In_Chromosomal_Location',
-                r158: 'Allele_Plays_Altered_Role_In_Process',
-                r160: 'Allele_Plays_Role_In_Metabolism_Of_Chemical_Or_Drug',
-                r81: 'Anatomic_Structure_Has_Location',
-                r82: 'Anatomic_Structure_Is_Physical_Part_Of',
-                r30: 'Biological_Process_Has_Associated_Location',
-                r32: 'Biological_Process_Has_Initiator_Chemical_Or_Drug',
-                r28: 'Biological_Process_Has_Initiator_Process',
-                r31: 'Biological_Process_Has_Result_Anatomy',
-                r34: 'Biological_Process_Has_Result_Biological_Process',
-                r29: 'Biological_Process_Has_Result_Chemical_Or_Drug',
-                r35: 'Biological_Process_Is_Part_Of_Process',
-                r150: 'Chemical_Or_Drug_Affects_Abnormal_Cell',
-                r72: 'Chemical_Or_Drug_Affects_Cell_Type_Or_Tissue',
-                r146: 'Chemical_Or_Drug_Affects_Gene_Product',
-                r124: 'Chemical_Or_Drug_Has_Mechanism_Of_Action',
-                r125: 'Chemical_Or_Drug_Has_Physiologic_Effect',
-                r122: 'Chemical_Or_Drug_Is_Metabolized_By_Enzyme',
-                r66: 'Chemical_Or_Drug_Plays_Role_In_Biological_Process',
-                r123: 'Chemotherapy_Regimen_Has_Component',
-                r27: 'Conceptual_Part_Of',
-                r173: 'Cytogenetic_Abnormality_Involves_Chromosome',
-                r139: 'Disease_Excludes_Abnormal_Cell',
-                r141: 'Disease_Excludes_Cytogenetic_Abnormality',
-                r142: 'Disease_Excludes_Finding',
-                r136: 'Disease_Excludes_Metastatic_Anatomic_Site',
-                r140: 'Disease_Excludes_Molecular_Abnormality',
-                r138: 'Disease_Excludes_Normal_Cell_Origin',
-                r137: 'Disease_Excludes_Normal_Tissue_Origin',
-                r135: 'Disease_Excludes_Primary_Anatomic_Site',
-                r105: 'Disease_Has_Abnormal_Cell',
-                r100: 'Disease_Has_Associated_Anatomic_Site',
-                r126: 'Disease_Has_Associated_Disease',
-                r107: 'Disease_Has_Cytogenetic_Abnormality',
-                r108: 'Disease_Has_Finding',
-                r102: 'Disease_Has_Metastatic_Anatomic_Site',
-                r106: 'Disease_Has_Molecular_Abnormality',
-                r104: 'Disease_Has_Normal_Cell_Origin',
-                r103: 'Disease_Has_Normal_Tissue_Origin',
-                r101: 'Disease_Has_Primary_Anatomic_Site',
-                r110: 'Disease_Is_Grade',
-                r88: 'Disease_Is_Stage',
-                r174: 'Disease_Mapped_To_Chromosome',
-                r176: 'Disease_Mapped_To_Gene',
-                r113: 'Disease_May_Have_Abnormal_Cell',
-                r116: 'Disease_May_Have_Associated_Disease',
-                r114: 'Disease_May_Have_Cytogenetic_Abnormality',
-                r115: 'Disease_May_Have_Finding',
-                r89: 'Disease_May_Have_Molecular_Abnormality',
-                r112: 'Disease_May_Have_Normal_Cell_Origin',
-                r111: 'Disease_May_Have_Normal_Tissue_Origin',
-                r23: 'EO_Disease_Has_Associated_Cell_Type',
-                r25: 'EO_Disease_Has_Associated_EO_Anatomy',
-                r26: 'EO_Disease_Has_Property_Or_Attribute',
-                r24: 'EO_Disease_Maps_To_Human_Disease',
-                r38: 'Gene_Associated_With_Disease',
-                r41: 'Gene_Found_In_Organism',
-                r132: 'Gene_Has_Abnormality',
-                r145: 'Gene_Has_Physical_Location',
-                r40: 'Gene_In_Chromosomal_Location',
-                r175: 'Gene_Involved_In_Pathogenesis_Of_Disease',
-                r39: 'Gene_Is_Biomarker_Of',
-                r36: 'Gene_Is_Biomarker_Type',
-                r130: 'Gene_Is_Element_In_Pathway',
-                r178: 'Gene_Mutant_Encodes_Gene_Product_Sequence_Variation',
-                r37: 'Gene_Plays_Role_In_Process',
-                r54: 'Gene_Product_Encoded_By_Gene',
-                r49: 'Gene_Product_Expressed_In_Tissue',
-                r133: 'Gene_Product_Has_Abnormality',
-                r46: 'Gene_Product_Has_Associated_Anatomy',
-                r52: 'Gene_Product_Has_Biochemical_Function',
-                r44: 'Gene_Product_Has_Chemical_Classification',
-                r45: 'Gene_Product_Has_Organism_Source',
-                r50: 'Gene_Product_Has_Structural_Domain_Or_Motif',
-                r47: 'Gene_Product_Is_Biomarker_Of',
-                r42: 'Gene_Product_Is_Biomarker_Type',
-                r131: 'Gene_Product_Is_Element_In_Pathway',
-                r51: 'Gene_Product_Is_Physical_Part_Of',
-                r48: 'Gene_Product_Malfunction_Associated_With_Disease',
-                r53: 'Gene_Product_Plays_Role_In_Biological_Process',
-                r179: 'Gene_Product_Sequence_Variation_Encoded_By_Gene_Mutant',
-                r182: 'Gene_Product_Variant_Of_Gene_Product',
-                r177: 'Molecular_Abnormality_Involves_Gene',
-                r171: 'Procedure_Has_Completely_Excised_Anatomy',
-                r167: 'Procedure_Has_Excised_Anatomy',
-                r165: 'Procedure_Has_Imaged_Anatomy',
-                r169: 'Procedure_Has_Partially_Excised_Anatomy',
-                r163: 'Procedure_Has_Target_Anatomy',
-                r180: 'Procedure_Has_Target_Disease',
-                r170: 'Procedure_May_Have_Completely_Excised_Anatomy',
-                r166: 'Procedure_May_Have_Excised_Anatomy',
-                r168: 'Procedure_May_Have_Partially_Excised_Anatomy',
-                r181: 'Procedure_Uses_Manufactured_Object',
-                r172: 'Regimen_Has_Accepted_Use_For_Disease',
-                allele_absent_from_wild-type_chromosomal_location: 'Allele_Absent_From_Wild-type_Chromosomal_Location',
-                allele_has_abnormality: 'Allele_Has_Abnormality',
-                allele_has_activity: 'Allele_Has_Activity',
-                allele_in_chromosomal_location: 'Allele_In_Chromosomal_Location',
-                allele_plays_altered_role_in_process: 'Allele_Plays_Altered_Role_In_Process',
-                allele_plays_role_in_metabolism_of_chemical_or_drug: 'Allele_Plays_Role_In_Metabolism_Of_Chemical_Or_Drug',
-                anatomic_structure_has_location: 'Anatomic_Structure_Has_Location',
-                anatomic_structure_is_physical_part_of: 'Anatomic_Structure_Is_Physical_Part_Of',
-                biological_process_has_associated_location: 'Biological_Process_Has_Associated_Location',
-                biological_process_has_initiator_chemical_or_drug: 'Biological_Process_Has_Initiator_Chemical_Or_Drug',
-                biological_process_has_initiator_process: 'Biological_Process_Has_Initiator_Process',
-                biological_process_has_result_anatomy: 'Biological_Process_Has_Result_Anatomy',
-                biological_process_has_result_biological_process: 'Biological_Process_Has_Result_Biological_Process',
-                biological_process_has_result_chemical_or_drug: 'Biological_Process_Has_Result_Chemical_Or_Drug',
-                biological_process_is_part_of_process: 'Biological_Process_Is_Part_Of_Process',
-                chemical_or_drug_affects_abnormal_cell: 'Chemical_Or_Drug_Affects_Abnormal_Cell',
-                chemical_or_drug_affects_cell_type_or_tissue: 'Chemical_Or_Drug_Affects_Cell_Type_Or_Tissue',
-                chemical_or_drug_affects_gene_product: 'Chemical_Or_Drug_Affects_Gene_Product',
-                chemical_or_drug_has_mechanism_of_action: 'Chemical_Or_Drug_Has_Mechanism_Of_Action',
-                chemical_or_drug_has_physiologic_effect: 'Chemical_Or_Drug_Has_Physiologic_Effect',
-                chemical_or_drug_is_metabolized_by_enzyme: 'Chemical_Or_Drug_Is_Metabolized_By_Enzyme',
-                chemical_or_drug_plays_role_in_biological_process: 'Chemical_Or_Drug_Plays_Role_In_Biological_Process',
-                chemotherapy_regimen_has_component: 'Chemotherapy_Regimen_Has_Component',
-                conceptual_part_of: 'Conceptual_Part_Of',
-                cytogenetic_abnormality_involves_chromosome: 'Cytogenetic_Abnormality_Involves_Chromosome',
-                disease_excludes_abnormal_cell: 'Disease_Excludes_Abnormal_Cell',
-                disease_excludes_cytogenetic_abnormality: 'Disease_Excludes_Cytogenetic_Abnormality',
-                disease_excludes_finding: 'Disease_Excludes_Finding',
-                disease_excludes_metastatic_anatomic_site: 'Disease_Excludes_Metastatic_Anatomic_Site',
-                disease_excludes_molecular_abnormality: 'Disease_Excludes_Molecular_Abnormality',
-                disease_excludes_normal_cell_origin: 'Disease_Excludes_Normal_Cell_Origin',
-                disease_excludes_normal_tissue_origin: 'Disease_Excludes_Normal_Tissue_Origin',
-                disease_excludes_primary_anatomic_site: 'Disease_Excludes_Primary_Anatomic_Site',
-                disease_has_abnormal_cell: 'Disease_Has_Abnormal_Cell',
-                disease_has_associated_anatomic_site: 'Disease_Has_Associated_Anatomic_Site',
-                disease_has_associated_disease: 'Disease_Has_Associated_Disease',
-                disease_has_cytogenetic_abnormality: 'Disease_Has_Cytogenetic_Abnormality',
-                disease_has_finding: 'Disease_Has_Finding',
-                disease_has_metastatic_anatomic_site: 'Disease_Has_Metastatic_Anatomic_Site',
-                disease_has_molecular_abnormality: 'Disease_Has_Molecular_Abnormality',
-                disease_has_normal_cell_origin: 'Disease_Has_Normal_Cell_Origin',
-                disease_has_normal_tissue_origin: 'Disease_Has_Normal_Tissue_Origin',
-                disease_has_primary_anatomic_site: 'Disease_Has_Primary_Anatomic_Site',
-                disease_is_grade: 'Disease_Is_Grade',
-                disease_is_stage: 'Disease_Is_Stage',
-                disease_mapped_to_chromosome: 'Disease_Mapped_To_Chromosome',
-                disease_mapped_to_gene: 'Disease_Mapped_To_Gene',
-                disease_may_have_abnormal_cell: 'Disease_May_Have_Abnormal_Cell',
-                disease_may_have_associated_disease: 'Disease_May_Have_Associated_Disease',
-                disease_may_have_cytogenetic_abnormality: 'Disease_May_Have_Cytogenetic_Abnormality',
-                disease_may_have_finding: 'Disease_May_Have_Finding',
-                disease_may_have_molecular_abnormality: 'Disease_May_Have_Molecular_Abnormality',
-                disease_may_have_normal_cell_origin: 'Disease_May_Have_Normal_Cell_Origin',
-                disease_may_have_normal_tissue_origin: 'Disease_May_Have_Normal_Tissue_Origin',
-                eo_disease_has_associated_cell_type: 'EO_Disease_Has_Associated_Cell_Type',
-                eo_disease_has_associated_eo_anatomy: 'EO_Disease_Has_Associated_EO_Anatomy',
-                eo_disease_has_property_or_attribute: 'EO_Disease_Has_Property_Or_Attribute',
-                eo_disease_maps_to_human_disease: 'EO_Disease_Maps_To_Human_Disease',
-                gene_associated_with_disease: 'Gene_Associated_With_Disease',
-                gene_found_in_organism: 'Gene_Found_In_Organism',
-                gene_has_abnormality: 'Gene_Has_Abnormality',
-                gene_has_physical_location: 'Gene_Has_Physical_Location',
-                gene_in_chromosomal_location: 'Gene_In_Chromosomal_Location',
-                gene_involved_in_pathogenesis_of_disease: 'Gene_Involved_In_Pathogenesis_Of_Disease',
-                gene_is_biomarker_of: 'Gene_Is_Biomarker_Of',
-                gene_is_biomarker_type: 'Gene_Is_Biomarker_Type',
-                gene_is_element_in_pathway: 'Gene_Is_Element_In_Pathway',
-                gene_mutant_encodes_gene_product_sequence_variation: 'Gene_Mutant_Encodes_Gene_Product_Sequence_Variation',
-                gene_plays_role_in_process: 'Gene_Plays_Role_In_Process',
-                gene_product_encoded_by_gene: 'Gene_Product_Encoded_By_Gene',
-                gene_product_expressed_in_tissue: 'Gene_Product_Expressed_In_Tissue',
-                gene_product_has_abnormality: 'Gene_Product_Has_Abnormality',
-                gene_product_has_associated_anatomy: 'Gene_Product_Has_Associated_Anatomy',
-                gene_product_has_biochemical_function: 'Gene_Product_Has_Biochemical_Function',
-                gene_product_has_chemical_classification: 'Gene_Product_Has_Chemical_Classification',
-                gene_product_has_organism_source: 'Gene_Product_Has_Organism_Source',
-                gene_product_has_structural_domain_or_motif: 'Gene_Product_Has_Structural_Domain_Or_Motif',
-                gene_product_is_biomarker_of: 'Gene_Product_Is_Biomarker_Of',
-                gene_product_is_biomarker_type: 'Gene_Product_Is_Biomarker_Type',
-                gene_product_is_element_in_pathway: 'Gene_Product_Is_Element_In_Pathway',
-                gene_product_is_physical_part_of: 'Gene_Product_Is_Physical_Part_Of',
-                gene_product_malfunction_associated_with_disease: 'Gene_Product_Malfunction_Associated_With_Disease',
-                gene_product_plays_role_in_biological_process: 'Gene_Product_Plays_Role_In_Biological_Process',
-                gene_product_sequence_variation_encoded_by_gene_mutant: 'Gene_Product_Sequence_Variation_Encoded_By_Gene_Mutant',
-                gene_product_variant_of_gene_product: 'Gene_Product_Variant_Of_Gene_Product',
-                molecular_abnormality_involves_gene: 'Molecular_Abnormality_Involves_Gene',
-                procedure_has_completely_excised_anatomy: 'Procedure_Has_Completely_Excised_Anatomy',
-                procedure_has_excised_anatomy: 'Procedure_Has_Excised_Anatomy',
-                procedure_has_imaged_anatomy: 'Procedure_Has_Imaged_Anatomy',
-                procedure_has_partially_excised_anatomy: 'Procedure_Has_Partially_Excised_Anatomy',
-                procedure_has_target_anatomy: 'Procedure_Has_Target_Anatomy',
-                procedure_has_target_disease: 'Procedure_Has_Target_Disease',
-                procedure_may_have_completely_excised_anatomy: 'Procedure_May_Have_Completely_Excised_Anatomy',
-                procedure_may_have_excised_anatomy: 'Procedure_May_Have_Excised_Anatomy',
-                procedure_may_have_partially_excised_anatomy: 'Procedure_May_Have_Partially_Excised_Anatomy',
-                procedure_uses_manufactured_object: 'Procedure_Uses_Manufactured_Object',
-                regimen_has_accepted_use_for_disease: 'Regimen_Has_Accepted_Use_For_Disease'}
diff --git a/software/evsrestapi-util/lib/commons-codec-1.10.jar b/software/evsrestapi-util/lib/commons-codec-1.10.jar
deleted file mode 100644
index d3b0e264a..000000000
Binary files a/software/evsrestapi-util/lib/commons-codec-1.10.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/commons-collections4-4.4.jar b/software/evsrestapi-util/lib/commons-collections4-4.4.jar
deleted file mode 100644
index 86216c47a..000000000
Binary files a/software/evsrestapi-util/lib/commons-collections4-4.4.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/commons-compress-1.20.jar b/software/evsrestapi-util/lib/commons-compress-1.20.jar
deleted file mode 100644
index 43020dd55..000000000
Binary files a/software/evsrestapi-util/lib/commons-compress-1.20.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/commons-io-1.4.jar b/software/evsrestapi-util/lib/commons-io-1.4.jar
deleted file mode 100644
index ad18b06a3..000000000
Binary files a/software/evsrestapi-util/lib/commons-io-1.4.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/commons-lang-2.4.jar b/software/evsrestapi-util/lib/commons-lang-2.4.jar
deleted file mode 100644
index 68bccc18f..000000000
Binary files a/software/evsrestapi-util/lib/commons-lang-2.4.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/commons-lang3-3.12.0.jar b/software/evsrestapi-util/lib/commons-lang3-3.12.0.jar
deleted file mode 100644
index 6d00ee544..000000000
Binary files a/software/evsrestapi-util/lib/commons-lang3-3.12.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/commons-logging-1.2.jar b/software/evsrestapi-util/lib/commons-logging-1.2.jar
deleted file mode 100644
index 97ee4ad79..000000000
Binary files a/software/evsrestapi-util/lib/commons-logging-1.2.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/commons-math3-3.6.1.jar b/software/evsrestapi-util/lib/commons-math3-3.6.1.jar
deleted file mode 100644
index 59c5e82a8..000000000
Binary files a/software/evsrestapi-util/lib/commons-math3-3.6.1.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/commons-text-1.10.0.jar b/software/evsrestapi-util/lib/commons-text-1.10.0.jar
deleted file mode 100644
index eba22529f..000000000
Binary files a/software/evsrestapi-util/lib/commons-text-1.10.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/dom4j-1.6.1.jar b/software/evsrestapi-util/lib/dom4j-1.6.1.jar
deleted file mode 100644
index 1890e9e52..000000000
Binary files a/software/evsrestapi-util/lib/dom4j-1.6.1.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/formatter.jar b/software/evsrestapi-util/lib/formatter.jar
deleted file mode 100644
index c090f5865..000000000
Binary files a/software/evsrestapi-util/lib/formatter.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/graphviz-java-api-1.0-SNAPSHOT.jar b/software/evsrestapi-util/lib/graphviz-java-api-1.0-SNAPSHOT.jar
deleted file mode 100644
index 11850c829..000000000
Binary files a/software/evsrestapi-util/lib/graphviz-java-api-1.0-SNAPSHOT.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/gson-2.6.2.jar b/software/evsrestapi-util/lib/gson-2.6.2.jar
deleted file mode 100644
index 9d78626d8..000000000
Binary files a/software/evsrestapi-util/lib/gson-2.6.2.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/httpclient-4.5.12.jar b/software/evsrestapi-util/lib/httpclient-4.5.12.jar
deleted file mode 100644
index 92502e232..000000000
Binary files a/software/evsrestapi-util/lib/httpclient-4.5.12.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/httpcore-4.4.13.jar b/software/evsrestapi-util/lib/httpcore-4.4.13.jar
deleted file mode 100644
index 8047b941b..000000000
Binary files a/software/evsrestapi-util/lib/httpcore-4.4.13.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/jackson-core-2.2.2.jar b/software/evsrestapi-util/lib/jackson-core-2.2.2.jar
deleted file mode 100644
index 0893601e0..000000000
Binary files a/software/evsrestapi-util/lib/jackson-core-2.2.2.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/jaxb-api-2.2.jar b/software/evsrestapi-util/lib/jaxb-api-2.2.jar
deleted file mode 100644
index 68a82508c..000000000
Binary files a/software/evsrestapi-util/lib/jaxb-api-2.2.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/jdom-1.0.jar b/software/evsrestapi-util/lib/jdom-1.0.jar
deleted file mode 100644
index 22acadda2..000000000
Binary files a/software/evsrestapi-util/lib/jdom-1.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/jsf-api.jar b/software/evsrestapi-util/lib/jsf-api.jar
deleted file mode 100644
index 8c7fd61e4..000000000
Binary files a/software/evsrestapi-util/lib/jsf-api.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/jsf-impl.jar b/software/evsrestapi-util/lib/jsf-impl.jar
deleted file mode 100644
index eca967518..000000000
Binary files a/software/evsrestapi-util/lib/jsf-impl.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/json-20080701.jar b/software/evsrestapi-util/lib/json-20080701.jar
deleted file mode 100644
index c9a093edb..000000000
Binary files a/software/evsrestapi-util/lib/json-20080701.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/json-xml-4.2-SNAPSHOT.jar b/software/evsrestapi-util/lib/json-xml-4.2-SNAPSHOT.jar
deleted file mode 100644
index 4f05dfda7..000000000
Binary files a/software/evsrestapi-util/lib/json-xml-4.2-SNAPSHOT.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/json_simple-1.1.jar b/software/evsrestapi-util/lib/json_simple-1.1.jar
deleted file mode 100644
index 38ea99eee..000000000
Binary files a/software/evsrestapi-util/lib/json_simple-1.1.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/junit-4.8.2.jar b/software/evsrestapi-util/lib/junit-4.8.2.jar
deleted file mode 100644
index 459b2b885..000000000
Binary files a/software/evsrestapi-util/lib/junit-4.8.2.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/log4j-api-2.17.0.jar b/software/evsrestapi-util/lib/log4j-api-2.17.0.jar
deleted file mode 100644
index cdfbe3077..000000000
Binary files a/software/evsrestapi-util/lib/log4j-api-2.17.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/log4j-core-2.17.0.jar b/software/evsrestapi-util/lib/log4j-core-2.17.0.jar
deleted file mode 100644
index 4a3d3cb16..000000000
Binary files a/software/evsrestapi-util/lib/log4j-core-2.17.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/lvg2020dist.jar b/software/evsrestapi-util/lib/lvg2020dist.jar
deleted file mode 100644
index c62b31e3b..000000000
Binary files a/software/evsrestapi-util/lib/lvg2020dist.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/mockito-all-1.8.5.jar b/software/evsrestapi-util/lib/mockito-all-1.8.5.jar
deleted file mode 100644
index 7dd4cc87c..000000000
Binary files a/software/evsrestapi-util/lib/mockito-all-1.8.5.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/opencsv-3.8.jar b/software/evsrestapi-util/lib/opencsv-3.8.jar
deleted file mode 100644
index 6ad352184..000000000
Binary files a/software/evsrestapi-util/lib/opencsv-3.8.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/opennlp-tools-1.9.2.jar b/software/evsrestapi-util/lib/opennlp-tools-1.9.2.jar
deleted file mode 100644
index e63d23729..000000000
Binary files a/software/evsrestapi-util/lib/opennlp-tools-1.9.2.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/poi-5.0.0.jar b/software/evsrestapi-util/lib/poi-5.0.0.jar
deleted file mode 100644
index 8a804a7ba..000000000
Binary files a/software/evsrestapi-util/lib/poi-5.0.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/poi-ooxml-5.0.0.jar b/software/evsrestapi-util/lib/poi-ooxml-5.0.0.jar
deleted file mode 100644
index a61b752fb..000000000
Binary files a/software/evsrestapi-util/lib/poi-ooxml-5.0.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/poi-ooxml-lite-5.0.0.jar b/software/evsrestapi-util/lib/poi-ooxml-lite-5.0.0.jar
deleted file mode 100644
index 81d4b9e36..000000000
Binary files a/software/evsrestapi-util/lib/poi-ooxml-lite-5.0.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/poi-ooxml-schemas-3.17.jar b/software/evsrestapi-util/lib/poi-ooxml-schemas-3.17.jar
deleted file mode 100644
index 3d35e3749..000000000
Binary files a/software/evsrestapi-util/lib/poi-ooxml-schemas-3.17.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/porter-stemmer.jar b/software/evsrestapi-util/lib/porter-stemmer.jar
deleted file mode 100644
index 54bee8afe..000000000
Binary files a/software/evsrestapi-util/lib/porter-stemmer.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/servlet-api.jar b/software/evsrestapi-util/lib/servlet-api.jar
deleted file mode 100644
index 72e670e57..000000000
Binary files a/software/evsrestapi-util/lib/servlet-api.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/slf4j-api-1.5.6.jar b/software/evsrestapi-util/lib/slf4j-api-1.5.6.jar
deleted file mode 100644
index d79425233..000000000
Binary files a/software/evsrestapi-util/lib/slf4j-api-1.5.6.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/slf4j-log4j12-1.5.6.jar b/software/evsrestapi-util/lib/slf4j-log4j12-1.5.6.jar
deleted file mode 100644
index 97241bb14..000000000
Binary files a/software/evsrestapi-util/lib/slf4j-log4j12-1.5.6.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/spring-beans-5.1.2.RELEASE.jar b/software/evsrestapi-util/lib/spring-beans-5.1.2.RELEASE.jar
deleted file mode 100644
index 2809de536..000000000
Binary files a/software/evsrestapi-util/lib/spring-beans-5.1.2.RELEASE.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/spring-boot-2.1.0.RELEASE.jar b/software/evsrestapi-util/lib/spring-boot-2.1.0.RELEASE.jar
deleted file mode 100644
index b320204b0..000000000
Binary files a/software/evsrestapi-util/lib/spring-boot-2.1.0.RELEASE.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/spring-core-5.1.2.RELEASE.jar b/software/evsrestapi-util/lib/spring-core-5.1.2.RELEASE.jar
deleted file mode 100644
index d44297963..000000000
Binary files a/software/evsrestapi-util/lib/spring-core-5.1.2.RELEASE.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/spring-web-5.1.2.RELEASE.jar b/software/evsrestapi-util/lib/spring-web-5.1.2.RELEASE.jar
deleted file mode 100644
index 10bb22b45..000000000
Binary files a/software/evsrestapi-util/lib/spring-web-5.1.2.RELEASE.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/xmlbeans-4.0.0.jar b/software/evsrestapi-util/lib/xmlbeans-4.0.0.jar
deleted file mode 100644
index e56f62ce1..000000000
Binary files a/software/evsrestapi-util/lib/xmlbeans-4.0.0.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/xmlunit-1.3.jar b/software/evsrestapi-util/lib/xmlunit-1.3.jar
deleted file mode 100644
index 3c8417617..000000000
Binary files a/software/evsrestapi-util/lib/xmlunit-1.3.jar and /dev/null differ
diff --git a/software/evsrestapi-util/lib/xstream-1.2.2.jar b/software/evsrestapi-util/lib/xstream-1.2.2.jar
deleted file mode 100644
index 2d813c229..000000000
Binary files a/software/evsrestapi-util/lib/xstream-1.2.2.jar and /dev/null differ
diff --git a/software/evsrestapi-util/runEVSStat.bat b/software/evsrestapi-util/runEVSStat.bat
deleted file mode 100644
index a34199beb..000000000
--- a/software/evsrestapi-util/runEVSStat.bat
+++ /dev/null
@@ -1,10 +0,0 @@
-set OCP=%CLASSPATH%
-set lib1=.
-set lib2=lib
-set CLASSPATH=.
-set CLASSPATH=%CLASSPATH%;%lib1%\*
-set CLASSPATH=%CLASSPATH%;%lib2%\*
-
-java -d64 -Xms512m -Xmx4g -classpath %CLASSPATH% gov.nih.nci.evs.restapi.appl.EVSStatistics     
-
-set CLASSPATH=%OCP%
\ No newline at end of file
diff --git a/software/evsrestapi-util/runNCItWikiStat.bat b/software/evsrestapi-util/runNCItWikiStat.bat
deleted file mode 100644
index 31af59bea..000000000
--- a/software/evsrestapi-util/runNCItWikiStat.bat
+++ /dev/null
@@ -1,10 +0,0 @@
-set OCP=%CLASSPATH%
-set lib1=.
-set lib2=lib
-set CLASSPATH=.
-set CLASSPATH=%CLASSPATH%;%lib1%\*
-set CLASSPATH=%CLASSPATH%;%lib2%\*
-
-java -d64 -Xms512m -Xmx4g -classpath %CLASSPATH% gov.nih.nci.evs.restapi.appl.WiKiHomeStatistics ThesaurusInferred_forTS.owl
-
-set CLASSPATH=%OCP%
\ No newline at end of file
diff --git a/software/evsrestapi-util/runUNIIQA.bat b/software/evsrestapi-util/runUNIIQA.bat
deleted file mode 100644
index a4b1171f8..000000000
--- a/software/evsrestapi-util/runUNIIQA.bat
+++ /dev/null
@@ -1,10 +0,0 @@
-set OCP=%CLASSPATH%
-set lib1=.
-set lib2=lib
-set CLASSPATH=.
-set CLASSPATH=%CLASSPATH%;%lib1%\*
-set CLASSPATH=%CLASSPATH%;%lib2%\*
-
-java -d64 -Xms512m -Xmx4g -classpath %CLASSPATH% gov.nih.nci.evs.restapi.appl.UNIIProcessor https://sparql-evs.nci.nih.gov/sparql http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl UNII_Names_27Mar2020.txt UNII_Records_27Mar2020.txt  
-
-set CLASSPATH=%OCP%
\ No newline at end of file
diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/AsciiApiUtils.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/AsciiApiUtils.java
deleted file mode 100644
index 8f0b606f5..000000000
--- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/AsciiApiUtils.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package gov.nih.nci.evs.restapi.appl;
-
-import gov.nih.nci.evs.restapi.util.*;
-
-import java.io.*;
-import java.util.*;
-import java.nio.charset.StandardCharsets;
-
-import gov.nih.nlm.nls.lvg.Api.*;
-import gov.nih.nlm.nls.lvg.Lib.*;
-
-// This class uses ToAsciiApi to convert an input term to ASCII
-public class AsciiApiUtils
-{
-	private ToAsciiApi api = null;
-
-	public AsciiApiUtils() {
-		Hashtable properties = new Hashtable();
-		String currentDirectory = System.getProperty("user.dir");
-		properties.put("LVG_DIR", currentDirectory + "/");
-		api = new ToAsciiApi(properties);
-	}
-
-	public AsciiApiUtils(String currentDirectory) {
-		Hashtable properties = new Hashtable();
-		if (currentDirectory == null) {
-			currentDirectory = System.getProperty("user.dir");
-		}
-		properties.put("LVG_DIR", currentDirectory + "/");
-		api = new ToAsciiApi(properties);
-	}
-
-
-	public Vector readFromFile(String filename) {
-		Vector v = new Vector();
-		try {
-			BufferedReader in = new BufferedReader(
-			   new InputStreamReader(
-				  new FileInputStream(filename)));
-			String str;
-			while ((str = in.readLine()) != null) {
-				v.add(str);
-			}
-            in.close();
-		} catch (Exception ex) {
-            ex.printStackTrace();
-		}
-		return v;
-	}
-
-	public void writeToFile(String outputfile, String content) {
-		try {
-			File file = new File(outputfile);
-			if (!file.exists()) {
-				file.createNewFile();
-			}
-			FileWriter fw = new FileWriter(file.getAbsoluteFile());
-			BufferedWriter bw = new BufferedWriter(fw);
-			bw.write(content);
-			bw.close();
-
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-
-	public String toAscii(String inTerm) {
-		// mutate the inTerm
-		String outTerm = api.Mutate(inTerm);
-		return outTerm;
-	}
-
-	public String getFootNote() {
-		return "";
-	}
-
-    //scan non-ascii characters in a file
-	public void scan(String inputfile, String outputfile) {
-		try {
-			File file = new File(outputfile);
-			if (!file.exists()) {
-				file.createNewFile();
-			}
-			FileWriter fw = new FileWriter(file.getAbsoluteFile());
-			BufferedWriter bw = new BufferedWriter(fw);
-
-			Vector lines = readFromFile(inputfile);
-			for (int i=0; i");
-			System.exit(1);
-		}
-		AsciiApiUtils utils = new AsciiApiUtils();
-		String inputfile = args[0];
-		//Vector v = readFile(inputfile);
-		int n = inputfile.lastIndexOf(".");
-		String outputfile = inputfile.substring(0, n) + "_" + StringUtils.getToday() + inputfile.substring(n, inputfile.length());
-		String warning_file = "warning_" + outputfile;
-        new AsciiApiUtils().scan(inputfile, warning_file);
-		new AsciiApiUtils().run(inputfile, outputfile);
-	}
-}
diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/CASProcessor.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/CASProcessor.java
deleted file mode 100644
index ac41f36fd..000000000
--- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/CASProcessor.java
+++ /dev/null
@@ -1,417 +0,0 @@
-package gov.nih.nci.evs.restapi.appl;
-
-import gov.nih.nci.evs.restapi.util.*;
-import gov.nih.nci.evs.restapi.bean.*;
-import gov.nih.nci.evs.restapi.common.*;
-
-import java.io.*;
-//import java.math.*;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.*;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-import java.util.*;
-import java.util.regex.*;
-import org.apache.commons.codec.binary.Base64;
-import org.json.*;
-
-/**
- * 
- * Copyright 2020 MSC. This software was developed in conjunction
- * with the National Cancer Institute, and so to the extent government
- * employees are co-authors, any rights in such works shall be subject
- * to Title 17 of the United States Code, section 105.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the disclaimer of Article 3,
- *      below. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials provided
- *      with the distribution.
- *   2. The end-user documentation included with the redistribution,
- *      if any, must include the following acknowledgment:
- *      "This product includes software developed by MSC and the National
- *      Cancer Institute."   If no such end-user documentation is to be
- *      included, this acknowledgment shall appear in the software itself,
- *      wherever such third-party acknowledgments normally appear.
- *   3. The names "The National Cancer Institute", "NCI" and "MSC" must
- *      not be used to endorse or promote products derived from this software.
- *   4. This license does not authorize the incorporation of this software
- *      into any third party proprietary programs. This license does not
- *      authorize the recipient to use any trademarks owned by either NCI
- *      or MSC
- *   5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED
- *      WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- *      OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE
- *      DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE,
- *      MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT,
- *      INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *      BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *      LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *      CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *      LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *      ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *      POSSIBILITY OF SUCH DAMAGE.
- * 
- */
-
-/**
- * @author EVS Team
- * @version 1.0
- *
- * Modification history:
- *     Initial implementation kim.ong@nih.gov
- *
- */
-
-
-public class CASProcessor {
-    String named_graph = null;
-    String serviceUrl = null;
-
-    private OWLSPARQLUtils owlSPARQLUtils = null;
-    private Vector unii_link = null;
-	private Vector unii_data = null;
-	private String username = null;
-	private String password = null;
-	private String namedGraph = null;
-	private static String ncit_unii_txt_file = "ncit_unii.txt";
-    private HashMap code2LabelMap = null;
-    private HashMap code2CasRegistryMap = null;
-    private HashMap code2UNIIMap = null;
-    private String unii_file = "FDA_UNII_Code.txt";
-    private String case_registry_file = "CAS_Registry.txt";
-    private HashMap ncit_code2CasRegistryMap = null;
-    private HashMap ncit_code2UNIIMap = null;
-
-	public CASProcessor() {
-
-	}
-
-
-	public CASProcessor(String serviceUrl, String namedGraph) {
-		this.serviceUrl = serviceUrl;
-		this.namedGraph = namedGraph;
-		System.out.println("serviceUrl: " + this.serviceUrl);
-		System.out.println("namedGraph: " + this.namedGraph);
-		owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, null, null);
-		owlSPARQLUtils.set_named_graph(this.namedGraph);
-		new MetadataUtils(serviceUrl).dumpNameVersion2NamedGraphMap();
-
-    }
-
-    private void initialize() {
-		code2LabelMap = new HashMap();
-        code2CasRegistryMap = new HashMap();
-        code2UNIIMap = new HashMap();
-        // single valued
-        Vector v = null;
-        if (!new File(unii_file).exists()) {
-			System.out.println(unii_file + " does not exist.");
-			Vector w = owlSPARQLUtils.findConceptsWithProperty(this.namedGraph, "FDA_UNII_Code");
-			Utils.saveToFile(unii_file, w);
-		}
-		v = Utils.readFile(unii_file);
-        System.out.println("Number of records in " + unii_file + ": " + v.size());
-
-        code2LabelMap = gov.nih.nci.evs.restapi.util.StringUtils.constructHashMap(v, 1, 0, '|');
-        ncit_code2UNIIMap = gov.nih.nci.evs.restapi.util.StringUtils.constructHashMap(v, 1, 3, '|');
-
-        // multiple valued
-
-        if (!new File(case_registry_file).exists()) {
-			System.out.println(case_registry_file + " does not exist.");
-			Vector w = owlSPARQLUtils.findConceptsWithProperty(this.namedGraph, "CAS_Registry");
-			Utils.saveToFile(case_registry_file, w);
-		}
-        v = Utils.readFile(case_registry_file);
-        HashMap hmap = gov.nih.nci.evs.restapi.util.StringUtils.constructHashMap(v, 1, 0, '|');
-        Iterator it = hmap.keySet().iterator();
-        while (it.hasNext()) {
-			String key = (String) it.next();
-			if (!code2LabelMap.containsKey(key)) {
-				String value = (String) hmap.get(key);
-				code2LabelMap.put(key, value);
-			}
-		}
-
-
-		//String test_label = (String) code2LabelMap.get(test_code);
-		//System.out.println("**********" + test_code + " -> " + test_label);
-
-
-		//Utils.dumpHashMap("code2LabelMap", code2LabelMap);
-
-        System.out.println("Number of records in " + case_registry_file + ": " + v.size());
-        ncit_code2CasRegistryMap = gov.nih.nci.evs.restapi.util.StringUtils.constructMultiValuedHashMap(v, 1, 3, '|');
-
-		System.out.println(unii_file + ": " + ncit_code2UNIIMap.keySet().size());
-		System.out.println(case_registry_file + ": " + ncit_code2CasRegistryMap.keySet().size());
-
-
-	}
-
-
-
-    public void run() {
-		String property_name = "CAS_Registry";
-		String property_value = null;
-		Vector v = owlSPARQLUtils.findConceptsWithPropertyMatching(this.namedGraph, property_name, property_value);
-		v = new SortUtils().quickSort(v);
-		Utils.saveToFile(property_name + ".txt", v);
-
-		property_name = "FDA_UNII_Code";
-		property_value = null;
-		v = owlSPARQLUtils.findConceptsWithPropertyMatching(this.namedGraph, property_name, property_value);
-		v = new SortUtils().quickSort(v);
-		Utils.saveToFile(property_name + ".txt", v);
-	}
-
-
-/*
-        (1) NCIt Subset Code
-        (2) NCIt Subset Name
-        (3) NCIt Code
-        (4) NCIt PT
-        (5) NCIt Synonyms
-        (6) Definition
-        (7) CAS Registry
-        (8) FDA UNII Code
-*/
-
-
-	public static int countDelimiters(String line, char delim) {
-		int knt = 0;
-		for (int i=0; i 0 && w == null) {
-				if (values != null && values.length() > 0) {
-					for (int k=0; k
- * Copyright 2020 MSC. This software was developed in conjunction
- * with the National Cancer Institute, and so to the extent government
- * employees are co-authors, any rights in such works shall be subject
- * to Title 17 of the United States Code, section 105.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the disclaimer of Article 3,
- *      below. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials provided
- *      with the distribution.
- *   2. The end-user documentation included with the redistribution,
- *      if any, must include the following acknowledgment:
- *      "This product includes software developed by MSC and the National
- *      Cancer Institute."   If no such end-user documentation is to be
- *      included, this acknowledgment shall appear in the software itself,
- *      wherever such third-party acknowledgments normally appear.
- *   3. The names "The National Cancer Institute", "NCI" and "MSC" must
- *      not be used to endorse or promote products derived from this software.
- *   4. This license does not authorize the incorporation of this software
- *      into any third party proprietary programs. This license does not
- *      authorize the recipient to use any trademarks owned by either NCI
- *      or MSC
- *   5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED
- *      WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- *      OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE
- *      DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE,
- *      MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT,
- *      INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *      BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *      LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *      CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *      LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *      ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *      POSSIBILITY OF SUCH DAMAGE.
- * 
- */
-
-/**
- * @author EVS Team
- * @version 1.0
- *
- * Modification history:
- *     Initial implementation kim.ong@nih.gov
- *
- */
-
-
-public class CTRPProcessor {
-	static String CTRP_TERMINOLOGY_CODE = "C116977";
-	static String CTRP_TERMINOLOGY_LABEL = "CTRP terminology";
-
-    JSONUtils jsonUtils = null;
-    HTTPUtils httpUtils = null;
-    String named_graph = null;
-    String prefixes = null;
-    String sparql_endpoint = null;
-    String serviceUrl = null;
-    String named_graph_id = ":NHC0";
-    String base_uri = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl";
-
-    OWLSPARQLUtils owlSPARQLUtils = null;
-
-	private static String NCI_THESAURUS = "NCI_Thesaurus";
-	private String namedGraph = null;
-
-	public Vector concepts_in_subset = null;
-
-	private TermSearchUtils termSearchUtils = null;
-	private HashSet ncit_code_hset = null;
-
-	private List synonyms = null;
-    private HashMap code2SynonymMap = null;
-    private HashMap ncitcode2labelMap = null;
-
-    private UNIIDataRetriever uniiDataRetriever = null;
-
-	public CTRPProcessor(String serviceUrl, String namedGraph) {
-		this.serviceUrl = serviceUrl;
-		this.namedGraph = namedGraph;
-		System.out.println("serviceUrl: " + this.serviceUrl);
-		System.out.println("namedGraph: " + this.namedGraph);
-
-		owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, null, null);
-		new MetadataUtils(serviceUrl).dumpNameVersion2NamedGraphMap();
-		uniiDataRetriever = new UNIIDataRetriever(this.serviceUrl, this.namedGraph);
-/*
-		if (!fileExists(FDA_UNII_Subset_Code + ".txt")) {
-			System.out.println("Retrieving supporting data from triple store server ...");
-			uniiDataRetriever = new UNIIDataRetriever(this.serviceUrl, this.namedGraph);
-			uniiDataRetriever.retrieveUNIISupportingData();
-			System.out.println("Completed retrieving supporting data.");
-		}
-
-		System.out.println("Initialized TermSearchUtils ...");
-*/
-		//termSearchUtils = new TermSearchUtils(serviceUrl, this.namedGraph);
-		synonyms = loadSynonyms();
-		System.out.println("createCode2SynonymMap ...");
-		code2SynonymMap = createCode2SynonymMap(synonyms);
-		System.out.println("createCode2SynonymMap done. " + code2SynonymMap.keySet().size());
-	}
-
-	public void dumpSynonymData() {
-		for (int i=0; i parseData(String line) {
-		if (line == null) return null;
-        char tab = '|';
-        return parseData(line, tab);
-    }
-
-	public void saveSynonyms() {
-		saveSynonyms(synonyms);
-	}
-
-
-	public void saveSynonyms(List synonyms) {
-	    Vector w = new Vector();
-	    for (int i=0; i
- * Copyright 2008-2017 NGIS. This software was developed in conjunction
- * with the National Cancer Institute, and so to the extent government
- * employees are co-authors, any rights in such works shall be subject
- * to Title 17 of the United States Code, section 105.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the disclaimer of Article 3,
- *      below. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials provided
- *      with the distribution.
- *   2. The end-user documentation included with the redistribution,
- *      if any, must include the following acknowledgment:
- *      "This product includes software developed by NGIS and the National
- *      Cancer Institute."   If no such end-user documentation is to be
- *      included, this acknowledgment shall appear in the software itself,
- *      wherever such third-party acknowledgments normally appear.
- *   3. The names "The National Cancer Institute", "NCI" and "NGIS" must
- *      not be used to endorse or promote products derived from this software.
- *   4. This license does not authorize the incorporation of this software
- *      into any third party proprietary programs. This license does not
- *      authorize the recipient to use any trademarks owned by either NCI
- *      or NGIS
- *   5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED
- *      WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- *      OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE
- *      DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE,
- *      NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT,
- *      INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *      BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *      LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *      CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *      LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *      ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *      POSSIBILITY OF SUCH DAMAGE.
- * 
- */
-
-/**
- * @author EVS Team
- * @version 1.0
- *
- * Modification history:
- *     Initial implementation kim.ong@ngc.com
- *
- */
-
-
-public class ConceptDetailsBatchRunner {
-    JSONUtils jsonUtils = null;
-    HTTPUtils httpUtils = null;
-
-    String prefixes = null;
-    //String sparql_endpoint = null;
-    String serviceUrl = null;
-    String named_graph = null;
-    String username = null;
-    String password = null;
-
-    String named_graph_id = ":NHC0";
-    String base_uri = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl";
-    TreeBuilder treeBuilder = null;//new TreeBuilder(this);
-    ParserUtils parser = new ParserUtils();
-
-    gov.nih.nci.evs.restapi.util.OWLSPARQLUtils owlSPARQLUtils = null;
-    MainTypeHierarchy mth = null;
-    ExportUtils exportUtils = null;
-    String ncit_version = "17.07c";
-	HashSet main_type_set = null;
-	Vector category_vec = null;
-
-	HashSet ctrp_biomarker_set = null;
-	HashSet ctrp_reference_gene_set = null;
-
-
-	private Vector parent_child_vec = null;
-	private static String stage_file = "DISEASE_IS_STAGE.txt";
-	private static String grade_file = "DISEASE_IS_GRADE.txt";
-	private static String NCI_THESAURUS = "NCI_Thesaurus";
-
-	Vector disease_is_stage_vec = null;
-	Vector disease_is_grade_vec = null;
-
-	public ConceptDetailsBatchRunner(String serviceUrl, String named_graph, String username, String password) {
-        this.serviceUrl = serviceUrl;//"https://sparql-evs-dev.nci.nih.gov/ctrp/?query=";
-        this.named_graph = named_graph;
-        this.username = username;
-        this.password = password;
-        initialize();
-	}
-
-	public MainTypeHierarchy createMainTypeHierarchy() {
-        long ms = System.currentTimeMillis();
-        long ms0 = System.currentTimeMillis();
-		System.out.println("Instantiating MainTypeHierarchy. Please wait...");
-		MetadataUtils mdu = new MetadataUtils(serviceUrl, username, password);
-		//String named_graph = mdu.getNamedGraph(NCI_THESAURUS);
-		String ncit_version = mdu.getLatestVersion(NCI_THESAURUS);
-		gov.nih.nci.evs.restapi.util.OWLSPARQLUtils owlSPARQLUtils = new gov.nih.nci.evs.restapi.util.OWLSPARQLUtils(serviceUrl, username, password);
-		owlSPARQLUtils.set_named_graph(named_graph);
-
-		String parent_child_file = "parent_child.txt";
-		if (parent_child_vec == null) {
-			File file = new File(parent_child_file);
-			boolean exists = file.exists();
-			if (exists) {
-				System.out.println("Loading parent_child_vec...");
-				parent_child_vec = Utils.readFile("parent_child.txt");
-			} else {
-				System.out.println("Generating parent_child_vec...");
-				parent_child_vec = owlSPARQLUtils.getHierarchicalRelationships(named_graph);
-			}
-		}
-		File f = new File(stage_file);
-		if(f.exists() && !f.isDirectory()) {
-			disease_is_stage_vec = Utils.readFile(stage_file);
-			System.out.println(stage_file + " exists.");
-		}  else {
-			String association_name = "Disease_Is_Stage";
-			disease_is_stage_vec = owlSPARQLUtils.getAssociationSourceCodes(named_graph, association_name);
-			Utils.saveToFile(stage_file, disease_is_stage_vec);
-		}
-		HashMap stageConceptHashMap = new ParserUtils().getCode2LabelHashMap(disease_is_stage_vec);
-		System.out.println("Number of stage terms: " + stageConceptHashMap.keySet().size());
-
-		f = new File(grade_file);
-		if(f.exists() && !f.isDirectory()) {
-			disease_is_grade_vec = Utils.readFile(grade_file);
-			System.out.println(grade_file + " exists.");
-		}  else {
-			String association_name = "Disease_Is_Grade";
-			disease_is_grade_vec = owlSPARQLUtils.getAssociationSourceCodes(named_graph, association_name);
-			Utils.saveToFile(grade_file, disease_is_grade_vec);
-		}
-		HashMap gradeConceptHashMap = new ParserUtils().getCode2LabelHashMap(disease_is_grade_vec);
-		System.out.println("Number of grade terms: " + gradeConceptHashMap.keySet().size());
-
- 		MainTypeHierarchyData mthd = new MainTypeHierarchyData(serviceUrl, named_graph, username, password);
-
-		main_type_set = mthd.get_main_type_set();
-		ctrp_biomarker_set = mthd.get_ctrp_biomarker_set();
-		ctrp_reference_gene_set = mthd.get_ctrp_reference_gene_set();
-        category_vec = mthd.get_broad_category_vec();
-
-		System.out.println("main_type_set: " + main_type_set.size());
-		System.out.println("category_vec: " + category_vec.size());
-		System.out.println("ctrp_biomarker_set: " + ctrp_biomarker_set.size());
-		System.out.println("ctrp_reference_gene_set: " + ctrp_reference_gene_set.size());
-		System.out.println("Instantiating MainTypeHierarchy " + parent_child_vec.size());
-
-		MainTypeHierarchy mth = new MainTypeHierarchy(
-            ncit_version,
-            parent_child_vec,
-            main_type_set,
-            category_vec,
-            stageConceptHashMap,
-            gradeConceptHashMap,
-            ctrp_biomarker_set,
-            ctrp_reference_gene_set
-            );
-
-        System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms0));
-        return mth;
-	}
-
-    public void initialize() {
-		long ms = System.currentTimeMillis();
-        this.mth = createMainTypeHierarchy();
-		this.httpUtils = new HTTPUtils(serviceUrl, username, password);
-        this.jsonUtils = new JSONUtils();
-		MetadataUtils mdu = new MetadataUtils(serviceUrl, username, password);
-		this.named_graph = mdu.getNamedGraph(NCI_THESAURUS);
-		this.ncit_version = mdu.getLatestVersion(NCI_THESAURUS);
-		this.owlSPARQLUtils = new gov.nih.nci.evs.restapi.util.OWLSPARQLUtils(serviceUrl, username, password);
-		this.owlSPARQLUtils.set_named_graph(named_graph);
-        this.treeBuilder = new TreeBuilder(this.owlSPARQLUtils);
-        this.exportUtils = new ExportUtils(this.owlSPARQLUtils);
-        System.out.println("Total initialization run time (ms): " + (System.currentTimeMillis() - ms));
-	}
-
-    public HashSet combineMainTypesAndCategories() {
-		HashSet hset = main_type_set;
-        for (int i=0; i
- * Copyright 2020 MSC. This software was developed in conjunction
- * with the National Cancer Institute, and so to the extent government
- * employees are co-authors, any rights in such works shall be subject
- * to Title 17 of the United States Code, section 105.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the disclaimer of Article 3,
- *      below. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials provided
- *      with the distribution.
- *   2. The end-user documentation included with the redistribution,
- *      if any, must include the following acknowledgment:
- *      "This product includes software developed by MSC and the National
- *      Cancer Institute."   If no such end-user documentation is to be
- *      included, this acknowledgment shall appear in the software itself,
- *      wherever such third-party acknowledgments normally appear.
- *   3. The names "The National Cancer Institute", "NCI" and "MSC" must
- *      not be used to endorse or promote products derived from this software.
- *   4. This license does not authorize the incorporation of this software
- *      into any third party proprietary programs. This license does not
- *      authorize the recipient to use any trademarks owned by either NCI
- *      or MSC
- *   5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED
- *      WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- *      OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE
- *      DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE,
- *      MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT,
- *      INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *      BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *      LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *      CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *      LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *      ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *      POSSIBILITY OF SUCH DAMAGE.
- * 
- */
-
-/**
- * @author EVS Team
- * @version 1.0
- *
- * Modification history:
- *     Initial implementation kim.ong@nih.gov
- *
- */
-
-
-public class EVSStatistics {
-	String serviceUrl = null;
-	String named_graph = null;
-	String username = null;
-	String password = null;
-	MetadataUtils metadataUtils = null;
-	OWLSPARQLUtils owlSPARQLUtils = null;
-	int table_number = 0;
-
-	HTTPUtils httpUtils = null;
-	String prefixes = null;
-	static String PUBLISH_VALUE_SET = "Publish_Value_Set";
-
-	static String[] ANNOTATED_TARGETS = null;
-	static String[] ANNOTATED_TARGET_CODES = null;
-	static List ANNOTATED_TARGET_LIST = null;
-	static HashMap ANNOTATED_TARGET_HASHMAP = null;
-
-	Vector properties = null;
-	HashMap propertyCode2NameHashMap = new HashMap();
-	HashMap propertyName2CodeHashMap = new HashMap();
-
-	HashMap roleCode2NameHashMap = new HashMap();
-	HashMap roleName2CodeHashMap = new HashMap();
-
-	Vector table_data = null;
-	String version = null;
-
-	String named_graph_id = ":NHC0";
-	Vector roots = null;
-
-	HierarchyHelper hh = null;
-    static String NCIT_OWL = "ThesaurusInferred_forTS.owl";
-	static String PARENT_CHILD_FILE = "parent_child.txt";
-	static String RESTRICTION_FILE = "roles.txt";
-
-	HashSet retired_concepts = new HashSet();
-	HashMap valueset2ContributingSourceMap = new HashMap();
-	HashMap valuesetCode2NameMap = new HashMap();
-	HashMap valuesetName2CodeMap = new HashMap();
-
-	static HashMap propertyCode2CountMap = null;
-
-    static {
-		ANNOTATED_TARGETS = new String[] {"term-name", "go-term", "TARGET TERM"};
-		ANNOTATED_TARGET_CODES = new String[] {"P382", "P388", "P392"};
-		ANNOTATED_TARGET_LIST = Arrays.asList(ANNOTATED_TARGET_CODES);
-		ANNOTATED_TARGET_HASHMAP = new HashMap();
-		ANNOTATED_TARGET_HASHMAP.put("P382", "P90");
-		ANNOTATED_TARGET_HASHMAP.put("P388", "P211");
-		ANNOTATED_TARGET_HASHMAP.put("P392", "P375");
-
-		OWLScanner scanner = new OWLScanner(NCIT_OWL);
-		propertyCode2CountMap = scanner.getPropertyCode2CountMap();
-		Vector roles = scanner.extractOWLRestrictions(scanner.get_owl_vec());
-		Utils.saveToFile(RESTRICTION_FILE, roles);
-		scanner.get_owl_vec().clear();
-	}
-
-	public String get_ncit_version() {
-		Vector v = owlSPARQLUtils.get_ontology_info(named_graph);
-		Utils.dumpVector("get_ncit_version", v);
-		String line = (String) v.elementAt(0);
-		Vector u = StringUtils.parseData(line, '|');
-		String ncit_version = (String) u.elementAt(0);
-		System.out.println(ncit_version);
-		return ncit_version;
-	}
-
-	public EVSStatistics(String serviceUrl, String named_graph, String username, String password) {
-		this.serviceUrl = serviceUrl;
-		this.named_graph = named_graph;
-		this.username = username;
-		this.password = password;
-		this.table_number = 0;
-
-		this.metadataUtils = new MetadataUtils(serviceUrl, username, password);
-
-		this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password);
-		this.owlSPARQLUtils.set_named_graph(named_graph);
-		this.version  = get_ncit_version();//metadataUtils.getVocabularyVersion(named_graph);
-        System.out.println("NCI Thesaurus version: " + version);
-        try {
-			httpUtils = new HTTPUtils();
-		} catch (Exception ex) {
-			ex.printStackTrace();
-		}
-		System.out.println("httpUtils instantiated.");
-		System.out.println("getSupportedProperties ...");
-		properties = getSupportedProperties(named_graph);
-
-		System.out.println("properties: " + properties.size());
-		Utils.saveToFile("properties.txt", properties);
-
-		propertyCode2NameHashMap = new HashMap();
-		propertyName2CodeHashMap = new HashMap();
-        for (int i=0; i" + title);
-	}
-
-	public boolean is_retired(String code) {
-		return retired_concepts.contains(code);
-	}
-
-	public void addTable(String tableName, Vector th_vec, Vector data) {
-		table_data.add("" + tableName);
-		for (int i=0; i" + th);
-		}
-		table_data.add("");
-		table_data.addAll(data);
-		table_data.add("");
-        table_data.add("
"); - } - - public void addFooter() { - table_data.add("
(Source; NCI Thesaurus, version " + this.version + ")"); - } - - public boolean is_ANNOTATED_TARGET_CODES(String propertyCode) { - return ANNOTATED_TARGET_LIST.contains(propertyCode); - } - - public static void dumpVector(String label, Vector v) { - System.out.println(label); - for (int i=0; i").append("\n"); - buf.append("PREFIX base:").append("\n"); - buf.append("PREFIX Thesaurus:").append("\n"); - buf.append("PREFIX xml:").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("PREFIX ncicp:").append("\n"); - buf.append("PREFIX dc:").append("\n"); - return buf.toString(); - } - - public String loadQuery(String queryfile) { - return httpUtils.loadQuery(queryfile, false); - } - - public Vector executeQuery(String query) { - //boolean parsevalues = true; - //Vector w = httpUtils.execute(serviceUrl, username, password, query, parsevalues); - - //Vector w = HTTPUtils.runQuery(serviceUrl, username, password, query); - Vector w = owlSPARQLUtils.executeQuery(query); - - return w; - } - - public void run(String queryfile) { - String query = HTTPUtils.loadQuery(queryfile); - //boolean parsevalues = true; - //Vector w = httpUtils.execute(serviceUrl, username, password, query, parsevalues); - Vector w = HTTPUtils.runQuery(serviceUrl, username, password, query); - if (w != null && w.size() > 0) { - int n = queryfile.lastIndexOf("_query"); - if(n == -1) { - System.out.println("ERROR: Wrong query file naming."); - System.exit(1); - } - String t = queryfile.substring(0, n); - String methodSignature = "construct_get_" + t + "(String named_graph)"; - SPARQLQueryGenerator.generateCode(queryfile, methodSignature); - Utils.dumpVector("w", w); - } else { - System.out.println("ERROR: Query failed."); - int n = queryfile.lastIndexOf("_query"); - String t = queryfile.substring(0, n); - String methodSignature = "construct_get_" + t + "(String named_graph)"; - SPARQLQueryGenerator.generateCode(queryfile, methodSignature); - } - } - - public String construct_root_query(String named_graph) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select ?s_label ?s_code").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append("?s a owl:Class .").append("\n"); - buf.append("?s rdfs:label ?s_label .").append("\n"); - buf.append("?s :NHC0 ?s_code . ").append("\n"); - buf.append("filter not exists { ?s rdfs:subClassOf|owl:equivalentClass ?o } ").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getRoots(String named_graph, boolean code_only) { - Vector w = new Vector(); - String query = construct_root_query(named_graph); - Vector v = executeQuery(query); - if (!code_only) return v; - for (int i=0; i {").append("\n"); - buf.append(" ?p a owl:ObjectProperty.").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label ").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getObjectProperties(String named_graph) { - return executeQuery(construct_get_object_properties(named_graph)); - } - - public String construct_get_object_properties_domain_range(String named_graph) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT distinct ?x_pt ?x_code ?x_domain_label ?x_range_label ").append("\n"); - buf.append("{ ").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:ObjectProperty .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:domain ?x_domain .").append("\n"); - buf.append(" ?x_domain rdfs:label ?x_domain_label .").append("\n"); - buf.append(" ?x rdfs:range ?x_range .").append("\n"); - buf.append(" ?x_range rdfs:label ?x_range_label .").append("\n"); - buf.append(" ?x :P108 ?x_pt .").append("\n"); - buf.append(" }").append("\n"); - buf.append(" ").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public String construct_get_object_valued_annotation_properties(String named_graph) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT distinct ?x_label ?x_code ").append("\n"); - buf.append("{ ").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:AnnotationProperty .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x rdfs:range ?x_range").append("\n"); - buf.append(" }").append("\n"); - buf.append(" FILTER (str(?x_range)=\"http://www.w3.org/2001/XMLSchema#anyURI\")").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getObjectValuedProperty(String named_graph) { - String query = construct_get_object_valued_annotation_properties(named_graph); - return executeQuery(query); - } - - public String construct_get_supported_properties(String named_graph, String code, String propertyName, String propertyValue, boolean concept_only) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - if (concept_only) { - buf.append("select distinct ?x_label ?x_code").append("\n"); - } else { - buf.append("select distinct ?x_label ?x_code ?p_label ?p_value").append("\n"); - } - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append("").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?x ?p ?p_value .").append("\n"); - if (propertyValue != null) { - buf.append(" ?x ?p \"" + propertyValue + "\"^^xsd:string .").append("\n"); - } - - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label \"" + propertyName + "\"^^xsd:string .").append("\n"); - buf.append("").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getSupportedProperties(String named_graph, String code, String propertyName, String propertyValue, boolean concept_only) { - String query = construct_get_supported_properties(named_graph, code, propertyName, propertyValue, concept_only); - return executeQuery(query); - } - - public String construct_get_property_qualifier(String named_graph, String code, String propertyCode, - String qualifierCode, String qualifierValue, boolean concept_only) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - - if (concept_only) { - buf.append("select distinct ?x_label ?x_code").append("\n"); - } else { - buf.append("select ?x_label ?x_code ?p_label ?a_target ?q1_label ?q1_value").append("\n"); - } - - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a a owl:Axiom .").append("\n"); - buf.append(" ?a owl:annotatedSource ?x .").append("\n"); - buf.append(" ?a owl:annotatedProperty ?p .").append("\n"); - buf.append(" ?a owl:annotatedTarget ?a_target .").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p :NHC0 \"" + propertyCode + "\"^^xsd:string .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a ?q1 ?q1_value .").append("\n"); - buf.append(" ?a ?q1 \"" + qualifierValue + "\"^^xsd:string .").append("\n"); - buf.append(" ?q1 :NHC0 ?q1_code .").append("\n"); - buf.append(" ?q1 :NHC0 \"" + qualifierCode + "\"^^xsd:string .").append("\n"); - buf.append(" ?q1 rdfs:label ?q1_label .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getPropertyQualifier(String named_graph, String code, String propertyCode, - String qualifierCode, String qualifierValue, boolean concept_only) { - String query = construct_get_property_qualifier(named_graph, code, propertyCode, qualifierCode, qualifierValue, concept_only); - return executeQuery(query); - } - - public String construct_get_associations(String named_graph) { - return construct_get_associations(named_graph, null); - } - - public String construct_get_associations(String named_graph, String code) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT distinct ?x_label ?x_code ?y_label ?y_code ?z_label ?z_code").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?y a owl:AnnotationProperty .").append("\n"); - buf.append(" ?x ?y ?z .").append("\n"); - buf.append(" ?z a owl:Class .").append("\n"); - buf.append(" ?z rdfs:label ?z_label .").append("\n"); - buf.append(" ?z :NHC0 ?z_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:range ?y_range").append("\n"); - buf.append(" }").append("\n"); - buf.append(" FILTER (str(?y_range)=\"http://www.w3.org/2001/XMLSchema#anyURI\")").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getAssociations(String named_graph) { - String query = construct_get_associations(named_graph); - return executeQuery(query); - } - - public Vector getAssociations(String named_graph, String code) { - String query = construct_get_associations(named_graph, code); - return executeQuery(query); - } - - - public String construct_get_role_targets(String named_graph, String code, String roleName) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("").append("\n"); - buf.append("SELECT distinct ?x_label ?x_code ?p_label ?p_code ?c_label ?c_code").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + "> {").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?x owl:equivalentClass ?y .").append("\n"); - buf.append(" ?y (rdfs:subClassOf|(owl:intersectionOf/rdf:rest*/rdf:first))* ?r1 .").append("\n"); - buf.append(" ?r1 owl:onProperty ?p .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - if (roleName != null) { - buf.append(" ?p rdfs:label \"" + roleName + "\"^^xsd:string .").append("\n"); - } - buf.append("").append("\n"); - buf.append(" ?r1 owl:someValuesFrom ?c .").append("\n"); - buf.append(" ?c :NHC0 ?c_code .").append("\n"); - - buf.append(" ?c rdfs:label ?c_label .").append("\n"); - buf.append(" }").append("\n"); - buf.append(" UNION").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?x owl:equivalentClass ?y .").append("\n"); - buf.append(" ?y (rdfs:subClassOf|(owl:unionOf/rdf:rest*/rdf:first))* ?r1 .").append("\n"); - buf.append(" ?r1 owl:onProperty ?p .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - - if (roleName != null) { - buf.append(" ?p rdfs:label \"" + roleName + "\"^^xsd:string .").append("\n"); - } - - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append(" ?r1 owl:someValuesFrom ?c .").append("\n"); - buf.append(" ?c :NHC0 ?c_code .").append("\n"); - buf.append(" ?c rdfs:label ?c_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" }").append("\n"); - buf.append(" UNION").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x rdfs:subClassOf ?r .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?r owl:onProperty ?p .").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - - if (roleName != null) { - buf.append(" ?p rdfs:label \"" + roleName + "\"^^xsd:string .").append("\n"); - } - buf.append("").append("\n"); - buf.append(" ?r owl:someValuesFrom ?c .").append("\n"); - buf.append(" ?c :NHC0 ?c_code .").append("\n"); - buf.append(" ?c rdfs:label ?c_label .").append("\n"); - buf.append(" }").append("\n"); - buf.append(" }").append("\n"); - buf.append("").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getRoleTargets(String named_graph) { - return getRoleTargets(named_graph, true); - } - - public Vector getRoleTargets(String named_graph, boolean savefile) { - Vector v = getRoleTargets(named_graph, null, null); - if (savefile) { - Utils.saveToFile(RESTRICTION_FILE, v); - } - return v; - } - - public Vector getRoleTargets(String named_graph, String code, String roleName) { - String query = construct_get_role_targets(named_graph, code, roleName); - return executeQuery(query); - } - - - public String construct_get_hierarchical_relationships(String named_graph) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT ?z_label ?z_code ?x_label ?x_code").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" {").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x " + named_graph_id + " ?x_code .").append("\n"); - buf.append(" ?x rdfs:subClassOf ?z .").append("\n"); - buf.append(" ?z a owl:Class .").append("\n"); - buf.append(" ?z rdfs:label ?z_label .").append("\n"); - buf.append(" ?z " + named_graph_id + " ?z_code").append("\n"); - buf.append(" }").append("\n"); - buf.append(" FILTER (?x != ?z)").append("\n"); - buf.append(" }").append("\n"); - buf.append(" UNION").append("\n"); - buf.append(" {").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x " + named_graph_id + " ?x_code .").append("\n"); - buf.append(" ?x owl:equivalentClass ?y .").append("\n"); - buf.append(" ?y owl:intersectionOf ?list .").append("\n"); - buf.append(" ?list rdf:rest*/rdf:first ?z .").append("\n"); - buf.append(" ?z a owl:Class .").append("\n"); - buf.append(" ?z rdfs:label ?z_label .").append("\n"); - buf.append(" ?z " + named_graph_id + " ?z_code").append("\n"); - buf.append(" }").append("\n"); - buf.append(" FILTER (?x != ?z)").append("\n"); - buf.append(" }").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getHierarchicalRelationships(String named_graph) { - return executeQuery(construct_get_hierarchical_relationships(named_graph)); - } - - - public Vector get_roots(String named_graph) { - return executeQuery(construct_root_query(named_graph)); - } - - public String construct_get_concepts_with_annotation_property(String named_graph, String propertyName) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT ?x_label ?x_code ?y_label ?z").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?y a owl:AnnotationProperty .").append("\n"); - buf.append(" ?x ?y ?z .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ?y rdfs:label " + "\"" + propertyName + "\"^^xsd:string ").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getConceptsWithAnnotationProperty(String named_graph, String propertyName) { - String query = construct_get_concepts_with_annotation_property(named_graph, propertyName); - Vector v = executeQuery(query); - return v; - } - - public String construct_get_concepts_with_annotation_property_matching(String named_graph, - String propertyName, String propertyValue) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT ?x_label ?x_code ?y_label ?z").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?y a owl:AnnotationProperty .").append("\n"); - buf.append(" ?x ?y ?z .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ?y rdfs:label " + "\"" + propertyName + "\"^^xsd:string .").append("\n"); - if (propertyValue != null) { - buf.append(" ?x ?y " + "\"" + propertyValue + "\"^^xsd:string .").append("\n"); - } - - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getConceptsWithAnnotationPropertyMatching(String named_graph, String propertyName, String propertyValue) { - String query = construct_get_concepts_with_annotation_property_matching(named_graph, propertyName, propertyValue); - Vector v = executeQuery(query); - return v; - } - - - public String construct_get_supported_properties(String named_graph) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?p_label ?p_code ").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?p a owl:AnnotationProperty .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getSupportedProperties(String named_graph) { - String query = construct_get_supported_properties(named_graph); - Vector v = executeQuery(query); - return v; - } - - public String construct_get_concepts_with_property(String named_graph, String property_code) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_label ?x_code ?p_label ?p_value").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p a owl:AnnotationProperty .").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?p :NHC0 \"" + property_code + "\"^^xsd:string .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?x ?p ?p_value .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getConceptsWithProperty(String named_graph, String property_code) { - String query = construct_get_concepts_with_property(named_graph, property_code); - Vector v = executeQuery(query); - v = removeDuplicates(v); - v = new SortUtils().quickSort(v); - return v; - } - - public String construct_get_supported_qualifiers(String named_graph) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?p_label ?p_code ?q1_label ?q1_code").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a a owl:Axiom .").append("\n"); - buf.append(" ?a owl:annotatedSource ?x .").append("\n"); - buf.append(" ?a owl:annotatedProperty ?p .").append("\n"); - buf.append(" ?a owl:annotatedTarget ?a_target .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a ?q1 ?q1_value .").append("\n"); - buf.append(" ?q1 :NHC0 ?q1_code .").append("\n"); - buf.append(" ?q1 rdfs:label ?q1_label .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public HashMap createQualifierCode2PropertyCodeHashMap(String named_graph) { - Vector v = getSupportedQualifiers(named_graph); - HashMap hmap = new HashMap(); - for (int i=0; i").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a a owl:Axiom .").append("\n"); - buf.append(" ?a owl:annotatedSource ?x .").append("\n"); - buf.append(" ?a owl:annotatedProperty ?p .").append("\n"); - buf.append(" ?a owl:annotatedTarget ?a_target .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p :NHC0 \"" + propertyCode + "\"^^xsd:string .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a ?q1 ?q1_value .").append("\n"); - buf.append(" ?q1 :NHC0 ?q1_code .").append("\n"); - buf.append(" ?q1 :NHC0 \"" + qualifierCode + "\"^^xsd:string .").append("\n"); - buf.append(" ?q1 rdfs:label ?q1_label .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public int getAnnotatedTargetCount(String named_graph, String propertyCode, String qualifierCode) { - String query = construct_get_annotated_target_count(named_graph, propertyCode, qualifierCode); - Vector v = executeQuery(query); - if (v == null || v.size() == 0) return 0; - return v.size(); - } - - - public String construct_get_annotated_target_count(String named_graph, String propertyCode) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT ?a_target").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?a a owl:Axiom .").append("\n"); - buf.append(" ?a owl:annotatedSource ?x .").append("\n"); - buf.append(" ?a owl:annotatedProperty ?p .").append("\n"); - buf.append(" ?a owl:annotatedTarget ?a_target .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p :NHC0 \"" + propertyCode + "\"^^xsd:string .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public int getAnnotatedTargetCount(String named_graph, String propertyCode) { - String query = construct_get_annotated_target_count(named_graph, propertyCode); - Vector v = executeQuery(query); - if (v == null || v.size() == 0) return 0; - return v.size(); - } - - - public String construct_get_distinct_property_qualifier_values(String named_graph, - String code, - String propertyCode, - String qualifierCode) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?q1_value").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a a owl:Axiom .").append("\n"); - buf.append(" ?a owl:annotatedSource ?x .").append("\n"); - buf.append(" ?a owl:annotatedProperty ?p .").append("\n"); - buf.append(" ?a owl:annotatedTarget ?a_target .").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p :NHC0 \"" + propertyCode + "\"^^xsd:string .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a ?q1 ?q1_value .").append("\n"); - buf.append(" ?q1 :NHC0 ?q1_code .").append("\n"); - buf.append(" ?q1 :NHC0 \"" + qualifierCode + "\"^^xsd:string .").append("\n"); - buf.append(" ?q1 rdfs:label ?q1_label .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getDistinctPropertyQualifierValues(String named_graph, String code, String propertyCode, String qualifierCode) { - String query = construct_get_annotated_target_count(named_graph, propertyCode); - Vector v = executeQuery(query); - v = new SortUtils().quickSort(v); - return v; - } - - public String construct_get_distinct_property_values(String named_graph, String propertyName) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?p_value").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?p rdfs:label \"" + propertyName + "\"^^xsd:string .").append("\n"); - buf.append(" ?p a owl:AnnotationProperty .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x ?p ?p_value .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getDistinctPropertyValues(String named_graph, String propertyName) { - String query = construct_get_distinct_property_values(named_graph, propertyName); - Vector v = executeQuery(query); - v = new SortUtils().quickSort(v); - return v; - } - - - public String construct_get_concepts_with_property_value(String named_graph, String propertyName, String propertyValue) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_label ?x_code ?p_label ?p_value").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?p rdfs:label \"" + propertyName + "\"^^xsd:string .").append("\n"); - buf.append(" ?p a owl:AnnotationProperty .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x ?p ?p_value .").append("\n"); - buf.append(" ?x ?p \"" + propertyValue + "\"^^xsd:string .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getConceptsWithPropertyValue(String named_graph, String propertyName, String propertyValue) { - String query = construct_get_concepts_with_property_value(named_graph, propertyName, propertyValue); - Vector v = executeQuery(query); - v = removeDuplicates(v); - return v; - } - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public static HashMap getPropertyCountHashMap(String owlfile) { - OWLScanner owlscanner = new OWLScanner(owlfile); - Vector v = owlscanner.extractProperties(owlscanner.get_owl_vec()); - HashMap propertyCountHashMap = new HashMap(); - for (int i=0; i").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p2 a owl:AnnotationProperty .").append("\n"); - buf.append(" ?p2 :NHC0 ?p2_code .").append("\n"); - buf.append(" ?p2 rdfs:label ?p2_label .").append("\n"); - buf.append(" ?p2 rdfs:label \"Publish_Value_Set\"^^xsd:string .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x ?p2 ?p2_value .").append("\n"); - if (publishedOnly) { - buf.append(" ?x ?p2 \"Yes\"^^xsd:string .").append("\n"); - } - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getValueSets(String named_graph) { - boolean publishedOnly = true; - String query = construct_get_value_sets(named_graph, publishedOnly); - Vector v = executeQuery(query); - return v; - } - - public Vector getValueSets(String named_graph, boolean publishedOnly) { - String query = construct_get_value_sets(named_graph, publishedOnly); - Vector v = executeQuery(query); - return v; - } - - public String construct_get_value_sets_with_contributing_source(String named_graph) { - boolean publishedOnly = true; - return construct_get_value_sets_with_contributing_source(named_graph, publishedOnly); - } - - public String construct_get_value_sets_with_contributing_source(String named_graph, boolean publishedOnly) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_label ?x_code ?p1_label ?p1_value ").append("\n"); - //buf.append("select distinct ?x_label ?x_code ?p1_value ?p2_value ").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p1 a owl:AnnotationProperty .").append("\n"); - buf.append(" ?p1 :NHC0 ?p1_code .").append("\n"); - buf.append(" ?p1 rdfs:label ?p1_label .").append("\n"); - buf.append(" ?p1 rdfs:label \"Contributing_Source\"^^xsd:string .").append("\n"); - buf.append(" ?x ?p1 ?p1_value .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p2 a owl:AnnotationProperty .").append("\n"); - buf.append(" ?p2 :NHC0 ?p2_code .").append("\n"); - buf.append(" ?p2 rdfs:label ?p2_label .").append("\n"); - buf.append(" ?p2 rdfs:label \"Publish_Value_Set\"^^xsd:string .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x ?p2 ?p2_value .").append("\n"); - if (publishedOnly) { - buf.append(" ?x ?p2 \"Yes\"^^xsd:string .").append("\n"); - } - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getValueSetsWithContributingSource(String named_graph) { - boolean publishedOnly = true; - String query = construct_get_value_sets_with_contributing_source(named_graph, publishedOnly); - Vector v = executeQuery(query); - return v; - } - - public Vector getValueSetsWithContributingSource(String named_graph, boolean publishedOnly) { - String query = construct_get_value_sets_with_contributing_source(named_graph, publishedOnly); - Vector v = executeQuery(query); - return v; - } - - public String construct_get_concepts_in_subset(String named_graph, String subset_code, boolean codeOnly) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - if (codeOnly) { - buf.append("SELECT ?x_code").append("\n"); - } else { - buf.append("SELECT ?x_label ?x_code").append("\n"); - } - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x " + named_graph_id + " ?x_code .").append("\n"); - buf.append(" ?y a owl:AnnotationProperty .").append("\n"); - buf.append(" ?x ?y ?z .").append("\n"); - buf.append(" ?z " + named_graph_id + " \"" + subset_code + "\"^^xsd:string .").append("\n"); - buf.append(" ?y rdfs:label " + "\"" + "Concept_In_Subset" + "\"^^xsd:string ").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getConceptsInSubset(String named_graph, String code, boolean codeOnly) { - return executeQuery(construct_get_concepts_in_subset(named_graph, code, codeOnly)); - } - - public String construct_get_value_set_data(String named_graph) { - boolean publishedOnly = true; - return construct_get_value_set_data(named_graph, publishedOnly); - } - - public String construct_get_value_set_data(String named_graph, boolean publishedOnly) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?y_label ?y_code ?p0_label ?x_label ?x_code ?p1_label ?p1_value ?p2_label ?p2_value ").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?y a owl:Class .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p0 a owl:AnnotationProperty .").append("\n"); - buf.append(" ?p0 :NHC0 ?p0_code .").append("\n"); - buf.append(" ?p0 rdfs:label ?p0_label .").append("\n"); - buf.append(" ?p0 rdfs:label \"Concept_In_Subset\"^^xsd:string . ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?y ?p0 ?x . ").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p1 a owl:AnnotationProperty .").append("\n"); - buf.append(" ?p1 :NHC0 ?p1_code .").append("\n"); - buf.append(" ?p1 rdfs:label ?p1_label .").append("\n"); - buf.append(" ?p1 rdfs:label \"Contributing_Source\"^^xsd:string .").append("\n"); - - buf.append(" OPTIONAL {").append("\n"); - buf.append(" ?x ?p1 ?p1_value .").append("\n"); - buf.append(" }").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p2 a owl:AnnotationProperty .").append("\n"); - buf.append(" ?p2 :NHC0 ?p2_code .").append("\n"); - buf.append(" ?p2 rdfs:label ?p2_label .").append("\n"); - buf.append(" ?p2 rdfs:label \"Publish_Value_Set\"^^xsd:string .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x ?p2 ?p2_value .").append("\n"); - if (publishedOnly) { - buf.append(" ?x ?p2 \"Yes\"^^xsd:string .").append("\n"); - } - buf.append("}").append("\n"); - return buf.toString(); - } - - -// (221972) CTRP Disease Finding|C173902|Concept_In_Subset|CTS-API Disease Broad Category Terminology|C138189|Contributing_Source|Publish_Value_Set|null|Yes - - public Vector getValueSetData(String named_graph) { - boolean publishedOnly = true; - return getValueSetData(named_graph, publishedOnly); - } - - public Vector getValueSetData(String named_graph, boolean publishedOnly) { - Vector v = executeQuery(construct_get_value_set_data(named_graph, publishedOnly)); - - Utils.saveToFile("value_set_data.txt", v); - - Vector w = new Vector(); - for (int i=0; i " + Integer.valueOf(value)); - } - } - - - public HashMap getPropertyValueHashMap(Vector v) { - HashMap hmap = new HashMap(); - if (v == null) return hmap; - for (int i=0; i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class EVSStatisticsRunner { - String serviceUrl = null; - String named_graph = null; - String username = null; - String password = null; - - public static void main(String[] args) { - long ms = System.currentTimeMillis(); - -System.out.println("Downloading NCI Thesaurus..."); - //Download NCI Thesaurus - String currentWorkingDirectory = System.getProperty("user.dir"); - NCItDownload.download(NCItDownload.NCIt_URI + NCItDownload.NCIT_ZIP_FILE, NCItDownload.NCIT_ZIP_FILE); - String zipFilePath = currentWorkingDirectory + "/" + NCItDownload.NCIT_ZIP_FILE; - NCItDownload.unzip(zipFilePath, currentWorkingDirectory); - -System.out.println("Running OWLScanner ..."); - //Run scanner for extracting roles.txt - String owlfile = "ThesaurusInferred_forTS.owl"; - OWLScanner scanner = new OWLScanner(owlfile); - String RESTRICTION_FILE = "roles.txt"; - Vector v = scanner.extractOWLRestrictions(scanner.get_owl_vec()); - Utils.saveToFile(RESTRICTION_FILE, v); - v.clear(); - scanner.get_owl_vec().clear(); - -System.out.println("Running EVSStatistics ..."); - //Run EVSStatistics - String serviceUrl = args[0]; - String named_graph = args[1]; - String username = args[2]; - String password = args[3]; - EVSStatistics evsStatistics = new EVSStatistics(serviceUrl, named_graph, username, password); - evsStatistics.generate(); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/FlatFileGenerator.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/FlatFileGenerator.java deleted file mode 100644 index 050a7e4a9..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/FlatFileGenerator.java +++ /dev/null @@ -1,387 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.json.*; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class FlatFileGenerator { - JSONUtils jsonUtils = null; - HTTPUtils httpUtils = null; - String named_graph = null; - String prefixes = null; - String serviceUrl = null; - String restURL = null; - String named_graph_id = ":NHC0"; - String BASE_URI = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl"; - - ParserUtils parser = new ParserUtils(); - HashMap nameVersion2NamedGraphMap = null; - HashMap ontologyUri2LabelMap = null; - String version = null; - String username = null; - String password = null; - OWLSPARQLUtils owlSPARQLUtils = null; - - static String CONCEPT_MEMBESHIP_FILE = "concept_membership_results.txt"; - - public FlatFileGenerator(String serviceUrl, String named_graph, String username, String password) { - this.serviceUrl = serviceUrl; - this.named_graph = named_graph; - this.username = username; - this.password = password; - this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - this.owlSPARQLUtils.set_named_graph(named_graph); - } - - public OWLSPARQLUtils getOWLSPARQLUtils() { - return this.owlSPARQLUtils; - } - - public String construct_get_class_uris(String named_graph) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_code ?x").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + "> ").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getClassURIs(String named_graph) { - String query = construct_get_class_uris(named_graph); - - System.out.println(query); - - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - - public String construct_get_hierarchical_relationships(String named_graph) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_code ?y_code").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?y a owl:Class .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x (rdfs:subClassOf|owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) ?y . ").append("\n"); - buf.append(" } ").append("\n"); - buf.append("}").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public Vector getHierarchicalRelationships(String named_graph) { - String query = construct_get_hierarchical_relationships(named_graph); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public String construct_get_prop(String named_graph, String propertyCode) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT distinct ?x_code ?p_value").append("\n"); - buf.append("from <" + named_graph + "> ").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - //buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?p :NHC0 \"" + propertyCode + "\"^^xsd:string .").append("\n"); - //buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?x ?p ?p_value .").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getProp(String named_graph, String propertyCode) { - String query = construct_get_prop(named_graph, propertyCode); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public Vector getSynonyms(String named_graph) { - String propertyCode = "P90"; - return getProp(named_graph, propertyCode); - } - - public String construct_get_labels(String named_graph) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_code ?x_label").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + "> ").append("\n"); - buf.append(" {").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" }").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getLabels(String named_graph) { - String query = construct_get_labels(named_graph); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public String getClassUri(String code) { - return ""; - } - - public String construct_get_concept_membership(String named_graph) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("").append("\n"); - buf.append("SELECT distinct ?x_label ?x_code ?p_label ?y_label ?y_code ").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + "> {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?y a owl:Class .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?x ?p ?y .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?p rdfs:label \"Concept_In_Subset\"^^xsd:string .").append("\n"); - buf.append("").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public HashMap createMultiValuedHashMap(Vector data) { - HashMap hmap = new HashMap(); - for (int i=0; i - * Copyright 2022 Guidehouse. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by Guidehouse and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "Guidehouse" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or Guidehouse - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class FlatFileGeneratorRunner { - static String CONCEPT_MEMBESHIP_FILE = "concept_in_subset_data.txt"; - public static void run(String restURL, String named_graph, String username, String password) { - System.out.println("Generating NCI Thesaurus flat file ..."); - FlatFileGenerator generator = new FlatFileGenerator(restURL, named_graph, username, password); - String flatfile = generator.generate(); - Vector v = generator.getConceptMembership(named_graph); - HashMap code2LabelMap = new HashMap(); - HashMap hmap = new HashMap(); - for (int i=0; i 0) { - System.out.println("\nWARNING: Codes in " + CONCEPT_MEMBESHIP_FILE + " not found in " + flatfile + "."); - it = missing_codes.iterator(); - int lcv = 0; - while (it.hasNext()) { - lcv++; - String code = (String) it.next(); - String label = (String) code2LabelMap.get(code); - System.out.println("(" + lcv + ") " + label + " (" + code + ")"); - } - } - } - - public static void main(String[] args) { - long ms = System.currentTimeMillis(); - String restURL = args[0]; - String named_graph = args[1]; - String username = args[2]; - String password = args[3]; - run(restURL, named_graph, username, password); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchy.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchy.java deleted file mode 100644 index 6d1fff7f4..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchy.java +++ /dev/null @@ -1,1338 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; - -public class MainTypeHierarchy { - public int multiple_count = 0; - static String MAIN_TYPE_TREE = "main_type_tree"; - static String SUBTYPE_TREE = "subtype_tree"; - static String STAGE_TREE = "stage_tree"; - public static String DISEASE_DISORDER_OR_FINDING_CODE = "C7057"; - - - static String FINDING_CODE = "C3367"; - - public static String DISEASES_AND_DISORDERS_CODE = "C2991"; - public static String NEOPLASM_CODE = "C3262"; - static Vector main_type_hierarchy_data = null; - - static String RECURRENT = "recurrent"; - - Vector parent_child_vec = null; - HierarchyHelper hh = null; - HierarchyHelper mth_hh = null; - HierarchyHelper mth_hh_without_categories = null; - - PathFinder pathFinder = null; - - String ctrp_classification_data = null; - Vector main_types = null; - Vector main_type_leaves = null; - HashSet main_type_set = null; - HashSet ctrp_biomarker_set = null; - HashSet ctrp_reference_gene_set = null; - - - Vector subtype_terms = null; - Vector stage_terms = null; - - HashSet subtype_set = null; - HashSet stage_set = null; - - HashMap label2CodeMap = new HashMap(); - HashSet ctrp_codes = new HashSet(); - - HashMap levelMap = null; - HashMap stageConceptHashMap = null; - HashMap gradeConceptHashMap = null; - Vector category_vec = null; - HashSet category_hset = null; - - static String NCI_THESAURUS = "NCI_Thesaurus"; - - public MainTypeHierarchy() { - - } - - public MainTypeHierarchy(Vector parent_child_vec) { - this.parent_child_vec = parent_child_vec; - this.hh = new HierarchyHelper(parent_child_vec); - } - - public MainTypeHierarchy(String ncit_version, Vector parent_child_vec, HashSet main_type_set, Vector category_vec, - Vector stageConcepts, Vector gradeConcepts, HashSet ctrp_biomarker_set, HashSet ctrp_reference_gene_set) { - - this.parent_child_vec = parent_child_vec; - this.hh = new HierarchyHelper(parent_child_vec); - - this.stageConceptHashMap = new HashMap(); - for (int i=0; i 0) { - return true; - } else { - return false; - } - } - - if (isDiseaseGrade(code)) { - String name = (String) gradeConceptHashMap.get(code); - name = name.toLowerCase(); - if (name.indexOf("grade") == -1) { - return true; - } - return false; - } - - } catch (Exception ex) { - ex.printStackTrace(); - } - return true; - } - - public Vector generate_main_type_hierarchy() { - if (main_type_set == null) { - return null; - } - return generate_embedded_hierarchy(DISEASES_AND_DISORDERS_CODE, main_type_set); - } - - public Vector generate_embedded_hierarchy(String rootCode, HashSet nodeSet) { - return generate_embedded_hierarchy(rootCode, nodeSet, true); - } - - public Vector generate_embedded_hierarchy(String rootCode, HashSet nodeSet, boolean trim) { - Vector v = generateEmbeddedHierarchy(rootCode, nodeSet, trim); - HierarchyHelper hh = new HierarchyHelper(v); - Vector w = hh.exportTree(); - w = new ASCIITreeUtils().removeRootNode(w); - return w; - } - - public void generateMainTypeHierarchy(String outputfile) { - generateEmbeddedHierarchy(outputfile, DISEASES_AND_DISORDERS_CODE, main_type_set); - } - - public void generateEmbeddedHierarchy(String treefile, String rootCode, HashSet nodeSet) { - generateEmbeddedHierarchy(treefile, rootCode, nodeSet, true); - } - - public void generateEmbeddedHierarchy(String treefile, String rootCode, HashSet nodeSet, boolean trim) { - Vector v = generateEmbeddedHierarchy(rootCode, nodeSet, trim); - HierarchyHelper hh = new HierarchyHelper(v); - Vector w = hh.exportTree(); - //KLO - w = new ASCIITreeUtils().removeRootNode(w); - Utils.saveToFile(treefile, w); - } - - public Vector createEmbeddedHierarchy(String rootCode, HashSet nodeSet) { - return createEmbeddedHierarchy(rootCode, nodeSet, true); - } - - public Vector createEmbeddedHierarchy(String rootCode, HashSet nodeSet, boolean trim) { - Vector v = generateEmbeddedHierarchy(rootCode, nodeSet, trim); - HierarchyHelper hh = new HierarchyHelper(v); - Vector w = hh.exportTree(); - return w; - } - - public TreeItem trimTree(TreeItem ti, int level, String code, int maxLevel) { - if (level >= maxLevel) return ti; - if (ti._code.compareTo(code) == 0 && level < maxLevel) { - return null; - } - - List children = ti._assocToChildMap.get(Constants.ASSOCIATION_NAME); - if (children != null && children.size() > 0) { - List new_children = new ArrayList(); - for (int i=0; i= maxLevel) { - new_children.add(child_ti); - } - } - } - } - ti._assocToChildMap.put(Constants.ASSOCIATION_NAME, new_children); - } - return ti; - } - - public HashMap create_level_hashmap(Vector v) { - ASCIITreeUtils utils = new ASCIITreeUtils(); - HashMap hmap = new HashMap(); - for (int i=0; i 1) { - int maxLevel = findMaximumLevel(w); - w2.add(key + "|" + maxLevel); - } - } - return w2; - } - - public int findMaximumLevel(Vector v) { - int max = -1; - for (int i=0; i max) { - max = value; - } - } - return max; - } - - public HashMap createLevelHashMap(Vector parent_child_vec) { - HierarchyHelper hh = new HierarchyHelper(parent_child_vec); - ASCIITreeUtils utils = new ASCIITreeUtils(); - HashMap hmap = new HashMap(); - Vector v = hh.exportTree();//(Vector) parent_child_vec.clone(); - for (int i=0; i maxLevel) { - maxLevel = i1; - w = new Vector(); - w.add(parent_label + "|" + parent_code + "|" + maxLevel); - } else if (i1 == maxLevel) { - String t = parent_label + "|" + parent_code + "|" + maxLevel; - if (!w.contains(t)) { - w.add(t); - } - } - } - } - - if (child_code.compareTo(rootCode) != 0) { - Integer n2 = (Integer) levelMap.get(child_code); - if (n2 != null) { - int i2 = n2.intValue(); - if (i2 > maxLevel) { - maxLevel = i2; - w = new Vector(); - w.add(child_label + "|" + child_code + "|" + maxLevel); - } else if (i2 == maxLevel) { - String t = child_label + "|" + child_code + "|" + maxLevel; - if (!w.contains(t)) { - w.add(t); - } - } - } - } - } - return w; - } - - public List getMainMenuAncestors(String code) { - if (!isSubtype(code) && !isDiseaseStage(code) && !isDiseaseGrade(code)) { - return null; - } - String label = hh.getLabel(code); - if (label == null) return null; - List list = new ArrayList(); - Vector v = findMainMenuAncestors(code); - for (int i=0; i 0) { - for (int i=0; i 0) { - for (int i=0; i 0) { - w.addAll(u); - } - } - w = removeDuplicates(w); - return w; - } - - public Vector removeDuplicates(Vector codes) { - HashSet hset = new HashSet(); - Vector w = new Vector(); - for (int i=0; i 0) { - - System.out.println("\t(10) sups != null && sups.size() > 0 -- isSubtype: true"); - return true; - } else { - - System.out.println("\t(11) sups == null -- isSubtype: false"); - return false; - } - } - - System.out.println("\t(12)" + " isDiseaseGrade? " + isDiseaseGrade(code)); - if (isDiseaseGrade(code)) { - System.out.println("\t(13)" + " isDiseaseGrade " + isDiseaseGrade(code)); - String label = name; - label = label.toLowerCase(); - if (label.indexOf("grade") == -1) { - System.out.println("\t(14)" + " isSubtype? true (does not contains the word grade.)" ); - return true; - } - System.out.println("\t(15)" + " isSubtype? false -- contains the word grade." ); - return false; - } - } catch (Exception ex) { - ex.printStackTrace(); - } - - System.out.println("\t(16)" + " isSubtype: true"); - return true; - } - - - - public static void save_main_type_hierarchy() { - String today = StringUtils.getToday(); - Utils.saveToFile("main_type_hierarchy_" + today + ".txt", main_type_hierarchy_data); - } - - public void generate_main_type_label_code_file(HashSet main_type_set) { - Vector w = new Vector(); - Iterator it = main_type_set.iterator(); - while (it.hasNext()) { - String code = (String) it.next(); - String label = hh.getLabel(code); - w.add(label + "|" + code); - } - - w = new SortUtils().quickSort(w); - String today = StringUtils.getToday(); - Utils.saveToFile("main_type_label_and_code_" + today + ".txt", w); - } - - - public static void generate_data_files(String serviceUrl, String named_graph) { - OWLSPARQLUtils owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, null, null); - System.out.println("getHierarchicalRelationships ..."); - Vector v = owlSPARQLUtils.getHierarchicalRelationships(named_graph); - Vector parent_child_vec = new ParserUtils().toDelimited(v, 4, '|'); - String today = StringUtils.getToday(); - Utils.saveToFile("parent_child_" + today + ".txt", parent_child_vec); - - System.out.println("getDiseaseIsStageSourceCodes ..."); - v = owlSPARQLUtils.getDiseaseIsStageSourceCodes(named_graph); - Utils.saveToFile("DISEASE_IS_STAGE_" + today + ".txt", v); - - System.out.println("getDiseaseIsGradeSourceCodes ..."); - v = owlSPARQLUtils.getDiseaseIsGradeSourceCodes(named_graph); - Utils.saveToFile("DISEASE_IS_GRADE_" + today + ".txt", v); - } - - - public void testIsSubtype(Vector codes) { - for (int i=0; i 0) { - //remove all path_to_category - Iterator it = hmap.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - Vector u = StringUtils.parseData(key); - String code_1 = (String) u.elementAt(1); - if (!category_vec.contains(code_1)) { - hmap2.put(key, (Path) hmap.get(key)); - } - } - } - HashMap hmap3 = new HashMap(); - //code_0 --> List - Iterator it = hmap2.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - Vector u = StringUtils.parseData(key); - String code_0 = (String) u.elementAt(0); - Path path = (Path) hmap2.get(key); - List path_list = new ArrayList(); - if (hmap3.containsKey(code_0)) { - path_list = (List) hmap3.get(code_0); - } - path_list.add(path); - hmap3.put(code_0, path_list); - } - List paths_list = new ArrayList(); - it = hmap3.keySet().iterator(); - while (it.hasNext()) { - String code_0 = (String) it.next(); - List path_list = (List) hmap3.get(code_0); - Paths paths = new Paths(path_list); - paths_list.add(paths); - } - return paths_list; - } - - - public static String dumpMainTypeHierarchyCodes() { - Vector codes = new Vector(); - Vector w = (Vector) main_type_hierarchy_data.clone(); - Vector v = new Vector(); - for (int i=0; i 0) { - for (int i=0; i parent_child_vec = mthd.get_parent_child_vec(named_graph); - Vector v1 = mthd.getDiseaseIsStageSourceCodes(named_graph); - Vector v2 = mthd.getDiseaseIsGradeSourceCodes(named_graph); - HashMap stageConceptHashMap = mthd.generateStageConceptHashMap(v1); - HashMap gradeConceptHashMap = mthd.generateGradeConceptHashMap(v2); - - HashSet ctrp_biomarker_set = mthd.get_ctrp_biomarker_set(); - HashSet ctrp_reference_gene_set = mthd.get_ctrp_reference_gene_set(); - - MainTypeHierarchy mth = new MainTypeHierarchy(ncit_version, parent_child_vec, main_type_set, broad_category_vec, - stageConceptHashMap, gradeConceptHashMap, ctrp_biomarker_set, ctrp_reference_gene_set); - Vector mth_vec = mth.generate_main_type_hierarchy(); - Utils.saveToFile("MainTypeHierarchy_" + StringUtils.getToday() + ".txt", mth_vec); - - //AIDS-Related Primary Central Nervous System Lymphoma (C8284) - String code = "C8284"; - System.out.println("get_ctrp_response: " + code); - Vector v = mth.findMainMenuAncestors(code); - StringUtils.dumpVector("findMainMenuAncestors", v); - - String outputfile = mth.DISEASES_AND_DISORDERS_CODE + "_multiple.txt"; - PrintWriter pw = null; - try { - pw = new PrintWriter(outputfile, "UTF-8"); - Vector codes = mth.getTransitiveClosure(mth.DISEASES_AND_DISORDERS_CODE); - mth.searchMultiplePaths(pw, codes); - } catch (Exception ex) { - - } finally { - try { - pw.close(); - System.out.println("Output file " + outputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - System.out.println("Multiple cases: " + mth.multiple_count); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchyData.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchyData.java deleted file mode 100644 index 2fdea15da..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchyData.java +++ /dev/null @@ -1,309 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; - -public class MainTypeHierarchyData { - static String DISEASES_AND_DISORDERS_CODE = "C2991"; - static String CTS_API_Disease_Broad_Category_Terminology_Code = "C138189"; - static String CTS_API_Disease_Main_Type_Terminology_Code = "C138190"; - - static String CTRP_BIOMARKER_TERMINOLOGY_CODE = "C142799"; - static String CTRP_REFERENCE_GENE_TERMINOLOGY_CODE = "C142801"; - - String[] disease_main_types = null; - String[] disease_broad_categories = null; - - String[] ctrp_biomarkers = null; - String[] ctrp_reference_genes = null; - - HashSet main_type_set = null; - HashSet ctrp_biomarker_set = null; - HashSet ctrp_reference_gene_set = null; - - Vector broad_category_vec = null; - ArrayList broad_category_list = null; - OWLSPARQLUtils owlSPARQLUtils = null; - HierarchyHelper hh = null; - - Vector parent_child_vec = null; - Vector disease_is_stage_code_vec = null; - Vector disease_is_grade_code_vec = null; - String serviceUrl = null; - String version = null; - String named_graph = null; - - public MainTypeHierarchyData(String serviceUrl, String named_graph, String username, String password) { - owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - this.named_graph = named_graph; - owlSPARQLUtils.set_named_graph(named_graph); - this.disease_main_types = owlSPARQLUtils.get_concept_in_subset_codes(named_graph, CTS_API_Disease_Main_Type_Terminology_Code); - System.out.println("disease_main_types: "+ disease_main_types.length); - - this.disease_broad_categories = owlSPARQLUtils.get_concept_in_subset_codes(named_graph, CTS_API_Disease_Broad_Category_Terminology_Code); - System.out.println("disease_broad_categories: "+ disease_broad_categories.length); - - this.ctrp_biomarkers = owlSPARQLUtils.get_concept_in_subset_codes(named_graph, CTRP_BIOMARKER_TERMINOLOGY_CODE); - System.out.println("ctrp_biomarkers: "+ ctrp_biomarkers.length); - - this.ctrp_reference_genes = owlSPARQLUtils.get_concept_in_subset_codes(named_graph, CTRP_REFERENCE_GENE_TERMINOLOGY_CODE); - System.out.println("ctrp_reference_genes: "+ ctrp_reference_genes.length); - - main_type_set = new HashSet(); - for (int i=0; i(); - broad_category_vec = new Vector(); - for (int i=0; i get_broad_category_list() { - return this.broad_category_list; - } - - public Vector get_broad_category_vec() { - return this.broad_category_vec; - } - - public Vector getHierarchicalRelationships(String named_graph) { - String query = construct_get_hierarchical_relationships(named_graph); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public Vector getHierarchicalRelationships(String named_graph, boolean raw_data) { - Vector v = owlSPARQLUtils.executeQuery(construct_get_hierarchical_relationships(named_graph)); - if (raw_data) return v; - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - - public String construct_get_hierarchical_relationships(String named_graph) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - //buf.append("select distinct ?x_label ?x_code ?y_label ?y_code").append("\n"); - //buf.append("select distinct ?x_code ?y_code").append("\n"); - buf.append("select distinct ?y_label ?y_code ?x_label ?x_code ").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?y a owl:Class .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x (rdfs:subClassOf|owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first) ?y . ").append("\n"); - buf.append(" } UNION {").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?y a owl:Class .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x (rdfs:subClassOf/owl:intersectionOf/rdf:rest*/rdf:first) ?y . ").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public Vector generate_parent_child_vec(String named_graph) { - Vector parent_child_vec = null; - File f = new File("parent_child.txt"); - if(f.exists() && !f.isDirectory()) { - parent_child_vec = Utils.readFile("parent_child.txt"); - } else { - Vector parent_child_data = owlSPARQLUtils.getHierarchicalRelationships(named_graph); - Utils.saveToFile("parent_child.txt", parent_child_vec); - } - return parent_child_vec; - } - - public Vector generateDiseaseIsStageSourceCodes(String named_graph) { - Vector v1 = owlSPARQLUtils.getDiseaseIsStageSourceCodes(named_graph); - //v1 = new ParserUtils().getResponseValues(v1); - //v1 = new SortUtils().quickSort(v1); - return v1; - } - - public Vector generateDiseaseIsGradeSourceCodes(String named_graph) { - Vector v2 = owlSPARQLUtils.getDiseaseIsGradeSourceCodes(named_graph); - //v2 = new ParserUtils().getResponseValues(v2); - //v2 = new SortUtils().quickSort(v2); - return v2; - } - - public Vector get_parent_child_vec(String named_graph) { - if (this.named_graph.compareTo(named_graph) != 0) { - return generate_parent_child_vec(named_graph); - } - return parent_child_vec; - } - - public Vector getDiseaseIsStageSourceCodes(String named_graph) { - if (this.named_graph.compareTo(named_graph) != 0) { - return getDiseaseIsStageSourceCodes(named_graph); - } - return disease_is_stage_code_vec; - } - - public Vector getDiseaseIsGradeSourceCodes(String named_graph) { - if (this.named_graph.compareTo(named_graph) != 0) { - return getDiseaseIsGradeSourceCodes(named_graph); - } - return disease_is_grade_code_vec; - } - - public HashMap generateStageConceptHashMap(Vector stageConcepts) { - HashMap stageConceptHashMap = new HashMap(); - for (int i=0; i v = mthd.get_parent_child_vec(named_graph); - System.out.println("get_parent_child_vec: " + v.size()); - - Vector v1 = mthd.getDiseaseIsStageSourceCodes(named_graph); - StringUtils.dumpVector("getDiseaseIsStageSourceCodes", v1); - - Vector v2 = mthd.getDiseaseIsGradeSourceCodes(named_graph); - StringUtils.dumpVector("getDiseaseIsGradeSourceCodes", v2); - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchyRunner.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchyRunner.java deleted file mode 100644 index 1b50ff170..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MainTypeHierarchyRunner.java +++ /dev/null @@ -1,107 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; - -public class MainTypeHierarchyRunner { - - public static void countColumn(String filename, int column) { - int knt = 0; - - Vector v = gov.nih.nci.evs.restapi.util.Utils.readFile(filename); - int total = v.size()-1; - - String firstLine = (String) v.elementAt(0); - Vector u = gov.nih.nci.evs.restapi.util.StringUtils.parseData(firstLine, '\t'); - String columnLabel = (String) u.elementAt(column); - - for (int i=1; i parent_child_vec = mthd.get_parent_child_vec(named_graph); - - System.out.println( "parent_child_vec: " + parent_child_vec.size()); - - Vector v1 = mthd.getDiseaseIsStageSourceCodes(named_graph); - Vector v2 = mthd.getDiseaseIsGradeSourceCodes(named_graph); - HashMap stageConceptHashMap = mthd.generateStageConceptHashMap(v1); - HashMap gradeConceptHashMap = mthd.generateGradeConceptHashMap(v2); - - HashSet ctrp_biomarker_set = mthd.get_ctrp_biomarker_set(); - HashSet ctrp_reference_gene_set = mthd.get_ctrp_reference_gene_set(); - - -System.out.println("====================== Instantiating MainTypeHierarchy ======================"); - - MainTypeHierarchy mth = new MainTypeHierarchy(ncit_version, parent_child_vec, main_type_set, broad_category_vec, - stageConceptHashMap, gradeConceptHashMap, ctrp_biomarker_set, ctrp_reference_gene_set); -System.out.println("main_type_set: " + main_type_set.size()); - - Vector mth_vec = mth.generate_main_type_hierarchy(); - Utils.saveToFile("MainTypeHierarchy_" + StringUtils.getToday() + ".txt", mth_vec); - - String outputfile = mth.DISEASES_AND_DISORDERS_CODE + ".txt"; - try { - Vector codes = mth.getTransitiveClosure(mth.DISEASES_AND_DISORDERS_CODE); - boolean flatFormat = true; - mth.run(codes, outputfile, flatFormat); - } catch (Exception ex) { - ex.printStackTrace(); - } - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MapsToReportWriter.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MapsToReportWriter.java deleted file mode 100644 index b04c85575..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/MapsToReportWriter.java +++ /dev/null @@ -1,452 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.codec.binary.Base64; -import org.json.*; - - -public class MapsToReportWriter { - - public static String MAPS_TO_HEADING = "Subset Code|Subset Name|Concept Code|NCIt Preferred Term|Relationship To Target|Target Code|Target Term|Target Term Type|Target Terminology|Target Terminology Version"; - - public static String MAPS_TO = "Maps_To"; - public static int NUMER_OF_FIELDS = 8; - JSONUtils jsonUtils = null; - HTTPUtils httpUtils = null; - String named_graph = null; - String prefixes = null; - String serviceUrl = null; - String named_graph_id = ":NHC0"; - String BASE_URI = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl"; - String OWLFILE = "ThesaurusInferred_forTS.owl"; - - OWLSPARQLUtils owlSPARQLUtils = null; - MetadataUtils metadataUtils = null; - String namedGraph = null; - - String username = null; - String password = null; - - Vector raw_maps_to_data = null; - Vector mapsToEntries = null; - String ncit_version = null; - HashSet retired = null; - - public MapsToReportWriter(String serviceUrl, String namedGraph, String username, String password) { - this.serviceUrl = serviceUrl; - this.namedGraph = namedGraph; - this.username = username; - this.password = password; - - System.out.println("serviceUrl: " + serviceUrl); - System.out.println("namedGraph: " + namedGraph); - - owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - if (owlSPARQLUtils == null) { - System.out.println("WARNING: unable to instantiate owlSPARQLUtils???"); - } - - long ms = System.currentTimeMillis(); - owlSPARQLUtils.set_named_graph(namedGraph); - Vector concept_status_vec = owlSPARQLUtils.getPropertyValues(namedGraph, "Concept_Status"); - if (concept_status_vec == null) { - System.out.println("namedGraph: " + namedGraph); - System.out.println("WARNING: concept_status_vec == null???"); - } else { - //concept_status_vec = new ParserUtils().getResponseValues(concept_status_vec); - retired = new HashSet(); - for (int i=0; iNCIt_Properties_and_Relationships"); - pw.println("Supported Properties"); - pw.println("
Name"); - pw.println("Code"); - pw.println(""); - Vector v = owlSPARQLUtils.getSupportedProperties(named_graph); - for (int i=0; i"); - pw.println("
"); - - pw.println("Supported Roles"); - pw.println("
Name"); - pw.println("Code"); - pw.println(""); - v = owlSPARQLUtils.getSupportedRoles(named_graph); - for (int i=0; i"); - pw.println("
"); - - pw.println("Supported Associations"); - pw.println("
Name"); - pw.println("Code"); - pw.println(""); - v = owlSPARQLUtils.getSupportedAssociations(named_graph); - for (int i=0; i"); - pw.println("
"); - - pw.println("Supported Property Qualifiers"); - pw.println("
Property Name"); - pw.println("Property Code"); - pw.println("Qualifier Name"); - pw.println("QualifierCode"); - pw.println(""); - v = owlSPARQLUtils.getSupportedPropertyQualifiers(named_graph); - for (int i=0; i"); - pw.println("
"); - - pw.println("
(Source: NCI Thesaurus, version " + this.version + ")"); - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - try { - pw.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - } - - public static void main(String[] args) { - String serviceUrl = args[0]; - String named_graph = args[1]; - String username = args[2]; - String password = args[3]; - MetadataGenerator metadataGenerator = new MetadataGenerator(serviceUrl, named_graph, username, password); - String filename = "metadata.txt"; - metadataGenerator.generate(filename); - metadataGenerator.generateHTML(filename); - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/NCItQA.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/NCItQA.java deleted file mode 100644 index c943db70a..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/NCItQA.java +++ /dev/null @@ -1,906 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.model.*; -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import java.nio.charset.Charset; -import java.io.PrintWriter; - -public class NCItQA { - //ThesaurusInferred_forTS - public static String NCIT_OWL = "ThesaurusInferred_forTS.owl"; - public static String SEMANTIC_TYPE_URL = "https://metamap.nlm.nih.gov/Docs/SemanticTypes_2018AB.txt"; - public static String UMLS_SEMANTIC_TYPE_URL = "https://www.nlm.nih.gov/research/umls/META3_current_semantic_types.html"; - - public static String PROPERTY_FILE = "properties.txt"; - public static String ROLE_FILE = "roles.txt"; - public static String SEMANTIC_TYPE_FILE = "semantictypes.txt"; - public static String FULLSYN_FILE = "FULLSYN.txt"; - - public static String OBJECT_PROPERTY_FILE = "objectProperties.txt"; - public static String DEPRECATED_FILE = "deprecated.txt"; - public static String ANNOTATION_PROPERTY_FILE = "annotationProperties.txt"; - - public static String SEMANTIC_TYPE_PROP_CODE = "P106"; - public static String PREFERRED_NAME_PROP_CODE = "P108"; - public static String CONCEPT_STATUS_PROP_CODE = "P310"; - - - - public Vector semantic_types = null; - Vector objectProperties = null; - Vector association_vec = null; - - Vector deprecated_vec = null; - Vector property_vec = null; - Vector role_vec = null; - private PrintWriter pw = null; - - HashMap code2LabelMap = null;//getCode2LabelMap - HashMap roleCode2LabelMap = null; - - public static String AXIOM_FILE = "axioms.txt"; - - public HashMap concept_status_map = null; - public String owlfile = null; - OWLScanner owlScanner = null; - List full_syn_list = null; - List active_full_syn_list = null; - - Vector annotationProperties = null; - public boolean saveOption = false; - - public NCItQA() { - - } - - public NCItQA(String owlfile) { - this.owlfile = owlfile; - //initialize(); - } - - public void setSaveOption(boolean saveOption) { - this.saveOption = saveOption; - } - - public void initialize() { - if (owlfile == null) { - if (FileUtils.fileExists(NCIT_OWL)) { - System.out.println(NCIT_OWL + " exists."); - } else { - System.out.println(NCIT_OWL + " does not exist."); - NCItDownload.download(); - Vector files = NCItDownload.listFilesInDirectory(); - Utils.dumpVector("listFilesInDirectory", files); - } - this.owlfile = NCIT_OWL; - } - - owlScanner = new OWLScanner(NCIT_OWL); - if (FileUtils.fileExists(FULLSYN_FILE)) { - System.out.println(FULLSYN_FILE + " exists."); - Vector w = Utils.readFile(FULLSYN_FILE); - full_syn_list = new AxiomUtils().getSynonyms(w); - } else { - full_syn_list = extractFULLSyns(); - } - - semantic_types = owlScanner.extractSemanticTypes(owlScanner.get_owl_vec()); - - property_vec = null; - if (!FileUtils.fileExists(PROPERTY_FILE)) { - property_vec = owlScanner.extractProperties(owlScanner.get_owl_vec()); - if (saveOption) Utils.saveToFile(PROPERTY_FILE, property_vec); - } else { - property_vec = Utils.readFile(PROPERTY_FILE); - } - - Vector w = null; - if (!FileUtils.fileExists(ROLE_FILE)) { - role_vec = owlScanner.extractOWLRestrictions(owlScanner.get_owl_vec()); - if (saveOption) Utils.saveToFile(ROLE_FILE, role_vec); - } else { - role_vec = Utils.readFile(ROLE_FILE); - } - - if (!FileUtils.fileExists(OBJECT_PROPERTY_FILE)) { - objectProperties = owlScanner.extractObjectProperties(owlScanner.get_owl_vec()); - if (saveOption) Utils.saveToFile(OBJECT_PROPERTY_FILE, objectProperties); - } else { - objectProperties = Utils.readFile(OBJECT_PROPERTY_FILE); - } - - roleCode2LabelMap = new HashMap(); - for (int i=0; i 0) { - pw.println("WARNING: multiple Preferred names detected for " + code); - error_count++; - } - v.add(name); - pt_map.put(code, v); - } - } - String methodName = "QA_PreferredNames"; - dump_QA_error_counts(pw, methodName, error_count); - } - - public void QA_NCIPT(PrintWriter pw) { - pw.println("\n5. Verify exactly one NCI PT per concept."); - int num_errors = 0; - //System.out.println("active_full_syn_list: " + active_full_syn_list.size()); - HashMap hmap = new HashMap(); - for (int i=0; i 0) { - key = syn.getTermName() + "|" + syn.getTermGroup() + "|" + syn.getTermSource() + "|" + syn.getCode(); - String sourceCode = syn.getSourceCode(); - if (sourceCode == null) { - sourceCode = "null"; - } - key = key + "|" + sourceCode; - Vector v = new Vector(); - if (hmap.containsKey(key)) { - -pw.println("JSON: " + syn.toJson()); - -System.out.println("KEY: " + key); -pw.println("KEY: " + key); - - v = (Vector) hmap.get(key); - num_errors++; - for (int k=0; k 0) { - key = syn.getTermName() + "|" + syn.getTermGroup() + "|" + syn.getTermSource() + "|" + syn.getSourceCode(); - String subSourceName = syn.getSubSourceName(); - if (subSourceName == null) { - subSourceName = "null"; - } - key = key + "|" + subSourceName; - - Vector v = new Vector(); - if (hmap.containsKey(key)) { - //System.out.println("\nWARNING: Duplicated Atoms in multipe concepts identified."); - v = (Vector) hmap.get(key); - for (int k=0; k") != -1) { - break; - } - - if (t.indexOf("") != -1) { - switch_off = true; - } - if (t.indexOf("") != -1) { - switch_off = false; - } - - if (t.indexOf("")) { - int n = t.lastIndexOf("#"); - t = t.substring(n, t.length()); - n = t.lastIndexOf(" "); - classId = t.substring(1, n); - if (istart0) { - istart = true; - } - } - if (istart) { - t = t.trim(); - if (t.startsWith("<") && t.indexOf("rdf:resource=") != -1 && t.indexOf("owl:") == -1 && t.indexOf("rdfs:subClassOf") == -1) { - int n = t.indexOf(">"); - if (n != -1) { - String s = t.substring(1, n-1); - if (!switch_off) { - w.add(classId + "|" + new OWLScanner().parseProperty(t)); - } - } - } else if (t.startsWith("<") && t.indexOf("rdf:resource=") == -1 && t.indexOf("owl:") == -1 && t.indexOf("rdfs:subClassOf") == -1 - && t.indexOf("rdf:Description") == -1 && t.indexOf("rdfs:subClassOf") == -1) { - int n = t.indexOf(">"); - if (n != -1) { - String s = t.substring(1, n-1); - if (!switch_off) { - w.add(classId + "|" + new OWLScanner().parseProperty(t)); - } - } - } - } - } - return w; - } - - public void QA_SemanticTypes(PrintWriter pw) { - pw.println("\n4. Invalid STYs."); - int number_of_errors = 0; - for (int i=0; i " + - targetLabel + " (" + targetCode + ")"; - } - - public void QA_conflicting_RELAs(PrintWriter pw) { - pw.println("\n15. Conflicting RELAs between same concept pairs."); - - int num_errors = 0; - HashSet hset = new HashSet(); - for (int i=0; i 0) { - owlfile = (String) args[0]; - } - if (args.length > 1) { - String saveOptionStr = (String) args[1]; - if (saveOptionStr.compareTo("true") == 0) { - saveOption = true; - } - } - NCItQA ncitQA = new NCItQA(owlfile); - ncitQA.setSaveOption(saveOption); - ncitQA.initialize(); - ncitQA.runQA(); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/NCItWikiUtils.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/NCItWikiUtils.java deleted file mode 100644 index 5349bb1aa..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/NCItWikiUtils.java +++ /dev/null @@ -1,325 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.config.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.codec.binary.Base64; -import java.nio.charset.Charset; - -import java.time.Duration; -/** - * - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. -6 * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class NCItWikiUtils { - String restURL = null; - String namedGraph = null; - String username = null; - String password = null; - MetadataUtils metadataUtils = null; - OWLSPARQLUtils owlSPARQLUtils = null; - HashSet retired_concepts = new HashSet(); - - public NCItWikiUtils(String restURL, String namedGraph, String username, String password) { - this.restURL = restURL; - this.namedGraph = namedGraph; - this.username = username; - this.password = password; - -System.out.println( "restURL: " + restURL); -System.out.println( "namedGraph: " + namedGraph); -System.out.println( "username: " + username); -System.out.println( "password: " + password); - - metadataUtils = new MetadataUtils(restURL, username, password); - owlSPARQLUtils = new OWLSPARQLUtils(restURL, username, password); - owlSPARQLUtils.set_named_graph(namedGraph); - - String ncit_version = getVersion(); - System.out.println(ncit_version); - - String property_name = "Concept_Status"; - String property_value = "Retired_Concept"; - Vector w = findConceptsWithPropertyMatching(namedGraph, property_name, property_value); - for (int i=0; i").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p2 a owl:AnnotationProperty .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?a1 a owl:Axiom .").append("\n"); - buf.append(" ?a1 owl:annotatedSource ?x .").append("\n"); - buf.append(" ?a1 owl:annotatedProperty ?p2 .").append("\n"); - buf.append(" ?p2 :NHC0 \"P90\"^^xsd:string .").append("\n"); - buf.append(" ?a1 owl:annotatedTarget ?a_target .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?q1 :NHC0 \"P384\"^^xsd:string .").append("\n"); - buf.append(" ?q1 rdfs:label ?q1_label .").append("\n"); - buf.append(" ?a1 ?q1 ?q1_value .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?q2 :NHC0 \"P383\"^^xsd:string . ").append("\n"); - buf.append(" ?q2 rdfs:label ?q2_label . ").append("\n"); - buf.append(" ?a1 ?q2 ?q2_value .").append("\n"); - buf.append("").append("\n"); - buf.append("}").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public Vector getAxiomData(String named_graph) { - String query = cnstruct_get_axiom_data(named_graph); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - //v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - - public String construct_get_contributing_source(String named_graph) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x1_label ?x1_code ?p_label ?p_value ").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x1 a owl:Class .").append("\n"); - buf.append(" ?x1 :NHC0 ?x1_code .").append("\n"); - buf.append(" ?x1 rdfs:label ?x1_label .").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ?x1 ?p ?p_value .").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p :NHC0 \"P322\"^^xsd:string .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append("}").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - - public Vector getContributingSource(String named_graph) { - - System.out.println("************************ getContributingSource "); - String query = construct_get_contributing_source(named_graph); - Vector v = owlSPARQLUtils.executeQuery(query); - - if (v == null) { - //System.out.println("************************ v=null??? "); - return null; - } - //System.out.println("************************ v: " + v.size()); - //Utils.dumpVector("getContributingSource", v); - - if (v.size() == 0) return v; - //???????????????????????????????????????????????????????????????? - //v = new ParserUtils().getResponseValues(v); - - Utils.saveToFile("debug_cs.txt", v); - - return new SortUtils().quickSort(v); - } - - public String getVersion() { - Vector v = owlSPARQLUtils.get_ontology_info(namedGraph); - Utils.dumpVector("get_ncit_version", v); - String line = (String) v.elementAt(0); - Vector u = StringUtils.parseData(line, '|'); - String ncit_version = (String) u.elementAt(0); - System.out.println(ncit_version); - return ncit_version; - } - -//Activity|C43431|Contributing_Source|BRIDG - public Vector removedRetired(Vector w) { - Vector v = new Vector(); - for (int i=0; i - * Copyright 2020, MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class OWLDiffUtils { - //OWLSPARQLUtils owlSPARQLUtils = null; - //String serviceUrl = null; - //String namedGraph = null; - Vector properties = null; - Vector qualifiers = null; - HashMap qualifierMap = null; - HashMap propertyMap = null; - Vector propertyCountVec = null; - String owlfile = null; - Vector owl_vec = null; - static PrintWriter pw = null; - - public OWLDiffUtils() { - - } - - public static boolean fileExists(String filename) { - File file = new File(filename); - return file.exists(); - } - - public static void dumpHashSet(HashSet hset) { - Iterator it = hset.iterator(); - while (it.hasNext()) { - String t = (String) it.next(); - System.out.println(t); - } - } - - public static Vector hashSet2Vector(HashSet hset) { - Vector w = new Vector(); - Iterator it = hset.iterator(); - while (it.hasNext()) { - String t = (String) it.next(); - w.add(t); - } - return w; - } - - public static void compute(String owlfile1, String owlfile2) { - long ms = System.currentTimeMillis(); - //String owlfile = "ThesaurusInferred_20.04d.owl"; - System.out.println("owlfile1: " + owlfile1); - OWLScanner owlScanner = new OWLScanner(owlfile1); - Vector w1 = owlScanner.getAllOWLClassHashCode(); - String hashfile_1 = "hash_" + owlfile1; - Utils.saveToFile(hashfile_1, w1); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - owlScanner.clear(); - - System.out.println("owlfile2: " + owlfile2); - ms = System.currentTimeMillis(); - owlScanner = new OWLScanner(owlfile2); - Vector w2 = owlScanner.getAllOWLClassHashCode(); - String hashfile_2 = "hash_" + owlfile2; - Utils.saveToFile(hashfile_2, w2); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - owlScanner.clear(); - - //w2 versus w1 - ms = System.currentTimeMillis(); - w2.removeAll(w1); - w1.clear(); - String hash_2_rm_1 = "hash_2_rm_1.txt"; - Utils.saveToFile(hash_2_rm_1, w2); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - - w1 = Utils.readFile(hashfile_1); - w2 = Utils.readFile(hashfile_2); - w1.removeAll(w2); - w2.clear(); - String hash_1_rm_2 = "hash_1_rm_2.txt"; - Utils.saveToFile(hash_1_rm_2, w1); - System.out.println("RM Total run time (ms): " + (System.currentTimeMillis() - ms)); - - ms = System.currentTimeMillis(); - Vector hash_2_rm_1_vec = Utils.readFile(hash_2_rm_1); - System.out.println("hash_2_rm_1_vec: " + hash_2_rm_1_vec.size()); - Vector codes = new Vector(); - for (int i=0; i - * Copyright 2020, MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class OWLDiffUtilsRunner { - - public OWLDiffUtilsRunner() { - - } - - public static void clear(String outfile1, String outfile2) { - Utils.deleteFile("hash_1_rm_2.txt"); - Utils.deleteFile("hash_2_rm_1.txt"); - Utils.deleteFile("hash_" + outfile1); - Utils.deleteFile("hash_" + outfile2); - Utils.deleteFile("partial_" + outfile1); - Utils.deleteFile("partial_" + outfile2); - } - - public static void main(String[] args) { - long ms = System.currentTimeMillis(); - /* - String version1 = args[0]; - String owlfile1 = FTPUtils.downloadNCItInferredOWL(version1); - System.out.println("owlfile1: " + owlfile1); - - String version2 = args[1]; - String owlfile2 = FTPUtils.downloadNCItInferredOWL(version2); - System.out.println("owlfile2: " + owlfile2); - */ - String owlfile1 = args[0]; - String owlfile2 = args[1]; - - System.out.println(owlfile1); - System.out.println(owlfile2); - - String diff_file = OWLDiffUtils.run(owlfile1, owlfile2); - System.out.println("Total diff run time (ms): " + (System.currentTimeMillis() - ms)); - - HistoryUtils hist = new HistoryUtils(owlfile2, diff_file); - hist.run(); - - clear(owlfile1, owlfile2); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/OWLDisjointWithAnalyzer.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/OWLDisjointWithAnalyzer.java deleted file mode 100644 index fe882021d..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/OWLDisjointWithAnalyzer.java +++ /dev/null @@ -1,164 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; - -import java.io.*; -import java.util.*; - - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class OWLDisjointWithAnalyzer { - - HierarchyHelper hh = null; - static int CODE_ONLY = 1; - static int LABEL_AND_CODE = 2; - static int LABEL_WITH_CODE_IN_BRACKET = 3; - - - public OWLDisjointWithAnalyzer() { - } - - public OWLDisjointWithAnalyzer(Vector v) { - hh = new HierarchyHelper(v); - } - - public HierarchyHelper getHierarchyHelper() { - return this.hh; - } - - public Vector getRoots(int format) { - Vector roots = hh.getRoots(); - Vector w = new Vector(); - for (int i=0; i [" + "owl:disjointWith" + "} --> " + label_2 + " (" + c2 + ")"); - } - output_vec = new SortUtils().quickSort(output_vec); - branch_vec.addAll(output_vec); - return branch_vec; - } - - public static void main(String[] args) { - String owlfile = "20.05d_disjoint-test-export_200601.owl"; - Vector output_vec = test(owlfile); - Utils.saveToFile("output_vec_1.txt", output_vec); - - owlfile = "ThesaurusInferred_forTS.owl"; - output_vec = test(owlfile); - Utils.saveToFile("output_vec_2.txt", output_vec); - - } - -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/PostOWLScrubber.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/PostOWLScrubber.java deleted file mode 100644 index 703b090d1..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/PostOWLScrubber.java +++ /dev/null @@ -1,558 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.text.*; - -/** - * - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class PostOWLScrubber { - String owlfile = null; - Vector owl_vec = null; - Vector disjointwith_classes = null; - HashMap subclassOfHashMap = null; - - static String NCIT_NAMESPACE_TARGET = ""; - boolean istart = false; - for (int i=0; i"; - } - - public boolean hasOwlDisjointWith(Vector v) { - for (int i=0; i 0) { - if (hasOwlDisjointWith(v)) { - class_line = getClassLine(v); - String code = getCode(class_line); - w.add(code); - } - } - v = new Vector(); - istart = true; - } else if (istart && line.indexOf(OWL_CLS_TARGET) != -1 && line.indexOf("enum") == -1) { - istart = false; - } - if (istart) { - v.add(line); - } - i++; - } - return w; - } - - public String getCode(String line) { - int n = line.lastIndexOf("#"); - String t = line.substring(n+1, line.length()); - n = t.indexOf("\""); - t = t.substring(0, n); - return t; - } - - public void getModifiedClasses(PrintWriter pw) { - for (int i=0; i 0) { - if (hasOwlDisjointWith(v)) { - class_line = getClassLine(v); - String code = getCode(class_line); - v = removeOwlDisjointWith(v); - if (!subclassOfHashMap.containsKey(code)) { - v = addOwlDisjointWith(v, code); - } - for (int k=0; k 0) { - if (hasOwlDisjointWith(v)) { - class_line = getClassLine(v); - String code = getCode(class_line); - v = removeOwlDisjointWith(v); - if (!subclassOfHashMap.containsKey(code)) { - v = addOwlDisjointWith(v, code); - } - for (int k=0; k"); - } - - - public static void main(String[] args) { - long ms = System.currentTimeMillis(); - String owlfile = args[0]; - PostOWLScrubber postOWLScrubber = new PostOWLScrubber(owlfile); - int n = owlfile.lastIndexOf("."); - String outputfile = owlfile.substring(0, n) + "_" + getToday() + ".owl"; - postOWLScrubber.run(outputfile); - String changefile = "owlDisjointWith_mod_" + getToday() + ".txt"; - postOWLScrubber.getModifiedClasses(changefile); - - -/* - (1) Abnormal Cell (C12913) - (2) Activity (C43431) - (3) Anatomic Structure, System, or Substance (C12219) - (4) Biochemical Pathway (C20633) - (5) Biological Process (C17828) - (6) Chemotherapy Regimen or Agent Combination (C12218) - (7) Conceptual Entity (C20181) - (8) Diagnostic or Prognostic Factor (C20047) - (9) Diagnostic, Therapeutic, or Research Equipment (C19238) - (10) Disease, Disorder or Finding (C7057) - (11) Drug, Food, Chemical or Biomedical Material (C1908) - (12) Experimental Organism Anatomical Concept (C22188) - (13) Experimental Organism Diagnosis (C22187) - (14) Gene (C16612) - (15) Gene Product (C26548) - (16) Manufactured Object (C97325) - (17) Molecular Abnormality (C3910) - (18) Organism (C14250) - (19) Property or Attribute (C20189) - (20) Retired Concept (C28428) - -*/ - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/PropertyQAProcessor.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/PropertyQAProcessor.java deleted file mode 100644 index 6f7139f04..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/PropertyQAProcessor.java +++ /dev/null @@ -1,339 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -//import java.math.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.codec.binary.Base64; -import org.json.*; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class PropertyQAProcessor { - String named_graph = null; - String serviceUrl = null; - - private OWLSPARQLUtils owlSPARQLUtils = null; - private String username = null; - private String password = null; - private String namedGraph = null; - private static String ncit_unii_txt_file = "ncit_unii.txt"; - private HashMap code2LabelMap = null; - private HashMap code2PropertyMap = null; - private String property_file = null; - private HashMap ncit_code2PropertyMap = null; - private Vector supported_properties = null; - private HashMap supported_properties_hmap = null; - private String propertyName = null; - - public PropertyQAProcessor() { - - } - - - public PropertyQAProcessor(String serviceUrl, String namedGraph) { - this.serviceUrl = serviceUrl; - this.namedGraph = namedGraph; - System.out.println("serviceUrl: " + this.serviceUrl); - System.out.println("namedGraph: " + this.namedGraph); - owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, null, null); - owlSPARQLUtils.set_named_graph(this.namedGraph); - new MetadataUtils(serviceUrl).dumpNameVersion2NamedGraphMap(); - supported_properties = owlSPARQLUtils.getSupportedProperties(this.namedGraph); - supported_properties_hmap = gov.nih.nci.evs.restapi.util.StringUtils.constructHashMap(supported_properties, 0, 1, '|'); - } - - private void initialize(String propertyName) { - if (!supported_properties_hmap.containsKey(propertyName)) { - System.out.println("Unidentifiable property name: " + propertyName + ". Program aborts."); - System.exit(1); - } - this.propertyName = propertyName; - property_file = propertyName + ".txt"; - code2LabelMap = new HashMap(); - code2PropertyMap = new HashMap(); - - // single valued - Vector v = null; - if (!new File(property_file).exists()) { - System.out.println(property_file + " does not exist."); - Vector w = owlSPARQLUtils.findConceptsWithProperty(this.namedGraph, propertyName); - Utils.saveToFile(property_file, w); - } - v = Utils.readFile(property_file); - System.out.println("Number of records in " + property_file + ": " + v.size()); - code2LabelMap = gov.nih.nci.evs.restapi.util.StringUtils.constructHashMap(v, 1, 0, '|'); - // use multiple valued - ncit_code2PropertyMap = gov.nih.nci.evs.restapi.util.StringUtils.constructMultiValuedHashMap(v, 1, 3, '|'); - - Iterator it = ncit_code2PropertyMap.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - if (!code2LabelMap.containsKey(key)) { - String value = (String) ncit_code2PropertyMap.get(key); - code2LabelMap.put(key, value); - } - } - - System.out.println("Number of records in " + property_file + ": " + v.size()); - } - - public static int countDelimiters(String line, char delim) { - int knt = 0; - for (int i=0; i 0 && w == null) { - if (values != null && values.length() > 0) { - for (int k=0; k - * Copyright 2020, MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIT - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history Initial implementation kim.ong@ngc.com - * - */ - - -public class SRSDownload { - - public static void download(String uri, String outputfile) { - try (BufferedInputStream in = new BufferedInputStream(new URL(uri).openStream()); - FileOutputStream fileOutputStream = new FileOutputStream(outputfile)) { - byte dataBuffer[] = new byte[1024]; - int bytesRead; - while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { - fileOutputStream.write(dataBuffer, 0, bytesRead); - } - } catch (IOException e) { - // handle exception - } - } - - private static void unzip(String zipFilePath, String destDir) { - File dir = new File(destDir); - // create output directory if it doesn't exist - if(!dir.exists()) dir.mkdirs(); - FileInputStream fis; - //buffer for read and write data to file - byte[] buffer = new byte[1024]; - try { - fis = new FileInputStream(zipFilePath); - ZipInputStream zis = new ZipInputStream(fis); - ZipEntry ze = zis.getNextEntry(); - while(ze != null){ - String fileName = ze.getName(); - File newFile = new File(destDir + File.separator + fileName); - System.out.println("Unzipping to "+newFile.getAbsolutePath()); - //create directories for sub directories in zip - new File(newFile.getParent()).mkdirs(); - FileOutputStream fos = new FileOutputStream(newFile); - int len; - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len); - } - fos.close(); - //close this ZipEntry - zis.closeEntry(); - ze = zis.getNextEntry(); - } - //close last ZipEntry - zis.closeEntry(); - zis.close(); - fis.close(); - } catch (IOException e) { - e.printStackTrace(); - } - - } - - public static Vector listUNIITextFilesInDirectory() { - String dirName = null; - return listUNIITextFilesInDirectory(dirName); - } - - - public static Vector listUNIITextFilesInDirectory(String dirName) { - Vector v = new Vector(); - if (dirName == null) { - dirName = System.getProperty("user.dir");; - } - File f = new File(dirName); - String[] pathnames = f.list(); - for (String pathname : pathnames) { - if (pathname.indexOf("UNII") != -1) { - if (pathname.endsWith(".txt") && pathname.indexOf("READ ME") == -1) { - System.out.println(pathname); - v.add(pathname); - } - } - } - return v; - } - - public static Vector run(String SRS_URI) { - String currentWorkingDirectory = System.getProperty("user.dir"); - String UNII_DATA_FILE = "UNII_Data.zip"; - download(SRS_URI + UNII_DATA_FILE, UNII_DATA_FILE); - - String UNIIS_FILE = "UNIIs.zip"; - download(SRS_URI + UNIIS_FILE, UNIIS_FILE); - - String zipFilePath = currentWorkingDirectory + "/" + UNII_DATA_FILE; - unzip(zipFilePath, currentWorkingDirectory); - - zipFilePath = currentWorkingDirectory + "/" + UNIIS_FILE; - unzip(zipFilePath, currentWorkingDirectory); - - Vector files = listUNIITextFilesInDirectory(); - return files; - } - - public static void main(String[] args) { - String SRS_URI = "https://fdasis.nlm.nih.gov/srs/download/srs/"; - Vector files = run(SRS_URI); - Utils.dumpVector("listUNIITextFilesInDirectory", files); - } - -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/SemanticTypeQA.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/SemanticTypeQA.java deleted file mode 100644 index b71c42057..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/SemanticTypeQA.java +++ /dev/null @@ -1,214 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; -import gov.nih.nci.evs.restapi.util.*; - -import gov.nih.nci.evs.restapi.bean.*; -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.text.*; - -/** - * - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class SemanticTypeQA { - String owlfile = null; - OWLScanner scanner = null; - static String DISEASE_ROOT = "C2991"; //Disease or Disorder (Code C2991) - static String FINDING_ROOT = "C3367"; - static String SEMANTIC_TYPE_PROP_CODE = "P106"; - - HierarchyHelper hh = null; - Vector parent_child_vec = null; - Vector semantic_type_vec = null; - HashMap semantic_type_hashmap = null; - Vector roots = null; - - public SemanticTypeQA(String owlfile) { - long ms = System.currentTimeMillis(); - this.owlfile = owlfile; - scanner = new OWLScanner(owlfile); - parent_child_vec = scanner.extractHierarchicalRelationships(); - - //C100003|P106|Therapeutic or Preventive Procedure - semantic_type_vec = scanner.extractProperties(scanner.get_owl_vec(), SEMANTIC_TYPE_PROP_CODE); - semantic_type_hashmap = new HashMap(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class ServerMonitor { - public static String SERVER_STATUS = "server_status.txt"; - - public static void query(String version) throws Exception { - query("NCI_Thesaurus", version); - } - - public static void query(String codingScheme, String version) throws Exception { - if (version == null) { - version = DateUtils.getNCItMonthlyVersion(); - } - Vector v = Utils.readFile(SERVER_STATUS); - Vector w = new Vector(); - String serviceUrl = null; - for (int i=0; i 0) { - System.out.println(version + " available at"); - for (int i=0; i " + value); - w.add(key + "|" + key2 + "|" + value); - } - } - } - Utils.saveToFile("stardog_server_status_" + StringUtils.getToday() + ".txt", w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/TransitiveClosureRunner.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/TransitiveClosureRunner.java deleted file mode 100644 index 0ccc521d0..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/TransitiveClosureRunner.java +++ /dev/null @@ -1,139 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; - -public class TransitiveClosureRunner { - private MainTypeHierarchy mth = null; - private HierarchyHelper hh = null; - private Vector parent_child_vec = null; - - public TransitiveClosureRunner(MainTypeHierarchy mth) { - this.mth = mth; - this.hh = mth.getHierarchyHelper(); - } - - public HierarchyHelper getHierarchyHelper() { - return hh; - } - - public TransitiveClosureRunner(Vector parent_child_vec) { - this.parent_child_vec = parent_child_vec; - hh = new HierarchyHelper(parent_child_vec); - } - - public Vector removeDuplicates(Vector codes) { - HashSet hset = new HashSet(); - Vector w = new Vector(); - for (int i=0; i 0) { - w.addAll(u); - } - } - w = removeDuplicates(w); - return w; - } - - - public Vector run(Vector codes) { - Vector v = new Vector(); - for (int i=0; i 1) { - named_graph = args[1]; - } - */ - - /* - String serviceUrl = args[0]; - System.out.println(serviceUrl); - - String named_graph = args[1]; - String inputfile = args[2]; - String outputfile = args[3]; - - MainTypeHierarchyData mthd = new MainTypeHierarchyData(serviceUrl, named_graph); - String ncit_version = mthd.getVersion(); - System.out.println("version " + ncit_version); - Vector broad_category_vec = mthd.get_broad_category_vec(); - HashSet main_type_set = mthd.get_main_type_set(); - Vector parent_child_vec = mthd.get_parent_child_vec(named_graph); - Vector v1 = mthd.getDiseaseIsStageSourceCodes(named_graph); - Vector v2 = mthd.getDiseaseIsGradeSourceCodes(named_graph); - HashMap stageConceptHashMap = mthd.generateStageConceptHashMap(v1); - HashMap gradeConceptHashMap = mthd.generateGradeConceptHashMap(v2); - - HashSet ctrp_biomarker_set = mthd.get_ctrp_biomarker_set(); - HashSet ctrp_reference_gene_set = mthd.get_ctrp_reference_gene_set(); - - MainTypeHierarchy mth = new MainTypeHierarchy(ncit_version, parent_child_vec, main_type_set, broad_category_vec, - stageConceptHashMap, gradeConceptHashMap, ctrp_biomarker_set, ctrp_reference_gene_set); - - TransitiveClosureRunner runner = new TransitiveClosureRunner(mth); - */ - - String parent_child_file = args[0]; - Vector parent_child_vec = Utils.readFile(parent_child_file); - String root = args[1]; - Vector codes = new Vector(); - codes.add(root); - TransitiveClosureRunner runner = new TransitiveClosureRunner(parent_child_vec); - Vector v = runner.run(codes); - String outputfile = "parent_child_" + root + ".txt"; - Utils.saveToFile(outputfile, v); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/UNIIDataRetriever.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/UNIIDataRetriever.java deleted file mode 100644 index c4d7a3fee..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/UNIIDataRetriever.java +++ /dev/null @@ -1,325 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -//import java.math.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.codec.binary.Base64; -import org.json.*; - -/** - * - * Copyright Copyright 2020 MSC.. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class UNIIDataRetriever { - static String UNIDENTIFIABLE_SRS_UNII_CODE = "Unknown SRS UNII code"; - static String UNIDENTIFIABLE_NCIT_UNII_CODE = "UNII code not found in NCIt"; - static String MISSING_NCIT_CODE = "NCIT code not given"; - static String UNKNOWN_NCIT_CODE = "Unknown NCIt code"; - static String FDA_UNII_Subset_Code = "C63923"; - static String FDA_UNII_Subset = "FDA Established Names and Unique Ingredient Identifier Codes Terminology"; - static String FDA_UNII_Code = "FDA_UNII_Code"; - - public Vector term_source_fda_vec = null; - public Vector fda_unii_subset_vec = null; - public Vector ncit_concepts_with_unii_code_vec = null; - public Vector ncit_retired_concepts_vec = null; - public Vector term_source_vec = null; - public Vector term_source_code_vec = null; - public Vector full_syn_vec = null; - - JSONUtils jsonUtils = null; - HTTPUtils httpUtils = null; - String named_graph = null; - String prefixes = null; - String sparql_endpoint = null; - String serviceUrl = null; - String named_graph_id = ":NHC0"; - String base_uri = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl"; - - OWLSPARQLUtils owlSPARQLUtils = null; - - private static String NCI_THESAURUS = "NCI_Thesaurus"; - private Vector unii_link = null; - private Vector unii_data = null; - private String username = null; - private String password = null; - private String namedGraph = null; - - HashMap unii2ncitcode_map = new HashMap(); - HashMap ncitcode2unii_map = new HashMap(); - HashMap ncitcode2pt_map = new HashMap(); - - static String term_source_fda_file = "term-source-fda.txt"; - static String subsource_name_file = "subsource-name.txt"; - static String source_code_file = "source-code.txt"; - - static String obsolete_concept_file = "retired_and_obsolete_concepts.txt"; - static String ncit_unii_file = "ncit_unii.txt"; - static String FDA_UNII_Subset_file = FDA_UNII_Subset_Code + ".txt"; - static String full_syn_file = "FULL_SYN.txt"; - - public Vector concepts_in_subset = null; - - public String unii_link_file = null; - public String unii_data_file = null; - - private TermSearchUtils termSearchUtils = null; - private HashSet ncit_code_hset = null; - - private List synonyms = null; - private HashMap code2SynonymMap = null; - private HashMap ncitcode2labelMap = null; - - - public UNIIDataRetriever(String serviceUrl, String namedGraph) { - this.serviceUrl = serviceUrl; - if (serviceUrl.indexOf("?") == -1) { - if (!serviceUrl.endsWith("/")) { - this.serviceUrl = serviceUrl + "/"; - } - } - this.namedGraph = namedGraph; - owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, null, null); - } - - public Vector get_term_source_vec(String source) { - return retrieveTermSourceData(source); - } - - public Vector get_term_source_fda_vec() { - if (term_source_fda_vec == null) { - term_source_fda_vec = retrieveTermSourceFDAdata(); - } - return term_source_fda_vec; - } - - public Vector get_fda_unii_subset_vec() { - if (fda_unii_subset_vec == null) { - fda_unii_subset_vec = retrieveUNIIConceptsInSubsetData(); - } - return fda_unii_subset_vec; - } - - public Vector get_ncit_concepts_with_unii_code_vec() { - if (ncit_concepts_with_unii_code_vec == null) { - ncit_concepts_with_unii_code_vec = retrieveConceptsWithUNIICode(); - } - return ncit_concepts_with_unii_code_vec; - } - - public Vector get_ncit_retired_concepts_vec() { - if (ncit_retired_concepts_vec == null) { - ncit_retired_concepts_vec = retrieveRetiredConceptData(); - } - return ncit_retired_concepts_vec; - } - - public Vector get_term_source_vec() { - if (term_source_vec == null) { - term_source_vec = retrieveTermSourceData(); - } - return term_source_vec; - } - - public Vector get_term_source_code_vec() { - if (term_source_code_vec == null) { - term_source_code_vec = retrieveSourceCodeData(); - } - return term_source_code_vec; - } - - public Vector get_full_syn_vec() { - if (full_syn_vec == null) { - full_syn_vec = retrievePropertyData("FULL_SYN"); - } - return full_syn_vec; - } - - public void retrieveUNIISupportingData() { - Vector v = null; - v = retrieveTermSourceFDAdata(); - Utils.saveToFile(term_source_fda_file, v); - - v = retrieveUNIIConceptsInSubsetData(); - Utils.saveToFile(FDA_UNII_Subset_Code + ".txt", v); - - v = retrieveConceptsWithUNIICode(); - Utils.saveToFile(ncit_unii_file, v); - - v = retrieveRetiredConceptData(); - Utils.saveToFile(obsolete_concept_file, v); - - v = retrieveTermSourceData(); - Utils.saveToFile(subsource_name_file, v); - - v = retrieveSourceCodeData(); - Utils.saveToFile(source_code_file, v); - - if (!FileUtils.fileExists(full_syn_file)) { - v = retrievePropertyData("FULL_SYN"); - Utils.saveToFile(full_syn_file, v); - } - } - - public Vector retrievePropertyData(String propertyName) { - Vector v = owlSPARQLUtils.get_property_query(this.namedGraph, propertyName); - return v; - } - - public Vector retrieveTermSourceFDAdata() { - String prop_label = "FULL_SYN"; - String qualifier_label = "Term Source"; - String qualifier_value = "FDA"; - Vector v = owlSPARQLUtils.getAxiomsWithQualifierMatching(this.namedGraph, null, prop_label, qualifier_label, qualifier_value); - return v; - } - - public Vector retrieveTermSourceData(String qualifier_value) { - String prop_label = "FULL_SYN"; - String qualifier_label = "Term Source"; - Vector v = owlSPARQLUtils.getAxiomsWithQualifierMatching(this.namedGraph, null, prop_label, qualifier_label, qualifier_value); - return v; - } - -/* -bnode_301c03a7_663e_49c8_be4e_8726b4fc92ea_800112|Molecular Abnormality|C3910|FULL_SYN|P90|Molecular Alteration|Subsource Name|P386|caDSR -bnode_301c03a7_663e_49c8_be4e_8726b4fc92ea_800110|Molecular Abnormality|C3910|FULL_SYN|P90|Molecular Abnormality|Subsource Name|P386|caDSR -*/ - - public Vector retrieveTermSourceData() { - String prop_label = "FULL_SYN"; - String qualifier_label = "Subsource Name"; - String qualifier_value = null; - Vector v = owlSPARQLUtils.getAxiomsWithQualifierMatching(this.namedGraph, null, prop_label, qualifier_label, qualifier_value); - return v; - } - -/* -bnode_301c03a7_663e_49c8_be4e_8726b4fc92ea_800110|Molecular Abnormality|C3910|FULL_SYN|P90|Molecular Abnormality|Source Code|P385|TCGA -bnode_301c03a7_663e_49c8_be4e_8726b4fc92ea_550723|Gene|C16612|FULL_SYN|P90|Gene|Source Code|P385|TCGA -*/ - - public Vector get_term_type_data(String term_type) { - return retrieveTermTypeData(term_type); - } - - public Vector retrieveTermTypeData(String term_type) { - String prop_label = "FULL_SYN"; - String qualifier_label = "Term Type"; - String qualifier_value = term_type; - Vector v = owlSPARQLUtils.getAxiomsWithQualifierMatching(this.namedGraph, null, prop_label, qualifier_label, qualifier_value); - return v; - } - - public Vector retrieveTermTypeData() { - String prop_label = "FULL_SYN"; - String qualifier_label = "Term Type"; - String qualifier_value = null; - Vector v = owlSPARQLUtils.getAxiomsWithQualifierMatching(this.namedGraph, null, prop_label, qualifier_label, qualifier_value); - return v; - } - - public Vector retrieveSourceCodeData() { - String prop_label = "FULL_SYN"; - String qualifier_label = "Source Code"; - String qualifier_value = null; - Vector v = owlSPARQLUtils.getAxiomsWithQualifierMatching(this.namedGraph, null, prop_label, qualifier_label, qualifier_value); - return v; - } - - public Vector retrieveUNIIConceptsInSubsetData() { - Vector v = owlSPARQLUtils.getConceptsInSubset(this.namedGraph, FDA_UNII_Subset_Code); - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - - public Vector retrieveConceptsWithUNIICode() { - Vector v = owlSPARQLUtils.findConceptsWithProperty(this.namedGraph, FDA_UNII_Code); - return v; - } - -/* -Cyclophosphamide/Fluoxymesterone/Mitolactol/Prednisone/Tamoxifen|C10000|Concept_Status|Obsolete_Concept -Agent Combination Indexed in Open Clinical Trials|C61007|Concept_Status|Obsolete_Concept -*/ - - public Vector retrieveRetiredConceptData() { - String property_name = "Concept_Status"; - String property_value = "Obsolete_Concept"; - Vector v = owlSPARQLUtils.findConceptsWithPropertyMatching(this.namedGraph, property_name, property_value); - property_value = "Retired_Concept"; - Vector v2 = owlSPARQLUtils.findConceptsWithPropertyMatching(this.namedGraph, property_name, property_value); - v.addAll(v2); - return v; - } - - public static void main(String[] args) { - String serviceUrl = args[0]; - String namedGraph = args[1]; - UNIIDataRetriever test = new UNIIDataRetriever(serviceUrl, namedGraph); - test.retrieveUNIISupportingData(); - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/UNIIProcessor.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/UNIIProcessor.java deleted file mode 100644 index 66c0d95cf..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/UNIIProcessor.java +++ /dev/null @@ -1,812 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -//import java.math.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.codec.binary.Base64; -import org.json.*; - -/** - * - * Copyright Copyright 2020 MSC.. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class UNIIProcessor { - static String UNIDENTIFIABLE_SRS_UNII_CODE = "Unknown SRS UNII code"; - static String UNIDENTIFIABLE_NCIT_UNII_CODE = "UNII code not found in NCIt"; - static String MISSING_NCIT_CODE = "NCIT code not given"; - static String UNKNOWN_NCIT_CODE = "Unknown NCIt code"; - - JSONUtils jsonUtils = null; - HTTPUtils httpUtils = null; - String named_graph = null; - String prefixes = null; - String sparql_endpoint = null; - String serviceUrl = null; - String named_graph_id = ":NHC0"; - String base_uri = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl"; - - OWLSPARQLUtils owlSPARQLUtils = null; - - private static String NCI_THESAURUS = "NCI_Thesaurus"; - private Vector unii_link = null; - private Vector unii_data = null; - private String username = null; - private String password = null; - private String namedGraph = null; - private static String ncit_unii_txt_file = "ncit_unii.txt"; - - HashMap unii2ncitcode_map = new HashMap(); - HashMap ncitcode2unii_map = new HashMap(); - HashMap ncitcode2pt_map = new HashMap(); - public static String FDA_UNII_Subset_Code = "C63923"; - public static String FDA_UNII_Subset = "FDA Established Names and Unique Ingredient Identifier Codes Terminology"; - - public Vector concepts_in_subset = null; - - public String unii_link_file = null; - public String unii_data_file = null; - - private TermSearchUtils termSearchUtils = null; - private HashSet ncit_code_hset = null; - - private List synonyms = null; - private HashMap code2SynonymMap = null; - private HashMap ncitcode2labelMap = null; - - private MetadataUtils metadataUtils = null; - private UNIIDataRetriever uniiDataRetriever = null; - - public Vector term_source_fda_vec = null; - public Vector fda_unii_subset_vec = null; - public Vector ncit_concepts_with_unii_code_vec = null; - public Vector ncit_retired_concepts_vec = null; - public Vector term_source_vec = null; - public Vector term_source_code_vec = null; - public Vector full_syn_vec = null; - - public UNIIProcessor(String serviceUrl, String namedGraph) { - this.serviceUrl = serviceUrl; - this.namedGraph = namedGraph; - System.out.println("serviceUrl: " + this.serviceUrl); - System.out.println("namedGraph: " + this.namedGraph); - - owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, null, null); - metadataUtils = new MetadataUtils(serviceUrl); - metadataUtils.dumpNameVersion2NamedGraphMap(); - uniiDataRetriever = new UNIIDataRetriever(this.serviceUrl, this.namedGraph); - - System.out.println("Initialized TermSearchUtils ..."); - termSearchUtils = new TermSearchUtils(serviceUrl, this.namedGraph); - - synonyms = loadSynonyms(); - code2SynonymMap = createCode2SynonymMap(synonyms); - System.out.println("TermSearchUtils initialized."); - } - - public boolean fileExists(String filename) { - File file = new File(filename); - return file.exists(); - } - - public void initialize() { - concepts_in_subset = uniiDataRetriever.get_fda_unii_subset_vec(); - ncitcode2labelMap = createNCItCode2LabelMap(); - } - - public void loadSRSData(String unii_link_file, String unii_data_file) { - this.unii_link_file = unii_link_file; - this.unii_data_file = unii_data_file; - unii_link = Utils.readFile(unii_link_file); - unii_data = Utils.readFile(unii_data_file); - if (ncit_concepts_with_unii_code_vec == null) { - ncit_concepts_with_unii_code_vec = uniiDataRetriever.get_ncit_concepts_with_unii_code_vec(); - } - - create_unii_hashmaps(ncit_concepts_with_unii_code_vec); - } - -/* -Name TYPE UNII Display Name -(R)-2-(5-CYANO-2-(6-(METHOXYCARBONYL)-7-METHYL-3-OXO-8-(3-(TRIFLUOROMETHYL)PHENYL)-2,3,5,8-TETRAHYDRO-(1,2,4)TRIAZOLO(4,3-A)PYRIMIDIN-5-YL)PHENYL)-N,N,N-TRIMETHYLETHANAMINIUM sys 00174624E2 CHF-6333 CATION -(R)-2-(5-CYANO-2-(6-(METHOXYCARBONYL)-7-METHYL-3-OXO-8-(3-(TRIFLUOROMETHYL)PHENYL)-2,3,5,8-TETRAHYDRO-(1,2,4)TRIAZOLO(4,3-A)PYRIMIDIN-5-YL)PHENYL)-N,N,N-TRIMETHYLETHANAMINIUM ION cn 00174624E2 CHF-6333 CATION -*/ - - public void create_unii_hashmaps(Vector v) { - unii2ncitcode_map = new HashMap(); - ncitcode2unii_map = new HashMap(); - ncitcode2pt_map = new HashMap(); - for (int i=0; i parseData(String line) { - if (line == null) return null; - char tab = '|'; - return parseData(line, tab); - } - - - public Vector findConceptsWithPropertyMatching(String property_name, String property_value) { - return owlSPARQLUtils.findConceptsWithPropertyMatching(this.namedGraph, property_name, property_value); - } - - - - public void runFDASubstanceRegistrationSystemFilesQA(String unii_link_file, String unii_data_file) { - if (ncit_code_hset == null) { - HashMap hmap = createSynonymHashMap(); - } - - this.unii_link_file = unii_link_file; - this.unii_data_file = unii_data_file; - loadSRSData(unii_link_file, unii_data_file); - initialize(); - char demiliter = '|'; - char comma = ','; - - // STEP 1: Name TYPE UNII Display Name - String unii_link_file_heading = null; - String line = (String) unii_link.elementAt(0); - Vector u = StringUtils.parseData(line, '\t'); - String name = (String) u.elementAt(0); - String unii = (String) u.elementAt(2); - String display_name = (String) u.elementAt(3); - - Vector headings = new Vector(); - headings.add(name); - headings.add(unii); - headings.add(display_name); - - headings.add("Comment (" + unii + ")"); - headings.add("Matched NCIt Concepts"); - - String new_unii_link_file_heading = FormatHelper.toCSVLine(headings); - - int count = 0; - - Vector w = new Vector(); - w.add(new_unii_link_file_heading); - HashSet hset = new HashSet(); - for (int i=1; i= 1 - at java.util.Vector.elementAt(Vector.java:474) - at UNIIProcessor.runFDASubstanceRegistrationSystemFilesQA(UNIIProcessor.java:554) - at UNIIProcessor.main(UNIIProcessor.java:862) - -*/ \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/ValueSetColumnAppender.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/ValueSetColumnAppender.java deleted file mode 100644 index 93d674367..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/appl/ValueSetColumnAppender.java +++ /dev/null @@ -1,139 +0,0 @@ -package gov.nih.nci.evs.restapi.appl; -import gov.nih.nci.evs.restapi.util.*; -import java.io.*; -import java.text.*; -import java.net.*; -import java.util.*; -import java.nio.file.*; -import java.nio.charset.Charset; - -/** - * - * Copyright 2022 Guidehouse. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by Guidehouse and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "Guidehouse" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or Guidehouse - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class ValueSetColumnAppender { - - public static void run(String restURL, String named_graph, String username, String password, String flatfile) { - FlatFileGenerator generator = new FlatFileGenerator(restURL, named_graph, username, password); - //flatfile = generator.generate(); - Vector v = generator.getConceptMembership(named_graph); - HashMap code2LabelMap = new HashMap(); - HashMap hmap = new HashMap(); - for (int i=0; i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class WiKiHomeStatistics { - String serviceUrl = null; - String named_graph = null; - String username = null; - String password = null; - - int councept_cocunt= -1; - int def_count = -1; - int relationship_count = -1; - - OWLScanner owlScanner = null; - static String NCI_THESAURUS_OWL = "ThesaurusInferred_forTS.owl"; - - public WiKiHomeStatistics(String owlfile) { - owlScanner = new OWLScanner(owlfile); - } - - public String wikiStat() { - HashMap hmap = owlScanner.getCode2LabelMap(); - int n1 = hmap.keySet().size(); - System.out.println("Number of concepts: " + n1); - - Vector v1 = owlScanner.extractProperties(owlScanner.get_owl_vec(), "P97"); - int n2 = v1.size(); - System.out.println("Number of DEFINITION: " + n2); - Vector v2 = owlScanner.extractProperties(owlScanner.get_owl_vec(), "P325"); - int n3 = v2.size(); - System.out.println("Number of ALT_DEFINITION: " + n3); - int total = v1.size() + v2.size(); - int n4 = n2 + n3; - System.out.println("Total number of textual definitions: " + n4); - - Vector v3 = owlScanner.extractAssociations(owlScanner.get_owl_vec()); - int n5 = v3.size(); - System.out.println("Number of associations: " + n5); - Vector v4 = owlScanner.extractOWLRestrictions(owlScanner.get_owl_vec()); - int n6 = v4.size(); - total = v3.size() + v4.size(); - int n7 = n5 + n6; - System.out.println("Number of roles: " + n6); - System.out.println("Total number of inter-concept relationships: " + n7); - - StringBuffer buf = new StringBuffer(); - - String stat = "NCI Thesaurus (NCIt) is NCI's reference terminology and core biomedical ontology, covering some " - + n1 - + " key biomedical concepts with a rich set of terms, codes, " - + n4 - + " textual definitions, and over " - + n7 + - " inter-concept relationships. NCIt combined and extended core NCI terminologies within a scientifically and technically rigorous framework. NCIt is now a broadly shared coding and semantic infrastructure resource - over half of NCIt concepts include content explicitly tagged by one or more EVS partners (see the shared terminology development wiki page )."; - return stat; - } - - public static void main(String[] args) { - String owlfile = NCI_THESAURUS_OWL; - if (args.length == 1) { - owlfile = args[0]; - } - WiKiHomeStatistics test = new WiKiHomeStatistics(owlfile); - String stat = test.wikiStat(); - System.out.println("\n" + stat); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/AltDefinition.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/AltDefinition.java deleted file mode 100644 index a6b69e53c..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/AltDefinition.java +++ /dev/null @@ -1,137 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class AltDefinition -{ - -// Variable declaration - private String code; - private String label; - private String propertyLabel; - private String description; - private String attribution; - private String source; - -// Default constructor - public AltDefinition() { - } - -// Constructor - public AltDefinition( - String code, - String label, - String description, - String attribution, - String source) { - - this.code = code; - this.label = label; - this.propertyLabel = "ALT_DEFINITION"; - this.description = description; - this.attribution = attribution; - this.source = source; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setLabel(String label) { - this.label = label; - } -/* - public void setPropertyLabel(String propertyLabel) { - this.propertyLabel = propertyLabel; - } -*/ - public void setDescription(String description) { - this.description = description; - } - - public void setAttribution(String attribution) { - this.attribution = attribution; - } - - public void setSource(String source) { - this.source = source; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getLabel() { - return this.label; - } - - public String getPropertyLabel() { - return this.propertyLabel; - } - - public String getDescription() { - return this.description; - } - - public String getAttribution() { - return this.attribution; - } - - public String getSource() { - return this.source; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class Association -{ - -// Variable declaration - private String relationship; - private String relatedConceptCode; - private String relatedConceptLabel; - -// Default constructor - public Association() { - } - -// Constructor - public Association( - String relationship, - String relatedConceptCode, - String relatedConceptLabel) { - - this.relationship = relationship; - this.relatedConceptCode = relatedConceptCode; - this.relatedConceptLabel = relatedConceptLabel; - } - -// Set methods - public void setRelationship(String relationship) { - this.relationship = relationship; - } - - public void setRelatedConceptCode(String relatedConceptCode) { - this.relatedConceptCode = relatedConceptCode; - } - - public void setRelatedConceptLabel(String relatedConceptLabel) { - this.relatedConceptLabel = relatedConceptLabel; - } - - -// Get methods - public String getRelationship() { - return this.relationship; - } - - public String getRelatedConceptCode() { - return this.relatedConceptCode; - } - - public String getRelatedConceptLabel() { - return this.relatedConceptLabel; - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Atom.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Atom.java deleted file mode 100644 index e603892b0..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Atom.java +++ /dev/null @@ -1,208 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class Atom -{ - -// Variable declaration - private String code; - private String str; - private String aui; - private String sab; - private String cui; - private String ispref; - private String lat; - private String stt; - private String ts; - private String tty; - -// Default constructor - public Atom() { - } - -// Constructor - public Atom( - String code, - String str, - String aui, - String sab, - String cui, - String ispref, - String lat, - String stt, - String ts, - String tty) { - - this.code = code; - this.str = str; - this.aui = aui; - this.sab = sab; - this.cui = cui; - this.ispref = ispref; - this.lat = lat; - this.stt = stt; - this.ts = ts; - this.tty = tty; - } - - public Atom( - String code, - String str, - String aui, - String sab, - String cui - ) { - this.code = code; - this.str = str; - this.aui = aui; - this.sab = sab; - this.cui = cui; - this.ispref = null; - this.lat = null; - this.stt = null; - this.ts = null; - this.tty = null; - } - - public Atom( - String code, - String str, - String aui, - String sab, - String cui, - String tty) { - this.code = code; - this.str = str; - this.aui = aui; - this.sab = sab; - this.cui = cui; - this.ispref = "Y"; - this.lat = "ENG"; - this.stt = "PF"; - this.ts = "P"; - this.tty = tty; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setStr(String str) { - this.str = str; - } - - public void setAui(String aui) { - this.aui = aui; - } - - public void setSab(String sab) { - this.sab = sab; - } - - public void setCui(String cui) { - this.cui = cui; - } - - public void setIspref(String ispref) { - this.ispref = ispref; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public void setStt(String stt) { - this.stt = stt; - } - - public void setTs(String ts) { - this.ts = ts; - } - - public void setTty(String tty) { - this.tty = tty; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getStr() { - return this.str; - } - - public String getAui() { - return this.aui; - } - - public String getSab() { - return this.sab; - } - - public String getCui() { - return this.cui; - } - - public String getIspref() { - return this.ispref; - } - - public String getLat() { - return this.lat; - } - - public String getStt() { - return this.stt; - } - - public String getTs() { - return this.ts; - } - - public String getTty() { - return this.tty; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Biomarker -{ - -// Variable declaration - private String code; - private String label; - -// Default constructor - public Biomarker() { - } - -// Constructor - public Biomarker( - String code, - String label) { - - this.code = code; - this.label = label; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setLabel(String label) { - this.label = label; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getLabel() { - return this.label; - } - - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ComplexDefinition.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ComplexDefinition.java deleted file mode 100644 index 18346054e..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ComplexDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.annotations.XStreamAlias; -import com.thoughtworks.xstream.annotations.XStreamImplicit; - -@XStreamAlias("ComplexDefinition") -public class ComplexDefinition implements java.io.Serializable -{ - -// Variable declaration - @XStreamImplicit - private String definition; - private String source; - -// Default constructor - public ComplexDefinition() { - } - -// Constructor - public ComplexDefinition( - String definition, - String source) { - - this.definition = definition; - this.source = source; - } - -// Set methods - public void setDefinition(String definition) { - this.definition = definition; - } - - public void setSource(String source) { - this.source = source; - } - - -// Get methods - public String getDefinition() { - return this.definition; - } - - public String getSource() { - return this.source; - } - - - public String getDisplayForm() { - return definition + " (source: " + source + ")"; - } - - @Override - public String toString() { - return "ComplexDefinition [definition=" + definition + "]" + "[source=" + source + "]"; - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ComplexProperty.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ComplexProperty.java deleted file mode 100644 index 2e9830a3b..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ComplexProperty.java +++ /dev/null @@ -1,92 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class ComplexProperty extends Property -{ - -// Variable declaration - private String name; - private String value; - private List qualifiers; - -// Default constructor - public ComplexProperty() { - } - -// Constructor - public ComplexProperty( - String name, - String value, - List qualifiers) { - this.name = name; - this.value = value; - this.qualifiers = qualifiers; - } - -// Set methods - public void setName(String name) { - this.name = name; - } - - public void setValue(String value) { - this.value = value; - } - - public void setQualifiers(List qualifiers) { - this.qualifiers = qualifiers; - } - - -// Get methods - public String getName() { - return this.name; - } - - public String getValue() { - return this.value; - } - - public List getQualifiers() { - return this.qualifiers; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; iAcinar CellSYNCITCGA - - -Acinar CellSY< -/ncicp:term-group>NCIT -CGA -Acinar CellSY< -/ncicp:term-group>NCIT -CGAcaDSR -Acinar CellSYNCITCGAcaDSR -*/ diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Concept.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Concept.java deleted file mode 100644 index fea9fbfc6..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Concept.java +++ /dev/null @@ -1,203 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - - -import java.io.*; -import java.net.*; -import java.util.*; - - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Concept -{ - -// Variable declaration - private int idx; - private String codingScheme; - private String version; - private String label; - private String code; - - private String cui; - private String aui; - private String sab; - - -// Default constructor - public Concept() { - } - -// Constructor - public Concept( - int idx, - String codingScheme, - String version, - String label, - String code) { - - this.idx = idx; - this.codingScheme = codingScheme; - this.version = version; - this.label = label; - this.code = code; - this.cui = null; - this.aui = null; - this.sab = null; - } - - public Concept( - int idx, - String label, - String code, - String cui, - String aui, - String sab - ) { - - this.idx = idx; - this.codingScheme = null; - this.version = null; - this.label = label; - this.code = code; - this.cui = cui; - this.aui = aui; - this.sab = sab; - } - - public Concept( - int idx, - String codingScheme, - String version, - String label, - String code, - String cui, - String aui, - String sab - ) { - - this.idx = idx; - this.codingScheme = codingScheme; - this.version = version; - this.label = label; - this.code = code; - this.cui = cui; - this.aui = aui; - this.sab = sab; - } - -// Set methods - public void setIdx(int idx) { - this.idx = idx; - } - - public void setCodingScheme(String codingScheme) { - this.codingScheme = codingScheme; - } - - public void setVersion(String version) { - this.version = version; - } - - public void setLabel(String label) { - this.label = label; - } - - public void setCode(String code) { - this.code = code; - } - - public void setCui(String cui) { - this.cui = cui; - } - - public void setAui(String aui) { - this.aui = aui; - } - - public void setSab(String sab) { - this.sab = sab; - } - -// Get methods - public int getIdx() { - return this.idx; - } - - public String getCodingScheme() { - return this.codingScheme; - } - - public String getVersion() { - return this.version; - } - - public String getLabel() { - return this.label; - } - - public String getCode() { - return this.code; - } - - public String getCui() { - return this.cui; - } - - public String getAui() { - return this.aui; - } - public String getSab() { - return this.sab; - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ConceptDetails.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ConceptDetails.java deleted file mode 100644 index 8e8b338ac..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ConceptDetails.java +++ /dev/null @@ -1,350 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import gov.nih.nci.evs.restapi.common.*; - -import gov.nih.nci.evs.restapi.util.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -import java.io.*; -import java.net.*; -import java.util.*; - -public class ConceptDetails -{ - -// Variable declaration - private String code; - private String label; - private String preferredName; - private String displayName; - private Boolean isMainType; - private Boolean isSubtype; - private Boolean isDiseaseStage; - private Boolean isDiseaseGrade; - private Boolean isDisease; - private Boolean isBiomarker; - private Boolean isReferenceGene; - private List mainMenuAncestors; - private List definitions; - private List synonyms; - private List conceptStatus; - private List semanticTypes; - private List superconcepts; - private List subconcepts; - private List additionalProperties; - -// Default constructor - public ConceptDetails() { - } - -// Constructor - public ConceptDetails( - String code, - String label, - String preferredName, - String displayName, - Boolean isMainType, - Boolean isSubtype, - Boolean isDiseaseStage, - Boolean isDiseaseGrade, - Boolean isDisease, - List mainMenuAncestors, - List definitions, - List synonyms, - List conceptStatus, - List semanticTypes, - List superconcepts, - List subconcepts, - List additionalProperties) { - - this.code = code; - this.label = label; - this.preferredName = preferredName; - this.displayName = displayName; - this.isMainType = isMainType; - this.isSubtype = isSubtype; - this.isDiseaseStage = isDiseaseStage; - this.isDiseaseGrade = isDiseaseGrade; - this.isDisease = isDisease; - this.mainMenuAncestors = mainMenuAncestors; - this.definitions = definitions; - this.synonyms = synonyms; - this.conceptStatus = conceptStatus; - this.semanticTypes = semanticTypes; - this.superconcepts = superconcepts; - this.subconcepts = subconcepts; - this.additionalProperties = additionalProperties; - } - - public static List vector2List(Vector v) { - if (v == null) return null; - return new ArrayList(v); - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setLabel(String label) { - this.label = label; - } - - public void setPreferredName(String preferredName) { - this.preferredName = preferredName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public void setIsMainType(Boolean isMainType) { - this.isMainType = isMainType; - } - - public void setIsSubtype(Boolean isSubtype) { - this.isSubtype = isSubtype; - } - - public void setIsDiseaseStage(Boolean isDiseaseStage) { - this.isDiseaseStage = isDiseaseStage; - } - - public void setIsDiseaseGrade(Boolean isDiseaseGrade) { - this.isDiseaseGrade = isDiseaseGrade; - } - - public void setIsDisease(Boolean isDisease) { - this.isDisease = isDisease; - } - - public void setmainMenuAncestors(List mainMenuAncestors) { - this.mainMenuAncestors = mainMenuAncestors; - } - - public void setDefinitions(List definitions) { - this.definitions = definitions; - } - - public void setSynonyms(List synonyms) { - this.synonyms = synonyms; - } - - public void setConceptStatus(List conceptStatus) { - this.conceptStatus = conceptStatus; - } - - public void setSemanticTypes(List semanticTypes) { - this.semanticTypes = semanticTypes; - } - - public void setSuperconcepts(List superconcepts) { - this.superconcepts = superconcepts; - } - - public void setSubconcepts(List subconcepts) { - this.subconcepts = subconcepts; - } - - public void setAdditionalProperties(List additionalProperties) { - this.additionalProperties = additionalProperties; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getLabel() { - return this.label; - } - - public String getPreferredName() { - return this.preferredName; - } - - public String getDisplayName() { - return this.displayName; - } - - public Boolean getIsMainType() { - return this.isMainType; - } - - public Boolean getIsSubtype() { - return this.isSubtype; - } - - public Boolean getIsDiseaseStage() { - return this.isDiseaseStage; - } - - public Boolean getIsDiseaseGrade() { - return this.isDiseaseGrade; - } - - public Boolean getIsDisease() { - return this.isDisease; - } - public List getmainMenuAncestors() { - return this.mainMenuAncestors; - } - - public List getDefinitions() { - return this.definitions; - } - - public List getSynonyms() { - return this.synonyms; - } - - public List getConceptStatus() { - return this.conceptStatus; - } - - public List getSemanticTypes() { - return this.semanticTypes; - } - - public List getSuperconcepts() { - return this.superconcepts; - } - - public List getSubconcepts() { - return this.subconcepts; - } - - public List getAdditionalProperties() { - return this.additionalProperties; - } - - public ConceptDetails( - Vector label_vec, - Vector property_vec, - Vector property_qualifier_vec, - Vector synonym_vec, - Vector superclass_vec, - Vector subclass_vec, - List mainMenuAncestors, - Boolean isMainType, - Boolean isSubtype, - Boolean isDiseaseStage, - Boolean isDiseaseGrade, - Boolean isDisease, - Boolean isBiomarker, - Boolean isReferenceGene - ) { - ParserUtils parser = new ParserUtils(); - HashMap prop_hmap = parser.parseProperties(property_vec); - Vector code_vec = (Vector) prop_hmap.get("code"); - - String code = null; - if (code_vec != null) { - code = (String) code_vec.elementAt(0); - } - String label = parser.parseLabel(label_vec); - Vector displayNames = (Vector) prop_hmap.get("Display_Name"); - if (displayNames != null) { - displayName = (String) displayNames.elementAt(0); - } - Vector preferredName_vec = (Vector) prop_hmap.get("Preferred_Name"); - String preferredName = null; - if (preferredName_vec != null) { - preferredName = (String) preferredName_vec.elementAt(0); - } - - Vector displayName_vec = (Vector) prop_hmap.get("Display_Name"); - if (displayName_vec != null) { - displayName = (String) displayName_vec.elementAt(0); - } - - List synonyms = parser.getSynonyms(synonym_vec); - List list = new ParserUtils().getSynonyms(synonym_vec); - - Vector conceptStatus_vec = (Vector) prop_hmap.get("Concept_Status"); - Vector semanticType_vec = (Vector) prop_hmap.get("Semantic_Type"); - - HashMap superclasses_hmap = parser.parseSuperclasses(superclass_vec); - List superconcepts = new ArrayList(); - Iterator it = superclasses_hmap.keySet().iterator(); - while (it.hasNext()) { - String cd = (String) it.next(); - Vector w = (Vector) superclasses_hmap.get(cd); - String name = null; - if (w != null) { - name = (String) w.elementAt(0); - } - superconcepts.add(new Superconcept(cd, name)); - } - - HashMap subclasses_hmap = parser.parseSubclasses(subclass_vec); - List subconcepts = new ArrayList(); - it = subclasses_hmap.keySet().iterator(); - while (it.hasNext()) { - String cd = (String) it.next(); - Vector w = (Vector) subclasses_hmap.get(cd); - String name = null; - if (w != null) { - name = (String) w.elementAt(0); - } - subconcepts.add(new Subconcept(cd, name)); - } - this.code = code; - this.label = label; - this.preferredName = preferredName; - this.displayName = displayName; - this.synonyms =synonyms; - - this.conceptStatus = vector2List(conceptStatus_vec); - this.semanticTypes = vector2List(semanticType_vec); - this.superconcepts = superconcepts; - this.subconcepts = subconcepts; - - List definitions = new ArrayList(); - Vector def_vec = parser.filterPropertyQualifiers(property_qualifier_vec, Constants.DEFINITION);//) { //type: FULL_SYN, DEFINITION, ALT_DEFINITION - definitions = parser.getDefinitions(def_vec); - Vector alt_def_vec = parser.filterPropertyQualifiers(property_qualifier_vec, Constants.ALT_DEFINITION);//) { //type: FULL_SYN, DEFINITION, ALT_DEFINITION - List alt_definitions = parser.getDefinitions(alt_def_vec);//) { //type: FULL_SYN, DEFINITION, ALT_DEFINITION - if (alt_definitions != null && alt_definitions.size() > 0) { - for (int j=0; j"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008,2009 NGIT. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIT and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIT" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIT - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history Initial implementation kim.ong@ngc.com - * - */ - -public class DisplayItem { - private String _propertyName; - private String _itemLabel; - private String _url; - private String _hyperlinkText; - private boolean _isExternalCode; - - public DisplayItem() { - } - - public DisplayItem(String propertyName, String itemLabel, String url, - String hyperlinkText) { - _propertyName = propertyName; - _itemLabel = itemLabel; - _url = url; - _hyperlinkText = hyperlinkText; - _isExternalCode = false; - } - - public DisplayItem(String propertyName, String itemLabel, String url, - String hyperlinkText, boolean isExternalCode) { - _propertyName = propertyName; - _itemLabel = itemLabel; - _url = url; - _hyperlinkText = hyperlinkText; - _isExternalCode = isExternalCode; - } - - public String getPropertyName() { - return _propertyName; - } - - public void setPropertyName(String propertyName) { - _propertyName = propertyName; - } - - public String getItemLabel() { - return _itemLabel; - } - - public void setItemLabel(String itemLabel) { - _itemLabel = itemLabel; - } - - public String getUrl() { - return _url; - } - - public void setUrl(String url) { - _url = url; - } - - public String getHyperlinkText() { - return _hyperlinkText; - } - - public void setHyperlinkText(String hyperlinkText) { - _hyperlinkText = hyperlinkText; - } - - public boolean getIsExternalCode() { - return _isExternalCode; - } - - public void setIsExternalCode(String isExternalCode) { - _hyperlinkText = isExternalCode; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("DisplayItem "); - sb.append("\n"); - sb.append("\tpropertyName: " + getPropertyName()); - sb.append("\n"); - sb.append("\titemLabel: " + getItemLabel()); - sb.append("\n"); - sb.append("\turl: " + getUrl()); - sb.append("\n"); - sb.append("\thyperlinkText: " + getHyperlinkText()); - sb.append("\n"); - sb.append("\tisExternalCode: " + getIsExternalCode()); - sb.append("\n"); - return sb.toString(); - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/EditAction.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/EditAction.java deleted file mode 100644 index 0432b9924..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/EditAction.java +++ /dev/null @@ -1,119 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class EditAction -{ - -// Variable declaration - private String label; - private String code; - private String action; - private String type; - private String value; - -// Default constructor - public EditAction() { - } - -// Constructor - public EditAction( - String label, - String code, - String action, - String type, - String value) { - - this.label = label; - this.code = code; - this.action = action; - this.type = type; - this.value = value; - } - -// Set methods - public void setLabel(String label) { - this.label = label; - } - - public void setCode(String code) { - this.code = code; - } - - public void setAction(String action) { - this.action = action; - } - - public void setType(String type) { - this.type = type; - } - - public void setValue(String value) { - this.value = value; - } - - -// Get methods - public String getLabel() { - return this.label; - } - - public String getCode() { - return this.code; - } - - public String getAction() { - return this.action; - } - - public String getType() { - return this.type; - } - - public String getValue() { - return this.value; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class InverseAssociation -{ - -// Variable declaration - private String relationship; - private String relatedConceptCode; - private String relatedConceptLabel; - -// Default constructor - public InverseAssociation() { - } - -// Constructor - public InverseAssociation( - String relationship, - String relatedConceptCode, - String relatedConceptLabel) { - - this.relationship = relationship; - this.relatedConceptCode = relatedConceptCode; - this.relatedConceptLabel = relatedConceptLabel; - } - -// Set methods - public void setRelationship(String relationship) { - this.relationship = relationship; - } - - public void setRelatedConceptCode(String relatedConceptCode) { - this.relatedConceptCode = relatedConceptCode; - } - - public void setRelatedConceptLabel(String relatedConceptLabel) { - this.relatedConceptLabel = relatedConceptLabel; - } - - -// Get methods - public String getRelationship() { - return this.relationship; - } - - public String getRelatedConceptCode() { - return this.relatedConceptCode; - } - - public String getRelatedConceptLabel() { - return this.relatedConceptLabel; - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/InverseRole.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/InverseRole.java deleted file mode 100644 index d4f9cf9a9..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/InverseRole.java +++ /dev/null @@ -1,111 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class InverseRole -{ - -// Variable declaration - private String relationship; - private String relatedConceptCode; - private String relatedConceptLabel; - -// Default constructor - public InverseRole() { - } - -// Constructor - public InverseRole( - String relationship, - String relatedConceptCode, - String relatedConceptLabel) { - - this.relationship = relationship; - this.relatedConceptCode = relatedConceptCode; - this.relatedConceptLabel = relatedConceptLabel; - } - -// Set methods - public void setRelationship(String relationship) { - this.relationship = relationship; - } - - public void setRelatedConceptCode(String relatedConceptCode) { - this.relatedConceptCode = relatedConceptCode; - } - - public void setRelatedConceptLabel(String relatedConceptLabel) { - this.relatedConceptLabel = relatedConceptLabel; - } - - -// Get methods - public String getRelationship() { - return this.relationship; - } - - public String getRelatedConceptCode() { - return this.relatedConceptCode; - } - - public String getRelatedConceptLabel() { - return this.relatedConceptLabel; - } - - public String toString() { - return "[" + relatedConceptLabel + " (" + relatedConceptCode + ")] --> (" + relationship + ")"; - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Link.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Link.java deleted file mode 100644 index a71fc9db0..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Link.java +++ /dev/null @@ -1,136 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Link { - int id; - String sourceCode; - String sourceName; - String targetCode; - String targetName; - - -// Default constructor - public Link() { - } - -// Constructor - public Link( - int id, - String sourceCode, - String sourceName, - String targetCode, - String targetName) { - this.id = id; - this.sourceCode = sourceCode; - this.sourceName = sourceName; - this.targetCode = targetCode; - this.targetName = targetName; - } - - public int getId() { - return id; - } - - public String getSourceCode() { - return sourceCode; - } - - public String getSourceName() { - return sourceName; - } - - public String getTargetCode() { - return targetCode; - } - - public String getTargetName() { - return targetName; - } - - - @XmlAttribute - public void setId(int id) { - this.id = id; - } - - @XmlElement - public void setSourceCode(String sourceCode) { - this.sourceCode = sourceCode; - } - - @XmlElement - public void setSourceName(String sourceName) { - this.sourceName = sourceName; - } - - @XmlElement - public void setTargetCode(String targetCode) { - this.targetCode = targetCode; - } - - @XmlElement - public void setTargetName(String targetName) { - this.targetName = targetName; - } - - public String toString() { - return "Id: " + this.id + "\n\t" + "SourceCode: " + this.sourceCode + "\n\t" + "SourceName: " + this.sourceName + "\n\t" + "TargetCode: " + this.targetCode + "\n\t" + "TargetName: " + this.targetName; - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Links.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Links.java deleted file mode 100644 index d190f40e5..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Links.java +++ /dev/null @@ -1,105 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.util.List; -import gov.nih.nci.evs.restapi.common.*; -import gov.nih.nci.evs.restapi.util.*; -/* -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; -import gov.nih.nci.evs.restapi.common.*; - -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -*/ - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Links -{ - //@XmlElement(name = "Link") - private List links = null; - - public List getLinks() { - return links; - } - - public void setLinks(List links) { - this.links = links; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = StringUtils.escapeDoubleQuotes(xml); - xml = Constants.XML_DECLARATION + "\n" + xml; - xml = StringUtils.removePackageNames(Constants.EVSRESTAPI_BEAN, xml); - return xml; - } - - public String toJson() { - //return new Gson().toJson(this); - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/MapEntry.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/MapEntry.java deleted file mode 100644 index ddae7d590..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/MapEntry.java +++ /dev/null @@ -1,203 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class MapEntry -{ - -// Variable declaration - private String sourceCode; - private String sourceName; - private String sourceCodingScheme; - private String sourceCodingSchemeVersion; - private String sourceCodingSchemeNamespace; - private String associationName; - private String rel; - private String mapRank; - private String targetCode; - private String targetName; - private String targetCodingScheme; - private String targetCodingSchemeVersion; - private String targetCodingSchemeNamespace; - -// Default constructor - public MapEntry() { - } - -// Constructor - public MapEntry( - String sourceCode, - String sourceName, - String sourceCodingScheme, - String sourceCodingSchemeVersion, - String sourceCodingSchemeNamespace, - String associationName, - String rel, - String mapRank, - String targetCode, - String targetName, - String targetCodingScheme, - String targetCodingSchemeVersion, - String targetCodingSchemeNamespace) { - - this.sourceCode = sourceCode; - this.sourceName = sourceName; - this.sourceCodingScheme = sourceCodingScheme; - this.sourceCodingSchemeVersion = sourceCodingSchemeVersion; - this.sourceCodingSchemeNamespace = sourceCodingSchemeNamespace; - this.associationName = associationName; - this.rel = rel; - this.mapRank = mapRank; - this.targetCode = targetCode; - this.targetName = targetName; - this.targetCodingScheme = targetCodingScheme; - this.targetCodingSchemeVersion = targetCodingSchemeVersion; - this.targetCodingSchemeNamespace = targetCodingSchemeNamespace; - } - -// Set methods - public void setSourceCode(String sourceCode) { - this.sourceCode = sourceCode; - } - - public void setSourceName(String sourceName) { - this.sourceName = sourceName; - } - - public void setSourceCodingScheme(String sourceCodingScheme) { - this.sourceCodingScheme = sourceCodingScheme; - } - - public void setSourceCodingSchemeVersion(String sourceCodingSchemeVersion) { - this.sourceCodingSchemeVersion = sourceCodingSchemeVersion; - } - - public void setSourceCodingSchemeNamespace(String sourceCodingSchemeNamespace) { - this.sourceCodingSchemeNamespace = sourceCodingSchemeNamespace; - } - - public void setAssociationName(String associationName) { - this.associationName = associationName; - } - - public void setRel(String rel) { - this.rel = rel; - } - - public void setMapRank(String mapRank) { - this.mapRank = mapRank; - } - - public void setTargetCode(String targetCode) { - this.targetCode = targetCode; - } - - public void setTargetName(String targetName) { - this.targetName = targetName; - } - - public void setTargetCodingScheme(String targetCodingScheme) { - this.targetCodingScheme = targetCodingScheme; - } - - public void setTargetCodingSchemeVersion(String targetCodingSchemeVersion) { - this.targetCodingSchemeVersion = targetCodingSchemeVersion; - } - - public void setTargetCodingSchemeNamespace(String targetCodingSchemeNamespace) { - this.targetCodingSchemeNamespace = targetCodingSchemeNamespace; - } - - -// Get methods - public String getSourceCode() { - return this.sourceCode; - } - - public String getSourceName() { - return this.sourceName; - } - - public String getSourceCodingScheme() { - return this.sourceCodingScheme; - } - - public String getSourceCodingSchemeVersion() { - return this.sourceCodingSchemeVersion; - } - - public String getSourceCodingSchemeNamespace() { - return this.sourceCodingSchemeNamespace; - } - - public String getAssociationName() { - return this.associationName; - } - - public String getRel() { - return this.rel; - } - - public String getMapRank() { - return this.mapRank; - } - - public String getTargetCode() { - return this.targetCode; - } - - public String getTargetName() { - return this.targetName; - } - - public String getTargetCodingScheme() { - return this.targetCodingScheme; - } - - public String getTargetCodingSchemeVersion() { - return this.targetCodingSchemeVersion; - } - - public String getTargetCodingSchemeNamespace() { - return this.targetCodingSchemeNamespace; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Parameter -{ - -// Variable declaration - private String name; - private String type; - private String nodeType; - -// Default constructor - public Parameter() { - } - -// Constructor - public Parameter( - String name, - String type, - String nodeType) { - - this.name = name; - this.type = type; - this.nodeType = nodeType; - } - -// Set methods - public void setName(String name) { - this.name = name; - } - - public void setType(String type) { - this.type = type; - } - - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - -// Get methods - public String getName() { - return this.name; - } - - public String getType() { - return this.type; - } - - public String getNodeType() { - return this.nodeType; - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Path.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Path.java deleted file mode 100644 index d6f4e3cb0..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Path.java +++ /dev/null @@ -1,101 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - - -import java.io.*; -import java.net.*; -import java.util.*; - - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Path -{ -// Variable declaration - private int direction; - private List concepts; - -// Default constructor - public Path() { - } - -// Constructor - public Path( - int direction, - List concepts) { - - this.direction = direction; - this.concepts = concepts; - } - -// Set methods - public void setDirection(int direction) { - this.direction = direction; - } - - - public void setConcepts(List concepts) { - this.concepts = concepts; - } - - -// Get methods - public int getDirection() { - return this.direction; - } - - public List getConcepts() { - return this.concepts; - } - - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Paths.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Paths.java deleted file mode 100644 index 0511ecca7..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Paths.java +++ /dev/null @@ -1,161 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; -import gov.nih.nci.evs.restapi.common.*; - -import gov.nih.nci.evs.restapi.util.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -import java.io.*; -import java.net.*; -import java.util.*; - - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Paths -{ -// Variable declaration - private List paths; - -// Default constructor - public Paths() { - paths = new ArrayList(); - } - -// Constructor - public Paths( - List paths) { - - this.paths = paths; - } - -// Set methods - public void setPath(List paths) { - this.paths = paths; - } - - - public void add(Path path) { - this.paths.add(path); - } - - -// Get methods - public List getPaths() { - return this.paths; - } - - - public int getPathCount() { - return this.paths.size(); - } - - - public static String getIndentation(int n) { - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class RelatedConcepts -{ - -// Variable declaration - private List superconcepts; - private List subconcepts; - private List associations; - private List inverseAssoications; - private List roles; - private List inverseRoles; - -// Default constructor - public RelatedConcepts() { - } - -// Constructor - public RelatedConcepts( - List superconcepts, - List subconcepts, - List associations, - List inverseAssoications, - List roles, - List inverseRoles) { - - this.superconcepts = superconcepts; - this.subconcepts = subconcepts; - this.associations = associations; - this.inverseAssoications = inverseAssoications; - this.roles = roles; - this.inverseRoles = inverseRoles; - } - -// Set methods - public void setSuperconcepts(List superconcepts) { - this.superconcepts = superconcepts; - } - - public void setSubconcepts(List subconcepts) { - this.subconcepts = subconcepts; - } - - public void setAssociations(List associations) { - this.associations = associations; - } - - public void setInverseAssoications(List inverseAssoications) { - this.inverseAssoications = inverseAssoications; - } - - public void setRoles(List roles) { - this.roles = roles; - } - - public void setInverseRoles(List inverseRoles) { - this.inverseRoles = inverseRoles; - } - - -// Get methods - public List getSuperconcepts() { - return this.superconcepts; - } - - public List getSubconcepts() { - return this.subconcepts; - } - - public List getAssociations() { - return this.associations; - } - - public List getInverseAssoications() { - return this.inverseAssoications; - } - - public List getRoles() { - return this.roles; - } - - public List getInverseRoles() { - return this.inverseRoles; - } - - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = StringUtils.escapeDoubleQuotes(xml); - xml = Constants.XML_DECLARATION + "\n" + xml; - xml = StringUtils.removePackageNames(Constants.EVSRESTAPI_BEAN, xml); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Relationship.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Relationship.java deleted file mode 100644 index 160a03d51..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Relationship.java +++ /dev/null @@ -1,147 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class Relationship -{ -// Variable declaration - private String type; - private String name; - private String sourceCode; - private String sourceLabel; - private String targetCode; - private String targetLabel; - -// Default constructor - public Relationship() { - } - -// Constructor - public Relationship( - String type, - String name, - String sourceCode, - String sourceLabel, - String targetCode, - String targetLabel) { - - this.type = type; - this.name = name; - this.sourceCode = sourceCode; - this.sourceLabel = sourceLabel; - this.targetCode = targetCode; - this.targetLabel = targetLabel; - } - -// Set methods - public void setType(String type) { - this.type = type; - } - - public void setName(String name) { - this.name = name; - } - - public void setSourceCode(String sourceCode) { - this.sourceCode = sourceCode; - } - - public void setSourceLabel(String sourceLabel) { - this.sourceLabel = sourceLabel; - } - - public void setTargetCode(String targetCode) { - this.targetCode = targetCode; - } - - public void setTargetLabel(String targetLabel) { - this.targetLabel = targetLabel; - } - - -// Get methods - public String getType() { - return this.type; - } - - public String getName() { - return this.name; - } - - public String getSourceCode() { - return this.sourceCode; - } - - public String getSourceLabel() { - return this.sourceLabel; - } - - public String getTargetCode() { - return this.targetCode; - } - - public String getTargetLabel() { - return this.targetLabel; - } - - - public String toString() { - return "[" + sourceLabel + " (" + sourceCode + ")] -- (" + name + ") --> " - + "[" + targetLabel + " (" + targetCode + ")]"; - - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedConceptReference.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedConceptReference.java deleted file mode 100644 index 9ca5aca1d..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedConceptReference.java +++ /dev/null @@ -1,79 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -public class ResolvedConceptReference implements java.io.Serializable -{ - -// Variable declaration - private String codingScheme; - private String version; - private String code; - private String namespace; - private String name; - -// Default constructor - public ResolvedConceptReference() { - } - -// Constructor - public ResolvedConceptReference( - String codingScheme, - String version, - String code, - String namespace, - String name) { - - this.codingScheme = codingScheme; - this.version = version; - this.code = code; - this.namespace = namespace; - this.name = name; - } - -// Set methods - public void setCodingScheme(String codingScheme) { - this.codingScheme = codingScheme; - } - - public void setVersion(String version) { - this.version = version; - } - - public void setCode(String code) { - this.code = code; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public void setName(String name) { - this.name = name; - } - - -// Get methods - public String getCodingScheme() { - return this.codingScheme; - } - - public String getVersion() { - return this.version; - } - - public String getCode() { - return this.code; - } - - public String getNamespace() { - return this.namespace; - } - - public String getName() { - return this.name; - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedConceptReferenceList.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedConceptReferenceList.java deleted file mode 100644 index 13d3c61ec..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedConceptReferenceList.java +++ /dev/null @@ -1,114 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; - - -public class ResolvedConceptReferenceList implements java.io.Serializable { - - private Boolean _incomplete = Boolean.valueOf("false"); - private java.util.List _resolvedConceptReferenceList; - - - public ResolvedConceptReferenceList() { - super(); - this._resolvedConceptReferenceList = new java.util.ArrayList(); - } - - - public void addResolvedConceptReference( - final ResolvedConceptReference vResolvedConceptReference) - throws java.lang.IndexOutOfBoundsException { - this._resolvedConceptReferenceList.add(vResolvedConceptReference); - } - - public void addResolvedConceptReference( - final int index, - final ResolvedConceptReference vResolvedConceptReference) - throws java.lang.IndexOutOfBoundsException { - this._resolvedConceptReferenceList.add(index, vResolvedConceptReference); - } - - public java.util.Enumeration enumerateResolvedConceptReference( - ) { - return java.util.Collections.enumeration(this._resolvedConceptReferenceList); - } - - public java.lang.Boolean getIncomplete( - ) { - return this._incomplete; - } - - public ResolvedConceptReference getResolvedConceptReference( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._resolvedConceptReferenceList.size()) { - throw new IndexOutOfBoundsException("getResolvedConceptReference: Index value '" + index + "' not in range [0.." + (this._resolvedConceptReferenceList.size() - 1) + "]"); - } - return (ResolvedConceptReference) _resolvedConceptReferenceList.get(index); - } - - public ResolvedConceptReference[] getResolvedConceptReference( - ) { - ResolvedConceptReference[] array = new ResolvedConceptReference[0]; - return (ResolvedConceptReference[]) this._resolvedConceptReferenceList.toArray(array); - } - - public int getResolvedConceptReferenceCount( - ) { - return this._resolvedConceptReferenceList.size(); - } - - public java.lang.Boolean isIncomplete( - ) { - return this._incomplete; - } - - public java.util.Iterator iterateResolvedConceptReference( - ) { - return this._resolvedConceptReferenceList.iterator(); - } - - public void removeAllResolvedConceptReference( - ) { - this._resolvedConceptReferenceList.clear(); - } - - public boolean removeResolvedConceptReference( - final ResolvedConceptReference vResolvedConceptReference) { - boolean removed = _resolvedConceptReferenceList.remove(vResolvedConceptReference); - return removed; - } - - public ResolvedConceptReference removeResolvedConceptReferenceAt( - final int index) { - java.lang.Object obj = this._resolvedConceptReferenceList.remove(index); - return (ResolvedConceptReference) obj; - } - - public void setIncomplete( - final java.lang.Boolean incomplete) { - this._incomplete = incomplete; - } - - public void setResolvedConceptReference( - final int index, - final ResolvedConceptReference vResolvedConceptReference) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._resolvedConceptReferenceList.size()) { - throw new IndexOutOfBoundsException("setResolvedConceptReference: Index value '" + index + "' not in range [0.." + (this._resolvedConceptReferenceList.size() - 1) + "]"); - } - this._resolvedConceptReferenceList.set(index, vResolvedConceptReference); - } - - public void setResolvedConceptReference( - final ResolvedConceptReference[] vResolvedConceptReferenceArray) { - _resolvedConceptReferenceList.clear(); - - for (int i = 0; i < vResolvedConceptReferenceArray.length; i++) { - this._resolvedConceptReferenceList.add(vResolvedConceptReferenceArray[i]); - } - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedValueSet.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedValueSet.java deleted file mode 100644 index 2dbcec07e..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ResolvedValueSet.java +++ /dev/null @@ -1,93 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class ResolvedValueSet -{ - -// Variable declaration - private String uri; - private String name; - private List concepts; - -// Default constructor - public ResolvedValueSet() { - } - -// Constructor - public ResolvedValueSet( - String uri, - String name, - List concepts) { - - this.uri = uri; - this.name = name; - this.concepts = concepts; - } - -// Set methods - public void setUri(String uri) { - this.uri = uri; - } - - public void setName(String name) { - this.name = name; - } - - public void setConcepts(List concepts) { - this.concepts = concepts; - } - - -// Get methods - public String getUri() { - return this.uri; - } - - public String getName() { - return this.name; - } - - public List getConcepts() { - return this.concepts; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i editActions; - -// Default constructor - public Revision() { - } - -// Constructor - public Revision( - String codingScheme, - String version, - String date, - List editActions) { - - this.codingScheme = codingScheme; - this.version = version; - this.date = date; - this.editActions = editActions; - } - -// Set methods - public void setCodingScheme(String codingScheme) { - this.codingScheme = codingScheme; - } - - public void setVersion(String version) { - this.version = version; - } - - public void setDate(String date) { - this.date = date; - } - - public void setEditActions(List editActions) { - this.editActions = editActions; - } - - -// Get methods - public String getCodingScheme() { - return this.codingScheme; - } - - public String getVersion() { - return this.version; - } - - public String getDate() { - return this.date; - } - - public List getEditActions() { - return this.editActions; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class Role -{ - -// Variable declaration - private String relationship; - private String relatedConceptCode; - private String relatedConceptLabel; - -// Default constructor - public Role() { - } - -// Constructor - public Role( - String relationship, - String relatedConceptCode, - String relatedConceptLabel) { - - this.relationship = relationship; - this.relatedConceptCode = relatedConceptCode; - this.relatedConceptLabel = relatedConceptLabel; - } - -// Set methods - public void setRelationship(String relationship) { - this.relationship = relationship; - } - - public void setRelatedConceptCode(String relatedConceptCode) { - this.relatedConceptCode = relatedConceptCode; - } - - public void setRelatedConceptLabel(String relatedConceptLabel) { - this.relatedConceptLabel = relatedConceptLabel; - } - - -// Get methods - public String getRelationship() { - return this.relationship; - } - - public String getRelatedConceptCode() { - return this.relatedConceptCode; - } - - public String getRelatedConceptLabel() { - return this.relatedConceptLabel; - } - - public String toString() { - return "(" + relationship + ") --> [" + relatedConceptLabel + " (" + relatedConceptCode + ")]"; - - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Row.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Row.java deleted file mode 100644 index 2f42bcfe6..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Row.java +++ /dev/null @@ -1,70 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class Row -{ - -// Variable declaration - private List row; - -// Default constructor - public Row() { - } - -// Constructor - public Row( - List row) { - this.row = row; - } - -// Set methods - public void setrow(List row) { - this.row = row; - } - - -// Get methods - public List getrow() { - return this.row; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class SearchResult -{ - public static final String XML_DECLARATION = ""; - -// Variable declaration - private List matchedConcepts; - -// Default constructor - public SearchResult() { - } - -// Constructor - public SearchResult( - List matchedConcepts) { - - this.matchedConcepts = matchedConcepts; - } - -// Set methods - public void setMatchedConcepts(List matchedConcepts) { - this.matchedConcepts = matchedConcepts; - } - - -// Get methods - public List getMatchedConcepts() { - return this.matchedConcepts; - } - - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = StringUtils.escapeDoubleQuotes(xml); - xml = XML_DECLARATION + "\n" + xml; - xml = StringUtils.removePackageNames(Constants.EVSRESTAPI_BEAN, xml); - return xml; - } - - public String toJson() { - //return new Gson().toJson(this); - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public static Vector searchResult2DelimitedStrings(SearchResult sr) { - if (sr == null) return null; - Vector v = new Vector(); - List matchedConcepts = sr.getMatchedConcepts(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class ServerInfo -{ - -// Variable declaration - private String name; - private String serviceUrl; - private String username; - private String password; - private String defaultGraph; - -// Default constructor - public ServerInfo() { - } - -// Constructor - public ServerInfo( - String name, - String serviceUrl, - String username, - String password) { - - this.name = name; - this.serviceUrl = serviceUrl; - this.username = username; - this.password = password; - this.defaultGraph = null; - } - - public ServerInfo( - String name, - String serviceUrl, - String username, - String password, - String defaultGraph) { - - this.name = name; - this.serviceUrl = serviceUrl; - this.username = username; - this.password = password; - this.defaultGraph = defaultGraph; - } - -// Set methods - public void setName(String name) { - this.name = name; - } - - public void setServiceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - } - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setDefaultGraph(String defaultGraph) { - this.defaultGraph = defaultGraph; - } - - -// Get methods - public String getName() { - return this.name; - } - - public String getServiceUrl() { - return this.serviceUrl; - } - - public String getUsername() { - return this.username; - } - - public String getPassword() { - return this.password; - } - - public String getDefaultGraph() { - return this.defaultGraph; - } - - - public String toString() { - StringBuffer buf = new StringBuffer(); - buf.append("Name: " + name).append("\n"); - buf.append("URL: " + serviceUrl).append("\n"); - buf.append("Username: " + username).append("\n"); - buf.append("Password: " + password).append("\n"); - buf.append("DefaultGraph: " + defaultGraph); - return buf.toString(); - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Subconcept.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Subconcept.java deleted file mode 100644 index ba7aa5f6b..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Subconcept.java +++ /dev/null @@ -1,101 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - - -import java.io.*; -import java.net.*; -import java.util.*; - - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Subconcept -{ - -// Variable declaration - private String code; - private String label; - -// Default constructor - public Subconcept() { - } - -// Constructor - public Subconcept( - String code, - String label) { - - this.code = code; - this.label = label; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setLabel(String label) { - this.label = label; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getLabel() { - return this.label; - } - - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Subset.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Subset.java deleted file mode 100644 index 9dd3401cb..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Subset.java +++ /dev/null @@ -1,71 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class Subset -{ - -// Variable declaration - private List entities; - -// Default constructor - public Subset() { - } - -// Constructor - public Subset( - List entities) { - - this.entities = entities; - } - -// Set methods - public void setEntities(List entities) { - this.entities = entities; - } - - -// Get methods - public List getEntities() { - return this.entities; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Superconcept -{ - -// Variable declaration - private String code; - private String label; - -// Default constructor - public Superconcept() { - } - -// Constructor - public Superconcept( - String code, - String label) { - - this.code = code; - this.label = label; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setLabel(String label) { - this.label = label; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getLabel() { - return this.label; - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Synonym.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Synonym.java deleted file mode 100644 index 74295cd84..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/Synonym.java +++ /dev/null @@ -1,243 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - - -import java.io.*; -import java.net.*; -import java.util.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Synonym -{ - -// Variable declaration - private String code; - private String label; - private String termName; - private String termGroup; - private String termSource; - private String sourceCode; - private String subSourceName; - private String subSourceCode; - -// Default constructor - public Synonym() { - } - -// Constructor - public Synonym( - String code, - String label, - String termName, - String termGroup, - String termSource, - String sourceCode, - String subSourceName, - String subSourceCode) { - - this.code = code; - this.label = label; - this.termName = termName; - this.termGroup = termGroup; - this.termSource = termSource; - this.sourceCode = sourceCode; - this.subSourceName = subSourceName; - this.subSourceCode = subSourceCode; - } - - public Synonym( - String termName, - String termGroup, - String termSource, - String sourceCode) { - this.code = null; - this.label = null; - this.termName = termName; - this.termGroup = termGroup; - this.termSource = termSource; - this.sourceCode = sourceCode; - this.subSourceName = null; - this.subSourceCode = null; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setLabel(String label) { - this.label = label; - } - - public void setTermName(String termName) { - this.termName = termName; - } - - public void setTermGroup(String termGroup) { - this.termGroup = termGroup; - } - - public void setTermSource(String termSource) { - this.termSource = termSource; - } - - public void setSourceCode(String sourceCode) { - this.sourceCode = sourceCode; - } - - public void setSubSourceName(String subSourceName) { - this.subSourceName = subSourceName; - } - - public void setSubSourceCode(String subSourceCode) { - this.subSourceCode = subSourceCode; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getLabel() { - return this.label; - } - - public String getTermName() { - return this.termName; - } - - public String getTermGroup() { - return this.termGroup; - } - - public String getTermSource() { - return this.termSource; - } - - public String getSourceCode() { - return this.sourceCode; - } - - public String getSubSourceName() { - return this.subSourceName; - } - - public String getSubSourceCode() { - return this.subSourceCode; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i headings; - private List rows; - -// Default constructor - public Table() { - } - -// Constructor - public Table( - String label, - List headings, - List rows) { - - this.label = label; - this.headings = headings; - this.rows = rows; - } - - - public Table( - String label, - Vector heading_vec, - Vector data_vec) { - this.label = label; - this.headings = new ArrayList(); - for (int i=0; i headings) { - this.headings = headings; - } - - public void setRows(List rows) { - this.rows = rows; - } - - -// Get methods - public String getLabel() { - return this.label; - } - - public List getHeadings() { - return this.headings; - } - - public List getRows() { - return this.rows; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i").append("\n"); - buf.append("
").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - List headings = table.getHeadings(); - for (int i=0; i").append("\n"); - buf.append(heading).append("\n"); - buf.append("").append("\n"); - } - buf.append("").append("\n"); - List rows = table.getRows(); - for (int i=0; i").append("\n"); - Row row = rows.get(i); - List cell_values = row.getrow(); - for (int j=0; j").append("\n"); - buf.append(cell_value).append("\n"); - buf.append("").append("\n"); - } - buf.append("").append("\n"); - } - buf.append("
").append("\n"); - buf.append("
").append("\n"); - return buf.toString(); - } - - - public static Table construct_table( - String label, - Vector heading_vec, - Vector data_vec) { - List headings = new ArrayList(); - for (int i=0; i rows = new ArrayList(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i nodes; - -// Default constructor - public Tree() { - } - -// Constructor - public Tree( - String root, - List nodes) { - - this.root = root; - this.nodes = nodes; - } - -// Set methods - public void setRoot(String root) { - this.root = root; - } - - public void setNodes(List nodes) { - this.nodes = nodes; - } - - -// Get methods - public String getRoot() { - return this.root; - } - - public List getNodes() { - return this.nodes; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class TreeItem implements Serializable, Comparable { - public String _code = null; - public String _text = null; - - public String _ns = null;//"na"; - public String _id = null; // tree_node_id - - public String _auis = null; - public boolean _expandable = false; - - public static String ROOT = "Root"; - public static String ROOT_CODE = ""; - - public Map> _assocToChildMap = - new TreeMap>(); - - public boolean equals(Object o) { - if (o == null) return false; - if (!(o instanceof TreeItem)) return false; - TreeItem item = (TreeItem) o; - if (_ns == null) { - return _text.compareTo(item._text) == 0 && _code.compareTo(item._code) == 0; - } else { - if (item._ns == null) return false; - return _text.compareTo(item._text) == 0 && _code.compareTo(item._code) == 0 && _ns.compareTo(item._ns) == 0; - } - } - - public int compareTo(TreeItem ti) { - String c1 = _code; - String c2 = ti._code; - if (c1.startsWith("@")) - return 1; - if (c2.startsWith("@")) - return -1; - int i = c1.compareTo(c2); - return i != 0 ? i : _text.compareTo(ti._text); - } - - public TreeItem(String code, String text) { - super(); - _code = code; - _text = text; - _auis = null; - _ns = null; - } - - public TreeItem(String code, String text, String auiText) { - super(); - _code = code; - _text = text; - _auis = auiText; - _ns = null; - } - - public TreeItem(String code, String text, String ns, String auiText) { - super(); - _code = code; - _ns = ns; - _text = text; - _auis = auiText; - } - - public TreeItem(String code, String text, String ns, String id, String auiText) { - super(); - _code = code; - _ns = ns; - _text = text; - _id = id; - _auis = auiText; - } - - public void setNs(String ns) { - _ns = ns; - } - - public void setId(String id) { - _id = id; - } - - public void addAll(String assocText, List children) { - for (TreeItem item : children) - addChild(assocText, item); - } - - public void addChild(String assocText, TreeItem child) { - List children = _assocToChildMap.get(assocText); - if (children == null) { - children = new ArrayList(); - _assocToChildMap.put(assocText, children); - } - int i; - if ((i = children.indexOf(child)) >= 0) { - TreeItem existingTreeItem = children.get(i); - for (String assoc : child._assocToChildMap.keySet()) { - List toAdd = child._assocToChildMap.get(assoc); - if (!toAdd.isEmpty()) { - existingTreeItem.addAll(assoc, toAdd); - existingTreeItem._expandable = false; - } - } - } else - children.add(child); - } - - public int hashCode() { - int hashcode = 0; - if (_code != null) hashcode = hashcode + _code.hashCode(); - if (_ns != null && _ns.compareTo("na") != 0) hashcode = hashcode + _ns.hashCode(); - if (_id != null) hashcode = hashcode + _id.hashCode(); - if (_text != null) hashcode = hashcode + _text.hashCode(); - if (_auis != null) hashcode = hashcode + _auis.hashCode(); - if (_expandable) { - hashcode = hashcode + "expandable".hashCode(); - } - return hashcode; - } - - public String toString() { - String s = _text; - if (_code != null && _code.length() > 0) - s += " (" + _code + ")"; - - if (_ns != null && _ns.length() > 0 && _ns.compareTo("na") != 0) - s += " (" + _ns + ")"; - - return s; - } - - public static void printTree(TreeItem ti, int depth) { - printTree(ti, depth, true); - } - - public static void printTree(TreeItem ti, int depth, boolean print_code_first) { - if (ti == null) return; - - StringBuffer indent = new StringBuffer(); - for (int i = 0; i < depth; i++) { - indent.append("\t"); - } - - StringBuffer codeAndText = new StringBuffer(); - - codeAndText.append(indent); - - if (print_code_first) { - codeAndText.append("").append(ti._code) - .append(':').append(ti._text).append(ti._expandable ? " [+]" : ""); - } else { - codeAndText.append("").append(ti._text).append(" (").append(ti._code).append(")"); - } - System.out.println(codeAndText); - - for (String association : ti._assocToChildMap.keySet()) { - List children = ti._assocToChildMap.get(association); - new SortUtils().quickSort(children); - for (int i=0; i children = ti._assocToChildMap.get(association); - new SortUtils().quickSort(children); - for (int i=0; i") != 0) return ti; - List children = ti._assocToChildMap.get(getAssociation(ti)); - return (TreeItem) children.get(0); - } - - public static TreeItem searchTree(TreeItem ti, String text) { - if (ti._text.compareTo(text) == 0) return ti; - TreeItem node = null; - for (String association : ti._assocToChildMap.keySet()) { - List children = ti._assocToChildMap.get(association); - if (children != null) { - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class TypeAndValue -{ - -// Variable declaration - private String type; - private String value; - -// Default constructor - public TypeAndValue() { - } - -// Constructor - public TypeAndValue( - String type, - String value) { - - this.type = type; - this.value = value; - } - -// Set methods - public void setType(String type) { - this.type = type; - } - - public void setValue(String value) { - this.value = value; - } - - -// Get methods - public String getType() { - return this.type; - } - - public String getValue() { - return this.value; - } - -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ValueSetConfig.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ValueSetConfig.java deleted file mode 100644 index a1a6b18b3..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ValueSetConfig.java +++ /dev/null @@ -1,132 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.net.*; -import java.util.*; - - -/** - * - * Copyright 2008,2009 NGIT. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIT and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIT" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIT - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history Initial implementation kim.ong@ngc.com - * - */ - - -public class ValueSetConfig -{ - -// Variable declaration - private String name; - private String uri; - private String reportURI; - private String extractionRule; - -// Default constructor - public ValueSetConfig() { - } - -// Constructor - public ValueSetConfig( - String name, - String uri, - String reportURI, - String extractionRule) { - - this.name = name; - this.uri = uri; - this.reportURI = reportURI; - this.extractionRule = extractionRule; - } - -// Set methods - public void setName(String name) { - this.name = name; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public void setReportURI(String reportURI) { - this.reportURI = reportURI; - } - - public void setExtractionRule(String extractionRule) { - this.extractionRule = extractionRule; - } - - -// Get methods - public String getName() { - return this.name; - } - - public String getUri() { - return this.uri; - } - - public String getReportURI() { - return this.reportURI; - } - - public String getExtractionRule() { - return this.extractionRule; - } - - public String toString() { - StringBuffer buf = new StringBuffer(); - buf.append("name: ").append(name); - buf.append("\n\turi: ").append(uri); - String report_uri = reportURI; - if (report_uri != null) { - report_uri = reportURI.replaceAll(" ", "%20"); - } - buf.append("\n\treportURI: ").append(report_uri); - buf.append("\n\textractionRule: ").append(extractionRule); - return buf.toString(); - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ValueSetDefinition.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ValueSetDefinition.java deleted file mode 100644 index 2f678627f..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/bean/ValueSetDefinition.java +++ /dev/null @@ -1,126 +0,0 @@ -package gov.nih.nci.evs.restapi.bean; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - -public class ValueSetDefinition -{ - -// Variable declaration - private String uri; - private String defaultCodingScheme; - private String conceptDomain; - private String name; - private String code; - private List sources; - -// Default constructor - public ValueSetDefinition() { - } - -// Constructor - public ValueSetDefinition( - String uri, - String defaultCodingScheme, - String conceptDomain, - String name, - String code, - List sources) { - - this.uri = uri; - this.defaultCodingScheme = defaultCodingScheme; - this.conceptDomain = conceptDomain; - this.name = name; - this.code = code; - this.sources = sources; - } - -// Set methods - public void setUri(String uri) { - this.uri = uri; - } - - public void setDefaultCodingScheme(String defaultCodingScheme) { - this.defaultCodingScheme = defaultCodingScheme; - } - - public void setConceptDomain(String conceptDomain) { - this.conceptDomain = conceptDomain; - } - - public void setName(String name) { - this.name = name; - } - - public void setCode(String code) { - this.code = code; - } - - public void setSources(List sources) { - this.sources = sources; - } - - -// Get methods - public String getUri() { - return this.uri; - } - - public String getDefaultCodingScheme() { - return this.defaultCodingScheme; - } - - public String getConceptDomain() { - return this.conceptDomain; - } - - public String getName() { - return this.name; - } - - public String getCode() { - return this.code; - } - - public List getSources() { - return this.sources; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class Constants { - public static final String INVERSE_IS_A = "inverse_is_a"; - public static final int TRAVERSE_UP = 1; - public static final int TRAVERSE_DOWN = 0; - public static final String NEW_CODE = "NHC0"; - public static final String NCIT_NS = ""; - - public static final String XML_DECLARATION = ""; - public static final String INVERSE_IS_OF = "inverseIsA"; - public static final String ROLE = "Role"; - public static final String ASSOCIATION = "Association"; - public static final String HIERARCHICAL = "Hierarchical"; - - public static final String FULL_SYN = "FULL_SYN"; - public static final String DEFINITION = "DEFINITION"; - public static final String ALT_DEFINITION = "ALT_DEFINITION"; - - public static final String EXACT_MATCH = "exactMatch"; - public static final String STARTS_MATCH = "startsWith"; - public static final String ENDS_MATCH = "endsWith"; - public static final String CONTAINS = "contains"; - public static String DISEASE_IS_STAGE = "Disease_Is_Stage"; - public static int MAXIMUM_LEVEL = 1000; - - public static final String EVSRESTAPI_BEAN = "gov.nih.nci.evs.restapi.bean"; - - public static String[] COMMON_PROPERTIES = {"code", "label", "Preferred_Name", "Display_Name", "DEFINITION", "ALT_DEFINITION", - "FULL_SYN", "Concept_Status", "Semantic_Type"}; - - public static String DEFAULT_VERSION_PREDICATE = "owl:versionInfo"; - public static String OBO_VERSION_PREDICATE = "oboInOwl:hasOBOFormatVersion"; - - public static String[] VERSION_PREDICATE = new String[] {DEFAULT_VERSION_PREDICATE, OBO_VERSION_PREDICATE}; - - public static String ASSOCIATION_NAME = "inverse_is_a"; - - public static final String TYPE_ROLE = "type_role"; - public static final String TYPE_ASSOCIATION = "type_association"; - public static final String TYPE_SUPERCONCEPT = "type_superconcept"; - public static final String TYPE_SUBCONCEPT = "type_subconcept"; - public static final String TYPE_INVERSE_ROLE = "type_inverse_role"; - public static final String TYPE_INVERSE_ASSOCIATION = "type_inverse_association"; - - public static String STARTS_WITH = "startsWith"; - public static String ENDS_WITH = "endsWith"; - - public static String TERMINOLOGY_SUBSET_CODE = "C54443"; //Terminology Subset (Code C54443) - - public static String CONCEPT_IN_SUBSET = "Concept_In_Subset"; - public static String CONTRIBUTING_SOURCE = "Contributing_Source"; - public static String NCI_THESAURUS = "NCI_Thesaurus"; - - public static int DEFAULT_LIMIT = 15000; - - public static final String VALUE_SET_REPORT_CONFIG = "gov.nih.nci.evs.browser.ValueSetReportConfig"; - - public static final String VALUE_SET_URI_PREFIX = "http://evs.nci.nih.gov/valueset/"; - public static final String VALUE_SET_URI_PREFIX_OLD = "http://ncit"; - - - /** - * Constructor - */ - private Constants() { - - } - -} // Class Constants diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/config/ConfigurationController.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/config/ConfigurationController.java deleted file mode 100644 index e0b7fbdbe..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/config/ConfigurationController.java +++ /dev/null @@ -1,132 +0,0 @@ -package gov.nih.nci.evs.restapi.config; - -import gov.nih.nci.evs.restapi.util.*; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Iterator; -import java.util.Properties; -import java.util.Vector; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - -abstract public class ConfigurationController { - /** The sys prop. */ - private static Properties sysProp = System.getProperties(); - - /** The dom. */ - private static Document dom; - - /** The properties. */ - private static Properties properties = loadProperties(); - - /** The Constants. */ - public final static String owlfile = properties.getProperty("owlfile"); - - public final static String username = properties.getProperty("username"); - public final static String password = properties.getProperty("password"); - public final static String serviceUrl = properties.getProperty("serviceUrl"); - public final static String namedGraph = properties.getProperty("namedGraph"); - public final static String restURL = properties.getProperty("restURL"); - public final static String serviceUrl_ctrp = properties.getProperty("serviceUrl_ctrp"); - public final static String serviceUrls = properties.getProperty("serviceUrls"); - - public final static String masterSubsetCodeColumnNumber = properties.getProperty("masterSubsetCodeColumnNumber"); - public final static String masterConceptCodeColumnNumber = properties.getProperty("masterConceptCodeColumnNumber"); - public final static String subsetCodeColumnNumber = properties.getProperty("subsetCodeColumnNumber"); - public final static String conceptCodeColumnNumber = properties.getProperty("conceptCodeColumnNumber"); - - public final static String compositeFile = properties.getProperty("compositeFile"); - public final static String projectFile = properties.getProperty("projectFile"); - - public final static String mapping_source_shortname = properties.getProperty("mapping_source_shortname"); - public final static String mapping_target_shortname = properties.getProperty("mapping_target_shortname"); - public final static String mapping_source_graphname = properties.getProperty("mapping_source_graphname"); - public final static String mapping_target_graphname = properties.getProperty("mapping_target_graphname"); - public final static String mapping_datafile = properties.getProperty("mapping_datafile"); - public final static String mapping_filename = properties.getProperty("mapping_filename"); - public final static String mapping_source_id = properties.getProperty("mapping_source_id"); - public final static String mapping_target_id = properties.getProperty("mapping_target_id"); - - public final static String source_coding_scheme = properties.getProperty("source_coding_scheme"); - public final static String source_coding_scheme_version = properties.getProperty("source_coding_scheme_version"); - public final static String target_coding_scheme = properties.getProperty("target_coding_scheme"); - public final static String target_coding_scheme_version = properties.getProperty("target_coding_scheme_version"); - public final static String mapping_name = properties.getProperty("mapping_name"); - public final static String mapping_version = properties.getProperty("mapping_version"); - - public final static String source_ns = properties.getProperty("source_ns"); - public final static String target_ns = properties.getProperty("target_ns"); - - public final static String ontology_display_label = properties.getProperty("ontology_display_label"); - public final static String ontology_version_info = properties.getProperty("ontology_version_info"); - public final static String ontology_release_date = properties.getProperty("ontology_release_date"); - public final static String ontology_description = properties.getProperty("ontology_description"); - - public final static String termfiles = properties.getProperty("termfiles"); - public final static String term_file_heading = properties.getProperty("term_file_heading"); - public final static String term_file_delim = properties.getProperty("term_file_delim"); - public final static String match_file_heading = properties.getProperty("match_file_heading"); - public final static String term_column = properties.getProperty("term_column"); - - /** - * To be implemented by each descendant testcase. - * - * @return String - */ - protected String getTestID(){ - return "Test Case"; - } - - - /** - * Load properties. - * - * @return the properties - */ - private static Properties loadProperties() { - try{ - String propertyFile = "resources/Test.properties"; - Properties lproperties = new Properties(); - FileInputStream fis = new FileInputStream(new File(propertyFile)); - lproperties.load(fis); - return lproperties; - } catch (Exception e){ - System.out.println("Error reading properties file"); - e.printStackTrace(); - return null; - } - } - - /** - * Parses the xml file. - * - * @param filename the filename - */ - private static void parseXMLFile(String filename) - { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - try{ - DocumentBuilder db = dbf.newDocumentBuilder(); - dom=db.parse(filename); - } - catch (Exception e){ - e.printStackTrace(); - } - } - -} - - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/model/Association.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/model/Association.java deleted file mode 100644 index 487547490..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/model/Association.java +++ /dev/null @@ -1,94 +0,0 @@ -package gov.nih.nci.evs.restapi.model; - -import java.io.*; -import java.util.*; -import java.net.*; - -import com.google.gson.*; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import com.thoughtworks.xstream.io.xml.DomDriver; -import com.thoughtworks.xstream.XStream; - - -public class Association -{ - -// Variable declaration - private String type; - private String relatedCode; - private String relatedName; - -// Default constructor - public Association() { - } - -// Constructor - public Association( - String type, - String relatedCode, - String relatedName) { - - this.type = type; - this.relatedCode = relatedCode; - this.relatedName = relatedName; - } - -// Set methods - public void setType(String type) { - this.type = type; - } - - public void setRelatedCode(String relatedCode) { - this.relatedCode = relatedCode; - } - - public void setRelatedName(String relatedName) { - this.relatedName = relatedName; - } - - -// Get methods - public String getType() { - return this.type; - } - - public String getRelatedCode() { - return this.relatedCode; - } - - public String getRelatedName() { - return this.relatedName; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i synonyms; - private List definitions; - private List properties; - -// Default constructor - public Concept() { - } - -// Constructor - public Concept( - String code, - String name, - String terminology, - String version, - List synonyms, - List definitions, - List properties) { - - this.code = code; - this.name = name; - this.terminology = terminology; - this.version = version; - this.synonyms = synonyms; - this.definitions = definitions; - this.properties = properties; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setName(String name) { - this.name = name; - } - - public void setTerminology(String terminology) { - this.terminology = terminology; - } - - public void setVersion(String version) { - this.version = version; - } - - public void setSynonyms(List synonyms) { - this.synonyms = synonyms; - } - - public void setDefinitions(List definitions) { - this.definitions = definitions; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getName() { - return this.name; - } - - public String getTerminology() { - return this.terminology; - } - - public String getVersion() { - return this.version; - } - - public List getSynonyms() { - return this.synonyms; - } - - public List getDefinitions() { - return this.definitions; - } - - public List getProperties() { - return this.properties; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i parents; - private List children; - private List roles; - private List inverseRoles; - private List associations; - private List inverseAssociations; - private List maps; - -// Default constructor - public ConceptDetails() { - } - -// Constructor - public ConceptDetails( - List parents, - List children, - List roles, - List inverseRoles, - List associations, - List inverseAssociations, - List maps) { - - this.parents = parents; - this.children = children; - this.roles = roles; - this.inverseRoles = inverseRoles; - this.associations = associations; - this.inverseAssociations = inverseAssociations; - this.maps = maps; - } - -// Set methods - public void setParents(List parents) { - this.parents = parents; - } - - public void setChildren(List children) { - this.children = children; - } - - public void setRoles(List roles) { - this.roles = roles; - } - - public void setInverseRoles(List inverseRoles) { - this.inverseRoles = inverseRoles; - } - - public void setAssociations(List associations) { - this.associations = associations; - } - - public void setInverseAssociations(List inverseAssociations) { - this.inverseAssociations = inverseAssociations; - } - - public void setMaps(List maps) { - this.maps = maps; - } - - -// Get methods - public List getParents() { - return this.parents; - } - - public List getChildren() { - return this.children; - } - - public List getRoles() { - return this.roles; - } - - public List getInverseRoles() { - return this.inverseRoles; - } - - public List getAssociations() { - return this.associations; - } - - public List getInverseAssociations() { - return this.inverseAssociations; - } - - public List getMaps() { - return this.maps; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i descendants; - -// Default constructor - public Descendant() { - } - -// Constructor - public Descendant( - List descendants) { - - this.descendants = descendants; - } - -// Set methods - public void setDescendants(List descendants) { - this.descendants = descendants; - } - - -// Get methods - public List getDescendants() { - return this.descendants; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i children; - -// Default constructor - public Subtree() { - } - -// Constructor - public Subtree( - String code, - String label, - boolean leaf, - List children) { - - this.code = code; - this.label = label; - this.leaf = leaf; - this.children = children; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setLabel(String label) { - this.label = label; - } - - public void setLeaf(boolean leaf) { - this.leaf = leaf; - } - - public void setChildren(List children) { - this.children = children; - } - - -// Get methods - public String getCode() { - return this.code; - } - - public String getLabel() { - return this.label; - } - - public boolean getLeaf() { - return this.leaf; - } - - public List getChildren() { - return this.children; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i subtrees; - -// Default constructor - public Tree() { - } - -// Constructor - public Tree( - List subtrees) { - - this.subtrees = subtrees; - } - -// Set methods - public void setSubtrees(List subtrees) { - this.subtrees = subtrees; - } - - -// Get methods - public List getSubtrees() { - return this.subtrees; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i children; - -// Default constructor - public TreeNode() { - } - -// Constructor - public TreeNode( - String code, - String name, - int level, - boolean leaf, - List children) { - - this.code = code; - this.name = name; - this.level = level; - this.leaf = leaf; - this.children = children; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setName(String name) { - this.name = name; - } - - public void setLevel(int level) { - this.level = level; - } - - public void setLeaf(boolean leaf) { - this.leaf = leaf; - } - - public void setChildren(List children) { - this.children = children; - } - -// Get methods - public String getCode() { - return this.code; - } - - public String getName() { - return this.name; - } - - public int getLevel() { - return this.level; - } - - public boolean getLeaf() { - return this.leaf; - } - - public List getChildren() { - return this.children; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i codes; - -// Default constructor - public ValueSet() { - } - -// Constructor - public ValueSet( - String code, - String name, - String terminology, - String version, - List codes) { - - this.code = code; - this.name = name; - this.terminology = terminology; - this.version = version; - this.codes = codes; - } - -// Set methods - public void setCode(String code) { - this.code = code; - } - - public void setName(String name) { - this.name = name; - } - - public void setTerminology(String terminology) { - this.terminology = terminology; - } - - public void setVersion(String version) { - this.version = version; - } - - public void setCodes(List codes) { - this.codes = codes; - } - -// Get methods - public String getCode() { - return this.code; - } - - public String getName() { - return this.name; - } - - public String getTerminology() { - return this.terminology; - } - - public String getVersion() { - return this.version; - } - - public List getCodes() { - return this.codes; - } - - public String toXML() { - XStream xstream_xml = new XStream(new DomDriver()); - String xml = xstream_xml.toXML(this); - xml = escapeDoubleQuotes(xml); - StringBuffer buf = new StringBuffer(); - String XML_DECLARATION = ""; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i"; - buf.append(XML_DECLARATION).append("\n").append(xml); - xml = buf.toString(); - return xml; - } - - public String toJson() { - JsonParser parser = new JsonParser(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(this); - } - - public String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class OBOScannerTest { - - public static void extractHierarchicalRelationships(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - Vector w = new OBOScanner(owlfile).extractHierarchicalRelationships(); - String hierfile = "hier_" + owlfile + ".txt"; - Utils.saveToFile(hierfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractAxiomData(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "axiom_" + owlfile; - Vector w = new OBOScanner(owlfile).extractAxiomData(); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractOWLRestrictions(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "role_" + owlfile; - OBOScanner scanner = new OBOScanner(owlfile); - Vector w = scanner.extractOWLRestrictions(scanner.get_owl_vec()); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractProperties(String[] args) { - String owlfile = args[0]; - OBOScanner scanner = new OBOScanner(owlfile); - - long ms = System.currentTimeMillis(); - String outputfile = "properties_" + owlfile; - Vector w = null; - w = scanner.extractProperties(); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractAssociations(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "association_" + owlfile; - OBOScanner scanner = new OBOScanner(owlfile); - Vector w = scanner.extractAssociations(); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractRDFSLabels(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "label_" + owlfile; - OBOScanner scanner = new OBOScanner(owlfile); - if (args.length > 1) { - String namespace = args[1]; - OBOScanner.set_NAMESPACE(namespace); - } - Vector w = scanner.extractRDFSLabels(scanner.get_owl_vec()); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - - public static void extractSynonymsFromAxiomData(String filename){ - Vector v = Utils.readFile(filename); - Vector w = new Vector(); - for (int i=0; i " + ns); - } - } - return hmap; - } - - public static void extractAnnotationProperties(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "annotation_properties_" + owlfile; - OBOScanner scanner = new OBOScanner(owlfile); - Vector w = scanner.extractAnnotationProperties(); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractObjectProperties(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "object_properties_" + owlfile; - OBOScanner scanner = new OBOScanner(owlfile); - Vector w = scanner.extractObjectProperties(); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void generateTermFile(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "term_" + owlfile; - OBOScanner scanner = new OBOScanner(owlfile); - Vector v = scanner.extractAxiomData(); - Vector w = new Vector(); - for (int i=0; i"; - String outputfile = "mod_" + termfile; - Vector v = Utils.readFile(termfile); - HashSet hset = new HashSet(); - Vector w = new Vector(); - for (int i=0; i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class OWLScannerTest { - public static String[] AXIOM_PROP_CODES = new String[] { - "P325", "P97", "P90", "P211", "P375"}; - - public static void extractHierarchicalRelationships(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - Vector w = new OWLScanner(owlfile).extractHierarchicalRelationships(); - String hierfile = "hier_" + owlfile + ".txt"; - Utils.saveToFile(hierfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractAxiomData(String[] args) { - String owlfile = args[0]; - String prop_code = null;//args[1]; - long ms = System.currentTimeMillis(); - String outputfile = "axiom_" + owlfile; - if (prop_code != null) { - outputfile = "axiom_" + prop_code + "_" + owlfile; - } - Vector w = new OWLScanner(owlfile).extractAxiomData(prop_code); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractOWLRestrictions(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "role_" + owlfile; - OWLScanner scanner = new OWLScanner(owlfile); - Vector w = scanner.extractOWLRestrictions(scanner.get_owl_vec()); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractProperties(String[] args) { - String owlfile = args[0]; - OWLScanner scanner = new OWLScanner(owlfile); - String prop_code = null; - if (args.length > 1) { - prop_code = args[1]; - //OWLScanner.set_NAMESPACE(namespace); - } - long ms = System.currentTimeMillis(); - String outputfile = "properties_" + owlfile; - Vector w = null; - if (prop_code != null) { - outputfile = prop_code + "_" + owlfile; - w = scanner.extractProperties(scanner.get_owl_vec(), prop_code); - } else { - w = scanner.extractProperties(scanner.get_owl_vec()); - } - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractAssociations(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "association_" + owlfile; - OWLScanner scanner = new OWLScanner(owlfile); - Vector w = scanner.extractAssociations(scanner.get_owl_vec()); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void extractRDFSLabels(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - String outputfile = "label_" + owlfile; - OWLScanner scanner = new OWLScanner(owlfile); - if (args.length > 1) { - String namespace = args[1]; - OWLScanner.set_NAMESPACE(namespace); - } - Vector w = scanner.extractRDFSLabels(scanner.get_owl_vec()); - Utils.saveToFile(outputfile, w); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void generate_FULL_SYN(String[] args) { - String owlfile = args[0]; - long ms = System.currentTimeMillis(); - OWLScanner scanner = new OWLScanner(owlfile); - scanner.generate_FULL_SYN(); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void test(String[] args) { - long ms = System.currentTimeMillis(); - System.out.println("extractHierarchicalRelationships ..."); - extractHierarchicalRelationships(args); - System.out.println("extractAxiomData ..."); - extractAxiomData(args); - System.out.println("extractOWLRestrictions ..."); - extractOWLRestrictions(args); - System.out.println("extractAssociations ..."); - extractAssociations(args); - System.out.println("extractProperties ..."); - extractProperties(args); - System.out.println("extractRDFSLabels ..."); - extractRDFSLabels(args); - System.out.println("generate_FULL_SYN ..."); - generate_FULL_SYN(args); - System.out.println("Grand total run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public static void main(String[] args) { - test(args); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/test/RandomVariateGenerator.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/test/RandomVariateGenerator.java deleted file mode 100644 index afae05ce2..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/test/RandomVariateGenerator.java +++ /dev/null @@ -1,129 +0,0 @@ -package gov.nih.nci.evs.restapi.test; - -import java.io.*; -import java.util.*; - - -/** - * - * Copyright 2008-2015 NGIT. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIT and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIT" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIT - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class RandomVariateGenerator { - - public RandomVariateGenerator() { - - } - - public int uniform(int min, int max) { - Random random = new Random(); - int k = max - min + 1; - if (k <= 0) k = 1; - return random.nextInt(k) + min; - } - - public boolean verifyFrequencies(int[] frequencies) { - int sum = 0; - for (int i=0; i < frequencies.length; i++) { - if (frequencies[i] < 0) return false; - sum = sum + frequencies[i]; - } - - if (sum != 100) return false; - return true; - } - - public int discreteRamdomVariate(int[] frequencies) { - int rand = new Random().nextInt(100); - int begin = 0, end = 0; - for (int i=0; i < frequencies.length; i++) { - end += frequencies[i]; - if (rand >= begin && rand < end) - return i; - begin = end; - } - return 0; - } - - public void testDiscreteRamdomVariate(int knt) { - int[] frequencies = {10, 10, 80}; - for (int i=0; i arrayList = new ArrayList(); - for (int i=0; i targetList = new ArrayList(); - for (int j=0; j - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class TreeTraversal { - String serviceUrl = null; - String named_graph = null; - String username = null; - String password = null; - OWLSPARQLUtils owlSPARQLUtils = null; - MetadataUtils metadataUtils = null; - String version = null; - - public TreeTraversal(String serviceUrl, String named_graph, String username, String password) { - this.serviceUrl = serviceUrl; - this.named_graph = named_graph; - this.username = username; - this.password = password; - this.metadataUtils = new MetadataUtils(serviceUrl, username, password); - this.version = metadataUtils.getLatestVersion("NCI_Thesaurus"); - System.out.println(this.version); - - this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - this.owlSPARQLUtils.set_named_graph(named_graph); - } - - public OWLSPARQLUtils getOWLSPARQLUtils() { - return owlSPARQLUtils; - } - - public Vector get_roots(String named_graph) { - return this.owlSPARQLUtils.get_roots(named_graph); - } - - - public Vector getAncestors(String namedGraph, String root) { - ParserUtils parser = new ParserUtils(); - Vector w = new Vector(); - Stack stack = new Stack(); - stack.push(root + "|" + "0"); - while (!stack.isEmpty()) { - String codeAndLevel = (String) stack.pop(); - Vector u0 = StringUtils.parseData(codeAndLevel, '|'); - String code = (String) u0.elementAt(0); - String level_str = (String) u0.elementAt(1); - Integer int_obj = Integer.valueOf(Integer.parseInt(level_str)); - int k = Integer.valueOf(int_obj); - w.add(codeAndLevel); - Vector u = this.owlSPARQLUtils.getSuperclassesByCode(namedGraph, code); - if (u != null && u.size() > 0) { - int n = u.size()/2; - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_subconcept"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_role"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_inverse_role"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + focused_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_association"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_inverse_association"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + focused_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - buf.append(focused_node_label + " [").append("\n"); - buf.append("fontcolor=white,").append("\n"); - buf.append("color=red,").append("\n"); - buf.append("]").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector generateGraphScriptVector(String scheme, String version, String namespace, String code, String[] types, int option, HashMap hmap) { - if (types == null) { - types = ALL_RELATIONSHIP_TYPES; - } - Vector graphData = generateGraphData(scheme, version, namespace, code, types, option, hmap); - return GraphUtils.generateGraphScriptVector(graphData, option); - } - - public Vector treeItem2GraphData(TreeItem root) { - Vector graphData = treeItem2GraphData(root, new Vector()); - return graphData; - } - - public Vector treeItem2GraphData(TreeItem ti, Vector v) { - String focused_node_label = getLabel(ti._text, ti._code); - for (String association : ti._assocToChildMap.keySet()) { - List children = ti._assocToChildMap.get(association); - for (TreeItem childItem : children) { - String code = childItem._code; - String text = childItem._text; - String rel_node_label = getLabel(text, code); - v.add(focused_node_label + "|" + rel_node_label + "|" + association + "|7"); - v = treeItem2GraphData(childItem, v); - } - } - return v; - } - - public Vector generateGraphData(String scheme, String version, String namespace, String code, String[] types, int option, HashMap hmap) { - Vector graphData = new Vector(); - List typeList = null; - if (types != null) { - typeList = Arrays.asList(types); - } else { - typeList = new ArrayList(); - typeList.add("type_superconcept"); - typeList.add("type_subconcept"); - } - - boolean useNamespace = true; - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - useNamespace = false; - } - - String name = ""; - String retstr = getEntityDescriptionByCode(code); - if (retstr != null) { - name = retstr; - } - name = encode(name); - - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - namespace = ""; - } - if (!gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - useNamespace = true; - } - String focused_node_label = getLabel(name, code); - - HashMap relMap = null; - if (hmap == null) { - //RelationshipHelper relUtils = new RelationshipHelper(sparql_service); - relMap = relationshipHelper.getRelationshipHashMap(scheme, version, code, namespace, useNamespace); - } else { - relMap = hmap; - } - - HashSet nodes = new HashSet(); - nodes.add(focused_node_label); - - ArrayList list = null; - - String key = null; - - key = "type_superconcept"; - if (typeList.contains(key)) { - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i graphReductionUtils.MINIMUM_REDUCED_GRAPH_SIZE) { - - group_node_id = graphReductionUtils.getGroupNodeId(v); - int group_node_id_int = Integer.parseInt(group_node_id); - group_node_id_2 = Integer.valueOf(group_node_id_int+1).toString(); - Vector w = graphReductionUtils.reduce_graph(v, direction); - - boolean graph_reduced = graphReductionUtils.graph_reduced(v, w); - if (graph_reduced) { - group_node_data = graphReductionUtils.get_removed_node_str(v, direction); - Vector group_node_ids = graphReductionUtils.get_group_node_ids(w); - for (int k=0; k"); - out.println(""); - out.println(""); - out.println(" View Graph"); - out.println(""); - out.println(" "); - out.println(""); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println(""); - out.println(" "); - out.println(""); - out.println(""); - out.println(""); - - out.println(""); - out.println("

"); - - if (!graph_available) { - out.println("

 No graph data is available.

"); - } - - out.println("
"); - - out.println("Relationships"); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println("  "); - out.println(""); - out.println("
"); - out.println(""); - - if (type.endsWith("path")) { - - out.println("

"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("

"); - out.println(""); - } - - out.println("
"); - out.println("
"); - out.println(""); - out.println("
"); - out.println(""); - out.println("

"); - out.println(""); - out.println(""); - - out.flush(); - - if (response != null) { - request.getSession().setAttribute("scheme", scheme); - request.getSession().setAttribute("version", version); - request.getSession().setAttribute("ns", namespace); - request.getSession().setAttribute("code", code); - request.getSession().setAttribute("nodes_and_edges", nodes_and_edges); - request.getSession().setAttribute("RelationshipHashMap", hmap); - } - - try { - out.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - public static String endPoint2ServiceUrl(String sparql_endpoint) { - int n = sparql_endpoint.indexOf("?"); - if (n == -1) return sparql_endpoint; - return sparql_endpoint.substring(0, n); - } - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - public static void main(String[] args) { - boolean testurl = false; - String serviceUrl = args[0]; - String named_graph = args[1]; - String username = args[2]; - String password = args[3]; - String code = args [4]; - - long ms = System.currentTimeMillis(); - - - MetadataUtils test = new MetadataUtils(serviceUrl, username, password); - String codingScheme = "NCI_Thesaurus"; - String version = test.getLatestVersion(codingScheme); - System.out.println(codingScheme); - System.out.println(version); - - String scheme = codingScheme; - -GraphDrawer gd = new GraphDrawer(serviceUrl, named_graph, username, password); - - //System.out.println(version); - //String named_graph = test.getNamedGraph(scheme); - //System.out.println(named_graph); - - PrintWriter pw = null; - String namespace = codingScheme; - //String code = "C12365"; - String type = "type_superconcept"; - String outputfile = "graph.html"; - - try { - pw = new PrintWriter(outputfile, "UTF-8"); - gd.view_graph(pw, named_graph, scheme, version, namespace, code, type); - - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - try { - pw.close(); - System.out.println("Output file " + outputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/GraphReductionUtils.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/GraphReductionUtils.java deleted file mode 100644 index 785d1a82b..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/GraphReductionUtils.java +++ /dev/null @@ -1,885 +0,0 @@ -package gov.nih.nci.evs.restapi.ui; - -import java.io.*; -import java.util.*; - -public class GraphReductionUtils { - static String POP_UP_MSG = "Click to view node content."; - Vector data_vec = null; - HashMap sourceEdge2TargetsMap = null; - HashMap targetEdge2SourcesMap = null; - public int MINIMUM_REDUCED_GRAPH_SIZE = 25; - private int MINIMUM_GRAPH_NODE_ID = 1000; - - int group_node_id = 0; - - static boolean FORWARD = true; - - public GraphReductionUtils() { - - } - - public void initialize_group_node_id(int n) { - MINIMUM_GRAPH_NODE_ID = n; - } - - private int getGroupNodeID() { - MINIMUM_GRAPH_NODE_ID++; - return MINIMUM_GRAPH_NODE_ID; - } - - public GraphReductionUtils(Vector data_vec) { - this.data_vec = data_vec; - sourceEdge2TargetsMap = createSourceEdge2TargetsMap(data_vec); - targetEdge2SourcesMap = getInverseHashMap(sourceEdge2TargetsMap); - } - - - public HashMap getInverseHashMap(HashMap hmap) { - HashMap inv_hmap = new HashMap(); - Iterator it = hmap.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - Vector node_edge = parseData(key); - String node = (String) node_edge.elementAt(0); - String edge = (String) node_edge.elementAt(1); - Vector w = (Vector) hmap.get(key); - for (int i=0; i max) { - max = w.size(); - max_key = key; - } - } - return max_key; - } - - public String getHighestFreqTargetEdge(HashMap targetEdge2SourcesMap) { - return getHighestFreqSourceEdge(targetEdge2SourcesMap); - } - - - public int getHighestFreqSourceEdgeCount(HashMap sourceEdge2TargetsMap) { - int max = -1; - String max_key = null; - Iterator it = sourceEdge2TargetsMap.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - Vector w = (Vector) sourceEdge2TargetsMap.get(key); - if (w.size() > max) { - max = w.size(); - max_key = key; - } - } - return max; - } - - public int getHighestFreqTargetEdgeCount(HashMap targetEdge2SourcesMap) { - return getHighestFreqSourceEdgeCount(targetEdge2SourcesMap); - } - - public Vector getCandidateTargetNodesToRemove(HashMap sourceEdge2TargetsMap) { - String key = getHighestFreqSourceEdge(sourceEdge2TargetsMap); - return (Vector) sourceEdge2TargetsMap.get(key); - } - - public Vector getCandidateSourceNodesToRemove(HashMap targetEdge2SourcesMap) { - return getCandidateTargetNodesToRemove(targetEdge2SourcesMap); - } - - public boolean isSourceNodeRemovable(Vector v, String targetEdge, String nodeId) { - Vector u = parseData(targetEdge); - String max_id = (String) u.elementAt(0); - String max_edge = (String) u.elementAt(1); - for (int i=0; i parseData(String line) { - if (line == null) return null; - String tab = "|"; - return parseData(line, tab); - } - - public Vector parseData(String line, String tab) { - if (line == null) return null; - Vector data_vec = new Vector(); - StringTokenizer st = new StringTokenizer(line, tab); - while (st.hasMoreTokens()) { - String value = st.nextToken(); - data_vec.add(value); - } - return data_vec; - } - - public static Vector readFile(String filename) - { - Vector v = new Vector(); - try { - - FileReader a = new FileReader(filename); - BufferedReader br = new BufferedReader(a); - String line; - line = br.readLine(); - while(line != null){ - v.add(line); - line = br.readLine(); - } - br.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - return v; - } - - //{id: 1, label: 'Adenocarcinoma of the Gastroesophageal Junction (C9296)', shape: 'dot', size: 5}, - public boolean isNode(String line) { - if (line.indexOf("id:") != -1 && line.indexOf("label:") != -1) { - return true; - } - return false; - } - - //{from: 44, to: 33, arrows:'to', label: 'Gene_Involved_In_Pathogenesis_Of_Disease', length: 400}, - public boolean isEdge(String line) { - if (line.indexOf("from:") != -1 && line.indexOf("to:") != -1) { - return true; - } - return false; - } - - //{id: 1, label: 'Adenocarcinoma of the Gastroesophageal Junction (C9296)', shape: 'dot', size: 5}, - public String getNodeId(String line) { - int n = line.indexOf("id:"); - String t = line.substring(n+3, line.length()); - n = t.indexOf(","); - t = t.substring(1, n); - return t; - } - - //{id: 1, label: 'Adenocarcinoma of the Gastroesophageal Junction (C9296)', shape: 'dot', size: 5}, - public String getNodeLabel(String line) { - int n = line.indexOf("label:"); - String t = line.substring(n+6, line.length()); - n = t.indexOf(","); - t = t.substring(2, n-1); - return t; - } - -// //{from: 44, to: 33, arrows:'to', label: 'Gene_Involved_In_Pathogenesis_Of_Disease', length: 400}, - public String getSourceId(String line) { - int n = line.indexOf("from:"); - String t = line.substring(n+5, line.length()); - n = t.indexOf(","); - t = t.substring(1, n); - return t; - } - - public String getTargetId(String line) { - int n = line.indexOf("to:"); - String t = line.substring(n+3, line.length()); - n = t.indexOf(","); - t = t.substring(1, n); - return t; - } - - public String getEdgeLabel(String line) { - int n = line.indexOf("label:"); - String t = line.substring(n+6, line.length()); - n = t.indexOf(","); - t = t.substring(2, n-1); - return t; - } - - public void dumpVector(Vector v) { - for (int i=0; i 0) { - System.out.println("(" + j + ")" + t); - } else { - System.out.println(t); - } - } - } - - public void dumpHashMap(String label, HashMap hmap) { - if (hmap == null) return; - System.out.println(label); - Iterator it = hmap.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - Vector v = (Vector) hmap.get(key); - StringBuffer buf = new StringBuffer(); - for (int i=0; i " + buf.toString()); - } - } - - public Vector extractNodeIDs(Vector v) { - Vector w = new Vector(); - for (int i=0; i"); - String groupNodeContent = "Node " + groupNodeId + " content:"; - buf.append(""); - buf.append("" + groupNodeContent + ""); - buf.append(""); - int j = 0; - for (int i=0; i"); - buf.append("(" + j + ") " + t); - buf.append(""); - } - buf.append(""); - return buf.toString(); - } - -/* - //PrintWriter out = response.getWriter(); - public void generateResponse(PrintWriter out, Vector v, String group_node_id, String group_node_data) { - out.println(""); - out.println(""); - out.println(""); - out.println(" View Graph"); - out.println(""); - out.println(" "); - out.println(""); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(""); - out.println(" "); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println("

"); - out.println("
"); - out.println("Relationships"); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println("  "); - out.println(""); - out.println("
"); - out.println(""); - out.println("
"); - out.println("
"); - out.println(""); - out.println("
"); - out.println(""); - out.println("

"); - out.println(""); - out.println(""); - } -*/ - public Vector get_nodes_to_remove(Vector v, HashMap hmap) { - int source_max = getHighestFreqSourceEdgeCount(hmap); - String max_source_edge_str = getHighestFreqSourceEdge(hmap); - Vector v1 = getCandidateTargetNodesToRemove(hmap); - //dumpVector("CandidateTargetNodesToRemove:", v1); - Vector nodes_to_remove = getTargetNodesToRemove(v, max_source_edge_str, v1); - return nodes_to_remove; - } - - - public String get_removed_node_str(Vector v, HashMap hmap) { - int n1 = getNodeCount(v); - String groupNodeId = Integer.valueOf(n1+1).toString(); - Vector w = null; - String removed_nodes_str = ""; - Vector nodes_to_remove = get_nodes_to_remove(v, hmap); - if (nodes_to_remove.size() == 0) return removed_nodes_str; - String max_source_edge_str = getHighestFreqSourceEdge(hmap); - w = removeNodes(v, nodes_to_remove); - Vector removed_nodes = vec_difference(v, w); - Vector removed_node_ids = extractNodeIDs(removed_nodes); - removed_nodes_str = get_removed_node_str(removed_node_ids, groupNodeId); - return removed_nodes_str; - } - - public Vector reduceGraph(Vector v, HashMap hmap) { - return reduceGraph(v, hmap, true); - } - - public Vector reduceGraph(Vector v, HashMap hmap, boolean forward) { - - //int n1 = getNodeCount(v); - //String groupNodeId = Integer.valueOf(n1+1).toString(); - int n1 = getGroupNodeID(); - String groupNodeId = Integer.valueOf(n1).toString(); - String groupNodeLabel = "Node " + groupNodeId; - Vector w = null; - try { - Vector nodes_to_remove = get_nodes_to_remove(v, hmap); - String removed_nodes_str = null; - if (nodes_to_remove.size() > 0) { - String max_source_edge_str = getHighestFreqSourceEdge(hmap); - w = removeNodes(v, nodes_to_remove); - Vector removed_nodes = vec_difference(v, w); - Vector removed_node_ids = extractNodeIDs(removed_nodes); - removed_nodes_str = get_removed_node_str(removed_node_ids, groupNodeId); - w = removeEdges(w, nodes_to_remove); - Vector u = parseData(max_source_edge_str); - String max_node = (String) u.elementAt(0); - String max_edge = (String) u.elementAt(1); - String sourceNodeId = max_node; - w = insert_group_node(w, groupNodeId, groupNodeLabel); - w = insert_edge_to_group_node(w, sourceNodeId, groupNodeId, max_edge, forward); - return w; - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return v; - } - - public String getGroupNodeId(Vector v) { - int n1 = getNodeCount(v); - return Integer.valueOf(n1+1).toString(); - } - - public Vector reduce_graph(Vector v, boolean direction) { - int n = getNodeCount(v); - HashMap hmap = createSourceEdge2TargetsMap(v); - if (!direction) { - hmap = getInverseHashMap(hmap); - } - return reduceGraph(v, hmap, direction); - } - - public boolean graph_reduced(Vector v, Vector w) { - int n1 = getNodeCount(v); - int n2 = getNodeCount(w); - //if (n1 > n2 * 2) { - if (n1 > n2) { - return true; - } - return false; - } - -/* - public Vector reduce_graph(Vector v) { - Vector w = reduce_graph(v, true); - if (graph_reduced(v, w)) { - return w; - } - w = reduce_graph(v, false); - if (graph_reduced(v, w)) { - return w; - } - return v; - } -*/ - - public String get_removed_node_str(Vector v, boolean direction) { - HashMap hmap = createSourceEdge2TargetsMap(v); - if (!direction) { - hmap = getInverseHashMap(hmap); - } - return get_removed_node_str(v, hmap); - } - - public Vector get_group_node_ids(Vector v) { - Vector w = new Vector(); - if (v == null) return w; - for (int i=0; i n2 * 2) { - graph_reduced = true; - String removed_nodes_str = get_removed_node_str(v, hmap); - generateResponse(pw, w, groupNodeId, removed_nodes_str); - System.out.println("Outputfile " + outputfile + " generated."); - } else { - System.out.println("No reduction at the forward direction."); - System.out.println("Attempting the reverse direction..."); - hmap = getInverseHashMap(hmap); - w = reduceGraph(v, hmap, false); - n2 = getNodeCount(w); - if (n1 > n2 * 2) { - graph_reduced = true; - String removed_nodes_str = get_removed_node_str(v, hmap); - - System.out.println("********** removed_nodes_str: " + removed_nodes_str); - - generateResponse(pw, w, groupNodeId, removed_nodes_str); - System.out.println("Outputfile " + outputfile + " generated."); - } - } - if (!graph_reduced) { - System.out.println("No graph reduction is made."); - } - - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - try { - pw.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - public static void main(String args[]) - { - String filename = args[0]; - Vector v = readFile(filename); - GraphReductionUtils util = new GraphReductionUtils(v); - - //test.reduceGraph(v); - int n = filename.lastIndexOf("."); - - String outputfile = filename.substring(0, n) + ".html"; - System.out.println("outputfile " + outputfile); - //test.reduceGraph2(v, outputfile); - - util.test(filename, outputfile); - - } -*/ -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/GraphUtils.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/GraphUtils.java deleted file mode 100644 index 82a846443..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/GraphUtils.java +++ /dev/null @@ -1,322 +0,0 @@ -package gov.nih.nci.evs.restapi.ui; - -import gov.nih.nci.evs.restapi.util.*; -import java.util.*; -import java.io.*; -import java.util.Map.Entry; - -public class GraphUtils { - public static final int NODES_ONLY = 1; - public static final int EDGES_ONLY = 2; - public static final int NODES_AND_EDGES = 3; - - public static final int NODE_COUNT_THRESHOLD = 25; - public static final int MIN_EDGE_LENGTH = 200; - public static final int EDGE_LENGTH = 400; - - public static final String NO_DATA_AVAILABLE = "No data available."; - - public static Vector readFile(String filename) - { - Vector v = new Vector(); - try { - FileReader a = new FileReader(filename); - BufferedReader br = new BufferedReader(a); - String line; - line = br.readLine(); - while(line != null){ - v.add(line); - line = br.readLine(); - } - br.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - return v; - } - - public static String generateGraphScript(Vector v) { - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008,2009 NGIT. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIT and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIT" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIT - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * SimpleSearchUtils (uses LexEVSAPI 6.1 SearchExtension) - * - * @author kimong - * - */ - - -public class SimpleTreeUtils { - int node_counter = 0; - static int MAXIMUM = 5; - static int MINIMUM = 0; - static String ASSOCIATION = "has_sub"; - static String TAB = ""; - private String URL = null; - private int tabindex = 0; - private String basePath = "/sparql/"; - private HashMap checkboxid2NodeIdMap = null; - - private String focusNodeId = null; - private boolean checkAll = false; - - private Vector selected_nodes = null; - private Set vocabularyNameSet = null; - - public SimpleTreeUtils(Set vocabularyNameSet) { - this.checkboxid2NodeIdMap = new HashMap(); - this.vocabularyNameSet = vocabularyNameSet; - } - - public void setBasePath(String basePath) { - this.basePath = basePath; - } - - public void setVocabularyNameSet(Set vocabularyNameSet) { - this.vocabularyNameSet = vocabularyNameSet; - } - - public boolean isFormalName(String name) { - if (vocabularyNameSet != null && vocabularyNameSet.contains(name)) return true; - return false; - } - - public void setFocusNodeId(String focusNodeId) { - this.focusNodeId = focusNodeId; - } - - public void setCheckAll(boolean checkAll) { - this.checkAll = checkAll; - } - - public String getCheckBoxStatus() { - if (this.checkAll) { - return "checked"; - } - return ""; - } - - public String getCheckBoxStatus(String node_id) { - if (this.selected_nodes == null) { - return getCheckBoxStatus(); - } else { - if (this.selected_nodes.contains(node_id)) { - return "checked"; - } - } - return ""; - } - - - public void setSelectedNodes(Vector selected_nodes) { - this.selected_nodes = selected_nodes; - } - - - public void setUrl(String url) { - this.URL = url; - } - - private String getIndentation(int level) { - if (level <= 0) return ""; - StringBuffer buf = new StringBuffer(); - for (int i=0; i 0) return true; - return false; - } - - private int getChildrenCount(TreeItem tree_node) { - int knt = 0; - for (String asso_name : tree_node._assocToChildMap.keySet()) { - List cs_vs_children = tree_node._assocToChildMap.get(asso_name); - knt = knt + cs_vs_children.size(); - } - return knt; - } - - private Vector getChildren(TreeItem tree_node) { - Vector sub_vec = new Vector(); - for (String asso_name : tree_node._assocToChildMap.keySet()) { - List cs_vs_children = tree_node._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - sub_vec.add(child_item); - } - } - return sub_vec; - } - - public StringBuffer getValueSetTreeStringBuffer(HashMap tree_map) { - if (tree_map == null) return null; - - TreeItem root = (TreeItem) tree_map.get(""); - int knt = 0; - for (String asso_name : root._assocToChildMap.keySet()) { - List cs_vs_children = root._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - knt++; - assignNodeId(null, child_item, knt); - } - } - - - Vector v = treeHashMap2StringBuffer(tree_map); - if (v == null) return null; - StringBuffer buf = new StringBuffer(); - if (v.size() == 0) { - return buf; - } - - for (int i=0; i"); - return treeItem2StringBuffer(root); - } - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - public void printFormHeader(PrintWriter out) { - //out.println(" "); - out.println(" "); - out.println("
"); - } - - public void printFormHeader(Vector v) { - v.add(" "); - //v.add(" "); - } - - public void printPageHeader(PrintWriter out) { - out.println(""); - out.println(""); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" Value Set Hierarchy"); - - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - - out.println(" "); - out.println(" "); - } - - -//Expand all Collapse all Check all Uncheck all - public void printSelectAllOrNoneLinks(PrintWriter out) { - out.println(""); - out.println("
"); - out.println("Expand all"); - out.println(" "); - out.println("Collapse all"); - out.println(" "); - out.println("Check all"); - out.println(" "); - out.println("Uncheck all"); - out.println("
"); - out.println(""); - } - - public String getTabIndex() { - tabindex++; - return "tabindex=\"" + tabindex + "\""; - } - - public static void printFormFooter(PrintWriter out) { - out.println(" "); - out.println("
"); - } - - - public static void printFormFooter(Vector v) { - v.add(" "); - v.add("
"); - } - - - - public static void printPageFooter(PrintWriter out) { - out.println(" "); - out.println("
"); - out.println(" "); - out.println(""); - } - - public HashMap getCheckboxid2NodeIdMap() { - return checkboxid2NodeIdMap; - } - - public void printNode(PrintWriter pw, TreeItem ti, int level) { - boolean expandAll = true; - printNode(pw, ti, level, expandAll); - } - - - public void printNode(PrintWriter pw, TreeItem ti, int level, boolean expandAll) { - if (ti == null) return; - String display_text = ti._text; - String indentation = getIndentation(level); - pw.println(indentation + "
  • "); - String checkbox_id = ti._id; - if (checkbox_id == null) { - checkbox_id = ti._code; - } - checkboxid2NodeIdMap.put(checkbox_id, ti._code); - String img_id = "IMG_" + checkbox_id; - if (ti._expandable) { - String div_id = "DIV_" + checkbox_id; - pw.println("\"show_hide\"" - + "" - + getHyperLink(ti)); - - if (expandAll) { - pw.println(indentation + "
    "); - pw.println(indentation + "
      "); - - for (String asso_name : ti._assocToChildMap.keySet()) { - List cs_vs_children = ti._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - printNode(pw, child_item, level+1, expandAll); - pw.flush(); - } - } - pw.println(indentation + "
    "); - pw.println(indentation + "
    "); - } - - pw.flush(); - } else { - pw.println("\"show_hide\"" - + "" - + getHyperLink(ti)); - } - pw.println(indentation + "
  • "); - pw.flush(); - } - - public void printNode(Vector v, TreeItem ti, int level) { - boolean expandAll = true; - printNode(v, ti, level, expandAll); - } - - public void printNode(Vector v, TreeItem ti, int level, boolean expandAll) { - String display_text = ti._text; - String indentation = getIndentation(level); - v.add(indentation + "
  • "); - String checkbox_id = ti._id; - if (checkbox_id == null) { - checkbox_id = ti._code; - } - checkboxid2NodeIdMap.put(checkbox_id, ti._code); - - String img_id = "IMG_" + checkbox_id; - - if (ti._expandable) { - String div_id = "DIV_" + checkbox_id; - v.add("\"show_hide\"" - + "" - + getHyperLink(ti)); - - if (expandAll) { - v.add(indentation + "
    "); - v.add(indentation + "
      "); - - for (String asso_name : ti._assocToChildMap.keySet()) { - List cs_vs_children = ti._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - printNode(v, child_item, level+1); - //pw.flush(); - } - } - v.add(indentation + "
    "); - v.add(indentation + "
    "); - } - //pw.flush(); - } else { - v.add("\"show_hide\"" - + "" - + getHyperLink(ti)); - } - v.add(indentation + "
  • "); - } - - - // Make root node clickable: - private String getHyperLink(TreeItem ti) { - //if (ti._code.startsWith("TVS_")) { - // return ti._text; - //} - - //if (!ti._code.startsWith("http:")) { - // return ti._text; - //} - - //if (DataUtils.getFormalName(ti._code) != null || DataUtils.getFormalName(ti._text) != null) { - if (isFormalName(ti._code) || isFormalName(ti._text)) { - return ti._text; - } - - if (focusNodeId != null && ti._code.compareTo(focusNodeId) == 0) { - return ti._text; - } - - return "" + ti._text + ""; - } - - -// Collapse nodes at initialization. - public void printTree(PrintWriter pw, HashMap tree_map) { - boolean expandAll = true; - printTree(pw, tree_map, expandAll); - } - - - public void printTree(PrintWriter pw, HashMap tree_map, boolean expandAll) { - if (tree_map == null) return; - //checkboxid2NodeIdMap = new HashMap(); - - TreeItem root = (TreeItem) tree_map.get(""); - if (root == null) { - System.out.println("ERROR in printTree -- root is null."); - return; - } - - if (root._assocToChildMap == null) { - System.out.println("ERROR in printTree -- root._assocToChildMap is null."); - return; - } - - int knt = 0; - for (String asso_name : root._assocToChildMap.keySet()) { - List cs_vs_children = root._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - if (child_item != null) { - knt++; - assignNodeId(null, child_item, knt); - } - } - } - printTree(pw, root, expandAll); - } - - public void printTree(Vector v, HashMap tree_map) { - boolean expandAll = true; - printTree(v, tree_map, expandAll); - } - - public void printTree(Vector v, HashMap tree_map, boolean expandAll) { - if (tree_map == null) return; - TreeItem root = (TreeItem) tree_map.get(""); - int knt = 0; - for (String asso_name : root._assocToChildMap.keySet()) { - List cs_vs_children = root._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - knt++; - assignNodeId(null, child_item, knt); - } - } - v = new Vector(); - printTree(v, root, expandAll); - } - - public void printTree(PrintWriter pw, TreeItem root) { - boolean expandAll = true; - printTree(pw, root, true); - } - - public void printTree(PrintWriter pw, TreeItem root, boolean expandAll) { - if (root == null) return; - pw.println("
      "); - for (String asso_name : root._assocToChildMap.keySet()) { - List cs_vs_children = root._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - printNode(pw, child_item, 0, expandAll); - } - } - pw.println("
    "); - } - - - public void printTree(TreeItem root) { - boolean expandAll = true; - printTree(root, expandAll); - } - - public void printTree(TreeItem root, boolean expandAll) { - PrintWriter pw = new PrintWriter(System.out); - printTree(pw, root, expandAll); - } - - public void printTree(Vector v, TreeItem root) { - boolean expandAll = true; - printTree(v, root, expandAll); - } - - public void printTree(Vector v, TreeItem root, boolean expandAll) { - if (root == null) return; - v.add("
      "); - for (String asso_name : root._assocToChildMap.keySet()) { - List cs_vs_children = root._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - printNode(v, child_item, 0, expandAll); - } - } - v.add("
    "); - } - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// - - public void assignNodeId(String parent_id, TreeItem ti, int index) { - String id = null; - if (parent_id == null) { - id = "N_" + index; - } else { - id = parent_id + "_" + index; - } - ti.setId(id); - - int lcv = 0; - for (String asso_name : ti._assocToChildMap.keySet()) { - List cs_vs_children = ti._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - lcv++; - assignNodeId(id, child_item, lcv); - } - } - } - - - public void assignNodeId(TreeItem root) { - node_counter = 0; - if (root._text.compareTo("") == 0) { - int knt = 0; - for (String asso_name : root._assocToChildMap.keySet()) { - List cs_vs_children = root._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - knt++; - assignNodeId(null, child_item, knt); - } - } - } else { - assignNodeId(null, root, 1); - } - } - - public void writeTree2HTML(HashMap hmap, String basePath, String htmlfile) { - setBasePath(basePath); - tabindex = 0; - TreeItem root = (TreeItem) hmap.get(""); - int knt = 0; - for (String asso_name : root._assocToChildMap.keySet()) { - List cs_vs_children = root._assocToChildMap.get(asso_name); - for (TreeItem child_item : cs_vs_children) { - knt++; - assignNodeId(null, child_item, knt); - } - } - - try { - PrintWriter pw = new PrintWriter(htmlfile, "UTF-8"); - printPageHeader(pw); - printSelectAllOrNoneLinks(pw); - printTree(pw, root); - printPageFooter(pw); - pw.close(); - - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - public static String getValueSetTreeKey(String uri, String name) { - return uri + "$" + name; - } - - public static HashMap createValueSetTreeKey2TreeItemMap(TreeItem ti) { - return createValueSetTreeKey2TreeItemMap(ti, new HashMap()); - } - - private static HashMap createValueSetTreeKey2TreeItemMap(TreeItem ti, HashMap map) { - String key = ti._code + "$" + ti._text; - map.put(key, ti); - for (String association : ti._assocToChildMap.keySet()) { - List children = ti._assocToChildMap.get(association); - for (TreeItem childItem : children) { - map = createValueSetTreeKey2TreeItemMap(childItem, map); - } - } - return map; - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/UICodeGenerator.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/UICodeGenerator.java deleted file mode 100644 index b0457a2f1..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/UICodeGenerator.java +++ /dev/null @@ -1,863 +0,0 @@ -package gov.nih.nci.evs.restapi.ui; - -import gov.nih.nci.evs.restapi.util.*; -import gov.nih.nci.evs.restapi.bean.*; - - -import java.io.*; -import java.util.*; -import java.text.*; -import java.sql.*; -import java.net.*; - -import org.apache.commons.lang.*; -//import org.apache.log4j.*; -import java.util.Map; -import java.util.Map.Entry; - -/** - * - * Copyright 2008,2009 NGIT. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIT and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIT" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIT - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history Initial implementation kim.ong@ngc.com - * - */ - - public class UICodeGenerator { - public String application_name = "ncimbrowser"; - public String bookmark_url = null; - - public UICodeGenerator() { - - } - - public void set_application_name(String application_name) { - this.application_name = application_name; - } - - public String get_application_name() { - return this.application_name; - } - - public void set_bookmark_url(String bookmark_url) { - this.bookmark_url = bookmark_url; - } - - public static String escapeDoubleQuotes(String inputStr) { - char doubleQ = '"'; - StringBuffer buf = new StringBuffer(); - for (int i=0; i").append("\n"); - buf.append("").append("\n"); - buf.append("Synonym Details:").append("\n"); - buf.append("").append("\n"); - buf.append(" ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); -if (syn_vec != null) { - for (int i=0; i").append("\n"); - buf.append(" ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - } -} - buf.append("
    ").append("\n"); - buf.append("Term").append("\n"); - buf.append("").append("\n"); - buf.append("Source").append("\n"); - buf.append("").append("\n"); - buf.append("\"Source").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Type").append("\n"); - buf.append("").append("\n"); - buf.append("\"Term").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Code").append("\n"); - buf.append("
    ").append("\n"); - buf.append("
    ").append("\n"); - - Synonym syn = (Synonym) syn_vec.elementAt(i); - String ncit_code = null; - String term = syn.getTermName(); - String sab = syn.getTermSource(); - - String type = syn.getTermGroup(); - String src_code = syn.getSourceCode(); - buf.append("" + term + "").append("\n"); - buf.append("
    ").append("\n"); - buf.append("
    " + sab + "" + type + "").append("\n"); - - if (codingSchemes != null && codingSchemes.contains(sab)) { - buf.append(getCodeHyperlink(src_code, sab)); - } else { - buf.append(src_code); - } - if (sourcesWithHierarchy_vec != null && sourcesWithHierarchy_vec.contains(sab)) { - buf.append("  " + getViewInSourceHierarchyLink(code, sab)); - } - buf.append("\n"); - buf.append("
    ").append("\n"); - return buf.toString(); - } - - public String generateRelationshipTable(String table_name, Vector rel_vec) { - StringBuffer buf = new StringBuffer(); - buf.append("" + table_name + " Concepts:").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append(" ").append("\n"); - -if (rel_vec != null) { - for (int i=0; i").append("\n"); - - String rela = (String) u.elementAt(1); - String name = (String) u.elementAt(4); - String cui = (String) u.elementAt(2); - String sab = (String) u.elementAt(6); - - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - } - buf.append("
    Relationship").append("\n"); - buf.append("").append("\n"); - buf.append("\"Relationship").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Rel. Attribute").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("\"Relationship").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Name").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Rel. Source").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("\"Source").append("\n"); - buf.append("").append("\n"); - buf.append("" + table_name + "" + rela + "").append("\n"); - buf.append("").append("\n"); - buf.append("" + name + "").append("\n"); - buf.append("").append("\n"); - buf.append("" + sab + "
    ").append("\n"); - buf.append("

    ").append("\n"); - buf.append("

    ").append("\n"); -} - return buf.toString(); - } - - public String generateRelationshipTable(HashMap rel_hashmap) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("Relationships with other NCI Metathesaurus Concepts:").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("Parents |").append("\n"); - buf.append("Children |").append("\n"); - buf.append("Broader |").append("\n"); - buf.append("Narrower |").append("\n"); - buf.append("Siblings |").append("\n"); - buf.append("Other").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("

    ").append("\n"); - buf.append("

    ").append("\n"); - -if (rel_hashmap != null) { - String table_name = "Parent"; - String content = generateRelationshipTable(table_name, (Vector) rel_hashmap.get("PAR")); - buf.append(content); - table_name = "Child"; - content = generateRelationshipTable(table_name, (Vector) rel_hashmap.get("CHD")); - buf.append(content); - table_name = "Broader"; - content = generateRelationshipTable(table_name, (Vector) rel_hashmap.get("RB")); - buf.append(content); - table_name = "Narrower"; - content = generateRelationshipTable(table_name, (Vector) rel_hashmap.get("RN")); - buf.append(content); - table_name = "Sibling"; - content = generateRelationshipTable(table_name, (Vector) rel_hashmap.get("SIB")); - buf.append(content); - table_name = "Other"; - content = generateRelationshipTable(table_name, (Vector) rel_hashmap.get("OTH")); - buf.append(content); -} - return buf.toString(); - } - - public String generateSourceTable(String cui, String source, Vector source_vec) { - StringBuffer buf = new StringBuffer(); - String str = generateSourceSynonymTable(cui, source, source_vec); - buf.append(str); - - buf.append("Relationships").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - - - if (source_vec != null) { - - int lcv = 0; - for (int i=0; i").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - lcv++; - } - } - - - } - buf.append("
    ").append("\n"); - buf.append("Relationship").append("\n"); - buf.append("").append("\n"); - buf.append("\"Relationship").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Rel. Attribute").append("\n"); - buf.append("").append("\n"); - buf.append("\"Relationship").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("CUI").append("\n"); - buf.append("").append("\n"); - buf.append("Term").append("\n"); - buf.append("").append("\n"); - buf.append("Source").append("\n"); - buf.append("").append("\n"); - buf.append("\"Source").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Type").append("\n"); - buf.append("").append("\n"); - buf.append("\"Term").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Code").append("\n"); - buf.append("
    " + rel + "" + rela + "").append("\n"); - buf.append("").append("\n"); - buf.append("" + cui2 + "").append("\n"); - buf.append("").append("\n"); - buf.append("" + term + "" + sab + "" + type + "" + code + "
    ").append("\n"); - buf.append("

    ").append("\n"); - buf.append("

    ").append("\n"); - - return buf.toString(); - } - - public String generateSourceSynonymTable(String cui, String source, Vector source_vec) { - StringBuffer buf = new StringBuffer(); - buf.append("Synonyms").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - -if (source_vec != null) { - int lcv = 0; - for (int i=0; i").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - lcv++; - } - } - buf.append("
    ").append("\n"); - buf.append("Term").append("\n"); - buf.append("").append("\n"); - buf.append("Source").append("\n"); - buf.append("").append("\n"); - buf.append("\"Source").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Type").append("\n"); - buf.append("").append("\n"); - buf.append("\"Term").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Code").append("\n"); - buf.append("
    " + term + "" + sab + "" + type + "" + code + "
    ").append("\n"); - buf.append("

    ").append("\n"); -} - return buf.toString(); - } - - public String generatePropertyTable(String cui, HashMap property_hashmap) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("Terms & Properties").append("\n"); - buf.append("
    ").append("\n"); - buf.append("

    Concept Unique Identifier (CUI): " + cui + "

    ").append("\n"); - buf.append("

    ").append("\n"); - -if(property_hashmap != null) { - String ncit_code = null; - Vector v = (Vector) property_hashmap.get("Synonym"); - int lcv = 0; - for (int i=0; iNCI Thesaurus Code: " + ncit_code + " ").append("\n"); - buf.append("(see NCI Thesaurus info)").append("\n"); - buf.append("

    ").append("\n"); - - v = (Vector) property_hashmap.get("Property"); - for (int i=0; iSemantic Type: " + semantic_type + "

    ").append("\n"); - } - } - buf.append("

    ").append("\n"); - - v = (Vector) property_hashmap.get("Definition"); - for (int i=0; i" + source + " Definition: " + description + "

    ").append("\n"); - } - - buf.append("

    ").append("\n"); - buf.append("Synonyms & Abbreviations:").append("\n"); - buf.append("(see Synonym Details)").append("\n"); - buf.append("").append("\n"); - v = (Vector) property_hashmap.get("Synonym"); - lcv = 0; - HashSet syn_hset = new HashSet(); - int k = 0; - for (int i=0; i").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - lcv++; - } - } - buf.append("
    " + termname + "
    ").append("\n"); - buf.append("

    ").append("\n"); - - buf.append("

    ").append("\n"); - buf.append("Other Properties:").append("\n"); - buf.append("").append("\n"); - buf.append("\"Property").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - - v = (Vector) property_hashmap.get("Property"); - lcv = 0; - for (int i=0; i").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - } -} - buf.append("
    ").append("\n"); - buf.append("Name").append("\n"); - buf.append("").append("\n"); - buf.append("Value").append("\n"); - buf.append("").append("\n"); - buf.append("Source").append("\n"); - buf.append("" + prop_name + "" + prop_value + "" + prop_source + "
    ").append("\n"); - buf.append("

    ").append("\n"); - buf.append("

    ").append("\n"); - buf.append("Additional Concept Data:  (none)").append("\n"); - buf.append("

    ").append("\n"); - buf.append("

    ").append("\n"); - buf.append("URL to Bookmark:").append("\n"); - //https://ncim65.nci.nih.gov/sparqlncim/ConceptReport.jsp?dictionary=NCI Metathesaurus&code= - buf.append("").append("\n"); - buf.append(bookmark_url + cui).append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public String generateSourceSelection(String code, String label, String sab, Vector sab_vec) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    '" + label + "' By Source: " + sab + "
    ").append("\n"); - buf.append("

    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("Select source:  ").append("\n"); - - for (int i=0; i").append("\n"); - buf.append(source).append("\n"); - buf.append(" ").append("\n"); - } - buf.append("
    "); - return buf.toString(); - } - - - public String generatePaginationForm(int total_count, String matchText) { - StringBuffer buf = new StringBuffer(); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("Results 1-50 of " + total_count + "").append("\n"); - buf.append("").append("\n"); - buf.append("      ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("1 ").append("\n"); - buf.append("").append("\n"); - buf.append("2").append("\n"); - buf.append(" ").append("\n"); - buf.append("").append("\n"); - buf.append(" ").append("\n"); - buf.append("").append("\n"); - buf.append("Next").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append(" results per page").append("\n"); - buf.append("").append("\n"); - buf.append("  ").append("\n"); - buf.append("").append("\n"); - buf.append(" ").append("\n"); - buf.append("
    ").append("\n"); - return buf.toString(); - } - - public String generateSearchResultsTable(int total_count, String matchText, Vector search_results_vec) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    Result for:cell aging
    ").append("\n"); - - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("Results 1-50 of " + total_count + " for: " + matchText + "").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - - buf.append("").append("\n"); - buf.append("").append("\n"); - - if (search_results_vec != null) { - String line = (String) search_results_vec.elementAt(0); - Vector u0 = gov.nih.nci.evs.restapi.util.StringUtils.parseData(line, '|'); - if (u0.size() > 2) { - buf.append("").append("\n"); - } - } - buf.append("").append("\n"); - if (search_results_vec != null) { - int lcv = 0; - for (int i=0; i 2) { - semantic_type = (String) u.elementAt(2); - } - String dataRowColor = "dataRowDark"; - if (!isEven(lcv).equals(Boolean.TRUE)) { - dataRowColor = "dataRowLight"; - } - buf.append("").append("\n"); - buf.append("").append("\n"); - if (u.size() > 2) { - buf.append("").append("\n"); - } - buf.append("").append("\n"); - } - } - buf.append("
    ConceptSemantic Type
    ").append("\n"); - buf.append("" + label + "").append("\n"); - buf.append("").append("\n"); - buf.append(semantic_type).append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public String generateAdvancedSearchForm(Vector source_vec) { - StringBuffer buf = new StringBuffer(); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    Advanced Search
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("  ").append("\n"); - buf.append("
    ").append("\n"); - buf.append("Concepts with this value in:").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - buf.append("
    ").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - buf.append("
    ").append("\n"); - return buf.toString(); - } - - - public String getViewInSourceHierarchyLink(String cui, String sab) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - buf.append("\"View").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public String getCodeHyperlink(String code, String sab) { - StringBuffer buf = new StringBuffer(); - buf.append(" ").append("\n"); - buf.append(code); - buf.append(" ").append("\n"); - return buf.toString(); - } - - public static void main(String[] args) { - - String filename = args[0]; - Vector v = Utils.readFile(filename); - String t = vector2String(v); - Vector w = new Vector(); - w.add(t); - Utils.saveToFile("test_" + filename, w); - /* - Vector w = new Vector(); - w.add(test()); - Utils.saveToFile("test_" + filename, w); - */ - String s = "Cell aging"; - //s = encode(s); - //System.out.println(s); - } - - } \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/UIUtils.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/UIUtils.java deleted file mode 100644 index 9c19d8d52..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/UIUtils.java +++ /dev/null @@ -1,200 +0,0 @@ -package gov.nih.nci.evs.restapi.ui; - -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; -import gov.nih.nci.evs.restapi.util.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.codec.binary.Base64; -import org.json.*; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class UIUtils { - - public static String getConceptReportHyperlink(String applicationName, String named_graph, String name, String code) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - buf.append(name).append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - -//sparql/ConceptReport.jsp - public static String getHyperlink(String named_graph, String name, String code) { - return getConceptReportHyperlink("sparqlncim", named_graph, name, code); - } - - public static String getHyperlink(String jsp, String named_graph, String name, String code) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - buf.append(name).append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - - public static void generateTestPage(String outputfile, String serviceUrl) { - PrintWriter pw = null; - try { - pw = new PrintWriter(outputfile, "UTF-8"); - generateTestPage(pw, serviceUrl); - - } catch (Exception ex) { - - } finally { - try { - pw.close(); - System.out.println("Output file " + outputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - } - - public static String generateCartContent(String applicationName, Vector label_vec, Vector semtype_vec) { - StringBuffer buf = new StringBuffer(); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - for (int i=0; i").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - } buf.append("").append("\n"); - buf.append("
     ConceptSemantic Type
    ").append("\n"); - String hyperlink = getConceptReportHyperlink(applicationName, null, name, code); - buf.append(" ").append("\n"); - buf.append(" " + semtype + "
    ").append("\n"); - //buf.append(" ").append("\n"); - //buf.append("").append("\n"); - return buf.toString(); - } - - - public static void generateTestPage(PrintWriter out, String serviceUrl) { - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println("
    "); - out.println("
    ");
    -		out.println("
    "); - out.println("

    "); - out.println("Code: "); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - } - - public static StringBuffer treeItem2StringBuffer(String applicationName, gov.nih.nci.evs.restapi.bean.TreeItem ti) { - HashSet _vocabularyNameSet = null; - gov.nih.nci.evs.restapi.util.SimpleTreeUtils stu = new gov.nih.nci.evs.restapi.util.SimpleTreeUtils(_vocabularyNameSet); - stu.setBasePath("/" + applicationName + "/"); - HashMap sourceValueSetTree = new HashMap(); - sourceValueSetTree.put("", ti); - return stu.getValueSetTreeStringBuffer(sourceValueSetTree); - } - -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/VisUtils.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/VisUtils.java deleted file mode 100644 index 805ccb2b6..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/ui/VisUtils.java +++ /dev/null @@ -1,612 +0,0 @@ -package gov.nih.nci.evs.restapi.ui; - -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; -import gov.nih.nci.evs.restapi.util.*; - -import java.util.*; -import java.io.*; -import java.util.Map.Entry; -//import org.apache.log4j.*; - -public class VisUtils { - //private static Logger _logger = Logger.getLogger(VisualizationUtils.class); - - private OWLSPARQLUtils owlSPARQLUtils = null;//(String sparql_service) { - private String sparql_service = null; - private String prefixes = null; - - public static int NODES_ONLY = 1; - public static int EDGES_ONLY = 2; - public static int NODES_AND_EDGES = 3; - - public static String ROOT = ""; - public static String PART_OF = "part_of"; - - public static final String[] ALL_RELATIONSHIP_TYPES = {"type_superconcept", - "type_subconcept", - "type_role", - "type_inverse_role", - "type_association", - "type_inverse_association"}; - public static HashMap RELATIONSHIP_LABEL_MAP; - String serviceUrl = null; - String named_graph = null; - String username = null; - String password = null; - - static { - RELATIONSHIP_LABEL_MAP = new HashMap(); - RELATIONSHIP_LABEL_MAP.put("ALL", "ALL"); - RELATIONSHIP_LABEL_MAP.put("type_superconcept", "Superconcept"); - RELATIONSHIP_LABEL_MAP.put("type_subconcept", "Subconcept"); - RELATIONSHIP_LABEL_MAP.put("type_role", "Role"); - RELATIONSHIP_LABEL_MAP.put("type_inverse_role", "Inverse Role"); - RELATIONSHIP_LABEL_MAP.put("type_association", "Association"); - RELATIONSHIP_LABEL_MAP.put("type_inverse_association", "Inverse Association"); - RELATIONSHIP_LABEL_MAP.put("type_part_of", "Part Of"); - RELATIONSHIP_LABEL_MAP.put("type_part_of_path", "Part Of (Path to Roots)"); - }; - - public static String getRelatinshipLabel(String option_label) { - if (!RELATIONSHIP_LABEL_MAP.containsKey(option_label)) return option_label; - return (String) RELATIONSHIP_LABEL_MAP.get(option_label); - } - - public VisUtils() { - - } - - public VisUtils(String serviceUrl, String named_graph, String username, String password) { - this.serviceUrl = serviceUrl; - this.sparql_service = serviceUrl; - this.username = username; - this.password = password; - - owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - owlSPARQLUtils.set_named_graph(named_graph); - - /* - String serviceUrl = sparql_service; - int n = sparql_service.lastIndexOf("?"); - if (n != -1) { - serviceUrl = sparql_service.substring(0, n); - } - - System.out.println("serviceUrl: " + serviceUrl); - */ - - MetadataUtils metadataUtils = new MetadataUtils(serviceUrl, username, password); - String codingScheme = "NCI_Thesaurus"; - long ms = System.currentTimeMillis(); - String version = metadataUtils.getLatestVersion(codingScheme); - System.out.println(codingScheme); - System.out.println(version); - this.named_graph = metadataUtils.getNamedGraph(codingScheme); - - - } - - public String getLabel(String name, String code) { - name = encode(name); - StringBuffer buf = new StringBuffer(); - buf.append(name + " (" + code + ")"); - return buf.toString(); - } - - public String getLabel(String line) { - Vector u = gov.nih.nci.evs.restapi.util.StringUtils.parseData(line); - String name = (String) u.elementAt(0); - name = encode(name); - String code = (String) u.elementAt(1); - return getLabel(name, code); - } - - public String getFieldValue(String line, int index) { - Vector u = gov.nih.nci.evs.restapi.util.StringUtils.parseData(line); - return (String) u.elementAt(index); - } - - public String encode(String t) { - if (t == null) return null; - t = t.replaceAll("'", "\'"); - return t; - } - - public String getEntityDescriptionByCode(String code) { - Vector v = owlSPARQLUtils.getLabelByCode(named_graph, code); - v = new ParserUtils().getResponseValues(v); - return (String) v.elementAt(0); - } - - public String generateDiGraph(String scheme, String version, String namespace, String code) { - boolean useNamespace = false; - if (namespace != null) useNamespace = true; - String name = ""; - String retstr = getEntityDescriptionByCode(code); - /* - Vector v = owlSPARQLUtils.getLabelByCode(named_graph, code); - v = new ParserUtils().getResponseValues(v); - String retstr = (String) v.elementAt(0); - */ - - if (retstr != null) { - name = retstr; - } - name = encode(name); - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - namespace = ""; - } - - StringBuffer buf = new StringBuffer(); - buf.append("\ndigraph {").append("\n"); - buf.append("node [shape=oval fontsize=16]").append("\n"); - buf.append("edge [length=100, color=gray, fontcolor=black]").append("\n"); - - String focused_node_label = "\"" + getLabel(name, code) + "\"" ; - - RelationshipHelper relUtils = new RelationshipHelper(serviceUrl, named_graph, username, password); - HashMap relMap = relUtils.getRelationshipHashMap(scheme, version, code, namespace, useNamespace); - - String key = "type_superconcept"; - ArrayList list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_subconcept"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_role"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_inverse_role"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + focused_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_association"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_inverse_association"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + focused_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - buf.append(focused_node_label + " [").append("\n"); - buf.append("fontcolor=white,").append("\n"); - buf.append("color=red,").append("\n"); - buf.append("]").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public String generateGraphScript(String scheme, String version, String namespace, String code) { - return generateGraphScript(scheme, version, namespace, code, null); - } - - - public String generateGraphScript(String scheme, String version, String namespace, String code, String[] types) { - return generateGraphScript(scheme, version, namespace, code, types, NODES_AND_EDGES, null); - } - - - - public String generateGraphScript(String scheme, String version, String namespace, String code, String[] types, int option, HashMap hmap) { - if (types == null) { - types = ALL_RELATIONSHIP_TYPES; - } - Vector graphData = generateGraphData(scheme, version, namespace, code, types, option, hmap); - return GraphUtils.generateGraphScript(graphData, option); - } - - - public Vector generateGraphScriptVector(String scheme, String version, String namespace, String code, String[] types, int option, HashMap hmap) { - if (types == null) { - types = ALL_RELATIONSHIP_TYPES; - } - System.out.println("generateGraphData ..."); - Vector graphData = generateGraphData(scheme, version, namespace, code, types, option, hmap); - - return GraphUtils.generateGraphScriptVector(graphData, option); - } - - public Vector treeItem2GraphData(TreeItem root) { - Vector graphData = treeItem2GraphData(root, new Vector()); - return graphData; - } - - public Vector treeItem2GraphData(TreeItem ti, Vector v) { - String focused_node_label = getLabel(ti._text, ti._code); - for (String association : ti._assocToChildMap.keySet()) { - List children = ti._assocToChildMap.get(association); - for (TreeItem childItem : children) { - String code = childItem._code; - String text = childItem._text; - String rel_node_label = getLabel(text, code); - v.add(focused_node_label + "|" + rel_node_label + "|" + association + "|7"); - v = treeItem2GraphData(childItem, v); - } - } - return v; - } - -/* - public Vector generatePartonomyGraphData(String scheme, String version, String namespace, String code, String type, int option, HashMap hmap) { - Vector graphData = new Vector(); - boolean useNamespace = true; - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - useNamespace = false; - } - - String name = ""; - String retstr = owlSPARQLUtils.getEntityDescriptionByCode(code); - if (retstr != null) { - name = retstr; - } - name = encode(name); - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - namespace = ""; - } - - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - namespace = ""; - } - if (!gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - useNamespace = true; - } - String focused_node_label = getLabel(name, code); - - HashMap relMap = null; - if (hmap == null) { - RelationshipHelper relUtils = new RelationshipHelper(sparql_service); - relMap = relUtils.getRelationshipHashMap(scheme, version, code, namespace, useNamespace); - } else { - relMap = hmap; - } - - HashSet nodes = new HashSet(); - nodes.add(focused_node_label); - - PartonomyUtils partUtils = new PartonomyUtils(sparql_service); - - if (type.compareTo("type_part_of") == 0) { - ArrayList list = null; - - List part_of_list = partUtils.getPartOfData(relMap); - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_subconcept"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_role"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_inverse_role"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + focused_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_association"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + rel_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - key = "type_inverse_association"; - list = (ArrayList) relMap.get(key); - if (list != null) { - for (int i=0; i " + focused_node_label).append("\n"); - buf.append("[label=" + rel_label + "];").append("\n"); - } - } - - buf.append(focused_node_label + " [").append("\n"); - buf.append("fontcolor=white,").append("\n"); - buf.append("color=red,").append("\n"); - buf.append("]").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public String generateGraphScript(String scheme, String version, String namespace, String code) { - return generateGraphScript(scheme, version, namespace, code, null); - } - - - public String generateGraphScript(String scheme, String version, String namespace, String code, String[] types) { - return generateGraphScript(scheme, version, namespace, code, types, NODES_AND_EDGES, null); - } - - - public String generateGraphScript(String scheme, String version, String namespace, String code, String[] types, int option, HashMap hmap) { - if (types == null) { - types = ALL_RELATIONSHIP_TYPES; - } - Vector graphData = generateGraphData(scheme, version, namespace, code, types, option, hmap); - return GraphUtils.generateGraphScript(graphData, option); - } - - - public Vector treeItem2GraphData(TreeItem root) { - Vector graphData = treeItem2GraphData(root, new Vector()); - return graphData; - } - - public Vector treeItem2GraphData(TreeItem ti, Vector v) { - String focused_node_label = getLabel(ti._text, ti._code); - for (String association : ti._assocToChildMap.keySet()) { - List children = ti._assocToChildMap.get(association); - for (TreeItem childItem : children) { - String code = childItem._code; - String text = childItem._text; - String rel_node_label = getLabel(text, code); - v.add(focused_node_label + "|" + rel_node_label + "|" + association + "|7"); - v = treeItem2GraphData(childItem, v); - } - } - return v; - } - -/* - public Vector generatePartonomyGraphData(String scheme, String version, String namespace, String code, String type, int option, HashMap hmap) { - Vector graphData = new Vector(); - boolean useNamespace = true; - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - useNamespace = false; - } - - String name = ""; - String retstr = OWLSPARQLUtils.getEntityDescriptionByCode(code); - if (retstr != null) { - name = retstr; - } - name = encode(name); - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - namespace = ""; - } - - if (gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - namespace = ""; - } - if (!gov.nih.nci.evs.restapi.util.StringUtils.isNullOrBlank(namespace)) { - useNamespace = true; - } - String focused_node_label = getLabel(name, code); - - HashMap relMap = null; - if (hmap == null) { - RelationshipHelper relUtils = new RelationshipHelper(sparql_service); - relMap = relUtils.getRelationshipHashMap(scheme, version, code, namespace, useNamespace); - } else { - relMap = hmap; - } - - HashSet nodes = new HashSet(); - nodes.add(focused_node_label); - - PartonomyUtils partUtils = new PartonomyUtils(sparql_service); - - if (type.compareTo("type_part_of") == 0) { - ArrayList list = null; - - List part_of_list = partUtils.getPartOfData(relMap); - for (int i=0; i", ti); - String url = "https://nciterms.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI%20Thesaurus&code="; - new SimpleTreeUtils().writeTree2HTML(hmap, url, htmlfile); - } - - public static void main(String[] args) { - String parent_child_file = args[0]; - Vector parent_child_vec = Utils.readFile(parent_child_file); - String nodefile = args[1]; - Vector v = Utils.readFile(nodefile); - HashSet nodeSet = new HashSet(); - for (int i=0; i - * Copyright 2008-2016 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class ASCIITreeUtils { - - public ASCIITreeUtils() { - - } - - public int getLevel(String t) { - int level = 0; - for (int i=0; i children = ti._assocToChildMap.get(association); - for (int i=0; i children = ti._assocToChildMap.get(association); - for (int i=0; i", "Root node"); - root._expandable = false; - int child_count = 0; - try { - for (int i=0; i children = root._assocToChildMap.get(Constants.ASSOCIATION_NAME); - if (children != null && children.size() > 0) { - TreeItem child_ti = null; - for (int i=0; i children = root._assocToChildMap.get(Constants.ASSOCIATION_NAME); - if (children != null && children.size() > 0) { - List new_children = new ArrayList(); - for (int i=0; i)") != 0) return v; - Vector w = new Vector(); - for (int i=1; i"); - out.println(""); - out.println(""); - out.println(" "); - out.println(" " + title + ""); - out.println(" "); - out.println(""); - out.println(""); - out.println("
    "); - out.println(""); - out.println(""); - } - - public void run(String title, String url, String outputfile) { - PrintWriter pw = null; - try { - pw = new PrintWriter(outputfile, "UTF-8"); - run(pw, title, url); - - } catch (Exception ex) { - - } finally { - try { - pw.close(); - System.out.println("Output file " + outputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - } - - public static void main(String[] args) { - long ms = System.currentTimeMillis(); - String title = args[0]; - String url = args[1]; - AjaxUtils ajaxUtils = new AjaxUtils(); - String outputfile = title + ".html"; - outputfile = outputfile.replace(" ", "_"); - ajaxUtils.run(title, url, outputfile); - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - } - -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/ApachePoiPieChartCS.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/ApachePoiPieChartCS.java deleted file mode 100644 index a794b293c..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/ApachePoiPieChartCS.java +++ /dev/null @@ -1,183 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.xddf.usermodel.chart.ChartTypes; -import org.apache.poi.xddf.usermodel.chart.LegendPosition; -import org.apache.poi.xddf.usermodel.chart.XDDFChartData; -import org.apache.poi.xddf.usermodel.chart.XDDFChartLegend; -import org.apache.poi.xddf.usermodel.chart.XDDFDataSource; -import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory; -import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource; -import org.apache.poi.xssf.usermodel.XSSFChart; -import org.apache.poi.xssf.usermodel.XSSFClientAnchor; -import org.apache.poi.xssf.usermodel.XSSFDrawing; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -import java.io.*; -import java.util.*; -import java.text.*; - -public class ApachePoiPieChartCS { - static HashSet retired_concepts = null; -//1,1-Dimethylhydrazine|C1072|Contributing_Source|FDA - static { - retired_concepts = new HashSet(); - Vector w = Utils.readFile("Retired_Concept.txt"); - for (int i=0; i sources = XDDFDataSourcesFactory.fromStringCellRange(sheet, - new CellRangeAddress(1, src_vec.size(), 0, 0)); - - XDDFNumericalDataSource values = XDDFDataSourcesFactory.fromNumericCellRange(sheet, - new CellRangeAddress(1, count_vec.size(), 1, 1)); - - //XDDFChartData data = chart.createData(ChartTypes.PIE3D, null, null); - XDDFChartData data = chart.createData(ChartTypes.PIE, null, null); - - data.setVaryColors(true); - data.addSeries(sources, values); - chart.plot(data); - String exceloutputfile = "NCIT_Concept_Stats_By_Contributing_Source.xlsx"; - try (FileOutputStream fileOut = new FileOutputStream(exceloutputfile)) { - wb.write(fileOut); - fileOut.close(); - wb.close(); - System.out.println(exceloutputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/AxiomParser.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/AxiomParser.java deleted file mode 100644 index 96ac7c656..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/AxiomParser.java +++ /dev/null @@ -1,387 +0,0 @@ -package gov.nih.nci.evs.restapi.util; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.json.*; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class AxiomParser { - JSONUtils jsonUtils = null; - HTTPUtils httpUtils = null; - String named_graph = null; - String prefixes = null; - String serviceUrl = null; - String restURL = null; - String named_graph_id = ":NHC0"; - String BASE_URI = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl"; - - ParserUtils parser = new ParserUtils(); - HashMap nameVersion2NamedGraphMap = null; - HashMap ontologyUri2LabelMap = null; - String version = null; - String username = null; - String password = null; - OWLSPARQLUtils owlSPARQLUtils = null; - - public AxiomParser() { - - } - - public AxiomParser(String serviceUrl, String named_graph, String username, String password) { - this.named_graph = named_graph; - this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - this.owlSPARQLUtils.set_named_graph(named_graph); - } - - public OWLSPARQLUtils getOWLSPARQLUtils() { - return this.owlSPARQLUtils; - } - - - public static HashSet getDistinctAxiomIds(Vector v) { - HashSet hset = new HashSet(); - for (int i=0; i - * Copyright 2011, MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC. - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation ongki@nih.gov - * - */ - -public class AxiomRetrieval { - String owlfile = null; - OWLScanner owlscanner = null; - Vector owl_vec = null; - - HashMap synonymMap = null; - HashMap sourceDefinitionMap = null; - HashMap definitionMap = null; - HashMap mapsToMap = null; - - String source = null; - - public AxiomRetrieval(String owlfile) { - this.owlfile = owlfile; - this.source = null; - initialize(); - } - - public AxiomRetrieval(String owlfile, String source) { - this.owlfile = owlfile; - this.source = source; - initialize(); - } - - public HashMap getSynonymMap() { - return this.synonymMap; - } - - public HashMap getSourceDefinitionMap() { - return this.sourceDefinitionMap; - } - - public HashMap getDefinitionMap() { - return this.definitionMap; - } - - public HashMap getMapsToMap() { - return this.mapsToMap; - } - - public void initialize() { - owlscanner = new OWLScanner(owlfile); - owl_vec = owlscanner.get_owl_vec(); - String propertyCode = "P325"; - Vector defs = owlscanner.extractAxiomData(propertyCode); - sourceDefinitionMap = new HashMap(); - for (int i=0; i"); - line = line.replace(""", "\""); - return line; - } - - public static Synonym string2Synonym(String line) { - Vector u = parseData(line, '|'); - String label = (String) u.elementAt(0); - String code = (String) u.elementAt(1); - String termName = (String) u.elementAt(3); - String termGroup = null; - String termSource = null; - String sourceCode = null; - String subSourceName = null; - String subSourceCode = null; - String qualifierCode = null; - String qualifierName = null; - if (u.size() > 4) { - for (int i=4; i 4) { - for (int i=4; i 0) { - s = s.substring(0, s.length()-4); - } - return s; - } - - - public String getDefinition(String code) { - if (definitionMap.containsKey(code)) { - return (String) definitionMap.get(code); - } - return ""; - } - - public String getSourceDefinition(String code) { - if (sourceDefinitionMap.containsKey(code)) { - return (String) sourceDefinitionMap.get(code); - } - return ""; - } - - public static Vector parseData(String line, char delimiter) { - if(line == null) return null; - Vector w = new Vector(); - StringBuffer buf = new StringBuffer(); - for (int i=0; i 0) { - t = t.substring(0, t.length()-1); - } - return t; - } - - public String findMatchedSourcecodes(String code, String source, String type) { - StringBuffer buf = new StringBuffer(); - Vector w = (Vector) synonymMap.get(code); - for (int i=0; i 0) { - t = t.substring(0, t.length()-1); - } - return t; - } - - public Vector extractAxiomData(String propertyCode) { - return owlscanner.extractAxiomData(propertyCode); - } - - public void test(String code) { - Vector w = (Vector) mapsToMap.get(code); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class AxiomUtils { - String serviceUrl = null; - OWLSPARQLUtils owlSPARQLUtils = null; - String username = null; - String password = null; - - public AxiomUtils() { - - } - -/* - public AxiomUtils(String serviceUrl) { - this.serviceUrl = serviceUrl; - this.owlSPARQLUtils = new OWLSPARQLUtils(this.serviceUrl, null, null); - } -*/ - public AxiomUtils(String serviceUrl, String username, String password) { - this.serviceUrl = serviceUrl; - this.username = username; - this.password = password; - this.owlSPARQLUtils = new OWLSPARQLUtils(this.serviceUrl, username, password); - } - - public Vector getAxioms(String named_graph, String code, String propertyName) { - return owlSPARQLUtils.getAxioms(named_graph, code, propertyName); - } - - public List getSynonyms(String named_graph, String code, String propertyName) { - Vector v = getAxioms(named_graph, code, propertyName); - return getSynonyms(v); - } - - public Vector getAxioms(String named_graph, String code, String propertyName, String qualifierName) { - Vector w = owlSPARQLUtils.getAxioms(named_graph, code, propertyName, qualifierName); - return w; - } - - public List getSynonyms(String named_graph, String code, String propertyName, String qualifierName) { - Vector v = getAxioms(named_graph, code, propertyName, qualifierName); - return getSynonyms(v); - } - - public List getSynonyms(Vector axiom_data) { - if (axiom_data == null) return null; - HashMap hmap = new HashMap(); - for (int i=0; i getSynonymWithQualifierMatching(String named_graph, String qualifierName, String qualifierValue) { - Vector syn_vec = new Vector(); - String propertyName = "FULL_SYN"; - List list = getSynonyms(named_graph, null, propertyName, qualifierName); - Vector codes = new Vector(); - for (int i=0; i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class BasicQueryUtils { - String named_graph = null; - String prefixes = null; - String serviceUrl = null; - String username = null; - String password = null; - OWLSPARQLUtils owlSPARQLUtils = null; - - public BasicQueryUtils(String serviceUrl, String named_graph, String username, String password) { - this.serviceUrl = serviceUrl; - this.named_graph = named_graph; - this.username = username; - this.password = password; - initialize(); - } - - public void initialize() { - owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - owlSPARQLUtils.set_named_graph(named_graph); - } - - public String getPrefixes() { - return owlSPARQLUtils.getPrefixes(); - } - - public Vector executeQuery(String query) { - return owlSPARQLUtils.executeQuery(query); - } - - public String construct_get_hierarchical_relationships(String named_graph) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?y_label ?y_code ?x_label ?x_code").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?y a owl:Class .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?x (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first)) ?y .").append("\n"); - buf.append(" } ").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getHierarchicalRelationships(String named_graph) { - String query = construct_get_hierarchical_relationships(named_graph); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - return new SortUtils().quickSort(v); - } - - public String construct_get_subsets(String named_graph, String code) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT ?x_label ?x_code ?p_label ?y_label ?y_code ").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append(" ?x a owl:Class . ").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label . ").append("\n"); - buf.append(" ?p a owl:AnnotationProperty . ").append("\n"); - buf.append(" ?p :NHC0 \"A8\"^^xsd:string .").append("\n"); - buf.append(" ?p rdfs:label ?p_label . ").append("\n"); - buf.append(" ?y a owl:Class . ").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - if (code != null) { - buf.append(" ?y :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - buf.append(" ?y rdfs:label ?y_label . ").append("\n"); - buf.append(" ?x ?p ?y").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getSubsets(String named_graph, String code) { - String query = construct_get_subsets(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - return new SortUtils().quickSort(v); - } - - public Vector getSubsets(String named_graph) { - return getSubsets(named_graph, null); - } - - public String construct_get_published_subset(String named_graph) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT ?x_label ?x_code ?p_label ?p_value").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class . ").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?p a owl:AnnotationProperty . ").append("\n"); - buf.append(" ?p rdfs:label ?p_label . ").append("\n"); - buf.append(" ?p rdfs:label \"Publish_Value_Set\"^^xsd:string . ").append("\n"); - buf.append(" ?x ?p ?p_value").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getPublishedSubset(String named_graph) { - String query = construct_get_published_subset(named_graph); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - return new SortUtils().quickSort(v); - } - - public static void main(String[] args) { - String serviceUrl = ConfigurationController.serviceUrl; - String namedGraph = ConfigurationController.namedGraph; - String username = ConfigurationController.username; - String password = ConfigurationController.password; - BasicQueryUtils generator = new BasicQueryUtils(serviceUrl, namedGraph, username, password); - - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CSV2HTMLTable.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CSV2HTMLTable.java deleted file mode 100644 index 14ddc1926..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CSV2HTMLTable.java +++ /dev/null @@ -1,60 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import java.io.*; -import java.text.*; -import java.util.*; - -public class CSV2HTMLTable { - - public static Vector addHyperlinks(String datafile, int columnIndex, String url) { - Vector w = new Vector(); - Vector v = Utils.readFile(datafile); - w.add((String) v.elementAt(0)); - - for (int i=1; i 5) { - String columnIndexStr = args[5]; - int columnIndex = Integer.parseInt(columnIndexStr); - String url = args[6]; - Vector w = addHyperlinks(inputfile, columnIndex, url); - Utils.saveToFile(inputfile, w); - } - - Utils.saveToFile(inputfile, v); - String outputfile = new HTMLTableDataConverter(serviceUrl, named_graph, username, password).convert(inputfile); - System.out.println(outputfile + " generated."); - v = Utils.readFile(outputfile); - outputfile = new HTMLTable().generate(v); - System.out.println(outputfile + " generated."); - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CSVFileConverter.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CSVFileConverter.java deleted file mode 100644 index edfb26cea..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CSVFileConverter.java +++ /dev/null @@ -1,81 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import com.opencsv.CSVReader; -import java.io.*; -import java.util.*; - - -/** - * - * Copyright 2008-2016 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class CSVFileConverter { - - public static void main(String[] args) { - String csvfile = args[0]; - Vector v = Utils.readFile(csvfile); - String heading = (String) v.elementAt(0); - heading = heading.replace("REL", "rel"); - heading = heading.replaceAll(" ", ""); - heading = heading.replaceAll(",", "|"); - Vector u = new Vector(); - u.add(heading); - Vector w = CSVFileReader.csv2Delimited(v, true, "|"); - w = new SortUtils().quickSort(w); - for (int j=0; j - * Copyright 2008-2016 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class CSVFileReader { - -/* - - public static void sortCSV(String inputfile, int[] sort_options, boolean skip_heading) { - Vector v = readCSV(inputfile, skip_heading, "$"); - String header = null; - if (skip_heading) { - String[] a = extractHeadings(inputfile); - header = convertToDelimitedValue(a, "$"); - } - v = quickSort(v, sort_options, "$"); - if (skip_heading) { - v.add(0, header); - } - PrintWriter pw = null; - try { - pw = new PrintWriter(inputfile, "UTF-8"); - for (int i=0; i 0) { - v.add(s); - } - } - return v; - } - - public static String convertToDelimitedValue(String[] a, String delim) { - StringBuffer buf = new StringBuffer(); - String s = null; - for (int j=0; j 0) { - for (int i=0; i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class CalendarUtils { - - public CalendarUtils() { - - } - - public static void test() { - Calendar calendar = Calendar.getInstance(); - System.out.println(calendar.getActualMaximum(Calendar.WEEK_OF_MONTH)); - } - - public static int getNumberOfWeeksInMonth(String year_month) throws Exception { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); - Date date = format.parse(year_month); - Calendar c = Calendar.getInstance(); - c.setTime(date); - int start = c.get(Calendar.WEEK_OF_MONTH); - c.add(Calendar.MONTH, 1); - c.add(Calendar.DATE, -1); - int end = c.get(Calendar.WEEK_OF_MONTH); - int num_weeks = end - start + 1; - System.out.println(" # of weeks in " + format.format(c.getTime()) + ": " + (end - start + 1)); - return num_weeks; - } - - public static int getReleaseWeek(char c) { - int int_c = (int) c; - return int_c - 96; - } - - public static char getReleaseChar(int int_c) { - char c = (char) (int_c + 96); - return c; - } - - public static String getReleaseVersion(int year, int month, int week) { - String year_str = Integer.valueOf(year).toString().substring(2, 4); - //System.out.println(year_str); - String month_str = Integer.valueOf(month).toString(); - if (month_str.length() == 1) { - month_str = "0" + month_str; - } - return year_str + "." + month_str + getReleaseChar(week); - } - - public static String getLatestMonthlyHistoryFile() { - String today = StringUtils.getToday(); - Vector u = StringUtils.parseData(today, '-'); - String month_str = (String) u.elementAt(0); - String day_str = (String) u.elementAt(1); - String year_str = (String) u.elementAt(2); - if (month_str.startsWith("0")) { - month_str = month_str.substring(1, month_str.length()); - } - System.out.println(year_str + " " + month_str + " " + day_str); - int year = Integer.parseInt(year_str); - int month = Integer.parseInt(month_str) - 1; - try { - String year_month = year_str + "-" + month; - System.out.println("year_month: " + year_month); - int week = CalendarUtils.getNumberOfWeeksInMonth(year_month); - String s = getReleaseVersion(year, month, week-1); - return s; - } catch (Exception ex) { - ex.printStackTrace(); - } - return null; - } - - public static void main(String[] args) throws Exception { - try { - String year_month = "2020-08"; - int num_weeks = getNumberOfWeeksInMonth(year_month); - - System.out.println(" # of weeks in " + year_month + ": " + num_weeks); - - } catch (Exception ex) { - ex.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CodeGenerator.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CodeGenerator.java deleted file mode 100644 index 9cf530cf5..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/CodeGenerator.java +++ /dev/null @@ -1,206 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import java.io.*; -import java.text.*; -import java.util.*; -import javax.servlet.*; -import javax.servlet.http.*; -import java.sql.*; - - -public class CodeGenerator { - static String BASE_URL = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl"; - - public CodeGenerator(String serviceUrl, String namedGraph, String username, String password) { - } - - public static Vector generateCode(String queryfile) { - int n = queryfile.lastIndexOf("_query"); - if(n == -1) { - System.out.println("queryfile: " + queryfile); - System.out.println("ERROR: Incorrect naming of query file (example: sparql_query.txt.)"); - return null; - } - String t = queryfile.substring(0, n); - String methodSignature = "construct_get_" + t + "(String named_graph)"; - - Vector v = Utils.readFile(queryfile); - Vector w = new Vector(); - w.addAll(SPARQLQueryGenerator.createConstrcQueryMethod(methodSignature, v)); - w.add("\n"); - w.addAll(SPARQLQueryGenerator.createQueryMethod(methodSignature)); - //w.addAll(SPARQLQueryGenerator.findHardCodedVariables(v)); - return w; - } - - - public static void run(PrintWriter out, String queryfile, String className) { - out.println("import gov.nih.nci.evs.restapi.util.*;"); - out.println("import gov.nih.nci.evs.restapi.bean.*;"); - out.println("import gov.nih.nci.evs.restapi.common.*;"); - out.println(""); - out.println("import java.io.*;"); - out.println("import java.io.BufferedReader;"); - out.println("import java.io.InputStream;"); - out.println("import java.io.InputStreamReader;"); - out.println("import java.net.*;"); - out.println("import java.net.HttpURLConnection;"); - out.println("import java.net.MalformedURLException;"); - out.println("import java.net.URL;"); - out.println("import java.net.URLConnection;"); - out.println("import java.net.URLEncoder;"); - out.println("import java.util.*;"); - out.println("import java.util.regex.*;"); - out.println("import org.json.*;"); - out.println(""); - out.println("/**"); - out.println(" * "); - out.println(" * Copyright 2008-2017 NGIS. This software was developed in conjunction"); - out.println(" * with the National Cancer Institute, and so to the extent government"); - out.println(" * employees are co-authors, any rights in such works shall be subject"); - out.println(" * to Title 17 of the United States Code, section 105."); - out.println(" * Redistribution and use in source and binary forms, with or without"); - out.println(" * modification, are permitted provided that the following conditions"); - out.println(" * are met:"); - out.println(" * 1. Redistributions of source code must retain the above copyright"); - out.println(" * notice, this list of conditions and the disclaimer of Article 3,"); - out.println(" * below. Redistributions in binary form must reproduce the above"); - out.println(" * copyright notice, this list of conditions and the following"); - out.println(" * disclaimer in the documentation and/or other materials provided"); - out.println(" * with the distribution."); - out.println(" * 2. The end-user documentation included with the redistribution,"); - out.println(" * if any, must include the following acknowledgment:"); - out.println(" * \"This product includes software developed by NGIS and the National"); - out.println(" * Cancer Institute.\" If no such end-user documentation is to be"); - out.println(" * included, this acknowledgment shall appear in the software itself,"); - out.println(" * wherever such third-party acknowledgments normally appear."); - out.println(" * 3. The names \"The National Cancer Institute\", \"NCI\" and \"NGIS\" must"); - out.println(" * not be used to endorse or promote products derived from this software."); - out.println(" * 4. This license does not authorize the incorporation of this software"); - out.println(" * into any third party proprietary programs. This license does not"); - out.println(" * authorize the recipient to use any trademarks owned by either NCI"); - out.println(" * or NGIS"); - out.println(" * 5. THIS SOFTWARE IS PROVIDED \"AS IS,\" AND ANY EXPRESSED OR IMPLIED"); - out.println(" * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES"); - out.println(" * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE"); - out.println(" * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE,"); - out.println(" * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT,"); - out.println(" * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,"); - out.println(" * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;"); - out.println(" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER"); - out.println(" * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT"); - out.println(" * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN"); - out.println(" * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE"); - out.println(" * POSSIBILITY OF SUCH DAMAGE."); - out.println(" * "); - out.println(" */"); - out.println(""); - out.println("/**"); - out.println(" * @author EVS Team"); - out.println(" * @version 1.0"); - out.println(" *"); - out.println(" * Modification history:"); - out.println(" * Initial implementation kim.ong@ngc.com"); - out.println(" *"); - out.println(" */"); - out.println(""); - out.println(""); - out.println("public class " + className + " {"); - out.println(" JSONUtils jsonUtils = null;"); - out.println(" HTTPUtils httpUtils = null;"); - out.println(" String named_graph = null;"); - out.println(" String prefixes = null;"); - out.println(" String serviceUrl = null;"); - out.println(" String restURL = null;"); - out.println(" String named_graph_id = \":NHC0\";"); - out.println(" String BASE_URI = \"http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl\";"); - out.println(""); - out.println(" ParserUtils parser = new ParserUtils();"); - out.println(" HashMap nameVersion2NamedGraphMap = null;"); - out.println(" HashMap ontologyUri2LabelMap = null;"); - out.println(" String version = null;"); - out.println(" String username = null;"); - out.println(" String password = null;"); - out.println(" OWLSPARQLUtils owlSPARQLUtils = null;"); - out.println(""); - out.println(" public " + className + "(String serviceUrl, String named_graph, String username, String password) {"); - out.println(" this.serviceUrl = serviceUrl;"); - out.println(" this.named_graph = named_graph;"); - out.println(" this.username = username;"); - out.println(" this.password = password;"); - out.println(" this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password);"); - out.println(" this.owlSPARQLUtils.set_named_graph(named_graph);"); - out.println(" }"); - out.println(""); - out.println(" public OWLSPARQLUtils getOWLSPARQLUtils() {"); - out.println(" return this.owlSPARQLUtils;"); - out.println(" }"); - out.println("\n"); - - Vector w = generateCode(queryfile); - String invokingMethod = null; - - for (int i=0; iAcinar CellSYNCITCGAcaDSR -*/ - -public class ComplexPropertyParser { - public static String reformat(String str) { - str = str.replaceAll("< ncicp", "ActivityPTBRIDG"; - ComplexTerm term = convertToComplexTerm(full_syn); - System.out.println(term.toString()); - } - -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/ConceptData.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/ConceptData.java deleted file mode 100644 index 104fca1c9..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/ConceptData.java +++ /dev/null @@ -1,290 +0,0 @@ -package gov.nih.nci.evs.restapi.util; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.json.*; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class ConceptData { - JSONUtils jsonUtils = null; - HTTPUtils httpUtils = null; - String named_graph = null; - String prefixes = null; - String serviceUrl = null; - String restURL = null; - String named_graph_id = ":NHC0"; - String BASE_URI = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl"; - - ParserUtils parser = new ParserUtils(); - HashMap nameVersion2NamedGraphMap = null; - HashMap ontologyUri2LabelMap = null; - String version = null; - String username = null; - String password = null; - OWLSPARQLUtils owlSPARQLUtils = null; - MetadataUtils metadataUtils = null; - AxiomParser axiomParser = null;// (String serviceUrl, String named_graph, String username, String password) - - public ConceptData(String serviceUrl, String named_graph, String username, String password) { - this.serviceUrl = serviceUrl; - this.named_graph = named_graph; - this.username = username; - this.password = password; - this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - this.owlSPARQLUtils.set_named_graph(named_graph); - this.metadataUtils = new MetadataUtils(serviceUrl, username, password); - this.version = metadataUtils.getVocabularyVersion(named_graph); - this.axiomParser = new AxiomParser(serviceUrl, named_graph, username, password); - } - - public OWLSPARQLUtils getOWLSPARQLUtils() { - return this.owlSPARQLUtils; - } - - - public String construct_get_concept_properties(String named_graph, String code) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("").append("\n"); - buf.append("SELECT distinct ?p_label ?p_value").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + "> {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p a owl:AnnotationProperty .").append("\n"); - buf.append(" ?x ?p ?p_value .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getConceptProperties(String named_graph, String code) { - String query = construct_get_concept_properties(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public void generate(String named_graph, String code) { - Vector qualifiers = owlSPARQLUtils.getSupportedPropertyQualifiers(named_graph); - Vector properties = new Vector(); - for (int i=0; i" + label + " (" + code + ")"); - w.add("Terms & Properties"); - w.add("
    Name"); - w.add("Value"); - w.add(""); - for (int i=0; i"); - w.add("
    "); - Vector axiomData = axiomParser.getAxioms(named_graph, code); - for (int i=0; i" + property); - w.add("Value"); - for (int j=0; j" + s); - } - } - w.add(""); - Vector w1 = filterAxiomData(axiomData, property); - w.addAll(w1); - w.add(""); - w.add(""); - } - - w.add("
    (Source: NCI Thesaurus, version " + version + ")"); - - HTMLTable.generate(w); - } - - public Vector filterAxiomData(Vector axiomData, String propertyName) { - Vector w = new Vector(); - if (propertyName.compareTo("FULL_SYN") == 0) { - for (int i=0; i 126) { - buf.append(" "); - } else { - String s = "" + c; - if (s.compareTo("'") == 0) { - buf.append("\\'"); - } else { - buf.append(s); - } - } - } - return buf.toString(); - } - - public void writeHeader(PrintWriter out, String title) { - out.println(""); - out.println(""); - out.println(""); - out.println(" "); - out.println(" " + title + ""); - out.println(" "); - writeFunction(out); - out.println(""); - } - - - public void writeFunction(PrintWriter out) { - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - } - - - public String getIndentation(int level) { - StringBuffer buf = new StringBuffer(); - for (int i=0; i").append("\n"); - buf.append("").append("\n"); - buf.append(" Source Code").append("\n"); - buf.append(" Source Term").append("\n"); - buf.append(" Target Code").append("\n"); - buf.append(" Target Term").append("\n"); - buf.append(" Property").append("\n"); - buf.append(" Property Value").append("\n"); - buf.append("").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - - Iterator it = propertyHashMap.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - String line = CSVFileReader.csv2Delimited(key, "|"); - Vector u = StringUtils.parseData(line, '|'); - String source_code = (String) u.elementAt(0); - String source_term = (String) u.elementAt(1); - String target_code = (String) u.elementAt(2); - String target_term = (String) u.elementAt(3); - StringBuffer property_buf = new StringBuffer(); - HashMap hmap = (HashMap) propertyHashMap.get(key); - Vector properties = new Vector(); - Iterator it2 = hmap.keySet().iterator(); - while (it2.hasNext()) { - String key2 = (String) it2.next(); - properties.add(key2); - } - properties = new gov.nih.nci.evs.restapi.util.SortUtils().quickSort(properties); - int line_num = 0; - for (int k=0; k").append("\n"); - if (line_num == 0) { - line_buf.append("").append(source_code).append("").append("\n"); - line_buf.append("").append(source_term).append("").append("\n"); - line_buf.append("").append("").append(target_code).append("").append("").append("\n"); - line_buf.append("").append(target_term).append("").append("\n"); - - } else { - line_buf.append("").append("").append("").append("\n"); - line_buf.append("").append("").append("").append("\n"); - line_buf.append("").append("").append("").append("\n"); - line_buf.append("").append("").append("").append("\n"); - } - String value = (String) values.elementAt(k2); - String col1 = property; - String col2 = value; - if (k2 != 0) { - col1 = ""; - } - line_buf.append("").append(col1).append("").append("\n"); - line_buf.append("").append(col2).append("").append("\n"); - - buf.append(line_buf.toString()).append("\n"); - buf.append("").append("\n"); - line_num++; - line_buf = new StringBuffer(); - } - - } - - } - buf.append("").append("\n"); - return buf.toString(); - } - - public void writeBody(PrintWriter out, String title) { - out.println(""); - out.println("

    " + title + "

    "); - out.println("
    "); - String content = null; - try { - content = propertyHashMap2HTML(this.propertyHashMap); - } catch (Exception ex) { - ex.printStackTrace(); - } - out.println(content); - out.println(""); - } - - public void writeFooter(PrintWriter out) { - out.println(""); - } - - public Vector sortByLabel(Vector codes) { - if (codes == null || codes.size()<=1) return codes; - Vector w = new Vector(); - HashMap hmap = new HashMap(); - for (int i=0; i|") == -1) { - w.add(line); - } - } - return w; - } - - - public HashMap appendPropertiesToMappingEntries(String serviceUrl, String namedGraph, Vector mapping_entries) { - HashMap propertyHashMap = new HashMap(); - OWLSPARQLUtils owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl); - ParserUtils parserUtils = new ParserUtils(); - Vector v = mapping_entries; - for (int i=1; i 0) { - String query = owlSPARQLUtils.construct_get_properties_by_code(namedGraph, target_code); - Vector w = owlSPARQLUtils.getPropertiesByCode(namedGraph, target_code); - if (w == null || w.size() == 0) { - //System.out.println("\tgetPropertiesByCode returns null???"); - } else { - w = parserUtils.getResponseValues(w); - HashMap hmap = createPropertyHashMap(w); - propertyHashMap.put(line, hmap); - } - } - } - return propertyHashMap; - } - - public void dumpPropertyHashMap(HashMap propertyHashMap) { - Iterator it = propertyHashMap.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - - HashMap hmap = (HashMap) propertyHashMap.get(key); - System.out.println(key); - Vector properties = new Vector(); - Iterator it2 = hmap.keySet().iterator(); - while (it2.hasNext()) { - String key2 = (String) it2.next(); - properties.add(key2); - } - properties = new gov.nih.nci.evs.restapi.util.SortUtils().quickSort(properties); - for (int k=0; k - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class ConceptHelper { - String serviceUrl = null; - String namedGraph = null; - String username = null; - String password = null; - OWLSPARQLUtils owlSPARQLUtils = null; - - public ConceptHelper(String serviceUrl, - String namedGraph, - String username, - String password) { - this.serviceUrl = serviceUrl; - this.namedGraph = namedGraph; - this.username = username; - this.password = password; - this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - this.owlSPARQLUtils.set_named_graph(namedGraph); - } - - public String construct_get_label(String named_graph, String code) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_label ?x_code").append("\n"); - buf.append("from ").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append("}").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public Vector getLabel(String named_graph, String code) { - String query = construct_get_label(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public String construct_get_roles(String named_graph, String code) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_code ?x_label ?p_code ?p_label ?y_code ?y_label").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + "> ").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?x (rdfs:subClassOf|owl:equivalentClass|owl:unionOf/rdf:rest*/rdf:first|owl:intersectionOf/rdf:rest*/rdf:first)* ?rs . ").append("\n"); - buf.append(" ?rs a owl:Restriction .").append("\n"); - buf.append(" ?rs owl:onProperty ?p .").append("\n"); - buf.append(" ?rs owl:someValuesFrom ?y .").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getRoles(String named_graph, String code) { - String query = construct_get_roles(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public String construct_get_proproperties(String named_graph, String code) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("SELECT distinct ?x1_code ?x1_label ?p_label ?p_value").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x1 a owl:Class .").append("\n"); - buf.append(" ?x1 :NHC0 ?x1_code .").append("\n"); - buf.append(" ?x1 :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - buf.append(" ?x1 rdfs:label ?x1_label .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append(" ?x1 ?p ?p_value . ").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getProperties(String named_graph, String code) { - String query = construct_get_proproperties(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public String construct_get_subclasses(String named_graph, String code) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?x_label ?x_code ").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + "> ").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ?y :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - buf.append(" ?x (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first)) ?y . ").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getSubclasses(String named_graph, String code) { - String query = construct_get_subclasses(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public String construct_get_superclasses(String named_graph, String code) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?y_label ?y_code ").append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + "> ").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ?x (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first)) ?y . ").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getSuperclasses(String named_graph, String code) { - String query = construct_get_superclasses(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public String construct_get_axioms(String named_graph, String code) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("select distinct ?a1 ?x1_label ?x1_code ?p_label ?a1_target ?q1_label ?q1_value").append("\n"); - buf.append("from <" + named_graph + ">").append("\n"); - buf.append("where { ").append("\n"); - buf.append(" ?x1 a owl:Class .").append("\n"); - buf.append(" ?x1 :NHC0 ?x1_code .").append("\n"); - buf.append(" ?x1 :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - buf.append(" ?x1 rdfs:label ?x1_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?a1 a owl:Axiom .").append("\n"); - buf.append(" ?a1 owl:annotatedSource ?x1 .").append("\n"); - buf.append(" ?a1 owl:annotatedProperty ?p .").append("\n"); - buf.append(" ?a1 owl:annotatedTarget ?a1_target .").append("\n"); - buf.append(" ?p :NHC0 ?p_code .").append("\n"); - buf.append(" ?p rdfs:label ?p_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?q1 :NHC0 ?q1_code .").append("\n"); - buf.append(" ?q1 rdfs:label ?q1_label .").append("\n"); - buf.append(" ?a1 ?q1 ?q1_value .").append("\n"); - buf.append("").append("\n"); - buf.append(" ").append("\n"); - buf.append("").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector getAxioms(String named_graph, String code) { - String query = construct_get_axioms(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public Vector getAxiomData(Vector w, String prop_label) { - Vector v = new Vector(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class DateUtils { - static String ALPHABETICS = "abcdefg"; - static String NCI_THESAURUS_URI = "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus"; - - public static String getToday() { - return getToday("yyyy-MM"); - } - - public static String getToday(String format) { - java.util.Date date = Calendar.getInstance().getTime(); - SimpleDateFormat sdf = new SimpleDateFormat(format); - return sdf.format(date); - } - - public static int getNumberOfWeeks() { - String m = getToday(); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); - try { - Date date = format.parse(m); - Calendar c = Calendar.getInstance(); - c.setTime(date); - - int start = c.get(Calendar.WEEK_OF_MONTH); - - c.add(Calendar.MONTH, 1); - c.add(Calendar.DATE, -1); - int end = c.get(Calendar.WEEK_OF_MONTH); - return end - start + 1; - } catch (Exception ex) { - return -1; - } - } - - public static int getDayNumberNew(LocalDate date) { - DayOfWeek day = date.getDayOfWeek(); - return day.getValue(); - } - - public static LocalDate getLocalDate() { - //Current Date - LocalDate today = LocalDate.now(); - System.out.println("Current Date="+today); - return today; - } - - - public static LocalDate getLocalDate(int year, int month, int day) { // month: Month.JANUARY - //Creating LocalDate by providing input arguments - LocalDate local_date = LocalDate.of(year, month, day); - return local_date; - } - - public static int getDayNumber(LocalDate date) { - DayOfWeek day = date.getDayOfWeek(); - printDayOfWeek(day); - return day.getValue(); - } - - public static void printDayOfWeek(DayOfWeek dow) { - Locale locale = Locale.getDefault(); - System.out.println(dow.getDisplayName(TextStyle.FULL, locale)); - System.out.println(dow.getDisplayName(TextStyle.NARROW, locale)); - System.out.println(dow.getDisplayName(TextStyle.SHORT, locale)); - } - - - - public static int getDaysInMonth(int year, int month) { - YearMonth yearMonthObject = YearMonth.of(year, month); - int daysInMonth = yearMonthObject.lengthOfMonth(); - return daysInMonth; - } - - public static int getNumberOfMondaysInAMonth(int year, int month) { - String weekDay = "Monday"; - return getNumberOfWeekDaysInAMonth(year, month, weekDay); - } - - public static int getNumberOfWeekDaysInAMonth(int year, int month, String weekDay) { - int m = 0; - Locale locale = Locale.getDefault(); - int num_days = getDaysInMonth(year, month); - for (int day=1; day<=num_days; day++) { - LocalDate date = getLocalDate(year, month, day); - DayOfWeek dow = date.getDayOfWeek(); - String fullName = dow.getDisplayName(TextStyle.FULL, locale); - if (fullName.compareTo(weekDay) == 0) { - m++; - } - } - return m; - } - - public static String getNCItMonthlyVersion(int year, int month) { - int n = getNumberOfMondaysInAMonth(year, month); - char c = ALPHABETICS.charAt(n-1); - StringBuffer buf = new StringBuffer(); - String year_str = "" + year; - String t = year_str.substring(2, 4); - buf.append(t).append("."); - if (month < 10) { - buf.append("0").append("" + month); - buf.append(c); - } else { - buf.append("" + month); - buf.append(c); - } - return buf.toString(); - } - - public static String getNCItMonthlyVersion() { - int currentYear = getCurrentYear(); - int currentMonth = getCurrentMonth(); - return getNCItMonthlyVersion(currentYear, currentMonth); - } - - public static String getNCIThesaurusGraphName(int year, int month) { - String version = getNCItMonthlyVersion(year, month); - return NCI_THESAURUS_URI + version + ".owl"; - } - - public static String getNCIThesaurusGraphName() { - int currentYear = getCurrentYear(); - int currentMonth = getCurrentMonth(); - String version = getNCItMonthlyVersion(currentYear, currentMonth); - return NCI_THESAURUS_URI + version + ".owl"; - } - - public static int getCurrentMonth() { - return Calendar.getInstance().get(Calendar.MONTH) + 1; - } - - public static int getCurrentYear() { - return Calendar.getInstance().get(Calendar.YEAR); - } - - public static Vector getNCItReleaseSchedule(int year) { - Vector w = new Vector(); - w.add("Year|Month|Version|Graph Name|Release Data"); - for (int i=1; i<=12; i++) { - String version = getNCItMonthlyVersion(year, i); - String graphName = getNCIThesaurusGraphName(year, i); - w.add("" + year + "|" + getMonthString(i) + "|" + version + "|" + graphName + "|" + getMonthlyNCItReleaseDate(year, i)); - } - return w; - } - - public static int getLastWeekdayOfAMonth(int year, int month, String weekDay) { - int m = 0; - Locale locale = Locale.getDefault(); - int num_days = getDaysInMonth(year, month); - for (int day=1; day<=num_days; day++) { - int j = num_days-day+1; - LocalDate date = getLocalDate(year, month, j); - DayOfWeek dow = date.getDayOfWeek(); - String fullName = dow.getDisplayName(TextStyle.FULL, locale); - if (fullName.compareTo(weekDay) == 0) { - return j; - } - } - return 0; - } - - public static String getMonthlyNCItReleaseDate(int year, int month) { - int n = getLastWeekdayOfAMonth(year, month, "Monday"); - StringBuffer buf = new StringBuffer(); - if (month < 10) { - buf.append("0"); - } - buf.append(month).append("/"); - if (n < 10) { - buf.append("0"); - } - buf.append(n).append("/"); - buf.append(year); - return buf.toString(); - } - - public static String getMonthString(int month) { - return new DateFormatSymbols().getMonths()[month-1]; - } - - public static HashMap getReleaseScheduleHashMap(int year) { - Vector w = getNCItReleaseSchedule(year); - HashMap hmap = new HashMap(); - for (int i=1; i columns, char delim) { - Vector w = Utils.readFile(filename); - Vector v = new Vector(); - for (int i=0; i columns, char delim) { - Vector v = new Vector(); - for (int i=0; i= 0) { - bufferOut.write(buffer,0,readbyte); - TotalDownload += readbyte; - percentOfDownload = (TotalDownload*100)/filesize; - String percent = String.format("%.2f", percentOfDownload); - System.out.println("Downloaded "+ percent + "%"); - } - - System.out.println("Download is complete."); - bufferOut.close(); - input.close(); - } - catch(IOException e){ - e.printStackTrace(); - } - } - - // trusting all certificate - public static void doTrustToCertificates() throws Exception { - //Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException { - return; - } - - public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException { - return; - } - } - }; - - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, new SecureRandom()); - HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); - HostnameVerifier hv = new HostnameVerifier() { - public boolean verify(String urlHostName, SSLSession session) { - if (!urlHostName.equalsIgnoreCase(session.getPeerHost())) { - System.out.println("Warning: URL host '" + urlHostName + "' is different to SSLSession host '" + session.getPeerHost() + "'."); - } - return true; - } - }; - HttpsURLConnection.setDefaultHostnameVerifier(hv); - } - - public static void main(String[] args) { - String link = "https://www.africau.edu/images/default/sample.pdf"; - File file = new File("sample.pdf"); - download(link, file); - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/EmbeddedHierarchy.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/EmbeddedHierarchy.java deleted file mode 100644 index 2a359c7cc..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/EmbeddedHierarchy.java +++ /dev/null @@ -1,674 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import gov.nih.nci.evs.restapi.appl.*; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; - -public class EmbeddedHierarchy { - static final String ROOT_NODE = "Root node"; - static final String ROOT_NODE_CODE = ""; - - static final String UNUSED_SUBSET_CONCEPT_CODE = "C103175"; - static final String TERMINOLOGY_SUBSET_CODE = "C54443"; - - static final String parent_child_file = "parent_child.txt"; - static final String vs_header_concept_file = "P372.txt"; - - int multiple_count = 0; - - Vector parent_child_vec = null; - HashSet node_set = null; - - HierarchyHelper hh = null; - HierarchyHelper eh_hh = null; - - PathFinder pathFinder = null; - - HashMap label2CodeMap = new HashMap(); - - HashMap levelMap = null; - - HashMap embeddedHierarchyCode2LabelHashMap = null; - - static int TRAVERSE_UP = 1; - static int TRAVERSE_DOWN = 2; - - public EmbeddedHierarchy() { - - } - - public EmbeddedHierarchy(Vector parent_child_vec) { - this.parent_child_vec = parent_child_vec; - this.hh = new HierarchyHelper(parent_child_vec); - } - - public void set_embedded_hierarchy(HierarchyHelper hh) { - this.eh_hh = hh; - } - - public HashMap createEmbeddedHierarchyCode2LabelHashMap(Vector v) { - //GAIA Terminology|C125481|GAIA Preeclampsia Level of Diagnostic Certainty Terminology|C126860 - //CDISC Questionnaire Terminology|C100110|CDISC Questionnaire ADAS-Cog CDISC Version Test Code Terminology|C100132 - HashMap hmap = new HashMap(); - for (int k=0; k= maxLevel) return ti; - if (ti._code.compareTo(code) == 0 && level < maxLevel) { - return null; - } - - List children = ti._assocToChildMap.get(Constants.ASSOCIATION_NAME); - if (children != null && children.size() > 0) { - List new_children = new ArrayList(); - for (int i=0; i= maxLevel) { - new_children.add(child_ti); - } - } - } - } - ti._assocToChildMap.put(Constants.ASSOCIATION_NAME, new_children); - } - return ti; - } - - public HashMap create_level_hashmap(Vector v) { - ASCIITreeUtils utils = new ASCIITreeUtils(); - HashMap hmap = new HashMap(); - for (int i=0; i 1) { - int maxLevel = findMaximumLevel(w); - w2.add(key + "|" + maxLevel); - } - } - return w2; - } - - public int findMaximumLevel(Vector v) { - int max = -1; - for (int i=0; i max) { - max = value; - } - } - return max; - } - - public HashMap createLevelHashMap(Vector parent_child_vec) { - HierarchyHelper hh = new HierarchyHelper(parent_child_vec); - ASCIITreeUtils utils = new ASCIITreeUtils(); - HashMap hmap = new HashMap(); - Vector v = hh.exportTree();//(Vector) parent_child_vec.clone(); - for (int i=0; i 0) { - w.addAll(u); - } - } - w = removeDuplicates(w); - return w; - } - - public Vector removeDuplicates(Vector codes) { - HashSet hset = new HashSet(); - Vector w = new Vector(); - for (int i=0; i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class ExcelDiffUtils { - public String datafile1 = null; - public String datafile2 = null; - Vector headings = null; - boolean NORMALIZE = true; - - public ExcelDiffUtils(String datafile1, String datafile2) { - this.datafile1 = datafile1; - this.datafile2 = datafile2; - } - - public Vector split(String line) { - return StringUtils.parseData(line, '\t'); - } - - public Vector split(String line, char delim) { - return StringUtils.parseData(line, delim); - } - - - public void run(PrintWriter pw) { - Vector v1 = Utils.readFile(datafile1); - String heading = (String) v1.elementAt(0); - headings = split(heading); - HashSet codes_1 = new HashSet(); - HashMap hmap_1 = new HashMap(); - for (int i=1; i 0) { - Vector u = split(line, '\t'); - String code = (String) u.elementAt(2); - if (!codes_1.contains(code)) { - codes_1.add(code); - } - HashMap hmap = new HashMap(); - for (int j=0; j 0) { - Vector u = split(line, '\t'); - String code = (String) u.elementAt(2); - if (!codes_2.contains(code)) { - codes_2.add(code); - } - HashMap hmap = new HashMap(); - for (int j=0; j " + value); - } - } - } - - public String normalize(String t) { - if (t.indexOf("||") == -1) return t; - t = t.replace(" || ", "|"); - Vector u = StringUtils.parseData(t, '|'); - u = new SortUtils().quickSort(u); - StringBuffer buf = new StringBuffer(); - for (int i=0; i 0) { - for (int i=0; i 0) { - for (int i=0; i - * Copyright 2011, MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC. - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation ongki@nih.gov - * - */ - - -public class ExcelReadWriteUtils { - - public static void saveToFile(String outputfile, String t) { - Vector v = new Vector(); - v.add(t); - saveToFile(outputfile, v); - } - - public static void saveToFile(String outputfile, Vector v) { - - PrintWriter pw = null; - try { - pw = new PrintWriter(outputfile, "UTF-8"); - if (v != null && v.size() > 0) { - for (int i=0; i 0) { - for (int i=0; i parseData(String line) { - if (line == null) return null; - char delim = '|'; - return parseData(line, delim); - } - - - public static String tab2CSV(String line, char delim) { - Vector u = parseData(line, delim); - StringBuffer buf = new StringBuffer(); - for (int i=0; i getXLSXSheetNames(String xslxfile) { - File file = new File(xslxfile); - List sheetNames = null; - try { - XSSFWorkbook wb = new XSSFWorkbook(file); - sheetNames = new ArrayList(); - for (int i=0; i getXLSSheetNames(String xlsfile) { - List sheetNames = null; - try { - InputStream is = new FileInputStream(xlsfile); - HSSFWorkbook wb = new HSSFWorkbook(is); - sheetNames = new ArrayList(); - for (int i=0; i textfiles, Vector sheetNames, char delim) throws IOException { - XSSFWorkbook wb = new XSSFWorkbook(); - for (int i=0; i textfiles, Vector sheetNames, char delim) throws IOException { - HSSFWorkbook wb = new HSSFWorkbook(); - for (int i=0; i rowIterator = sheet.rowIterator(); - while (rowIterator.hasNext()) { - Row row = rowIterator.next(); - Iterator cellIterator = row.cellIterator(); - StringBuffer buf = new StringBuffer(); - while (cellIterator.hasNext()) { - Cell cell = cellIterator.next(); - String cellValue = dataFormatter.formatCellValue(cell); - buf.append(cellValue + "\t"); - } - String t = buf.toString(); - t = t.substring(0, t.length()-1); - w.add(t); - } - ip.close(); - return w; - } - - public static int getNumberOfSheets(String excelfile) { - try { - Workbook workbook = WorkbookFactory.create(new File(excelfile)); - return workbook.getNumberOfSheets(); - } catch (Exception ex) { - //return -1; - } - return -1; - } - - public static Workbook openWorkbook(String excelfile) { - try { - Workbook workbook = WorkbookFactory.create(new File(excelfile)); - return workbook; - } catch (Exception ex) { - //return -1; - } - return null; - } - - public static int getNumberOfSheets(Workbook workbook) { - return workbook.getNumberOfSheets(); - } - - public static Vector getSheetNames(String excelfile) { - try { - Workbook workbook = WorkbookFactory.create(new File(excelfile)); - return getSheetNames(workbook); - } catch (Exception ex) { - //return -1; - } - return null; - } - - - public static Vector getSheetNames(Workbook workbook) { - Vector v = new Vector(); - Iterator sheetIterator = workbook.sheetIterator(); - System.out.println("Retrieving Sheets using Iterator"); - while (sheetIterator.hasNext()) { - Sheet sheet = sheetIterator.next(); - v.add(sheet.getSheetName()); - } - return v; - } - - public Sheet getSheet(Workbook workbook, int sheetNumber) { - return workbook.getSheetAt(sheetNumber); - } - - - public Sheet getSheet(String excelfile, int sheetNumber) { - try { - Workbook workbook = openWorkbook(excelfile); - return getSheet(workbook, sheetNumber); - } catch (Exception e) { - - } - return null; - } - - public static Vector toDelimited(String excelfile, char delim) { - return toDelimited(excelfile, 0, delim); - } - - - private static void printCellValue(Cell cell) { - //switch (cell.getCellTypeEnum()) { - switch (cell.getCellType()) { - case BOOLEAN: - System.out.print(cell.getBooleanCellValue()); - break; - case STRING: - System.out.print(cell.getRichStringCellValue().getString()); - break; - case NUMERIC: - if (DateUtil.isCellDateFormatted(cell)) { - System.out.print(cell.getDateCellValue()); - } else { - System.out.print(cell.getNumericCellValue()); - } - break; - case FORMULA: - System.out.print(cell.getCellFormula()); - break; - case BLANK: - System.out.print(""); - break; - default: - System.out.print(""); - } - System.out.print("\t"); - } - - - public static Vector toDelimited(String excelfile, int sheetNumber, char delim) { - Vector w = new Vector(); - Workbook workbook = openWorkbook(excelfile); - Sheet sheet = workbook.getSheetAt(sheetNumber); - Iterator rowIterator = sheet.rowIterator(); - while (rowIterator.hasNext()) { - StringBuffer buf = new StringBuffer(); - Row row = rowIterator.next(); - List list = getRowData(row); - for (int i=0; i 0) { - for (int i=0; i maxColumn ) - maxColumn = lastColumn; - - if (lastColumn < columnToDelete ) - continue; - - for (int x=columnToDelete+1; x < lastColumn + 1; x++){ - Cell oldCell = row.getCell(x-1); - if ( oldCell != null ) { - row.removeCell( oldCell ); - } - Cell nextCell = row.getCell(x); - if ( nextCell != null ){ - Cell newCell = row.createCell( x-1, nextCell.getCellType()); - cloneCell(newCell, nextCell); - } - } - } - // Adjust the column widths - for ( int c=0; c < maxColumn; c++ ){ - sheet.setColumnWidth( c, sheet.getColumnWidth(c+1) ); - } - return workbook; - } - -/* - private static void cloneCell( Cell cNew, Cell cOld ){ - cNew.setCellComment( cOld.getCellComment() ); - cNew.setCellStyle( cOld.getCellStyle() ); - switch ( cNew.getCellType() ){ - case Cell.CELL_TYPE_BOOLEAN:{ - cNew.setCellValue( cOld.getBooleanCellValue() ); - break; - } - case Cell.CELL_TYPE_NUMERIC:{ - cNew.setCellValue( cOld.getNumericCellValue() ); - break; - } - case Cell.CELL_TYPE_STRING:{ - cNew.setCellValue( cOld.getStringCellValue() ); - break; - } - case Cell.CELL_TYPE_ERROR:{ - cNew.setCellValue( cOld.getErrorCellValue() ); - break; - } - case Cell.CELL_TYPE_FORMULA:{ - cNew.setCellFormula( cOld.getCellFormula() ); - break; - } - } - - } -*/ - - private static void cloneCell( Cell cNew, Cell cOld ){ - cNew.setCellComment( cOld.getCellComment() ); - cNew.setCellStyle( cOld.getCellStyle() ); - switch ( cNew.getCellType() ){ - case BOOLEAN:{ - cNew.setCellValue( cOld.getBooleanCellValue() ); - break; - } - case NUMERIC:{ - cNew.setCellValue( cOld.getNumericCellValue() ); - break; - } - case STRING:{ - cNew.setCellValue( cOld.getStringCellValue() ); - break; - } - case ERROR:{ - cNew.setCellValue( cOld.getErrorCellValue() ); - break; - } - case FORMULA:{ - cNew.setCellFormula( cOld.getCellFormula() ); - break; - } - } - } - - public static boolean isInteger(String input) { - try { - Integer.parseInt( input ); - return true; - } - catch( Exception e ) { - return false; - } - } - - public static Workbook addRow(Workbook workbook, int sheetIndex, Vector rowData){ - Sheet sheet = workbook.getSheetAt(sheetIndex); - int lastRowNumber = sheet.getLastRowNum(); - Row row = sheet.createRow(lastRowNumber+1); - for (int i=0; i= 1; i--) - { - Row row = sheet.getRow(i); - if (row != null) - { - sheet.removeRow(row); - } - } - int numOfColumns = getNumberOfRows(sheet); - for (int j = numOfColumns; j >= 1; j--) - { - workbook = deleteColumn(workbook, sheetIndex, j); - } - return workbook; - } - - private String getFileType(File file) { - String fileName = file.getName(); - String folderName = file.getParent(); - if (fileName.toLowerCase().endsWith(FILE_TYPES[0])) { - return FILE_TYPES[0]; - } - return FILE_TYPES[1]; - } - - - public static String getExcelHeader(String filename, int sheet) { - if (filename.toLowerCase().endsWith(FILE_TYPES[0])) { - return getHSSFHeader(filename, sheet); - } else { - return getXSSFHeader(filename, sheet); - } - } - - public static String getHSSFHeader(String file, int sheet) { - StringBuffer buf = new StringBuffer(); - try { - FileInputStream fis = new FileInputStream(new File(file)); - //Get the workbook instance for XLS file - HSSFWorkbook workbook = new HSSFWorkbook(fis); - try { - fis.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - - //Get first sheet from the workbook - HSSFSheet hSSFSheet = workbook.getSheetAt(sheet); - HSSFRow row = hSSFSheet.getRow(0); - - int cells = row.getPhysicalNumberOfCells(); - for (int c = 0; c < cells; c++) { - HSSFCell cell = row.getCell(c); - String value = null; - /* - - switch (cell.getCellType()) { - case HSSFCell.CELL_TYPE_FORMULA: - value = cell.getCellFormula(); - break; - - case HSSFCell.CELL_TYPE_NUMERIC: - value = "" + cell.getNumericCellValue(); - break; - - case HSSFCell.CELL_TYPE_STRING: - value = cell.getStringCellValue(); - break; - - default: - } - */ - value = getCellData(cell); - buf.append(value); - if (c < cells-1) { - buf.append("|"); - } - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return buf.toString(); - } - - public static int getExcelStartRow(String filename, int sheet, int col, String code) { - if (filename.toLowerCase().endsWith(FILE_TYPES[0])) { - return getHSSFStartRow(filename, sheet, col, code); - } else { - return getXSSFStartRow(filename, sheet, col, code); - } - } - - public static int getHSSFStartRow(String file, int sheet, int col, String code) { - try { - FileInputStream fis = new FileInputStream(new File(file)); - //Get the workbook instance for XLS file - HSSFWorkbook workbook = new HSSFWorkbook(fis); - try { - fis.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - - //Get first sheet from the workbook - HSSFSheet hSSFSheet = workbook.getSheetAt(sheet); - - if (col == -1) { - return 1; - } - - //Get iterator to all the rows in current sheet - Iterator rowIterator = hSSFSheet.iterator(); - - //Get iterator to all cells of current row - int lcv = 0; - while (rowIterator.hasNext()) { - Row row = rowIterator.next(); - if (row == null) return -1; - //if (row.getCell(0).getStringCellValue().compareTo(code) == 0 || - if (row.getCell(col).getStringCellValue().compareTo(code) == 0) { - return lcv; - } - - lcv++; - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return -1; - } - - public static int getExcelEndRow(String filename, int sheet, int col, String code) { - if (filename.toLowerCase().endsWith(FILE_TYPES[0])) { - return getHSSFEndRow(filename, sheet, col, code); - } else { - return getXSSFEndRow(filename, sheet, col, code); - } - } - - public static int getHSSFEndRow(String file, int sheet, int col, String code) { - int num = -1; - try { - FileInputStream fis = new FileInputStream(new File(file)); - //Get the workbook instance for XLS file - HSSFWorkbook workbook = new HSSFWorkbook(fis); - try { - fis.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - - //Get first sheet from the workbook - HSSFSheet hSSFSheet = workbook.getSheetAt(sheet); - - if (col == -1) { - return hSSFSheet.getLastRowNum(); - } - - //Get iterator to all the rows in current sheet - Iterator rowIterator = hSSFSheet.iterator(); - - //Get iterator to all cells of current row - int lcv = 0; - - while (rowIterator.hasNext()) { - Row row = rowIterator.next(); - if (row == null) return -1; - //if (row.getCell(0).getStringCellValue().compareTo(code) == 0 || - if (row.getCell(col).getStringCellValue().compareTo(code) == 0) { - num = lcv; - } - lcv++; - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return num; - } - - - private static String getCellData(Cell cell) { - String value = null; - if (cell == null) { - return null; - } - switch (cell.getCellType()) { - case STRING: - value = cell.getStringCellValue(); - break; - case FORMULA: - value = cell.getCellFormula(); - break; - case NUMERIC: - HSSFDataFormatter dataFormatter = new HSSFDataFormatter(); - value = dataFormatter.formatCellValue(cell); - break; - case BLANK: - value = null; - break; - case ERROR: - value = "#ERROR#"; - break; - } - return value; - } - - - public static String getXSSFHeader(String file, int sheet) { - StringBuffer buf = new StringBuffer(); - try { - FileInputStream fis = new FileInputStream(new File(file)); - //Get the workbook instance for XLS file - XSSFWorkbook workbook = new XSSFWorkbook(fis); - try { - fis.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - - //Get first sheet from the workbook - XSSFSheet hSSFSheet = workbook.getSheetAt(sheet); - XSSFRow row = hSSFSheet.getRow(0); - - int cells = row.getPhysicalNumberOfCells(); - for (int c = 0; c < cells; c++) { - XSSFCell cell = row.getCell(c); - - /* - String value = null; - - switch (cell.getCellType()) { - - case XSSFCell.CELL_TYPE_FORMULA: - value = cell.getCellFormula(); - break; - - case XSSFCell.CELL_TYPE_NUMERIC: - value = "" + cell.getNumericCellValue(); - break; - - case XSSFCell.CELL_TYPE_STRING: - value = cell.getStringCellValue(); - break; - - default: - } - */ - String value = getCellData(cell); - buf.append(value); - if (c < cells-1) { - buf.append("|"); - } - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return buf.toString(); - } - - public static int getXSSFStartRow(String file, int sheet, int col, String code) { - try { - FileInputStream fis = new FileInputStream(new File(file)); - //Get the workbook instance for XLS file - XSSFWorkbook workbook = new XSSFWorkbook(fis); - try { - fis.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - - //Get first sheet from the workbook - XSSFSheet hSSFSheet = workbook.getSheetAt(sheet); - - if (col == -1) { - return 1; - } - - //Get iterator to all the rows in current sheet - Iterator rowIterator = hSSFSheet.iterator(); - - //Get iterator to all cells of current row - int lcv = 0; - while (rowIterator.hasNext()) { - Row row = rowIterator.next(); - if (row == null) return -1; - //if (row.getCell(0).getStringCellValue().compareTo(code) == 0 || - if (row.getCell(col).getStringCellValue().compareTo(code) == 0) { - return lcv; - } - - lcv++; - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return -1; - } - - public static int getXSSFEndRow(String file, int sheet, int col, String code) { - int num = -1; - try { - FileInputStream fis = new FileInputStream(new File(file)); - //Get the workbook instance for XLS file - XSSFWorkbook workbook = new XSSFWorkbook(fis); - try { - fis.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - - //Get first sheet from the workbook - XSSFSheet hSSFSheet = workbook.getSheetAt(sheet); - - if (col == -1) { - return hSSFSheet.getLastRowNum(); - } - - //Get iterator to all the rows in current sheet - Iterator rowIterator = hSSFSheet.iterator(); - - //Get iterator to all cells of current row - int lcv = 0; - - while (rowIterator.hasNext()) { - Row row = rowIterator.next(); - if (row == null) return -1; - if (row.getCell(col).getStringCellValue().compareTo(code) == 0) { - num = lcv; - } - lcv++; - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return num; - } - - public static void test(String excelfile, int sheet, int col, String code) { - System.out.println("excelfile: " + excelfile); - System.out.println("sheet: " + sheet); - System.out.println("col: " + col); - System.out.println("code: " + code); - - String header = getExcelHeader(excelfile, sheet); - System.out.println(header); - - int start_row = getExcelStartRow(excelfile, sheet, col, code); - System.out.println("getExcelStartRow: " + start_row); - - int end_row = getExcelEndRow(excelfile, sheet, col, code); - System.out.println("getExcelEndRow: " + end_row); - } - - public static void csvToXLSX(String csvfile, String xlsxfile, String sheet_name) { - try { - String csvFileAddress = csvfile; - String xlsxFileAddress = xlsxfile; - XSSFWorkbook workBook = new XSSFWorkbook(); - XSSFSheet sheet = workBook.createSheet(sheet_name); - String currentLine=null; - int RowNum=0; - BufferedReader br = new BufferedReader(new FileReader(csvFileAddress)); - while ((currentLine = br.readLine()) != null) { - String str[] = currentLine.split(","); - - XSSFRow currentRow=sheet.createRow(RowNum); - for(int i=0;i 0) { - String heading = (String) lines.elementAt(0); - String[] columns = getColumnHeadings(heading, delim); - - Row headerRow = sheet.createRow(0); - - for(int i = 0; i < columns.length; i++) { - Cell cell = headerRow.createCell(i); - cell.setCellValue(columns[i]); - cell.setCellStyle(headerCellStyle); - } - if (lines.size() > 1) { - for (int i=1;i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - - -public class ExtendedPropertyQuery { - JSONUtils jsonUtils = null; - HTTPUtils httpUtils = null; - String named_graph = null; - String prefixes = null; - String serviceUrl = null; - HashMap nameVersion2NamedGraphMap = null; - HashMap ontologyUri2LabelMap = null; - String version = null; - String username = null; - String password = null; - OWLSPARQLUtils owlSPARQLUtils = null; - static Vector states = null; - static int MAX_LENGTH = 7; - - static { - states = new Vector(); - states.add("H"); //hierarchical - states.add("S"); //subset - states.add("R"); //role - states.add("A"); //asociation - states.add("P"); //property - states.add("C"); //class - } - - public ExtendedPropertyQuery(String serviceUrl, String named_graph, String username, String password) { - this.serviceUrl = serviceUrl; - this.named_graph = named_graph; - this.username = username; - this.password = password; - this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, username, password); - this.owlSPARQLUtils.set_named_graph(named_graph); - } - - public OWLSPARQLUtils getOWLSPARQLUtils() { - return this.owlSPARQLUtils; - } - - public String getPropSelectStmt(Vector path) { - StringBuffer buf = new StringBuffer(); - if (path.size() > 1) { - buf.append("select distinct ?x_code ?x_label ?y_code ?y_label ?p_label ?p_value"); - } else { - buf.append("select distinct ?y_code ?y_label ?p_label ?p_value"); - } - String s = buf.toString(); - s = s.trim(); - return s; - } - - public String getPropertyQuery(String named_graph, String code, Vector path) { - String prefixes = owlSPARQLUtils.getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - String selectStmt = getPropSelectStmt(path); - buf.append(selectStmt).append("\n"); - buf.append("{").append("\n"); - buf.append(" graph <" + named_graph + ">").append("\n"); - buf.append(" {").append("\n"); - if (path.size() > 1) { - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - if (code != null) { - buf.append(" ?x :NHC0 \"" + code + "\"^^xsd:string .").append("\n"); - } - } - buf.append(" ?y rdfs:label ?y_label .").append("\n"); - buf.append(" ?y :NHC0 ?y_code .").append("\n"); - - for (int i=0; i - * Copyright 2020 MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. -6 * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@nih.gov - * - */ - -public class ExternalLinkPageGenerator { - static String NCI_BROWSER_PROPERTYES_XML = "NCItBrowserProperties.xml"; - String restURL = null; - String namedGraph = null; - String username = null; - String password = null; - OWLSPARQLUtils owlSPARQLUtils = null; - HashMap propertyCode2labelHashMap = null; - - public ExternalLinkPageGenerator() { - - } - - public ExternalLinkPageGenerator(String restURL, String namedGraph, String username, String password) { - this.restURL = restURL; - this.namedGraph = namedGraph; - this.username = username; - this.password = password; - owlSPARQLUtils = new OWLSPARQLUtils(restURL, username, password); - owlSPARQLUtils.set_named_graph(namedGraph); - - propertyCode2labelHashMap = new HashMap(); - Vector supportedProperties = owlSPARQLUtils.getSupportedProperties(namedGraph); - for (int i=0; i ").append("\n"); - buf.append(" {").append("\n"); - buf.append(" ?x a owl:Class .").append("\n"); - buf.append(" ?x :NHC0 ?x_code .").append("\n"); - buf.append(" ?x rdfs:label ?x_label .").append("\n"); - buf.append(" ?x ?p1 ?y1 .").append("\n"); - buf.append("").append("\n"); - buf.append(" ?p1 :NHC0 \"" + propertyCode + "\"^^xsd:string .").append("\n"); - buf.append(" ?p1 :NHC0 ?p1_code .").append("\n"); - buf.append(" ?p1 rdfs:label ?p1_label .").append("\n"); - buf.append("").append("\n"); - buf.append(" }").append("\n"); - buf.append("}").append("\n"); - buf.append("").append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public Vector getConceptsWithProperty(String named_graph, String propertyCode) { - String query = construct_get_concepts_with_property(named_graph, propertyCode); - Vector v = executeQuery(query); - if (v == null) return null; - if (v.size() == 0) return v; - v = new ParserUtils().getResponseValues(v); - return new SortUtils().quickSort(v); - } - - public static String hyperlink(String url, String code) { - return "" + code + ""; - } - - public void run(String propertyCode) { - run(NCI_BROWSER_PROPERTYES_XML, propertyCode); - } - - public String external_hyperlink_url = null; - - public String get_external_hyperlink_url() { - return external_hyperlink_url; - } - - public void set_external_hyperlink_url(String external_hyperlink_url) { - System.out.println("external_hyperlink_url: " + external_hyperlink_url); - this.external_hyperlink_url = external_hyperlink_url; - } - - public void run(String xmlfile, String propertyCode) { - String propertyName = getPropertyLabel(propertyCode); - String url = getUri(propertyName); - - Vector w = getConceptsWithProperty(namedGraph, propertyCode); - Vector w1 = new Vector(); - for (int i=0; i - * Copyright 2008,2009 NGIT. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIT and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIT" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIT - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history Initial implementation kim.ong@ngc.com - * - */ - - -public class FTPCrawler { - public static String NCIT_FTP_SITE = "https://evs.nci.nih.gov/ftp1/"; - public static String ABOUT_PAGE = "About.html"; - public static String MAPPINGS = "Mappings"; - public static String NCI_THESAURUS = "NCI_Thesaurus"; - public static String NCIT_MAPPINGS_SITE = NCIT_FTP_SITE + NCI_THESAURUS + "/" + MAPPINGS + "/"; - public static String NCIT_ABOUT_SITE = NCIT_MAPPINGS_SITE + ABOUT_PAGE; - public static String ICDO3_MAPPIGNS_SITE = NCIT_MAPPINGS_SITE + "ICD-O-3_Mappings/"; - public static String ICDO3_ABOUT_SITE = ICDO3_MAPPIGNS_SITE + "About.html"; - public static String[] MAPPING_SITES = new String[] {NCIT_MAPPINGS_SITE, NCIT_ABOUT_SITE, ICDO3_MAPPIGNS_SITE, ICDO3_ABOUT_SITE}; - - public static HashMap lastUpdatedHashMap = null; - - public static Vector otherMappingData = null; - - public static Vector getOtherMappingData() { - return otherMappingData; - } - - public static void dumpMappingSites() { - for (int i=0; i - * Copyright 2020, MSC. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIT - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIT, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history Initial implementation kim.ong@ngc.com - * - */ - - -public class FTPUtils { - static String NCIT_FTP_URL = "https://evs.nci.nih.gov/ftp1/NCI_Thesaurus/"; - static String currentWorkingDirectory; - static { - currentWorkingDirectory = System.getProperty("user.dir"); - } - - public static void download(String uri, String outputfile) { - try (BufferedInputStream in = new BufferedInputStream(new URL(uri).openStream()); - FileOutputStream fileOutputStream = new FileOutputStream(outputfile)) { - byte dataBuffer[] = new byte[1024]; - int bytesRead; - while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { - fileOutputStream.write(dataBuffer, 0, bytesRead); - } - } catch (IOException e) { - // handle exception - } - } - - private static void unzip(String zipFilePath, String destDir) { - System.out.println("zipFilePath: " + zipFilePath); - System.out.println("destDir: " + destDir); - - File dir = new File(destDir); - // create output directory if it doesn't exist - if(!dir.exists()) dir.mkdirs(); - FileInputStream fis; - //buffer for read and write data to file - byte[] buffer = new byte[1024]; - try { - fis = new FileInputStream(zipFilePath); - ZipInputStream zis = new ZipInputStream(fis); - ZipEntry ze = zis.getNextEntry(); - while(ze != null){ - String fileName = ze.getName(); - File newFile = new File(destDir + File.separator + fileName); - System.out.println("Unzipping to "+newFile.getAbsolutePath()); - //create directories for sub directories in zip - new File(newFile.getParent()).mkdirs(); - FileOutputStream fos = new FileOutputStream(newFile); - int len; - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len); - } - fos.close(); - zis.closeEntry(); - ze = zis.getNextEntry(); - } - //close last ZipEntry - zis.closeEntry(); - zis.close(); - fis.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void run(String NCIT_FTP_URL, String zipfile) { - String currentWorkingDirectory = System.getProperty("user.dir"); - System.out.println("currentWorkingDirectory: " + currentWorkingDirectory); - - download(NCIT_FTP_URL + zipfile, zipfile); - String zipFilePath = currentWorkingDirectory + "/" + zipfile; - unzip(zipFilePath, currentWorkingDirectory); - } - - public static boolean rename(String old_file, String new_file) { - File oldfile = new File(old_file); - File newfile = new File(new_file); - - if (!oldfile.exists()) { - System.out.println("File " + old_file + " does not existis."); - return false; - } - - if (oldfile.renameTo(newfile)){ - return true; - } - return false; - } - - public static String downloadNCItInferredOWL(String version) { - //String zipfile = args[0];//"ThesaurusInf_20.05d.OWL.zip"; - String zipfile = "ThesaurusInf_" + version + ".OWL.zip"; - System.out.println("NCIT_FTP_URL: " + NCIT_FTP_URL); - System.out.println("zipfile: " + zipfile); - run(NCIT_FTP_URL, zipfile); - int n = zipfile.indexOf("_"); - String old_file = zipfile.substring(0, n) + "erred.owl"; - int m = zipfile.indexOf("OWL"); - String new_file = zipfile.substring(0, m-1) + ".owl"; - System.out.println("oldfile: " + old_file); - System.out.println("newfile: " + new_file); - boolean bool = rename(old_file, new_file); - if (bool) { - System.out.println("File rename successful? " + bool); - new File(zipfile).delete(); - return new_file; - } - return null; - } - - public static void main(String[] args) { - long ms = System.currentTimeMillis(); - String version = args[0]; - String owlfile = downloadNCItInferredOWL(version); - System.out.println("owlfile: " + owlfile); - System.out.println("Total edit history run time (ms): " + (System.currentTimeMillis() - ms)); - } -} - diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FileUtils.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FileUtils.java deleted file mode 100644 index c9326e624..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FileUtils.java +++ /dev/null @@ -1,134 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.*; -import java.text.*; -import java.nio.file.*; - -public class FileUtils -{ - public static void copyfile(String src_file, String target_file) { - InputStream inStream = null; - OutputStream outStream = null; - try{ - File afile =new File(src_file); - File bfile =new File(target_file); - inStream = new FileInputStream(afile); - outStream = new FileOutputStream(bfile); - byte[] buffer = new byte[1024]; - int length; - while ((length = inStream.read(buffer)) > 0){ - outStream.write(buffer, 0, length); - } - inStream.close(); - outStream.close(); - System.out.println("File copied from " + src_file + " to " + target_file); - }catch(IOException e){ - e.printStackTrace(); - } - } - - public static boolean fileExists(String filename) { - File f = new File(filename); - if(f.exists() && !f.isDirectory()) { - return true; - } - return false; - } - - public static boolean directoryExists(String filename) { - File f = new File(filename); - if(f.exists()) { - return true; - } - return false; - } - - public static String getCurrentWorkingDirectory() { - return System.getProperty("user.dir"); - } - - public static String getToday() { - return getToday("MM-dd-yyyy"); - } - - public static String getToday(String format) { - java.util.Date date = Calendar.getInstance().getTime(); - SimpleDateFormat sdf = new SimpleDateFormat(format); - return sdf.format(date); - } - - public static boolean createDirectory(String pathname) { - Path path = Paths.get(pathname); - try { - Files.createDirectory(path); - return true; - } catch (Exception ex) { - return false; - } - } - - public static void copyFile(String sourceDir, String targetDir, Vector filesToCopy) { - for (int i=0; i { - Path destination = Paths.get(destinationDirectoryLocation, source.toString().substring(sourceDirectoryLocation.length())); - try { - Files.copy(source, destination); - } catch (IOException e) { - e.printStackTrace(); - } - }); - } - - public static void main(String[] args) { - String currentWorkingDir = getCurrentWorkingDirectory(); - System.out.println("getCurrentWorkingDirectory: " + currentWorkingDir); - String today = getToday("MMddyy"); - System.out.println("getToday: " + today); - boolean exists = directoryExists(today); - System.out.println("directory exist? " + exists); - String dirname = currentWorkingDir + File.separator + today + File.separator; - if (!exists) { - System.out.println(dirname); - boolean created = createDirectory(dirname); - System.out.println("directory created? " + created); - } - exists = directoryExists(dirname); - System.out.println("directory exist? " + exists); - Vector filesToCopy = new Vector(); - filesToCopy.add("cmd.exe"); - filesToCopy.add("run.bat"); - copyFile(currentWorkingDir, dirname, filesToCopy); - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FirstInFirstOutQueue.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FirstInFirstOutQueue.java deleted file mode 100644 index 4bd1d27d6..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FirstInFirstOutQueue.java +++ /dev/null @@ -1,43 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import java.util.LinkedList; -import java.util.Queue; - -public class FirstInFirstOutQueue { - Queue fifo = null; - - public FirstInFirstOutQueue() { - fifo = new LinkedList(); - } - - public void add(String link) { - fifo.add(link); - } - - public String remove() { - String link = fifo.remove(); - return link; - } - - public boolean isEmpty() { - return fifo.isEmpty(); - } - - public static void main(String args[]) { - char arr[] = {'3','1','4','1','5','9','2','6','5','3','5','8','9'}; - Queue fifo = new LinkedList(); - - for (int i = 0; i < arr.length; i++) { - String s = "" + arr[i]; - fifo.add(s); - } - - System.out.print (fifo.remove() + "."); - while (!fifo.isEmpty()) { - String link = fifo.remove(); - System.out.print(link); - } - System.out.println(); - - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FormatHelper.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FormatHelper.java deleted file mode 100644 index 85a9f853f..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/FormatHelper.java +++ /dev/null @@ -1,177 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.codec.binary.Base64; -import org.json.*; - -/** - * - * Copyright Copyright 2020 MSC.. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by MSC and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "MSC" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or MSC - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * MSC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class FormatHelper { - - public FormatHelper() { - - - } - - public static boolean isInteger(Object object) { - if(object instanceof Integer) { - return true; - } else { - String string = object.toString(); - - try { - Integer.parseInt(string); - } catch(Exception e) { - return false; - } - } - return true; - } - - public static String escapeComma(String field) { - char ch = ','; - return escapeChar(field, ch); - } - - - public static String escapeChar(String field, char ch) { - if (field == null) return ""; - StringBuffer buf = new StringBuffer(); - for (int i=0; i - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - -public class FormatUtils { - ParserUtils parserUtils = null; - String applicationName = "sparql"; - - public FormatUtils() { - parserUtils = new ParserUtils(); - } - - public void setApplicationName(String applicationName) { - this.applicationName = applicationName; - } - - public Vector toDelimited(Vector v) { - return parserUtils.getResponseValues(v); - } - - public PrintWriter systemOut2PrintWriter() { - return new PrintWriter(System.out, true); - } - - public Vector formatRelationships(Vector v, String label, String code) { - if (v == null || v.size() == 0) return new Vector(); - Vector w = new Vector(); - for (int i=0; i (" + role_name + ") --> [" + role_target + " (" + role_target_code + ")]"); - } - return w; - } - - public Vector formatInverseRelationships(Vector v, String label, String code) { - if (v == null || v.size() == 0) return new Vector(); - Vector w = new Vector(); - for (int i=0; i (" + role_name + ") --> [" + label + " (" + code + ")]"); - } - return w; - } - - public Vector formatSuperclasses(Vector v, String label, String code) { - if (v == null || v.size() == 0) return new Vector(); - Vector w = new Vector(); - for (int i=0; i (" + role_name + ") --> [" + role_target + " (" + role_target_code + ")]"); - } - return w; - } - - public Vector formatSubclasses(Vector v, String label, String code) { - if (v == null || v.size() == 0) return new Vector(); - Vector w = new Vector(); - for (int i=0; i (" + role_name + ") --> [" + label + " (" + code + ")]"); - } - return w; - } - - //formatSynonyms - public String formatSynonyms(Vector v) { - StringBuffer buf = new StringBuffer(); - if (v == null || v.size() == 0) return ""; - List list = new ParserUtils().getSynonyms(v); - Synonym first_syn = (Synonym) list.get(0); - String label = first_syn.getLabel(); - String code = first_syn.getCode(); - buf.append(label + " (" + code + ")").append("\n"); - buf.append("\tTerm\tSource\tType\tSource Code\tSubsource Name").append("\n"); - for (int i=0; i").append("\n"); - } else { - buf.append("").append("\n"); - } - buf.append(name).append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public String getHyperlink(String named_graph, String name, String code) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - buf.append(name).append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public String getRelationshipTableLabel(String defaultLabel, String type, boolean isEmpty) { - String NONE = "(none)"; - StringBuffer buf = new StringBuffer(); - - if (type.compareTo(Constants.TYPE_SUPERCONCEPT) == 0) { - buf.append("Parent Concepts:"); - if (isEmpty) { - buf.append(" ").append(NONE).append("\n"); - } - } else if (type.compareTo(Constants.TYPE_SUBCONCEPT) == 0) { - buf.append("Child Concepts:"); - if (isEmpty) { - buf.append(" ").append(NONE).append("\n"); - } - } else if (type.compareTo(Constants.TYPE_ROLE) == 0) { - buf.append("Role Relationships pointing from the current concept to other concepts:"); - if (isEmpty) { - buf.append(" ").append(NONE).append("\n"); - } else { - buf.append("
    ").append("\n"); - buf.append("(True for the current concept.)").append("\n"); - } - - } else if (type.compareTo(Constants.TYPE_ASSOCIATION) == 0) { - buf.append("Associations pointing from the current concept to other concepts:"); - if (isEmpty) { - buf.append(" ").append(NONE).append("\n"); - } else { - buf.append("
    ").append("\n"); - buf.append("(True for the current concept.)").append("\n"); - } - } else if (type.compareTo(Constants.TYPE_INVERSE_ROLE) == 0) { - buf.append("Incoming Role Relationships pointing from other concepts to the current concept:"); - if (isEmpty) { - buf.append(" ").append(NONE).append("\n"); - } - } else if (type.compareTo(Constants.TYPE_INVERSE_ASSOCIATION) == 0) { - buf.append("Incoming Associations pointing from other concepts to the current concept:"); - if (isEmpty) { - buf.append(" ").append(NONE).append("\n"); - } - } else { - buf.append("" + type + ":"); - if (isEmpty) { - buf.append(" ").append(NONE).append("\n"); - } - } - - - String label = buf.toString(); - if (label.length() == 0) { - label = defaultLabel; - } - return label; - } - - public Vector getSortedKeys(HashMap map) { - if (map == null) return null; - Vector v = new Vector(); - Iterator it = map.keySet().iterator(); - while (it.hasNext()) { - String t = (String) it.next(); - v.add(t); - } - v = new SortUtils().quickSort(v); - return v; - } - - public String formatTable(HashMap map, String firstColumnHeading, String secondColumnHeading, - int firstPercentColumnWidth, int secondPercentColumnWidth) { - - return formatTable(map, firstColumnHeading, secondColumnHeading, - firstPercentColumnWidth, secondPercentColumnWidth, false); - } - - - public String formatTable(HashMap map, String firstColumnHeading, String secondColumnHeading, - int firstPercentColumnWidth, int secondPercentColumnWidth, boolean encode) { - Vector prop_names = getSortedKeys(map); - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - - if (firstColumnHeading != null && secondColumnHeading != null) { - buf.append("").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append("").append("\n"); - } - - if (firstPercentColumnWidth <= 0 || firstPercentColumnWidth <= 0) { - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - } else { - String w1 = Integer.toString(firstPercentColumnWidth); - String w2 = Integer.toString(secondPercentColumnWidth); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - } - - int n = 0; - for (int i=0; i").append("\n"); - } else { - buf.append(" ").append("\n"); - } - buf.append("").append("\n"); - if (encode) { - value = formatComplexProperties(name, value); - value = StringUtils.encode_term(value); - } - buf.append("").append("\n"); - } - buf.append(" ").append("\n"); - } - buf.append("
    " + firstColumnHeading + "" + secondColumnHeading + "
    ").append("\n"); - buf.append(name).append("\n"); - buf.append("" + value + "
    ").append("\n"); - return buf.toString(); - } - - - public String formatTable(Vector v, String firstColumnHeading, String secondColumnHeading, - int firstPercentColumnWidth, int secondPercentColumnWidth) { - StringBuffer buf = new StringBuffer(); - buf.append("").append("\n"); - - if (firstColumnHeading != null && secondColumnHeading != null) { - buf.append("").append("\n"); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - buf.append("").append("\n"); - } - - if (firstPercentColumnWidth <= 0 || firstPercentColumnWidth <= 0) { - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - } else { - String w1 = Integer.toString(firstPercentColumnWidth); - String w2 = Integer.toString(secondPercentColumnWidth); - buf.append(" ").append("\n"); - buf.append(" ").append("\n"); - } - - int n = 0; - for (int i=0; i").append("\n"); - } else { - buf.append(" ").append("\n"); - } - buf.append("").append("\n"); - - buf.append("").append("\n"); - buf.append(" ").append("\n"); - } - buf.append("
    " + firstColumnHeading + "" + secondColumnHeading + "
    ").append("\n"); - buf.append(name).append("\n"); - buf.append("" + value + "
    ").append("\n"); - return buf.toString(); - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/GeneralizedQueryUtils.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/GeneralizedQueryUtils.java deleted file mode 100644 index 996958d01..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/GeneralizedQueryUtils.java +++ /dev/null @@ -1,1224 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.common.*; - -import java.io.*; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.codec.binary.Base64; -import org.json.*; - -import java.util.StringTokenizer; - -/** - * - * Copyright 2008-2017 NGIS. This software was developed in conjunction - * with the National Cancer Institute, and so to the extent government - * employees are co-authors, any rights in such works shall be subject - * to Title 17 of the United States Code, section 105. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the disclaimer of Article 3, - * below. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 2. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by NGIS and the National - * Cancer Institute." If no such end-user documentation is to be - * included, this acknowledgment shall appear in the software itself, - * wherever such third-party acknowledgments normally appear. - * 3. The names "The National Cancer Institute", "NCI" and "NGIS" must - * not be used to endorse or promote products derived from this software. - * 4. This license does not authorize the incorporation of this software - * into any third party proprietary programs. This license does not - * authorize the recipient to use any trademarks owned by either NCI - * or NGIS - * 5. THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE - * DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, - * NGIS, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** - * @author EVS Team - * @version 1.0 - * - * Modification history: - * Initial implementation kim.ong@ngc.com - * - */ - - -public class GeneralizedQueryUtils { - OWLSPARQLUtils owlSPARQLUtils = null; - String serviceUrl = null; - String named_graph = null; - String ncit_version = null; - String sparql_endpoint = null; - HashMap nameVersion2NamedGraphMap = null; - gov.nih.nci.evs.restapi.util.MetadataUtils mdu = null; - HashMap uriBaseHashMap = null; - HashMap nameGraph2PredicateHashMap = null; - Vector supportedNamedGraphs = null; - - SPARQLSearchUtils sparqlSearchUtils = null; - //ConceptDetailsPageGenerator cdpg = null; - - static int FORWARD = 1; - static int BACKWARD = 2; - - HierarchyHelper hh = null; - - HashMap namedGraph2UIDPredicateHashMap = null; - HashMap basePrefixUIDHashMap = null; - static String PARENT_CHILD_FILE = "parent_child.txt"; - - static String[] COMMON_PREFIXES = new String[] { - "PREFIX xml:", - "PREFIX rdf:", - "PREFIX owl:", - "PREFIX owl2xml:", - "PREFIX protege:", - "PREFIX xsd:", - "PREFIX rdfs:" - }; - - public GeneralizedQueryUtils(String serviceUrl, HashMap nameVersion2NamedGraphMap, HashMap basePrefixUIDHashMap) { - this.serviceUrl = serviceUrl; - this.nameVersion2NamedGraphMap = nameVersion2NamedGraphMap; - this.basePrefixUIDHashMap = basePrefixUIDHashMap; - this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, null, null); - } - - public String getServiceUrl() { - return this.serviceUrl; - } - - public HashMap getNameVersion2NamedGraphMap() { - return this.nameVersion2NamedGraphMap; - } - - public HashMap getBasePrefixUIDHashMap() { - return this.basePrefixUIDHashMap; - } - - public gov.nih.nci.evs.restapi.util.MetadataUtils getMetadataUrils() { - return this.mdu; - } - - public GeneralizedQueryUtils(String serviceUrl) { - long ms = System.currentTimeMillis(); - - int n = serviceUrl.indexOf("?"); - if (n != -1) { - serviceUrl = serviceUrl.substring(0, n); - } - this.serviceUrl = serviceUrl; - this.sparql_endpoint = serviceUrl + "?query="; - - mdu = new gov.nih.nci.evs.restapi.util.MetadataUtils(serviceUrl); - nameVersion2NamedGraphMap = mdu.getNameVersion2NamedGraphMap(); - uriBaseHashMap = mdu.getURIBaseHashMap(); - - this.supportedNamedGraphs = mdu.getSupportedNamedGraphs(); - - this.named_graph = mdu.getNamedGraph(gov.nih.nci.evs.restapi.common.Constants.NCI_THESAURUS); - this.ncit_version = mdu.getLatestVersion(gov.nih.nci.evs.restapi.common.Constants.NCI_THESAURUS); - - System.out.println("sparql_endpoint: " + sparql_endpoint); - System.out.println("named_graph: " + named_graph); - System.out.println("ncit_version: " + ncit_version); - - this.owlSPARQLUtils = new OWLSPARQLUtils(serviceUrl, null, null); - this.sparqlSearchUtils = new SPARQLSearchUtils(serviceUrl); - - if (FileUtils.fileExists(PARENT_CHILD_FILE)) { - Vector parent_child_vec = Utils.readFile(PARENT_CHILD_FILE); - hh = new HierarchyHelper(parent_child_vec); - } - namedGraph2UIDPredicateHashMap = createNamedGraph2UIDPredicateHashMap(); - basePrefixUIDHashMap = createBasePrefixUIDHashMap(); - System.out.println("Total initialization run time (ms): " + (System.currentTimeMillis() - ms)); - } - - public MetadataUtils getMetadataUtils() { - return this.mdu; - } - - - public HashMap createNamedGraph2UIDPredicateHashMap() { - HashMap namedGraph2UIDPredicateHashMap = new HashMap();; - HashMap hmap = getNameVersion2NamedGraphMap(); - Iterator it = hmap.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - Vector ng_vec = (Vector) hmap.get(key); - for (int j=0; j").append("\n"); - buf.append("{").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x ?y ?z .").append("\n"); - buf.append("?x rdfs:label ?x_label .").append("\n"); - buf.append("?y rdfs:label ?y_label .").append("\n"); - buf.append("?x " + identifier + " ?x_code .").append("\n"); - if (by_code) { - buf.append("?x " + identifier + " \"" + code + "\"^^ .").append("\n"); - } - buf.append("}").append("\n"); - if (!by_code) { - buf.append("FILTER (str(?x) = \"" + ns + code + "\"^^xsd:string)").append("\n"); - } - buf.append("}").append("\n"); - return buf.toString(); - } - - - public Vector getOWLClassData(String named_graph, String identifier, String code, String ns, boolean by_code) { - String q = owlSPARQLUtils.construct_get_owl_class_data(named_graph, identifier, code, ns, by_code); - //System.out.println(q); - Vector v = owlSPARQLUtils.getOWLClassData(named_graph, identifier, code, ns, by_code); - return v; - } - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - public String construct_simple_tuple_query(String named_graph, int limit) { - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX xml:").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT distinct ?x ?p ?y").append("\n"); - buf.append("{ ").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append("{").append("\n"); - //buf.append("?x a owl:Class .").append("\n"); - buf.append("?x ?p ?y ").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("} ").append("\n"); - buf.append("").append("\n"); - buf.append("LIMIT " + limit).append("\n"); - return buf.toString(); - } - - public Vector simple_tuple_query(String named_graph, int limit) { - String query = construct_simple_tuple_query(named_graph, limit); - -//System.out.println(query); - - - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - return null; - } - - - public String findNamedGraphIdentifierLine(Vector v) { - if (v == null) { - return null; - } - String id_line = null; - int n0 = 0; - for (int i=0; i n0 && n > 1) { - id_line = line; - n0 = n; - } - } - } - return id_line; - } - - public String getNamedGraphBasePrefix(String line) { - Vector u = StringUtils.parseData(line, '|'); - String t = (String) u.elementAt(1); - int n = t.lastIndexOf("#"); - if (n == -1) { - n = t.lastIndexOf("/"); - } - return "<" + t.substring(0, n+1) + ">"; - } - - public String getNamedGraphUniqueIdentifier(String line) { - Vector u = StringUtils.parseData(line, '|'); - String t = (String) u.elementAt(1); - int n = t.lastIndexOf("#"); - if (n == -1) { - n = t.lastIndexOf("/"); - } - return t.substring(n+1, t.length()); - } - - public String getNamespace(String ng) { - Vector w = simple_tuple_query(ng, 1000); - - String id_line = findNamedGraphIdentifierLine(w); - Vector u = StringUtils.parseData(id_line, '|'); - String t = (String) u.elementAt(0); - int n = t.lastIndexOf("#"); - if (n == -1) { - n = t.lastIndexOf("/"); - } - //return t.substring(n+1, t.length()); - return t.substring(0, n+1); - } - - public String getNamedGraphUIDPredicate(String named_graph) { - String s = getNamedGraphBasePrefixAndUniqueIdentifier(named_graph); - Vector u = StringUtils.parseData(s); - String basePrefix = (String) u.elementAt(0); - String uid = (String) u.elementAt(1); - //System.out.println("\nnamed_graph: " + named_graph); - //System.out.println("\tbasePrefix: " + basePrefix); - //System.out.println("\tid: " + uid); - return basePrefix.substring(1, basePrefix.length()-1) + uid; - } - - - public String getNamedGraphBasePrefixAndUniqueIdentifier(String ng) { - Vector w = simple_tuple_query(ng, 1000); - String id_line = findNamedGraphIdentifierLine(w); - return getNamedGraphBasePrefixAndUniqueIdentifier(ng, id_line); - } - - public String getNamedGraphBasePrefixAndUniqueIdentifier(String named_graph, String line) { - if (named_graph.compareTo("http://purl.obolibrary.org/obo/obi/2017-09-03/obi.owl") == 0) { - return "|IAO_0000111"; - } - String basePrefix = getNamedGraphBasePrefix(line); - String uid = getNamedGraphUniqueIdentifier(line); - return basePrefix + "|" + uid; - } - - - public String generate_sample_id(String named_graph, String basePrefix, String uid) { - int knt = 0; - Vector w = simple_tuple_query(named_graph, 1000); - String target = get_named_graph_predicate(named_graph); - - int rand = 500;//new RandomVariateGenerator().uniform(0, 999); - String line = (String) w.elementAt(rand); - Vector u = StringUtils.parseData(line, '|'); - String s = (String) u.elementAt(0); - String p = (String) u.elementAt(1); - String o = (String) u.elementAt(2); - return o; - - } - - - public String construct_class_uri_query(String named_graph, String code) { - //String p = getNamedGraphUIDPredicate(named_graph); - String p = get_named_graph_predicate(named_graph); - StringBuffer buf = new StringBuffer(); - - buf.append("PREFIX xml:").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - - buf.append("SELECT distinct ?x").append("\n"); - buf.append("{ ").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append("{").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x ?p ?y ").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("FILTER ((str(?p) = \"" + p + "\"^^xsd:string) && (str(?y) = \"" + code + "\"^^xsd:string))").append("\n"); - buf.append("} ").append("\n"); - return buf.toString(); - } - - - public String get_class_URI(String named_graph, String code) { - String query = construct_class_uri_query(named_graph, code); - System.out.println(query); - - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return (String) v.elementAt(0); - } - return null; - } - - - public String construct_class_query_by_cui(String named_graph, String cui) { - //String cui = get_class_URI(named_graph, code); - System.out.println("cui: " + cui); - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX xml:").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT distinct ?x ?p ?y").append("\n"); - buf.append("{ ").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append("{").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x ?p ?y ").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("FILTER (str(?x) = \"" + cui + "\"^^xsd:string)").append("\n"); - buf.append("} ").append("\n"); - return buf.toString(); - } - - public Vector class_query(String named_graph, String code) { - String query = construct_class_query_by_cui(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - return null; - } - - - public String construct_class_query_by_id(String named_graph, String id) { - String cui = get_class_URI(named_graph, id); - System.out.println("cui: " + cui); - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX xml:").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT distinct ?x ?p ?y").append("\n"); - buf.append("{ ").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append("{").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x ?p ?y ").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("FILTER (str(?x) = \"" + cui + "\"^^xsd:string)").append("\n"); - buf.append("} ").append("\n"); - return buf.toString(); - } - - public Vector class_query_by_id(String named_graph, String id) { - String query = construct_class_query_by_id(named_graph, id); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - return null; - } - - public String construct_class_query_by_code(String named_graph, String code) { - StringBuffer buf = new StringBuffer(); - String line = (String) basePrefixUIDHashMap.get(named_graph); - Vector u = StringUtils.parseData(line, '|'); - String basePrefix = (String) u.elementAt(0); - String uid = (String) u.elementAt(1); - buf.append("PREFIX :" + basePrefix).append("\n"); - buf.append("PREFIX xml:").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT distinct ?x ?p ?y").append("\n"); - buf.append("{ ").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append("{").append("\n"); - buf.append("?x :" + uid + " ?x_code .").append("\n"); - buf.append("?x :" + uid + " \"" + code + "\"^^xsd:string .").append("\n"); - buf.append("?x ?p ?y ").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("} ").append("\n"); - return buf.toString(); - } - - public Vector class_query_by_code(String named_graph, String code) { - String query = construct_class_query_by_code(named_graph, code); - - //System.out.println(query); - - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - return null; - } - - - public String getPrefixes() { - return owlSPARQLUtils.getPrefixes(); - } - - public String construct_annotation_property_query(String named_graph) { - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX xml:").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("").append("\n"); - buf.append("SELECT distinct ?p ?prop ?prop_value").append("\n"); - buf.append("{").append("\n"); - buf.append("graph <" + named_graph + "> {").append("\n"); - buf.append("?p a owl:AnnotationProperty .").append("\n"); - buf.append("?p ?prop ?prop_value ").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector annotation_property_query(String named_graph) { - String query = construct_annotation_property_query(named_graph); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - return null; - } - -/* - (73) http://purl.obolibrary.org/obo/IAO_0000115|http://www.w3.org/1999/02/22-rdf-syntax-ns#type|http://www.w3.org/2002/07/owl#AnnotationProperty - (74) http://purl.obolibrary.org/obo/IAO_0000115|http://www.w3.org/2000/01/rdf-schema#label|definition - (75) http://purl.obolibrary.org/obo/IAO_0000231|http://www.w3.org/1999/02/22-rdf-syntax-ns#type|http://www.w3.org/2002/07/owl#AnnotationProperty - (76) http://purl.obolibrary.org/obo/IAO_0000425|http://www.w3.org/1999/02/22-rdf-syntax-ns#type|http://www.w3.org/2002/07/owl#AnnotationProperty - (77) http://purl.obolibrary.org/obo/IAO_0000425|http://www.w3.org/2000/01/rdf-schema#label|expand assertion to -*/ - - public HashMap createPropertyHashMap(String named_graph) { - Vector w = annotation_property_query(named_graph); - HashMap hmap = new HashMap(); - for (int i=0; i").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("").append("\n"); - buf.append("SELECT distinct ?x_code").append("\n"); - buf.append("{").append("\n"); - buf.append("graph <" + named_graph + "> {").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x :" + uid + " ?x_code .").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("LIMIT " + limit).append("\n"); - buf.append("").append("\n"); - return buf.toString(); - } - - public Vector class_id_query(String named_graph, int limit) { - String query = construct_class_id_query(named_graph, limit); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - return null; - } - - public HashMap createBasePrefixUIDHashMap(){ - HashMap hmap = getNameVersion2NamedGraphMap(); - Iterator it = hmap.keySet().iterator(); - HashMap basePrefixUIDHashMap = new HashMap(); - while (it.hasNext()) { - String key = (String) it.next(); - Vector ng_vec = (Vector) hmap.get(key); - for (int j=0; j")) { - uid = "id"; - } - basePrefixUIDHashMap.put(ng, basePrefix + "|" + uid); - } - } - return basePrefixUIDHashMap; - } - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - public String construct_mapping_query(String named_graph, String code) { - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX xml:").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT distinct ?x ?p ?y").append("\n"); - buf.append("{ ").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - //buf.append("{").append("\n"); - buf.append("{").append("\n"); - buf.append("?x ?p ?y .").append("\n"); - if (code != null) { - buf.append("FILTER (contains(str(?y), \"" + code + "\") || contains(str(?x), \"" + code + "\"))").append("\n"); - } - //buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector mapping_query(String named_graph) { - return mapping_query(named_graph, null); - } - - - public Vector mapping_query(String named_graph, String code) { - String query = construct_mapping_query(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - Vector w = new Vector(); - for (int i=0; i").append("\n"); - buf.append("PREFIX rdf:").append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX owl2xml:").append("\n"); - buf.append("PREFIX protege:").append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - - buf.append("SELECT distinct ?x ?p ?y").append("\n"); - - buf.append("{ ").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append("{").append("\n"); - buf.append("?y :" + uid + " ?y_code .").append("\n"); - buf.append("?y :" + uid + " \"" + code + "\"^^xsd:string .").append("\n"); - buf.append("?x ?p ?y ").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("} ").append("\n"); - return buf.toString(); - } - - public Vector inverse_class_query_by_code(String named_graph, String code) { - String query = construct_inverse_class_query_by_code(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } - return null; - } - - public String construct_search_by_code(String code) { - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX xsd:").append("\n"); - buf.append("SELECT distinct ?g ?x ?p ?z ").append("\n"); - buf.append("{").append("\n"); - buf.append("graph ?g {").append("\n"); - buf.append("?x ?p \"" + code + "\"^^xsd:string .").append("\n"); - buf.append("?x ?p ?z").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector search_by_code(String code) { - String query = construct_search_by_code(code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - - public String construct_search_by_property(String matchText, int maxReturn) { - String prefixes = getPrefixes(); - StringBuffer buf = new StringBuffer(); - buf.append(prefixes); - buf.append("PREFIX owl:").append("\n"); - buf.append("SELECT distinct ?g ?x ?p ?y").append("\n"); - buf.append("{").append("\n"); - buf.append("graph ?g").append("\n"); - buf.append("{").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x ?p ?y .").append("\n"); - buf.append("FILTER contains(lcase(str(?y)), \"" + matchText + "\")").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - buf.append("LIMIT " + maxReturn).append("\n"); - return buf.toString(); - } - - public Vector search_by_property(String mathText, int maxReturn) { - String query = construct_search_by_property(mathText, maxReturn); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - - public String construct_superclass_query(String named_graph, String code) { - HashMap hmap = getBasePrefixUIDHashMap(); - String value = (String) hmap.get(named_graph); - Vector u = StringUtils.parseData(value); - String basePrefix = (String) u.elementAt(0); - String uid = (String) u.elementAt(1); - - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX :" + basePrefix).append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT ?y_label ?y_code").append("\n"); - buf.append("{").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - //buf.append("?x a owl:Class .").append("\n"); - buf.append("?x :" + uid + " \"" + code + "\"^^xsd:string .").append("\n"); - - buf.append("?x rdfs:subClassOf ?y .").append("\n"); - - //buf.append("?y a owl:Class .").append("\n"); - buf.append("?y :" + uid + " ?y_code .").append("\n"); - buf.append("?y rdfs:label ?y_label .").append("\n"); - - buf.append("}").append("\n"); - buf.append("}").append("\n"); - - return buf.toString(); - } - - public Vector get_superclasses(String named_graph, String code) { - String query = construct_superclass_query(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - - public String construct_subclass_query(String named_graph, String code) { - HashMap hmap = getBasePrefixUIDHashMap(); - String value = (String) hmap.get(named_graph); - Vector u = StringUtils.parseData(value); - String basePrefix = (String) u.elementAt(0); - String uid = (String) u.elementAt(1); - - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX :" + basePrefix).append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT ?x_label ?x_code").append("\n"); - buf.append("{").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - //buf.append("?x a owl:Class .").append("\n"); - buf.append("?x :" + uid + " ?x_code .").append("\n"); - buf.append("?x rdfs:label ?x_label .").append("\n"); - - //buf.append("?y a owl:Class .").append("\n"); - buf.append("?y :" + uid + " ?y_code .").append("\n"); - buf.append("?y :" + uid + " \"" + code + "\"^^xsd:string .").append("\n"); - - buf.append("?x rdfs:subClassOf ?y .").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector get_subclasses(String named_graph, String code) { - String query = construct_subclass_query(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - public String construct_label_query(String named_graph, String code) { - HashMap hmap = getBasePrefixUIDHashMap(); - String value = (String) hmap.get(named_graph); - Vector u = StringUtils.parseData(value); - String basePrefix = (String) u.elementAt(0); - String uid = (String) u.elementAt(1); - - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX :" + basePrefix).append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT ?x_label").append("\n"); - buf.append("{").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - //buf.append("?x a owl:Class .").append("\n"); - buf.append("?x :" + uid + " ?x_code .").append("\n"); - buf.append("?x :" + uid + " \"" + code + "\"^^xsd:string .").append("\n"); - buf.append("?x rdfs:label ?x_label .").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public String get_label(String named_graph, String code) { - String query = construct_label_query(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return (String) v.elementAt(0); - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - public String construct_hierarchical_relationship_query(String named_graph, int maxReturn) { - - HashMap hmap = getBasePrefixUIDHashMap(); - String value = (String) hmap.get(named_graph); - Vector u = StringUtils.parseData(value); - String basePrefix = (String) u.elementAt(0); - String uid = (String) u.elementAt(1); - - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX :" + basePrefix).append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT ?y_label ?y_code ?x_label ?x_code").append("\n"); - buf.append("{").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x rdfs:label ?x_label .").append("\n"); - buf.append("?x :" + uid + " ?x_code .").append("\n"); - buf.append("?y a owl:Class .").append("\n"); - buf.append("?y rdfs:label ?y_label .").append("\n"); - buf.append("?y :" + uid + " ?y_code .").append("\n"); - buf.append("?x rdfs:subClassOf ?y .").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - if (maxReturn != -1) { - buf.append("LIMIT " + maxReturn).append("\n"); - } - return buf.toString(); - } - - public Vector get_hierarchical_relationships(String named_graph, int maxReturn) { - String query = construct_hierarchical_relationship_query(named_graph, maxReturn); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - - public Vector get_hierarchical_relationships(String named_graph) { - return get_hierarchical_relationships(named_graph, -1); - } - - - public String formatLabelCodeString(String line) { - //Eye Part|C13019 - int n = line.indexOf("|"); - String label = line.substring(0, n); - String code = line.substring(n+1, line.length()); - return label + " (" + code + ")"; - } - - public String construct_search_by_name_query(String matchText, int maxReturn) { - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT distinct ?g ?x ?x_label").append("\n"); - buf.append("{").append("\n"); - buf.append("graph ?g").append("\n"); - buf.append("{").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x rdfs:label ?x_label .").append("\n"); - String matchText_lc = matchText.toLowerCase(); - buf.append("FILTER contains(lcase(str(?x_label)), \"" + matchText_lc + "\")").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - if (maxReturn != -1 && maxReturn > 0) { - buf.append("LIMIT " + maxReturn).append("\n"); - } - return buf.toString(); - } - - public Vector search_by_name(String matchText, int maxReturn) { - String query = construct_search_by_name_query(matchText, maxReturn); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - public String construct_search_by_name_query(String named_graph, String matchText, int maxReturn) { - HashMap hmap = getBasePrefixUIDHashMap(); - String value = (String) hmap.get(named_graph); - Vector u = StringUtils.parseData(value); - String basePrefix = (String) u.elementAt(0); - String uid = (String) u.elementAt(1); - - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX :" + basePrefix).append("\n"); - buf.append("PREFIX owl:").append("\n"); - buf.append("PREFIX rdfs:").append("\n"); - buf.append("SELECT distinct ?x_label ?x_code").append("\n"); - buf.append("{").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("{").append("\n"); - buf.append("?x a owl:Class .").append("\n"); - buf.append("?x :" + uid + " ?x_code .").append("\n"); - buf.append("?x rdfs:label ?x_label .").append("\n"); - - String matchText_lc = matchText.toLowerCase(); - buf.append("FILTER contains(lcase(str(?x_label)), \"" + matchText_lc + "\")").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - if (maxReturn != -1 && maxReturn > 0) { - buf.append("LIMIT " + maxReturn).append("\n"); - } - return buf.toString(); - } - - public Vector search_by_name(String named_graph, String matchText, int maxReturn) { - String query = construct_search_by_name_query(named_graph, matchText, maxReturn); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - - public String construct_search_by_code(String named_graph, String code) { - HashMap hmap = getBasePrefixUIDHashMap(); - String value = (String) hmap.get(named_graph); - Vector u = StringUtils.parseData(value); - String basePrefix = (String) u.elementAt(0); - String uid = (String) u.elementAt(1); - - StringBuffer buf = new StringBuffer(); - buf.append("PREFIX :" + basePrefix).append("\n"); - buf.append("PREFIX xsd:").append("\n"); - buf.append("SELECT distinct ?x_label ?x_code ").append("\n"); - buf.append("{").append("\n"); - buf.append("graph <" + named_graph + ">").append("\n"); - buf.append("?x rdfs:label ?x_label .").append("\n"); - buf.append("?x :" + uid + " ?x_code .").append("\n"); - buf.append("?x :" + uid + " \"" + code + "\"^^xsd:string").append("\n"); - buf.append("}").append("\n"); - buf.append("}").append("\n"); - return buf.toString(); - } - - public Vector search_by_code(String named_graph, String code) { - String query = construct_search_by_code(named_graph, code); - Vector v = owlSPARQLUtils.executeQuery(query); - if (v != null && v.size() > 0) { - v = new ParserUtils().getResponseValues(v); - v = new SortUtils().quickSort(v); - return v; - } else { - System.out.println("executeQuery returns NULL"); - } - return null; - } - - public static void main(String[] args) { - String serviceUrl = args[0]; - System.out.println(serviceUrl); - GeneralizedQueryUtils test = new GeneralizedQueryUtils(serviceUrl+"?query="); - long ms = System.currentTimeMillis(); - - String named_graph = args[1]; - named_graph = "http://ncicb.nci.nih.gov/trix/NCIt-HGNC"; - /* - test.set_named_graph(named_graph); - - String queryfile = args[2]; - System.out.println(queryfile); - //test.runQuery(queryfile); - - String code = "2002093"; - named_graph = "http://cbiit.nci.nih.gov/caDSR"; - String label = test.get_label(named_graph, code); - - System.out.println(named_graph); - System.out.println(code); - - System.out.println("label: " + label); - */ - Vector w = test.mapping_query(named_graph); - if (w != null) { - System.out.println(w.size()); - } - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/GraphGenerator.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/GraphGenerator.java deleted file mode 100644 index b012869db..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/GraphGenerator.java +++ /dev/null @@ -1,392 +0,0 @@ -package gov.nih.nci.evs.restapi.util; -import gov.nih.nci.evs.restapi.bean.*; -import gov.nih.nci.evs.restapi.test.*; - -import java.io.*; -import java.util.*; -import java.text.DecimalFormat; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.InputStreamReader; - -public class GraphGenerator { - static float default_ranksep = (float) 1.0; - static float default_nodesep = (float) 1.5; - - static Vector COLORS = new Vector(); - static { - COLORS.add("black"); - COLORS.add("blue"); - COLORS.add("blueviolet"); - COLORS.add("brown"); - COLORS.add("brown4"); - COLORS.add("burlywood"); - COLORS.add("cadetblue4"); - COLORS.add("chocolate4"); - COLORS.add("coral3"); - COLORS.add("cyan4"); - COLORS.add("crimson"); - COLORS.add("darkgreen"); - COLORS.add("darkolivegreen"); - COLORS.add("darkgoldenrod"); - COLORS.add("darkorchid"); - COLORS.add("darklategray"); - COLORS.add("darkviolet"); - COLORS.add("deeppink3"); - COLORS.add("firebrick2"); - COLORS.add("forestgreen"); - COLORS.add("gold"); - COLORS.add("grey6"); - COLORS.add("green3"); - COLORS.add("green4"); - COLORS.add("lawngreen"); - COLORS.add("lightblue"); - COLORS.add("lightslateblue"); - COLORS.add("limegreen"); - COLORS.add("maroon"); - COLORS.add("magenta"); - COLORS.add("maroon"); - COLORS.add("midnightblue"); - COLORS.add("navyblue"); - COLORS.add("orange"); - COLORS.add("orangered"); - COLORS.add("orangered4"); - COLORS.add("orchid"); - COLORS.add("palevioletred"); - COLORS.add("pink"); - COLORS.add("purple"); - COLORS.add("red"); - COLORS.add("saddlebrown"); - COLORS.add("sienna"); - COLORS.add("slateblue"); - COLORS.add("snow"); - COLORS.add("springgreen"); - COLORS.add("tan"); - COLORS.add("turquoise3"); - COLORS.add("tomato"); - COLORS.add("violet"); - COLORS.add("wheat"); - COLORS.add("yellowgreen"); - } - - public GraphGenerator() { - - } - - public static String generateColor() { - int n = new RandomVariateGenerator().uniform(0, COLORS.size()-1); - return (String) COLORS.elementAt(n); - } - - public static String toString(Vector v) { - StringBuffer buf = new StringBuffer(); - for (int i=0; i " + range_id - + " [label=" + "\"" + role + "\"" + " fontcolor=" + color + ", color=" + color + "];"); - } else { - if (selected_nodes.contains(domain_label) && selected_nodes.contains(range_label)) { - pw.println(domain_id + " -> " + range_id - + " [label=" + "\"" + role + "\"" + " fontcolor=" + color + ", color=" + color + "];"); - } - } - } - } - - - public static void generateGraphvizDataFile(Vector nodes, Vector edges, Vector selected_nodes, String outputfile) { - float ranksep = (float) 1.0; - float nodesep = (float) 1.5; - generateGraphvizDataFile(nodes, edges, selected_nodes, outputfile, ranksep, nodesep); - } - - public static void generateGraphvizDataFile(Vector nodes, Vector edges, Vector selected_nodes, String outputfile, float ranksep, float nodesep) { - PrintWriter pw = null; - try { - pw = new PrintWriter(outputfile, "UTF-8"); - pw.println("ranksep = \"" + ranksep + "\";"); - pw.println("nodesep = \"" + nodesep + "\";"); - pw.println("ratio=fill;"); - pw.println("overlap=scale;"); - pw.println("concentrate=true;"); - pw.println("ratio=auto;"); - pw.println("overlap = false;"); - pw.println("splines = true;"); - pw.println("node [style=filled,color=lightblue,shape=box];"); - pw.println("style=filled;"); - pw.println("color=lightgrey;"); - generateGraph(pw, nodes, edges, selected_nodes); - - } catch (Exception ex) { - - } finally { - try { - pw.close(); - System.out.println("Output file " + outputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - } - - - - public static GraphData createGraphData(String inputfile, String format) { //source|edge label|target - Vector data_vec = Utils.readFile(inputfile); - float ranksep = default_ranksep; - float nodesep = default_nodesep; - String filename = "graph_" + inputfile; - return createGraphData(data_vec, ranksep, nodesep, format, filename); - } - - public static GraphData createGraphData(Vector data_vec, float ranksep, float nodesep, String format, String filename) { //source|edge label|target - GraphData gd = new GraphData(); - Vector nodes = new Vector(); - Vector edges = new Vector(); - for (int i=0; i 0) { - --this.currentDpiPos; - } - } - - public int getImageDpi() { - return this.dpiSizes[this.currentDpiPos]; - } - - private StringBuilder graph = new StringBuilder(); - - public GraphViz() { - //String os = System.getProperty("os.name"); - //System.out.println(os); - } - - public String getDotSource() { - return this.graph.toString(); - } - - public void add(String line) { - this.graph.append(line); - } - - public void addln(String line) { - this.graph.append(line + "\n"); - } - - public void addln() { - this.graph.append('\n'); - } - - public void clearGraph(){ - this.graph = new StringBuilder(); - } - - public byte[] getGraph(String dot_source, String type) - { - File dot; - byte[] img_stream = null; - - try { - dot = writeDotSourceToFile(dot_source); - if (dot != null) - { - img_stream = get_img_stream(dot, type); - if (dot.delete() == false) - System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!"); - return img_stream; - } - return null; - } catch (java.io.IOException ioe) { return null; } - } - - - public byte[] getGraph(String dot_source, String type, String dotsourcefile) { - File dot; - byte[] img_stream = null; - - try { - dot = writeDotSourceToFile(dot_source, dotsourcefile); - if (dot != null) - { - img_stream = get_img_stream(dot, type); - if (dot.delete() == false) - System.err.println("Warning: " + dot.getAbsolutePath() + " could not be deleted!"); - return img_stream; - } - return null; - } catch (java.io.IOException ioe) { return null; } - } - - public int writeGraphToFile(byte[] img, String file) - { - File to = new File(file); - return writeGraphToFile(img, to); - } - - public int writeGraphToFile(byte[] img, File to) - { - try { - FileOutputStream fos = new FileOutputStream(to); - fos.write(img); - fos.close(); - } catch (java.io.IOException ioe) { return -1; } - return 1; - } - - private byte[] get_img_stream(File dot, String type) - { - File img; - byte[] img_stream = null; - - try { - img = File.createTempFile("graph_", "."+type, new File(GraphViz.TEMP_DIR)); - Runtime rt = Runtime.getRuntime(); - String[] args = {DOT, "-T"+type, "-Gdpi="+dpiSizes[this.currentDpiPos], dot.getAbsolutePath(), "-o", img.getAbsolutePath()}; - Process p = rt.exec(args); - p.waitFor(); - FileInputStream in = new FileInputStream(img.getAbsolutePath()); - img_stream = new byte[in.available()]; - in.read(img_stream); - if( in != null ) in.close(); - if (img.delete() == false) - System.err.println("Warning: " + img.getAbsolutePath() + " could not be deleted!"); - } - catch (java.io.IOException ioe) { - System.err.println("Error: in I/O processing of tempfile in dir " + GraphViz.TEMP_DIR+"\n"); - System.err.println(" or in calling external command"); - ioe.printStackTrace(); - } - catch (java.lang.InterruptedException ie) { - System.err.println("Error: the execution of the external program was interrupted"); - ie.printStackTrace(); - } - return img_stream; - } - - private File writeDotSourceToFile(String str, String dotfilename) throws java.io.IOException - { - File temp; - try { - temp = File.createTempFile("dorrr",".dot", new File(GraphViz.TEMP_DIR)); - FileWriter fout = new FileWriter(temp); - fout.write(str); - BufferedWriter br=new BufferedWriter(new FileWriter(dotfilename)); - br.write(str); - br.flush(); - br.close(); - fout.close(); - } - catch (Exception e) { - System.err.println("Error: I/O error while writing the dot source to temp file!"); - return null; - } - return temp; - } - - private File writeDotSourceToFile(String str) throws java.io.IOException - { - File temp; - try { - temp = File.createTempFile("dorrr",".dot", new File(GraphViz.TEMP_DIR)); - FileWriter fout = new FileWriter(temp); - fout.write(str); - BufferedWriter br=new BufferedWriter(new FileWriter("dotsource.dot")); - br.write(str); - br.flush(); - br.close(); - fout.close(); - } - catch (Exception e) { - System.err.println("Error: I/O error while writing the dot source to temp file!"); - return null; - } - return temp; - } - - public String start_graph() { - return "digraph G {"; - } - - public String end_graph() { - return "}"; - } - - public String start_subgraph(int clusterid) { - return "subgraph cluster_" + clusterid + " {"; - } - - public String end_subgraph() { - return "}"; - } - - public void readSource(String input) - { - StringBuilder sb = new StringBuilder(); - try - { - FileInputStream fis = new FileInputStream(input); - DataInputStream dis = new DataInputStream(fis); - BufferedReader br = new BufferedReader(new InputStreamReader(dis)); - String line; - while ((line = br.readLine()) != null) { - sb.append(line); - } - dis.close(); - } - catch (Exception e) { - System.err.println("Error: " + e.getMessage()); - } - this.graph = sb; - } -} diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/HTMLHierarchy.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/HTMLHierarchy.java deleted file mode 100644 index 331fb88c4..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/HTMLHierarchy.java +++ /dev/null @@ -1,189 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import java.io.*; -import java.text.*; -import java.util.*; - - -public class HTMLHierarchy { - HashMap code2NodeMap = new HashMap(); - HierarchyHelper hh = null; - - public String title = "NCI Thesaurus"; - - String datafile = null; - - public HTMLHierarchy(String datafile) { - this.datafile = datafile; - initialize(); - } - - public void initialize() { - Vector parent_child_vec = Utils.readFile(datafile); - System.out.println("parent_child_vec: " + parent_child_vec.size()); - - hh = new HierarchyHelper(parent_child_vec); - } - - public Vector sortByLabel(Vector codes) { - HashMap label2CodeMap = new HashMap(); - Vector w = new Vector(); - Vector labels = new Vector(); - for (int i=0; i" + title + ""); - out.println("
    "); - - - out.println("
      "); - out.println("
    • NCI Thesaurus"); - out.println("
        "); - out.println("
      • Child node 1
      • "); - out.println("
      • Child node 2
      • "); - out.println("
      "); - out.println("
    • "); - out.println("
    "); - - - out.println("
    "); - } - - - public void writeNode(PrintWriter out, String code) { - String label = (String) hh.getLabel(code); - String link_code = HyperlinkHelper.toHyperlink(code); - String display = label + " (" + link_code + ")"; - out.println("
      "); - out.println("
    • " + display); - - Vector subs = hh.getSubclassCodes(code); - if (subs != null) { - //subs = sortByLabel(subs); - for (int j=0; j"); - out.println("
    "); - } - - public void write_data(PrintWriter out, String title, String root) { - Stack stack = new Stack(); - if (root != null) { - stack.push(root); - } else { - Vector codes = hh.getRoots(); - codes = sortByLabel(codes); - - for (int i=0; i"); - out.println(""); - out.println(""); - out.println(" "); - out.println(" NCI Thesaurus"); - out.println(" "); - out.println(" "); - out.println(""); - out.println(""); - out.println(""); - - write_data(out, title, root); - - out.println(""); - out.println(""); - out.println(" "); - out.println(" "); - out.println(""); - out.println(" "); - out.println(""); - out.println(""); - } - - public static void run(String datafile, String title, String root) { - long ms = System.currentTimeMillis(); - PrintWriter pw = null; - int n = datafile.lastIndexOf("."); - String outputfile = datafile.substring(0, n) + ".html"; - try { - pw = new PrintWriter(outputfile, "UTF-8"); - HTMLHierarchy htmlHierarchy = new HTMLHierarchy(datafile); - htmlHierarchy.run(pw, title, root); - - } catch (Exception ex) { - - } finally { - try { - pw.close(); - System.out.println("Output file " + outputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - System.out.println("Total run time (ms): " + (System.currentTimeMillis() - ms)); - - } - - public static void main(String[] args) { - String datafile = args[0]; - String title = args[1]; - String root = args[2]; - HTMLHierarchy.run(datafile, title, root); - } -} \ No newline at end of file diff --git a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/HTMLTable.java b/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/HTMLTable.java deleted file mode 100644 index e5844c0c0..000000000 --- a/software/evsrestapi-util/src/gov/nih/nci/evs/restapi/util/HTMLTable.java +++ /dev/null @@ -1,348 +0,0 @@ -package gov.nih.nci.evs.restapi.util; - -import java.io.*; -import java.text.*; -import java.util.*; - -public class HTMLTable { - static String NCIT_URL = "https://nciterms.nci.nih.gov/ncitbrowser/pages/concept_details.jsf?dictionary=NCI_Thesaurus&&ns=ncit&code="; - - public static String hyperlink(String url, String code) { - return "" + code + ""; - } - - public static String generate(Vector v) { - char delim = searchDelimiter(v); - return generate(v, delim); - } - - public static String generate(Vector v, char delim) { - String title = null; - String table = null; - String outputfile = null; - PrintWriter pw = null; - Vector th_vec = null; - String th = null; - Vector data_vec = new Vector(); - String footer = null; - for (int i=0; i") != -1) { - int n = t.indexOf(""); - title = t.substring(n + "<title>".length(), t.length()); - outputfile = title + ".html"; - outputfile = outputfile.replace("/", "_"); - try { - pw = new PrintWriter(outputfile, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - printHeader(pw, title); - table = null; - } else if (t.startsWith("<table>")) { - table = t.substring("<table>".length(), t.length()); - th_vec = new Vector(); - } else if (t.startsWith("<th>")) { - th = t.substring("<th>".length(), t.length()); - th_vec.add(th); - } else if (t.startsWith("<data>")) { - data_vec = new Vector(); - } else if (t.startsWith("</table>")) { - printTable(pw, table, th_vec, data_vec, delim); - table = null; - th_vec = new Vector(); - data_vec = new Vector(); - } else if (t.startsWith("<footer>")) { - footer = t.substring("<footer>".length(), t.length()); - } else { - if (t.indexOf("</data>") == -1) { - data_vec.add(t); - } - } - } - try { - printFooter(pw, footer); - pw.close(); - System.out.println("Output file " + outputfile + " generated."); - } catch (Exception ex) { - ex.printStackTrace(); - } - - return outputfile; - } - - public static void printBanner(PrintWriter out) { - out.println("<div>"); - out.println(" <img"); - out.println(" src=\"https://nciterms.nci.nih.gov/ncitbrowser/images/evs-logo-swapped.gif\""); - out.println(" alt=\"EVS Logo\""); - out.println(" width=\"100%\""); - out.println(" height=\"26\""); - out.println(" border=\"0\""); - out.println(" usemap=\"#external-evs\""); - out.println(" />"); - out.println(" <map id=\"external-evs\" name=\"external-evs\">"); - out.println(" <area"); - out.println(" shape=\"rect\""); - out.println(" coords=\"0,0,140,26\""); - out.println(" href=\"/ncitbrowser/start.jsf\""); - out.println(" target=\"_self\""); - out.println(" alt=\"NCI Term Browser\""); - out.println(" />"); - out.println(" <area"); - out.println(" shape=\"rect\""); - out.println(" coords=\"520,0,941,26\""); - out.println(" href=\"http://evs.nci.nih.gov/\""); - out.println(" target=\"_blank\""); - out.println(" alt=\"Enterprise Vocabulary Services\""); - out.println(" />"); - out.println(" </map>"); - out.println("</div>"); - } - - public static void printHeader(PrintWriter out, String pageTitle) { - out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"); - out.println("<html xmlns:c=\"http://java.sun.com/jsp/jstl/core\">"); - out.println("<head>"); - out.println("<title>" + pageTitle + ""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(" "); - out.println("
    "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("
    "); - out.println(""); - out.println(""); - - printBanner(out); - - out.println(""); - out.println(""); - out.println("
    "); - out.println("

    " + pageTitle + "

    "); - out.println("

    "); - String today = StringUtils.getToday("MM-dd-yyyy"); - out.println("

    (Last modified: " + today + ")

    "); - out.println("

    "); - out.println("
    "); - } - - public static boolean isWideField(String th) { - th = th.toLowerCase(); - if (th.indexOf("label") != -1 || th.indexOf("term") != -1 - || th.indexOf("name") != -1 || th.indexOf("description") != -1 - || th.indexOf("definition") != -1) { - return true; - } - return false; - } - - public static int calculateWideFieldWidth(int numFields, int numWideFields) { - int total = 100; - int width = 10; - int remaining_width = 100 - 10 * (numFields - numWideFields); - return (int) (remaining_width / numWideFields + 0.5); - } - - public static int getWidth(int numFields, int numWideFields, String th) { - if (!isWideField(th)) return 10; - return calculateWideFieldWidth(numFields, numWideFields); - } - - public static char searchDelimiter(Vector data_vec) { - for (int i=0; i"); - out.println("
    "); - out.println("

    " + tableLabel + "

    "); - out.println(""); - out.println(""); - for (int i=0; i"); - out.println(th); - out.println(""); - } - out.println(""); - - for (int i=0; i"); - //Vector u = StringUtils.parseData(data, '\t'); - Vector u = StringUtils.parseData(data, delim); - - for (int j=0; j"); - out.println(value); - out.println(""); - } - out.println(""); - } - out.println("
    "); - out.println("
    "); - out.println(""); - } - - - public static void printFooter(PrintWriter out) { - printFooter(out, null); - } - - public static boolean isCode(String t) { - if (t == null) return false; - if (t.length() == 0) return false; - char c = t.charAt(0); - if (c != 'C') return false; - String s = t.substring(1, t.length()); - try { - int value = Integer.parseInt(s); - } catch (Exception ex) { - return false; - } - return true; - } - - - public static void printFooter(PrintWriter out, String footer) { - out.println("
    "); - out.println("

    "); - out.println("

    "); - out.println("
    "); - if(footer != null) { - out.println(footer); - } - out.println("
    "); - out.println(""); - out.println(""); - } - - public void generateHTMLPage(String filename) { - String hyperlink_url = NCIT_URL; - generateHTMLPage(filename, hyperlink_url); - } - - public void generateHTMLPage(String filename, String hyperlink_url) { - Vector w1 = Utils.readFile(filename); - Vector w = new Vector(); - for (int i=1; i" + title); - pw.println("" + table); - for (int i=0; i" + th); - } - pw.println(""); - for (int i=1; i"); - pw.println("
    "); - - pw.println("