Skip to content

Commit

Permalink
🔨 fix: add condition for keyword pdf #56
Browse files Browse the repository at this point in the history
  • Loading branch information
noparamin committed Nov 13, 2023
1 parent 1706fd6 commit a46ab1f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/main/java/com/smart/watchboard/service/SseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.itextpdf.text.DocumentException;
import com.smart.watchboard.common.support.AwsS3Uploader;
import com.smart.watchboard.domain.Document;
import com.smart.watchboard.domain.Note;
import com.smart.watchboard.domain.SttData;
import com.smart.watchboard.dto.*;
Expand Down Expand Up @@ -103,14 +104,25 @@ private void sendKeywords(Long documentId, String path) {
SseEmitter emitter = emitterRepository.get(documentId);
if (emitter != null) {
try {
ResponseEntity<KeywordsBodyDto> responseEntity = requestService.requestSTTKeywords(path);
//List<String> keywords = keywordService.createKeywords(responseEntity, documentId);
if (keywordService.findKeywords(documentId) == null) {
keywordService.createKeywords(responseEntity, documentId);
Document document = whiteboardService.findDoc(documentId);
ResponseEntity<KeywordsBodyDto> responseEntity;
if (document.getDataType().equals("pdf")) {
responseEntity = requestService.requestPdfKeywords(path);
if (keywordService.findKeywords(documentId) == null) {
keywordService.createKeywords(responseEntity, documentId);
} else {
keywordService.renewKeywords(responseEntity, documentId);
}
emitter.send(SseEmitter.event().id(String.valueOf(documentId)).name("keywords").data(responseEntity.getBody().getKeywords()));
} else {
keywordService.renewKeywords(responseEntity, documentId);
responseEntity = requestService.requestSTTKeywords(path);
if (keywordService.findKeywords(documentId) == null) {
keywordService.createKeywords(responseEntity, documentId);
} else {
keywordService.renewKeywords(responseEntity, documentId);
}
emitter.send(SseEmitter.event().id(String.valueOf(documentId)).name("keywords").data(responseEntity.getBody().getKeywords()));
}
emitter.send(SseEmitter.event().id(String.valueOf(documentId)).name("keywords").data(responseEntity.getBody().getKeywords()));
} catch (IOException exception) {
emitterRepository.deleteById(documentId);
emitter.completeWithError(exception);
Expand Down

0 comments on commit a46ab1f

Please sign in to comment.