use of de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CURATION_USER in project webanno by webanno.
the class CuratedDocumentsExporterTest method thatImportingCorrectionProjectWorks_3_6_1.
@Test
public void thatImportingCorrectionProjectWorks_3_6_1() throws Exception {
project.setMode(PROJECT_TYPE_CORRECTION);
// Export the project and import it again
List<Pair<SourceDocument, String>> imported = runImportAndFetchDocuments(new ZipFile("src/test/resources/exports/Export+Test+-+Curated+correction+project_3_6_1.zip"));
// Check that the curation for the document in the project is imported
assertThat(imported).extracting(p -> p.getKey().getName()).containsExactlyInAnyOrder("example_sentence.txt");
// Since WebAnno 3.5.x, the CORRECTION_USER CAS is stored with the annotations
assertThat(imported).extracting(Pair::getValue).containsExactlyInAnyOrder(CURATION_USER);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CURATION_USER in project webanno by webanno.
the class CuratedDocumentsExporterTest method thatImportingAnnotationProjectWorks_3_6_1.
@Test
public void thatImportingAnnotationProjectWorks_3_6_1() throws Exception {
project.setMode(PROJECT_TYPE_ANNOTATION);
// Export the project and import it again
List<Pair<SourceDocument, String>> imported = runImportAndFetchDocuments(new ZipFile("src/test/resources/exports/Export+Test+-+Curated+annotation+project_3_6_1.zip"));
// Check that the curation for the document in the project is imported
assertThat(imported).extracting(p -> p.getKey().getName()).containsExactlyInAnyOrder("example_sentence.txt");
assertThat(imported).extracting(Pair::getValue).containsExactlyInAnyOrder(CURATION_USER);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CURATION_USER in project webanno by webanno.
the class CuratedDocumentsExporterTest method thatImportingCorrectionProjectWorks_3_4_x.
@Test
public void thatImportingCorrectionProjectWorks_3_4_x() throws Exception {
project.setMode(PROJECT_TYPE_CORRECTION);
// Export the project and import it again
List<Pair<SourceDocument, String>> imported = runImportAndFetchDocuments(new ZipFile("src/test/resources/exports/Export+Test+-+Curated+correction+project_3_4_8.zip"));
// Check that the curation for the document in the project is imported
assertThat(imported).extracting(p -> p.getKey().getName()).containsExactlyInAnyOrder("example_sentence.txt", "example_sentence.txt");
// Before WebAnno 3.5.x, the CORRECTION_USER CAS was stored with the curations
assertThat(imported).extracting(Pair::getValue).containsExactlyInAnyOrder(CURATION_USER, CORRECTION_USER);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CURATION_USER in project webanno by webanno.
the class ProjectCasDoctorPanel method actionRepair.
private void actionRepair(AjaxRequestTarget aTarget, Form<?> aForm) throws IOException, UIMAException, ClassNotFoundException {
CasDoctor casDoctor = new CasDoctor();
casDoctor.setApplicationContext(ApplicationContextProvider.getApplicationContext());
casDoctor.setFatalChecks(false);
casDoctor.setRepairClasses(formModel.repairs);
Project project = getModelObject();
formModel.messageSets = new ArrayList<>();
for (SourceDocument sd : documentService.listSourceDocuments(project)) {
// Repair INITIAL CAS
{
LogMessageSet messageSet = new LogMessageSet(sd.getName() + " [INITIAL]");
try {
casStorageService.forceActionOnCas(sd, INITIAL_CAS_PSEUDO_USER, (doc, user) -> createOrReadInitialCasWithoutSaving(doc, messageSet), //
(cas) -> casDoctor.repair(project, cas, messageSet.messages), true);
} catch (Exception e) {
messageSet.messages.add(new LogMessage(getClass(), LogLevel.ERROR, "Error repairing initial CAS for [" + sd.getName() + "]: " + e.getMessage()));
LOG.error("Error repairing initial CAS for [{}]", sd.getName(), e);
}
noticeIfThereAreNoMessages(messageSet);
formModel.messageSets.add(messageSet);
}
// Repair CORRECTION_USER CAS if necessary
if (PROJECT_TYPE_CORRECTION.equals(project.getMode())) {
LogMessageSet messageSet = new LogMessageSet(sd.getName() + " [" + CORRECTION_USER + "]");
try {
casStorageService.forceActionOnCas(sd, CORRECTION_USER, (doc, user) -> casStorageService.readCas(doc, user, UNMANAGED_NON_INITIALIZING_ACCESS), //
(cas) -> casDoctor.repair(project, cas, messageSet.messages), true);
} catch (FileNotFoundException e) {
// If there is no CAS for the correction user, then correction has not started
// yet. This is not a problem, so we can ignore it. (REC: I wonder if this
// assumption is correct in curation mode...)
messageSet.messages.add(LogMessage.info(getClass(), "Correction seems to have not yet started."));
} catch (Exception e) {
messageSet.messages.add(new LogMessage(getClass(), LogLevel.ERROR, "Error checking annotations for [" + CORRECTION_USER + "] for [" + sd.getName() + "]: " + e.getMessage()));
LOG.error("Error checking annotations for [{}] for [{}]", CORRECTION_USER, sd.getName(), e);
}
noticeIfThereAreNoMessages(messageSet);
formModel.messageSets.add(messageSet);
}
// Repair CURATION_USER CAS
{
LogMessageSet messageSet = new LogMessageSet(sd.getName() + " [" + CURATION_USER + "]");
try {
casStorageService.forceActionOnCas(sd, CURATION_USER, (doc, user) -> casStorageService.readCas(doc, user, UNMANAGED_NON_INITIALIZING_ACCESS), //
(cas) -> casDoctor.repair(project, cas, messageSet.messages), true);
} catch (FileNotFoundException e) {
if (asList(CURATION_IN_PROGRESS, CURATION_FINISHED).contains(sd.getState())) {
messageSet.messages.add(LogMessage.error(getClass(), "Curation CAS missing."));
} else {
// If there is no CAS for the curation user, then curation has not started
// yet. This is not a problem, so we can ignore it.
messageSet.messages.add(LogMessage.info(getClass(), "Curation has not started."));
}
} catch (Exception e) {
messageSet.messages.add(new LogMessage(getClass(), LogLevel.ERROR, "Error checking annotations for [" + CURATION_USER + "] for [" + sd.getName() + "]: " + e.getMessage()));
LOG.error("Error checking annotations for [{}] for [{}]", CURATION_USER, sd.getName(), e);
}
noticeIfThereAreNoMessages(messageSet);
formModel.messageSets.add(messageSet);
}
// Repair regular annotator CASes
for (AnnotationDocument ad : documentService.listAnnotationDocuments(sd)) {
if (documentService.existsAnnotationCas(ad)) {
LogMessageSet messageSet = new LogMessageSet(sd.getName() + " [" + ad.getUser() + "]");
try {
casStorageService.forceActionOnCas(sd, ad.getUser(), (doc, user) -> casStorageService.readCas(doc, user, UNMANAGED_NON_INITIALIZING_ACCESS), //
(cas) -> casDoctor.repair(project, cas, messageSet.messages), true);
} catch (Exception e) {
messageSet.messages.add(new LogMessage(getClass(), LogLevel.ERROR, "Error repairing annotations of user [" + ad.getUser() + "] for [" + sd.getName() + "]: " + e.getMessage()));
LOG.error("Error repairing annotations of user [{}] for [{}]", ad.getUser(), sd.getName(), e);
}
noticeIfThereAreNoMessages(messageSet);
formModel.messageSets.add(messageSet);
}
}
}
aTarget.add(this);
}
use of de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.CURATION_USER in project webanno by webanno.
the class ProjectCasDoctorPanel method actionCheck.
private void actionCheck(AjaxRequestTarget aTarget, Form<?> aForm) throws IOException, UIMAException, ClassNotFoundException {
CasDoctor casDoctor = new CasDoctor();
casDoctor.setApplicationContext(ApplicationContextProvider.getApplicationContext());
casDoctor.setFatalChecks(false);
casDoctor.setCheckClasses(CasDoctor.scanChecks());
Project project = getModelObject();
formModel.messageSets = new ArrayList<>();
for (SourceDocument sd : documentService.listSourceDocuments(project)) {
// Check INITIAL CAS
{
LogMessageSet messageSet = new LogMessageSet(sd.getName() + " [INITIAL]");
try {
casStorageService.forceActionOnCas(sd, INITIAL_CAS_PSEUDO_USER, (doc, user) -> createOrReadInitialCasWithoutSaving(doc, messageSet), //
(cas) -> casDoctor.analyze(project, cas, messageSet.messages), false);
} catch (Exception e) {
messageSet.messages.add(new LogMessage(getClass(), LogLevel.ERROR, "Error checking initial CAS for [" + sd.getName() + "]: " + e.getMessage()));
LOG.error("Error checking initial CAS for [{}]", sd.getName(), e);
}
noticeIfThereAreNoMessages(messageSet);
formModel.messageSets.add(messageSet);
}
// Check CORRECTION_USER CAS if necessary
if (WebAnnoConst.PROJECT_TYPE_CORRECTION.equals(project.getMode())) {
LogMessageSet messageSet = new LogMessageSet(sd.getName() + " [" + CORRECTION_USER + "]");
try {
casStorageService.forceActionOnCas(sd, CORRECTION_USER, (doc, user) -> casStorageService.readCas(doc, user, UNMANAGED_NON_INITIALIZING_ACCESS), //
(cas) -> casDoctor.analyze(project, cas, messageSet.messages), false);
} catch (FileNotFoundException e) {
// If there is no CAS for the correction user, then correction has not started
// yet. This is not a problem, so we can ignore it. (REC: I wonder if this
// assumption is correct in curation mode...)
messageSet.messages.add(LogMessage.info(getClass(), "Correction seems to have not yet started."));
} catch (Exception e) {
messageSet.messages.add(new LogMessage(getClass(), LogLevel.ERROR, "Error checking annotations for [" + CORRECTION_USER + "] for [" + sd.getName() + "]: " + e.getMessage()));
LOG.error("Error checking annotations for [{}] for [{}]", CORRECTION_USER, sd.getName(), e);
}
noticeIfThereAreNoMessages(messageSet);
formModel.messageSets.add(messageSet);
}
// Check CURATION_USER CAS
{
LogMessageSet messageSet = new LogMessageSet(sd.getName() + " [" + CURATION_USER + "]");
try {
casStorageService.forceActionOnCas(sd, CURATION_USER, (doc, user) -> casStorageService.readCas(doc, user, UNMANAGED_NON_INITIALIZING_ACCESS), //
(cas) -> casDoctor.analyze(project, cas, messageSet.messages), false);
} catch (FileNotFoundException e) {
// If there is no CAS for the curation user, then curation has not started yet.
// This is not a problem, so we can ignore it.
messageSet.messages.add(LogMessage.info(getClass(), "Curation seems to have not yet started."));
} catch (Exception e) {
messageSet.messages.add(new LogMessage(getClass(), LogLevel.ERROR, "Error checking annotations for [" + CURATION_USER + "] for [" + sd.getName() + "]: " + e.getMessage()));
LOG.error("Error checking annotations for [{}] for [{}]", CURATION_USER, sd.getName(), e);
}
noticeIfThereAreNoMessages(messageSet);
formModel.messageSets.add(messageSet);
}
// Check regular annotator CASes
for (AnnotationDocument ad : documentService.listAnnotationDocuments(sd)) {
if (documentService.existsAnnotationCas(ad)) {
LogMessageSet messageSet = new LogMessageSet(sd.getName() + " [" + ad.getUser() + "]");
try {
casStorageService.forceActionOnCas(ad.getDocument(), ad.getUser(), (doc, user) -> casStorageService.readCas(doc, user, UNMANAGED_NON_INITIALIZING_ACCESS), //
(cas) -> casDoctor.analyze(project, cas, messageSet.messages), false);
} catch (Exception e) {
messageSet.messages.add(new LogMessage(getClass(), LogLevel.ERROR, "Error checking annotations of user [" + ad.getUser() + "] for [" + sd.getName() + "]: " + e.getMessage()));
LOG.error("Error checking annotations of user [{}] for [{}]", ad.getUser(), sd.getName(), e);
}
noticeIfThereAreNoMessages(messageSet);
formModel.messageSets.add(messageSet);
}
}
}
aTarget.add(this);
}
Aggregations