Skip to content

Commit

Permalink
Merge pull request #37 from kbss-cvut/process-annotations-on-import-d…
Browse files Browse the repository at this point in the history
…ocument

[UPD] Call process-annotation-service on document import
  • Loading branch information
blcham authored Mar 21, 2024
2 parents 9c4d2cf + dbeed3b commit 23f2987
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
public class AnnotatorConf {
private String listDocumentsAPI;
private String convertDocumentAPI;
private String processAnnotationAPI;
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void deleteComponent(@PathVariable(name = "systemFragment") String system
public void importDocument(@PathVariable(name = "systemFragment") String systemFragment, @RequestParam URI documentId) throws UnsupportedEncodingException {
URI systemURI = identifierService.composeIdentifier(Vocabulary.s_c_system, systemFragment);
log.info("> importing annotations from document <{}> into system <{}>", documentId, systemURI);
annotatorService.processAnnotations();
annotatorService.convertDocument(documentId.toString());
repositoryService.importDocument(systemURI, documentId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

@Service
@Slf4j
Expand Down Expand Up @@ -51,4 +49,16 @@ public void convertDocument(String docuementIri) throws UnsupportedEncodingExcep
// use document iri as the context in which to store converted annotations
rdfDao.persist(reader, docuementIri);
}

public void processAnnotations(){
try {
log.info("calling external annotation processing service {}", conf.getProcessAnnotationAPI());
RestTemplate restTemplate = new RestTemplate();
String url = conf.getProcessAnnotationAPI();
ResponseEntity<String> response
= restTemplate.getForEntity(url, String.class);
}catch (Exception e){
log.warn("Failed executing external process annotation service at <{}>. Error message - {}", e.getMessage());
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ logging:
annotator:
list-documents-api: ${LIST_DOCUMENT_API:http://localhost:8282/s-pipes/service?_pId=list-documents}
convert-document-api: ${CONVERT_DOCUMENT_API:http://localhost:8282/s-pipes/service?_pId=convert-document}
process-annotatoins-api: ${PROCESS_ANNOTATION_API:https://localhost:8090/annotator/process-annotation-service.sh}

0 comments on commit 23f2987

Please sign in to comment.