diff --git a/src/main/java/cz/cvut/kbss/termit/service/business/TermService.java b/src/main/java/cz/cvut/kbss/termit/service/business/TermService.java index 50e561a1d..e48f15ad6 100644 --- a/src/main/java/cz/cvut/kbss/termit/service/business/TermService.java +++ b/src/main/java/cz/cvut/kbss/termit/service/business/TermService.java @@ -373,8 +373,10 @@ public void persistRoot(Term term, Vocabulary owner) { Objects.requireNonNull(owner); languageService.getInitialTermState().ifPresent(is -> term.setState(is.getUri())); repositoryService.addRootTermToVocabulary(term, owner); - analyzeTermDefinition(term, owner.getUri()); - vocabularyService.runTextAnalysisOnAllTerms(owner); + if (!config.getTextAnalysis().isDisableVocabularyAnalysisOnTermEdit()) { + analyzeTermDefinition(term, owner.getUri()); + vocabularyService.runTextAnalysisOnAllTerms(owner); + } } /** @@ -389,8 +391,10 @@ public void persistChild(Term child, Term parent) { Objects.requireNonNull(parent); languageService.getInitialTermState().ifPresent(is -> child.setState(is.getUri())); repositoryService.addChildTerm(child, parent); - analyzeTermDefinition(child, parent.getVocabulary()); - vocabularyService.runTextAnalysisOnAllTerms(findVocabularyRequired(parent.getVocabulary())); + if (!config.getTextAnalysis().isDisableVocabularyAnalysisOnTermEdit()) { + analyzeTermDefinition(child, parent.getVocabulary()); + vocabularyService.runTextAnalysisOnAllTerms(findVocabularyRequired(parent.getVocabulary())); + } } /** @@ -407,10 +411,10 @@ public Term update(Term term) { checkForInvalidTerminalStateAssignment(original, term.getState()); // Ensure the change is merged into the repo before analyzing other terms final Term result = repositoryService.update(term); - if (!Objects.equals(original.getDefinition(), term.getDefinition())) { + if (!Objects.equals(original.getDefinition(), term.getDefinition()) && !config.getTextAnalysis().isDisableVocabularyAnalysisOnTermEdit()) { analyzeTermDefinition(term, original.getVocabulary()); } - if (!Objects.equals(original.getLabel(), term.getLabel())) { + if (!Objects.equals(original.getLabel(), term.getLabel()) && !config.getTextAnalysis().isDisableVocabularyAnalysisOnTermEdit()) { vocabularyService.runTextAnalysisOnAllTerms(getVocabularyReference(original.getVocabulary())); } return result; diff --git a/src/main/java/cz/cvut/kbss/termit/util/Configuration.java b/src/main/java/cz/cvut/kbss/termit/util/Configuration.java index 6b2d1eebe..88c89c131 100644 --- a/src/main/java/cz/cvut/kbss/termit/util/Configuration.java +++ b/src/main/java/cz/cvut/kbss/termit/util/Configuration.java @@ -586,6 +586,8 @@ public static class TextAnalysis { @Min(8) private int textQuoteSelectorContextLength = 32; + private boolean disableVocabularyAnalysisOnTermEdit = false; + public String getUrl() { return url; } @@ -609,6 +611,14 @@ public int getTextQuoteSelectorContextLength() { public void setTextQuoteSelectorContextLength(int textQuoteSelectorContextLength) { this.textQuoteSelectorContextLength = textQuoteSelectorContextLength; } + + public boolean isDisableVocabularyAnalysisOnTermEdit() { + return disableVocabularyAnalysisOnTermEdit; + } + + public void setDisableVocabularyAnalysisOnTermEdit(boolean disableVocabularyAnalysisOnTermEdit) { + this.disableVocabularyAnalysisOnTermEdit = disableVocabularyAnalysisOnTermEdit; + } } @Validated