use of de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel in project webanno by webanno.
the class AutomationPage method createDetailEditor.
private AnnotationDetailEditorPanel createDetailEditor() {
return new AnnotationDetailEditorPanel("annotationDetailEditorPanel", getModel()) {
private static final long serialVersionUID = 2857345299480098279L;
@Override
protected void onChange(AjaxRequestTarget aTarget) {
AnnotatorState state = getModelObject();
aTarget.addChildren(getPage(), IFeedback.class);
try {
annotationEditor.requestRender(aTarget);
} catch (Exception e) {
handleException(this, aTarget, e);
return;
}
try {
SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
curationContainer = builder.buildCurationContainer(state);
setCurationSegmentBeginEnd(getEditorCas());
curationContainer.setBratAnnotatorModel(state);
suggestionView.updatePanel(aTarget, curationContainer, annotationSelectionByUsernameAndAddress, curationSegment);
update(aTarget);
} catch (Exception e) {
handleException(this, aTarget, e);
}
}
@Override
public void onAnnotate(AjaxRequestTarget aTarget) {
AnnotatorState state = getModelObject();
if (state.isForwardAnnotation()) {
return;
}
AnnotationLayer layer = state.getSelectedAnnotationLayer();
int address = state.getSelection().getAnnotation().getId();
try {
JCas jCas = getEditorCas();
AnnotationFS fs = selectByAddr(jCas, address);
for (AnnotationFeature f : annotationService.listAnnotationFeature(layer)) {
Type type = CasUtil.getType(fs.getCAS(), layer.getName());
Feature feat = type.getFeatureByBaseName(f.getName());
if (!automationService.existsMiraTemplate(f)) {
continue;
}
if (!automationService.getMiraTemplate(f).isAnnotateAndRepeat()) {
continue;
}
TagSet tagSet = f.getTagset();
boolean isRepeatable = false;
// repeat only if the value is in the tagset
for (Tag tag : annotationService.listTags(tagSet)) {
if (fs.getFeatureValueAsString(feat) == null) {
// this is new annotation without values
break;
}
if (fs.getFeatureValueAsString(feat).equals(tag.getName())) {
isRepeatable = true;
break;
}
}
if (automationService.getMiraTemplate(f) != null && isRepeatable) {
if (layer.getType().endsWith(WebAnnoConst.RELATION_TYPE)) {
AutomationUtil.repeateRelationAnnotation(state, documentService, correctionDocumentService, annotationService, fs, f, fs.getFeatureValueAsString(feat));
update(aTarget);
break;
} else if (layer.getType().endsWith(WebAnnoConst.SPAN_TYPE)) {
AutomationUtil.repeateSpanAnnotation(state, documentService, correctionDocumentService, annotationService, fs.getBegin(), fs.getEnd(), f, fs.getFeatureValueAsString(feat));
update(aTarget);
break;
}
}
}
} catch (Exception e) {
handleException(this, aTarget, e);
}
}
@Override
protected void onAutoForward(AjaxRequestTarget aTarget) {
annotationEditor.requestRender(aTarget);
}
@Override
public void onDelete(AjaxRequestTarget aTarget, AnnotationFS aFS) {
AnnotatorState state = getModelObject();
AnnotationLayer layer = state.getSelectedAnnotationLayer();
for (AnnotationFeature f : annotationService.listAnnotationFeature(layer)) {
if (!automationService.existsMiraTemplate(f)) {
continue;
}
if (!automationService.getMiraTemplate(f).isAnnotateAndRepeat()) {
continue;
}
try {
Type type = CasUtil.getType(aFS.getCAS(), layer.getName());
Feature feat = type.getFeatureByBaseName(f.getName());
if (layer.getType().endsWith(WebAnnoConst.RELATION_TYPE)) {
AutomationUtil.deleteRelationAnnotation(state, documentService, correctionDocumentService, annotationService, aFS, f, aFS.getFeatureValueAsString(feat));
} else {
AutomationUtil.deleteSpanAnnotation(state, documentService, correctionDocumentService, annotationService, aFS.getBegin(), aFS.getEnd(), f, aFS.getFeatureValueAsString(feat));
}
update(aTarget);
} catch (Exception e) {
handleException(this, aTarget, e);
}
}
}
};
}
use of de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel 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);
}
};
}
Aggregations