Commit f71f6158 authored by jcorvi's avatar jcorvi
Browse files

First Commit

parents
#
# Project specific excludes
#
tomcat
#
# Default excludes
#
# Binaries
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.war
*.ear
*.sar
*.class
# Maven
target/
# IntelliJ project files
*.iml
*.iws
*.ipr
.idea/
# eclipse project file
.settings/
.classpath
.project
# NetBeans specific
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
# OS
.DS_Store
# Misc
*.swp
release.properties
pom.xml.releaseBackup
pom.xml.tag
#custom
pos/
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>text_tox</groupId>
<artifactId>ades-rest-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ades-rest-api</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
package es.bsc.inb.ades.rest.api;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan("es.bsc.inb.ades")
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
\ No newline at end of file
package es.bsc.inb.ades.rest.api.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource({ "classpath:ades_rest_api.properties" })
public class Config{
}
package es.bsc.inb.ades.rest.api.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource({ "classpath:ades_rest_api.properties" })
public class PersistenceJPAConfig{
}
package es.bsc.inb.ades.rest.api.controllers;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import es.bsc.inb.ades.rest.api.model.Document;
import es.bsc.inb.ades.rest.api.services.DocumentService;
@RestController
@CrossOrigin
public class DocumentController {
@Autowired
public DocumentService documentService;
@RequestMapping("/documents/")
public List<Document> findAll() {
return documentService.findAll();
}
@RequestMapping("/documents/{id}")
public Document find(@PathVariable(value="id") Long id) {
return documentService.findByDocumentId(id);
}
@RequestMapping("/documents/{id}/finding/{findingId}")
public String findFinding(@PathVariable(value="id") Long id, @PathVariable(value="findingId") Integer findingId) {
String snippet = documentService.findTextSnippetByDocumentIdAndFindingId(id, findingId);
return snippet;
}
@RequestMapping("/documents/{id}/finding2/{findingId}")
public String findFinding2(@PathVariable(value="id") Long id, @PathVariable(value="findingId") Integer findingId) {
String snippet = documentService.findTextSnippetByDocumentIdAndFindingId2(id, findingId);
// String snippet = "{\n" +
// " \"text\": \"Ed O Kelley was the man who shot the man who shot Jesse James.\",\n" +
// " \"entities\": [\n" +
// " [\"T1\", \"Person\", [\n" +
// " [0, 11]\n" +
// " ]],\n" +
// " [\"T2\", \"Person\", [\n" +
// " [20, 23]\n" +
// " ]],\n" +
// " [\"T3\", \"Person\", [\n" +
// " [37, 40]\n" +
// " ]],\n" +
// " [\"T4\", \"Person\", [\n" +
// " [50, 61]\n" +
// " ]]\n" +
// " ]\n" +
// "}";
return snippet;
}
}
\ No newline at end of file
package es.bsc.inb.ades.rest.api.model;
import java.util.List;
import es.bsc.inb.ades.rest.api.util.VisualizationHTMLUtil;
/**
*
* @author jcorvi
*
*/
public class Annotation implements Comparable<Annotation> {
private String text;
private String value;
private Integer startOffset;
private Integer endOffset;
private List<Feature> features;
private Boolean processed;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Integer getStartOffset() {
return startOffset;
}
public void setStartOffset(Integer startOffset) {
this.startOffset = startOffset;
}
public Integer getEndOffset() {
return endOffset;
}
public void setEndOffset(Integer endOffset) {
this.endOffset = endOffset;
}
public List<Feature> getFeatures() {
return features;
}
public void setFeatures(List<Feature> features) {
this.features = features;
}
@Override
public int compareTo(Annotation arg0) {
return this.getStartOffset() > arg0.getStartOffset() ? 1 : this.getStartOffset() < arg0.getStartOffset() ? -1 : 0;
}
public String getValue() {
return value;
}
// private String getSendCode() {
// for (Feature feature : features) {
// if(feature.getName().equals("CDISC_SEND_CODE")) {
// return feature.getValue();
// }
// }
// for (Feature feature : features) {
// if(feature.getName().equals("ETOX_SEND_CODE") || feature.getName().equals("ETOX_SEND_DOMAIN_CODE")) {
// return feature.getValue();
// }
// }
// for (Feature feature : features) {
// if(feature.getName().equals("MANUAL_SEND_CODE")) {
// return feature.getValue();
// }
// }
// return text;
// }
public Boolean getProcessed() {
return processed;
}
public void setProcessed(Boolean processed) {
this.processed = processed;
}
public void setValue(String value) {
this.value = value;
}
/**
* Return feature
* @param string
* @return
*/
public String getFeature(String featureName) {
for (Feature feature : features) {
if(feature.getName().equals(featureName)) {
return feature.getValue();
}
}
return null;
}
/**
*
* @return
*/
public String generateHTMLFeatures() {
StringBuilder htmlFeatures = new StringBuilder();
String sources = this.getFeature("SOURCES");
if(sources!=null) {
VisualizationHTMLUtil.generateHTMLLABEL(this, htmlFeatures);
if(sources.contains("CDISC")) {
VisualizationHTMLUtil.generateHTMLCDISC(this, htmlFeatures);
}
if(sources.contains("ETOX")) {
VisualizationHTMLUtil.generateHTMLETOX(this, htmlFeatures);
}
if(sources.contains("UMLS")) {
VisualizationHTMLUtil.generateHTMLUMLS(this, htmlFeatures);
}
if(sources.contains("DNORM")) {
VisualizationHTMLUtil.generateHTMLDNORM(this, htmlFeatures);
}
if(sources.contains("LIMTOX")) {
VisualizationHTMLUtil.generateHTMLLIMTOX(this, htmlFeatures);
}
if(sources.contains("MY_ONTOLOGY")) {
VisualizationHTMLUtil.generateHTMLMYONTOLOGY(this, htmlFeatures);
}
}else {
for (Feature feature : features) {
htmlFeatures = htmlFeatures.append(VisualizationHTMLUtil.getFeature(feature));
}
}
return htmlFeatures.toString();
}
}
package es.bsc.inb.ades.rest.api.model;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.Field;
@org.springframework.data.mongodb.core.mapping.Document(collection="reports")
public class Document{
@Field("_id")
private ObjectId _id;
@Field("id")
private Long documentId;
private String name;
private String text;
//private String textWithAnnotations;
private List<Finding> findings;
public Document() {
super();
}
public ObjectId get_id() {
return _id;
}
public void set_id(ObjectId _id) {
this._id = _id;
}
public Long getDocumentId() {
return documentId;
}
public void setDocumentId(Long documentId) {
this.documentId = documentId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Finding> getFindings() {
return findings;
}
public void setFindings(List<Finding> findings) {
this.findings = findings;
}
}
package es.bsc.inb.ades.rest.api.model;
/**
*
* @author jcorvi
*
*/
public class Feature {
private String name;
private String value;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package es.bsc.inb.ades.rest.api.model;
import java.util.ArrayList;
import java.util.List;
import org.springframework.data.mongodb.core.mapping.Field;
/**
*
* @author jcorvi
*
*/
public class Finding {
@Field("id")
private Integer findingId;
private Annotation finding_field;
@Field("FINDING")
private Annotation finding;
@Field("SPECIMEN")
private Annotation specimen;
@Field("SEX")
private Annotation sex;
@Field("MANIFESTATION_FINDING")
private Annotation manifestation_finding;
@Field("GROUP")
private Annotation group;
@Field("DOSE")
private Annotation dose;
@Field("STUDY_TESTCD")
private Annotation study_testcd;
@Field("STUDY_DOMAIN")
private Annotation study_domain;
@Field("IS_TREATMENT_RELATED")
private Annotation is_treatment_related;
@Field("RISK_LEVEL")
private Annotation risk_level;
@Field("ROUTE_OF_AMINISTRATION")
private Annotation route_of_administration;
@Field("DOSE_QUANTITY")
private Annotation dose_quantity;
@Field("DOSE_FREQUENCY")
private Annotation dose_frequency;
@Field("DOSE_DURATION")
private Annotation dose_duration;
@Field("STATISTICAL_SIGNIFICANCE")
private Annotation statistical_significance;
@Field("OBSERVATION_QUALIFICATION")
private Annotation observation_qualification;
@Field("RELEVANT_TEXT")
private Annotation relevant_text;
public Finding() {}
public Integer getFindingId() {
return findingId;
}
public void setFindingId(Integer findingId) {
this.findingId = findingId;
}
public Annotation getFinding_field() {
return finding_field;
}
public void setFinding_field(Annotation finding_field) {
this.finding_field = finding_field;
}