use of de.tudarmstadt.ukp.clarin.webanno.security.model.User in project webanno by webanno.
the class CopyAnnotationTest method copySpanWithSlotWithStackingTest.
@Test
public void copySpanWithSlotWithStackingTest() throws Exception {
AnnotatorState state = new AnnotatorStateImpl(Mode.CURATION);
state.setUser(new User());
slotLayer.setAllowStacking(true);
JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1"));
Type type = jcasA.getTypeSystem().getType(DiffUtils.HOST_TYPE);
Feature feature = type.getFeatureByBaseName("f1");
AnnotationFS clickedFs = DiffUtils.makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
JCas mergeCAs = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1"));
DiffUtils.makeLinkHostMultiSPanFeatureFS(mergeCAs, 0, 0, feature, "C", DiffUtils.makeLinkFS(mergeCAs, "slot1", 0, 0));
MergeCas.addSpanAnnotation(state, annotationSchemaService, slotLayer, mergeCAs, clickedFs, true);
assertEquals(2, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
use of de.tudarmstadt.ukp.clarin.webanno.security.model.User in project webanno by webanno.
the class SuggestionViewPanel method mergeArc.
private void mergeArc(IRequestParameters aRequest, UserAnnotationSegment aCurationUserSegment, JCas aJcas) throws AnnotationException, IOException, UIMAException, ClassNotFoundException {
int addressOriginClicked = aRequest.getParameterValue(PARAM_ORIGIN_SPAN_ID).toInt();
int addressTargetClicked = aRequest.getParameterValue(PARAM_TARGET_SPAN_ID).toInt();
String arcType = removePrefix(aRequest.getParameterValue(PARAM_TYPE).toString());
String fsArcaddress = aRequest.getParameterValue(PARAM_ARC_ID).toString();
AnnotatorState bModel = aCurationUserSegment.getAnnotatorState();
SourceDocument sourceDocument = bModel.getDocument();
// for correction and automation, the lower panel is the clickedJcase, from the suggestions
JCas clickedJCas;
if (!aCurationUserSegment.getAnnotatorState().getMode().equals(Mode.CURATION)) {
clickedJCas = correctionDocumentService.readCorrectionCas(sourceDocument);
} else {
User user = userRepository.get(aCurationUserSegment.getUsername());
AnnotationDocument clickedAnnotationDocument = documentService.getAnnotationDocument(sourceDocument, user);
clickedJCas = getJCas(bModel, clickedAnnotationDocument);
}
long layerId = TypeUtil.getLayerId(arcType);
AnnotationLayer layer = annotationService.getLayer(layerId);
TypeAdapter adapter = annotationService.getAdapter(layer);
int address = Integer.parseInt(fsArcaddress.split("\\.")[0]);
AnnotationFS clickedFS = selectByAddr(clickedJCas, address);
if (isCorefType(clickedFS)) {
throw new AnnotationException(" Coreference Annotation not supported in curation");
}
MergeCas.addArcAnnotation(adapter, aJcas, addressOriginClicked, addressTargetClicked, fsArcaddress, clickedJCas, clickedFS);
writeEditorCas(bModel, aJcas);
int sentenceNumber = getSentenceNumber(clickedJCas, clickedFS.getBegin());
bModel.setFocusUnitIndex(sentenceNumber);
// Update timestamp
bModel.getDocument().setSentenceAccessed(sentenceNumber);
if (bModel.getPreferences().isScrollPage()) {
Sentence sentence = selectSentenceAt(aJcas, bModel.getFirstVisibleUnitBegin(), bModel.getFirstVisibleUnitEnd());
sentence = findWindowStartCenteringOnSelection(aJcas, sentence, clickedFS.getBegin(), bModel.getProject(), bModel.getDocument(), bModel.getPreferences().getWindowSize());
bModel.setFirstVisibleUnit(sentence);
}
}
use of de.tudarmstadt.ukp.clarin.webanno.security.model.User in project webanno by webanno.
the class SuggestionViewPanel method mergeSpan.
private void mergeSpan(IRequestParameters aRequest, UserAnnotationSegment aCurationUserSegment, JCas aJcas) throws AnnotationException, UIMAException, ClassNotFoundException, IOException {
User user = userRepository.get(aCurationUserSegment.getUsername());
SourceDocument sourceDocument = aCurationUserSegment.getAnnotatorState().getDocument();
AnnotationDocument clickedAnnotationDocument = documentService.getAnnotationDocument(sourceDocument, user);
Integer address = aRequest.getParameterValue(PARAM_ID).toInteger();
String spanType = removePrefix(aRequest.getParameterValue(PARAM_TYPE).toString());
createSpan(spanType, aCurationUserSegment.getAnnotatorState(), aJcas, clickedAnnotationDocument, address);
}
use of de.tudarmstadt.ukp.clarin.webanno.security.model.User in project webanno by webanno.
the class SuggestionBuilder method createCorrectionCas.
private JCas createCorrectionCas(JCas mergeJCas, AnnotatorState aBratAnnotatorModel, AnnotationDocument randomAnnotationDocument) throws UIMAException, ClassNotFoundException, IOException {
User userLoggedIn = userRepository.get(SecurityContextHolder.getContext().getAuthentication().getName());
mergeJCas = documentService.readAnnotationCas(aBratAnnotatorModel.getDocument(), userLoggedIn);
correctionDocumentService.writeCorrectionCas(mergeJCas, randomAnnotationDocument.getDocument());
return mergeJCas;
}
use of de.tudarmstadt.ukp.clarin.webanno.security.model.User in project webanno by webanno.
the class SuggestionBuilder method listJcasesforCorrection.
private Map<String, JCas> listJcasesforCorrection(AnnotationDocument randomAnnotationDocument, SourceDocument aDocument, Mode aMode) throws UIMAException, ClassNotFoundException, IOException {
Map<String, JCas> jCases = new HashMap<>();
User user = userRepository.get(SecurityContextHolder.getContext().getAuthentication().getName());
randomAnnotationDocument = documentService.getAnnotationDocument(aDocument, user);
// Upgrading should be an explicit action during the opening of a document at the end
// of the open dialog - it must not happen during editing because the CAS addresses
// are used as IDs in the UI
// repository.upgradeCasAndSave(aDocument, aMode, user.getUsername());
JCas jCas = documentService.readAnnotationCas(randomAnnotationDocument);
jCases.put(user.getUsername(), jCas);
return jCases;
}
Aggregations