Commit 447c7c35 authored by javi's avatar javi
Browse files

improves srdomaintemplate tab

parent 27066537
Pipeline #22655 passed with stage
in 4 minutes and 38 seconds
......@@ -30,7 +30,12 @@ public class DocumentController {
@RequestMapping("/documents/{id}")
public DocumentAnnotations find(@PathVariable(value="id") Long id) {
return documentService.findByDocumentAnnotationsByDocumentId(id);
return documentService.findDocumentAnnotationsByDocumentId(id);
}
@RequestMapping("/documents/{id}/srdomain")
public DocumentAnnotations findDocumentSRDomain(@PathVariable(value="id") Long id) {
return documentService.findDocumentSRDomainByDocumentId(id);
}
// @RequestMapping("/documents/{id}")
......
package es.bsc.inb.ades.rest.api.model;
import java.util.ArrayList;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
......@@ -22,6 +23,8 @@ public class DocumentAnnotations {
private ArrayList<Annotation> relevantSentences;
private ArrayList<Finding> findings;
private List<SRDomainFinding> srdomainfindings;
public DocumentAnnotations() {}
......@@ -46,7 +49,6 @@ public class DocumentAnnotations {
return documentId;
}
public ArrayList<Annotation> getRelevantSentences() {
return relevantSentences;
}
......@@ -59,20 +61,22 @@ public class DocumentAnnotations {
this.documentId = documentId;
}
public ArrayList<Finding> getFindings() {
return findings;
}
public void setFindings(ArrayList<Finding> findings) {
this.findings = findings;
}
public List<SRDomainFinding> getSrdomainfindings() {
return srdomainfindings;
}
public void setSrdomainfindings(List<SRDomainFinding> srdomainfindings) {
this.srdomainfindings = srdomainfindings;
}
}
......@@ -34,6 +34,11 @@ public class SRDomainFinding implements Cloneable{
private String SRSIGF="";
private String SRTRTEF="";
private String SRCOMNT="";
private Boolean export;
private Integer findingId;
private Integer srDomainId;
public String getSTUDYID() {
return STUDYID;
}
......@@ -191,6 +196,27 @@ public class SRDomainFinding implements Cloneable{
SRCOMNT = sRCOMNT;
}
public Boolean getExport() {
return export;
}
public void setExport(Boolean export) {
this.export = export;
}
public Integer getSrDomainId() {
return srDomainId;
}
public void setSrDomainId(Integer srDomainId) {
this.srDomainId = srDomainId;
}
public Integer getFindingId() {
return findingId;
}
public void setFindingId(Integer findingId) {
this.findingId = findingId;
}
public SRDomainFinding clone() {
try {
return (SRDomainFinding)super.clone();
......
......@@ -18,7 +18,9 @@ public interface DocumentService {
String findFindingEvidenceByDocumentIdAndFindingId(Long id, Integer findingId);
DocumentAnnotations findByDocumentAnnotationsByDocumentId(Long id);
DocumentAnnotations findDocumentAnnotationsByDocumentId(Long id);
DocumentAnnotations findDocumentSRDomainByDocumentId(Long id);
String findSentenceEvidenceByDocumentIdAndSentenceId(Long id, Integer sentenceId);
......
......@@ -28,6 +28,7 @@ import es.bsc.inb.ades.rest.api.model.Annotation;
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.model.Finding;
import es.bsc.inb.ades.rest.api.model.SRDomainFinding;
import es.bsc.inb.ades.rest.api.repository.DocumentAnnotationsRepository;
import es.bsc.inb.ades.rest.api.repository.DocumentRepository;
import es.bsc.inb.ades.rest.api.util.Constants;
......@@ -60,10 +61,25 @@ public class DocumentServiceImpl implements DocumentService {
return documentRepository.findDocumentTextSubstringByDocumentId(id, start, end);
}
public DocumentAnnotations findByDocumentAnnotationsByDocumentId(Long id) {
public DocumentAnnotations findDocumentAnnotationsByDocumentId(Long id) {
return documentAnnotationsRepository.findByDocumentId(id);
}
public DocumentAnnotations findDocumentSRDomainByDocumentId(Long id) {
DocumentAnnotations docAnno = documentAnnotationsRepository.findByDocumentId(id);
List<SRDomainFinding> srdomains = new ArrayList<SRDomainFinding>();
for (Annotation sentence : docAnno.getRelevantSentences()) {
for (Finding finding : sentence.getFindings()) {
for (SRDomainFinding sr : finding.getSrDomainFindings()) {
srdomains.add(sr);
}
}
}
docAnno.setSrdomainfindings(srdomains);
docAnno.setRelevantSentences(null);
docAnno.setFindings(null);
return docAnno;
}
public Document findByDocumentId2(Long id) {
documentRepository.findByDocumentId(id);
......@@ -91,7 +107,7 @@ public class DocumentServiceImpl implements DocumentService {
@Override
public String findTextSnippetByDocumentIdAndFindingId2(Long id, Integer findingId) {
DocumentAnnotations documentAnnotations = this.findByDocumentAnnotationsByDocumentId(id);
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Document document = this.findByDocumentId(id);
Finding findingSelected = null;
for (Finding finding : documentAnnotations.getFindings()) {
......@@ -111,7 +127,7 @@ public class DocumentServiceImpl implements DocumentService {
@Override
public Boolean acceptFinding(Long id, Integer findingId) {
DocumentAnnotations documentAnnotations = this.findByDocumentAnnotationsByDocumentId(id);
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Finding findingSelected = null;
for (Annotation annotation : documentAnnotations.getRelevantSentences()) {
for (Finding finding : annotation.getFindings()) {
......@@ -131,7 +147,7 @@ public class DocumentServiceImpl implements DocumentService {
@Override
public Boolean rejectFinding(Long id, Integer findingId) {
DocumentAnnotations documentAnnotations = this.findByDocumentAnnotationsByDocumentId(id);
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Finding findingSelected = null;
for (Annotation annotation : documentAnnotations.getRelevantSentences()) {
for (Finding finding : annotation.getFindings()) {
......@@ -152,7 +168,7 @@ public class DocumentServiceImpl implements DocumentService {
@Override
public Boolean setExportFinding(Long id, Integer findingId,String export_finding) {
DocumentAnnotations documentAnnotations = this.findByDocumentAnnotationsByDocumentId(id);
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Finding findingSelected = null;
for (Annotation annotation : documentAnnotations.getRelevantSentences()) {
for (Finding finding : annotation.getFindings()) {
......@@ -174,7 +190,7 @@ public class DocumentServiceImpl implements DocumentService {
@Override
public String findSentenceEvidenceByDocumentIdAndSentenceId(Long id, Integer sentenceId) {
DocumentAnnotations documentAnnotations = this.findByDocumentAnnotationsByDocumentId(id);
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Annotation annotation = null;
for (Annotation sentence : documentAnnotations.getRelevantSentences()) {
if(sentence.getId().equals(sentenceId)) {
......@@ -205,14 +221,14 @@ public class DocumentServiceImpl implements DocumentService {
}
public String findFindingsEvidenceByDocumentId(Long id) {
DocumentAnnotations documentAnnotations = this.findByDocumentAnnotationsByDocumentId(id);
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Document document = this.findByDocumentId(id);
return this.generateFindingsSnippet4(document.getText(), documentAnnotations.getFindings());
}
@Override
public String findFindingEvidenceByDocumentIdAndFindingId(Long id, Integer findingId) {
DocumentAnnotations documentAnnotations = this.findByDocumentAnnotationsByDocumentId(id);
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Finding findingSelected = null;
for (Annotation annotation : documentAnnotations.getRelevantSentences()) {
for (Finding finding : annotation.getFindings()) {
......@@ -267,7 +283,7 @@ public class DocumentServiceImpl implements DocumentService {
public byte[] exportDocumentAnnotation(Long id) {
DocumentAnnotations documentAnnotations = this.findByDocumentAnnotationsByDocumentId(id);
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
StringBuilder retStr = new StringBuilder("");
retStr.append("STUDYID|DOMAIN|SRSEQ|SRRISK|SPGRPCD|GRPLBL|SRGRPDOS|SRSEX|SRSTDY|SRSTPHSE|SROBSTDY|SRENDY|SRENPHSE|SROBENDY|SRDOMAIN|SRSPEC|SRTSTCD|SRFNDG|SRORES|SROBSV|SROBSQ|SRSEV|SRPCNT|SRSIGF|SRTRTEF|SRCOMNT");
retStr.append(System.getProperty("line.separator"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment