Commit 8f81a134 authored by javi's avatar javi
Browse files

development adding important changes

parent 45fa858a
......@@ -3,11 +3,11 @@
<modelVersion>4.0.0</modelVersion>
<groupId>text_tox</groupId>
<artifactId>ades-rest-api</artifactId>
<artifactId>pretox-rest-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ades-rest-api</name>
<name>pretox-rest-api</name>
<url>http://maven.apache.org</url>
......
......@@ -3,11 +3,16 @@ package es.bsc.inb.ades.rest.api.controllers;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
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.model.DocumentAnnotations;
import es.bsc.inb.ades.rest.api.services.DocumentService;
......@@ -24,8 +29,8 @@ public class DocumentController {
}
@RequestMapping("/documents/{id}")
public Document find(@PathVariable(value="id") Long id) {
return documentService.findByDocumentId(id);
public DocumentAnnotations find(@PathVariable(value="id") Long id) {
return documentService.findByDocumentAnnotationsByDocumentId(id);
}
// @RequestMapping("/documents/{id}")
......@@ -39,9 +44,30 @@ public class DocumentController {
return snippet;
}
@RequestMapping("/documents/{id}/sentence/{sentenceId}")
public String findSentence(@PathVariable(value="id") Long id, @PathVariable(value="sentenceId") Integer sentenceId) {
String snippet = documentService.findSentenceById(id, sentenceId);
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);
return snippet;
}
@RequestMapping(value = "/export/{id}")
public ResponseEntity<byte[]> generateReport(@PathVariable("id") long documentId){
byte[] content = documentService.exportDocumentAnnotation(documentId);
HttpHeaders head = new HttpHeaders();
head.setContentType(MediaType.parseMediaType("text/plain"));
head.add("content-disposition", "attachment; filename=ejemple");
head.setContentDispositionFormData("ejemple", "ejemple");
head.setCacheControl("must-revalidate, post-check=0, pre-check=0");
return new ResponseEntity<>(content, head,HttpStatus.OK);
}
}
\ No newline at end of file
package es.bsc.inb.ades.rest.api.model;
import java.util.ArrayList;
import java.util.List;
import org.springframework.data.mongodb.core.mapping.Field;
import es.bsc.inb.ades.rest.api.util.VisualizationHTMLUtil;
/**
......@@ -10,7 +13,9 @@ import es.bsc.inb.ades.rest.api.util.VisualizationHTMLUtil;
*
*/
public class Annotation implements Comparable<Annotation> {
@Field("id")
private Integer id;
private String text;
private String value;
......@@ -19,10 +24,16 @@ public class Annotation implements Comparable<Annotation> {
private Integer endOffset;
private List<Feature> features;
private ArrayList<Feature> features;
private Boolean processed;
private List<Finding> findings;
public Annotation() {
super();
}
public String getText() {
return text;
}
......@@ -47,11 +58,11 @@ public class Annotation implements Comparable<Annotation> {
this.endOffset = endOffset;
}
public List<Feature> getFeatures() {
public ArrayList<Feature> getFeatures() {
return features;
}
public void setFeatures(List<Feature> features) {
public void setFeatures(ArrayList<Feature> features) {
this.features = features;
}
......@@ -111,6 +122,16 @@ public class Annotation implements Comparable<Annotation> {
return null;
}
public List<Finding> getFindings() {
return findings;
}
public void setFindings(List<Finding> findings) {
this.findings = findings;
}
/**
*
* @return
......@@ -146,6 +167,14 @@ public class Annotation implements Comparable<Annotation> {
return htmlFeatures.toString();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
......
......@@ -3,11 +3,14 @@ package es.bsc.inb.ades.rest.api.model;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Field;
@org.springframework.data.mongodb.core.mapping.Document(collection="reports")
@org.springframework.data.mongodb.core.mapping.Document(collection="documents")
public class Document{
@Field("_id")
@Id
private ObjectId _id;
@Field("id")
......@@ -17,44 +20,33 @@ public class Document{
private String text;
//private String textWithAnnotations;
private String processDate;
private String fileName;
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;
}
......@@ -85,4 +77,25 @@ public class Document{
public String getProcessDate() {
return processDate;
}
public void setProcessDate(String processDate) {
this.processDate = processDate;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
}
package es.bsc.inb.ades.rest.api.model;
import java.util.ArrayList;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Field;
@org.springframework.data.mongodb.core.mapping.Document(collection="annotations")
public class DocumentAnnotations {
@Field("_id")
@Id
private ObjectId _id;
@Field("id")
private Long documentId;
private String name;
@Field("relevant_sentences")
private ArrayList<Annotation> relevantSentences;
private ArrayList<Finding> findings;
public DocumentAnnotations() {}
public ObjectId get_id() {
return _id;
}
public void set_id(ObjectId _id) {
this._id = _id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getDocumentId() {
return documentId;
}
public ArrayList<Annotation> getRelevantSentences() {
return relevantSentences;
}
public void setRelevantSentences(ArrayList<Annotation> relevantSentences) {
this.relevantSentences = relevantSentences;
}
public void setDocumentId(Long documentId) {
this.documentId = documentId;
}
public ArrayList<Finding> getFindings() {
return findings;
}
public void setFindings(ArrayList<Finding> findings) {
this.findings = findings;
}
}
......@@ -10,6 +10,12 @@ public class Feature {
private String value;
public Feature() {
super();
}
public String getName() {
return name;
}
......
......@@ -10,7 +10,9 @@ import org.springframework.data.mongodb.core.mapping.Field;
* @author jcorvi
*
*/
public class Finding {
@Field("id")
private Integer findingId;
......
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 RelevantSentence {
@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 RelevantSentence() {}
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;
}
public Annotation getFinding() {
return finding;
}
public void setFinding(Annotation finding) {
this.finding = finding;
}
public Annotation getSpecimen() {
return specimen;
}
public void setSpecimen(Annotation specimen) {
this.specimen = specimen;
}
public Annotation getSex() {
return sex;
}
public void setSex(Annotation sex) {
this.sex = sex;
}
public Annotation getManifestation_finding() {
return manifestation_finding;
}
public void setManifestation_finding(Annotation manifestation_finding) {
this.manifestation_finding = manifestation_finding;
}
public Annotation getGroup() {
return group;
}
public void setGroup(Annotation group) {
this.group = group;
}
public Annotation getStudy_testcd() {
return study_testcd;
}
public void setStudy_testcd(Annotation study_testcd) {
this.study_testcd = study_testcd;
}
public Annotation getStudy_domain() {
return study_domain;
}
public void setStudy_domain(Annotation study_domain) {
this.study_domain = study_domain;
}
public Annotation getRelevant_text() {
return relevant_text;
}
public void setRelevant_text(Annotation relevant_text) {
this.relevant_text = relevant_text;
}
public Annotation getIs_treatment_related() {
return is_treatment_related;
}
public void setIs_treatment_related(Annotation is_treatment_related) {
this.is_treatment_related = is_treatment_related;
}
public Annotation getRisk_level() {
return risk_level;
}
public void setRisk_level(Annotation risk_level) {
this.risk_level = risk_level;
}
public Annotation getRoute_of_administration() {
return route_of_administration;
}
public void setRoute_of_administration(Annotation route_of_administration) {
this.route_of_administration = route_of_administration;
}
// public Annotation getDose_quantity() {
// return dose_quantity;
// }
//
// public void setDose_quantity(Annotation dose_quantity) {
// this.dose_quantity = dose_quantity;
// }
//
// public Annotation getDose_frequency() {
// return dose_frequency;
// }
//
//
// public void setDose_frequency(Annotation dose_frequency) {
// this.dose_frequency = dose_frequency;
// }
//
// public Annotation getDose_duration() {
// return dose_duration;
// }
//
// public void setDose_duration(Annotation dose_duration) {
// this.dose_duration = dose_duration;
// }
public Annotation getDose() {
return dose;