Skip to content

Commit

Permalink
[HotFix] Allow disabling automatic text analysis of all vocabulary te…
Browse files Browse the repository at this point in the history
…rms on term edit.

The automatic analysis causes issues when multiple users edit a vocabulary at the same time (Perf #285), this is until we have a more permanent solution.

(cherry picked from commit 8c9d086)
  • Loading branch information
ledsoft committed Aug 13, 2024
1 parent db11f75 commit 45b793f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand All @@ -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()));
}
}

/**
Expand All @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/cz/cvut/kbss/termit/util/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ public static class TextAnalysis {
@Min(8)
private int textQuoteSelectorContextLength = 32;

private boolean disableVocabularyAnalysisOnTermEdit = false;

public String getUrl() {
return url;
}
Expand All @@ -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
Expand Down

0 comments on commit 45b793f

Please sign in to comment.