use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder in project webanno by webanno.
the class CurationPage method actionLoadDocument.
/**
* Open a document or to a different document. This method should be used only the first time
* that a document is accessed. It reset the annotator state and upgrades the CAS.
*/
@Override
protected void actionLoadDocument(AjaxRequestTarget aTarget) {
LOG.info("BEGIN LOAD_DOCUMENT_ACTION");
AnnotatorState state = getModelObject();
String username = SecurityContextHolder.getContext().getAuthentication().getName();
User user = userRepository.get(username);
state.setUser(user);
try {
// ANNOTATION_FINISHED
if (!SourceDocumentState.CURATION_FINISHED.equals(state.getDocument().getState())) {
documentService.transitionSourceDocumentState(state.getDocument(), ANNOTATION_IN_PROGRESS_TO_CURATION_IN_PROGRESS);
}
// Load user preferences
PreferencesUtil.loadPreferences(username, settingsService, projectService, annotationService, state, state.getMode());
// Re-render whole page as sidebar size preference may have changed
aTarget.add(CurationPage.this);
List<AnnotationDocument> finishedAnnotationDocuments = new ArrayList<>();
for (AnnotationDocument annotationDocument : documentService.listAnnotationDocuments(state.getDocument())) {
if (annotationDocument.getState().equals(AnnotationDocumentState.FINISHED)) {
finishedAnnotationDocuments.add(annotationDocument);
}
}
SuggestionBuilder cb = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
AnnotationDocument randomAnnotationDocument = null;
if (finishedAnnotationDocuments.size() > 0) {
randomAnnotationDocument = finishedAnnotationDocuments.get(0);
}
// annotation
for (AnnotationDocument ad : finishedAnnotationDocuments) {
upgradeCasAndSave(ad.getDocument(), ad.getUser());
}
Map<String, JCas> jCases = cb.listJcasesforCuration(finishedAnnotationDocuments, randomAnnotationDocument, state.getMode());
JCas mergeJCas = cb.getMergeCas(state, state.getDocument(), jCases, randomAnnotationDocument, true);
// (Re)initialize brat model after potential creating / upgrading CAS
state.reset();
state.getPreferences().setCurationWindowSize(WebAnnoCasUtil.getSentenceCount(mergeJCas));
// Initialize the visible content
state.setFirstVisibleUnit(WebAnnoCasUtil.getFirstSentence(mergeJCas));
// if project is changed, reset some project specific settings
if (currentprojectId != state.getProject().getId()) {
state.clearRememberedFeatures();
}
currentprojectId = state.getProject().getId();
SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
curationContainer = builder.buildCurationContainer(state);
curationContainer.setBratAnnotatorModel(state);
curationPanel.editor.reset(aTarget);
updatePanel(curationContainer, aTarget);
updateSentenceNumber(mergeJCas, state.getFirstVisibleUnitAddress());
curationPanel.init(aTarget, curationContainer);
// curationPanel.updatePanel(aTarget, curationContainer);
// Load constraints
state.setConstraints(constraintsService.loadConstraints(state.getProject()));
aTarget.add(getOrCreatePositionInfoLabel());
aTarget.add(documentNamePanel);
aTarget.add(remergeDocumentLink);
aTarget.add(finishDocumentLink);
} catch (Exception e) {
handleException(aTarget, e);
}
LOG.info("END LOAD_DOCUMENT_ACTION");
}
use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder in project webanno by webanno.
the class CorrectionPage method actionRefreshDocument.
@Override
protected void actionRefreshDocument(AjaxRequestTarget aTarget) {
try {
AnnotatorState state = getModelObject();
SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
curationContainer = builder.buildCurationContainer(state);
setCurationSegmentBeginEnd(getEditorCas());
curationContainer.setBratAnnotatorModel(state);
update(aTarget);
annotationEditor.requestRender(aTarget);
} catch (Exception e) {
handleException(aTarget, e);
}
}
use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder in project webanno by webanno.
the class CorrectionPage method createDetailEditor.
private AnnotationDetailEditorPanel createDetailEditor() {
return new AnnotationDetailEditorPanel("annotationDetailEditorPanel", getModel()) {
private static final long serialVersionUID = 2857345299480098279L;
@Override
protected void onChange(AjaxRequestTarget aTarget) {
aTarget.addChildren(getPage(), IFeedback.class);
aTarget.add(getOrCreatePositionInfoLabel());
try {
AnnotatorState state = getModelObject();
JCas editorCas = getEditorCas();
// JCas correctionCas = repository.readCorrectionCas(state.getDocument());
annotationEditor.requestRender(aTarget);
// info(bratAnnotatorModel.getMessage());
SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
curationContainer = builder.buildCurationContainer(state);
setCurationSegmentBeginEnd(editorCas);
curationContainer.setBratAnnotatorModel(state);
update(aTarget);
} catch (Exception e) {
handleException(this, aTarget, e);
}
}
@Override
protected void onAutoForward(AjaxRequestTarget aTarget) {
annotationEditor.requestRender(aTarget);
}
};
}
use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder in project webanno by webanno.
the class CorrectionPage method actionGotoPage.
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception {
AnnotatorState state = getModelObject();
JCas editorCas = getEditorCas();
List<Sentence> sentences = new ArrayList<>(select(editorCas, Sentence.class));
int selectedSentence = gotoPageTextField.getModelObject();
selectedSentence = Math.min(selectedSentence, sentences.size());
gotoPageTextField.setModelObject(selectedSentence);
state.setFirstVisibleUnit(sentences.get(selectedSentence - 1));
state.setFocusUnitIndex(selectedSentence);
SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
curationContainer = builder.buildCurationContainer(state);
setCurationSegmentBeginEnd(editorCas);
curationContainer.setBratAnnotatorModel(state);
update(aTarget);
aTarget.add(gotoPageTextField);
annotationEditor.requestRender(aTarget);
}
Aggregations