@Override public JCas readCurationCas(SourceDocument aDocument) throws IOException { return casStorageService.readCas(aDocument, CURATION_USER); }
@Override public JCas readCorrectionCas(SourceDocument aDocument) throws IOException { return casStorageService.readCas(aDocument, CORRECTION_USER); }
@Override public JCas readCorrectionCas(SourceDocument aDocument) throws IOException { return casStorageService.readCas(aDocument, CORRECTION_USER); }
private JCas createOrReadInitialCasWithoutSaving(SourceDocument aDocument, LogMessageSet aMessageSet) throws IOException, UIMAException { JCas cas; if (casStorageService.existsCas(aDocument, INITIAL_CAS_PSEUDO_USER)) { cas = casStorageService.readCas(aDocument, INITIAL_CAS_PSEUDO_USER, false); } else { cas = importExportService.importCasFromFile( documentService.getSourceDocumentFile(aDocument), aDocument.getProject(), aDocument.getFormat()); aMessageSet.messages.add(new LogMessage(getClass(), LogLevel.INFO, "Created initial CAS for [" + aDocument.getName() + "]")); } return cas; }
private JCas createOrReadInitialCasWithoutSaving(SourceDocument aDocument, LogMessageSet aMessageSet) throws IOException, UIMAException { JCas cas; if (casStorageService.existsCas(aDocument, INITIAL_CAS_PSEUDO_USER)) { cas = casStorageService.readCas(aDocument, INITIAL_CAS_PSEUDO_USER, false); } else { cas = importExportService.importCasFromFile( documentService.getSourceDocumentFile(aDocument), aDocument.getProject(), aDocument.getFormat()); aMessageSet.messages.add(new LogMessage(getClass(), LogLevel.INFO, "Created initial CAS for [" + aDocument.getName() + "]")); } return cas; }
@Test public void testCasMetadataGetsCreated() throws Exception { List<TypeSystemDescription> typeSystems = new ArrayList<>(); typeSystems.add(createTypeSystemDescription()); typeSystems.add(CasMetadataUtils.getInternalTypeSystem()); JCas cas = JCasFactory.createJCas(mergeTypeSystems(typeSystems)); SourceDocument doc = makeSourceDocument(1l, 1l); String user = "test"; sut.writeCas(doc, cas, user); JCas cas2 = sut.readCas(doc, user); List<CASMetadata> cmds = new ArrayList<>(select(cas2, CASMetadata.class)); assertThat(cmds).hasSize(1); assertThat(cmds.get(0).getProjectId()).isEqualTo(doc.getProject().getId()); assertThat(cmds.get(0).getSourceDocumentId()).isEqualTo(doc.getId()); assertThat(cmds.get(0).getLastChangedOnDisk()) .isEqualTo(sut.getCasTimestamp(doc, user).get()); }
sd.getName() + " [" + CORRECTION_USER + "]"); try { JCas correctionCas = casStorageService.readCas(sd, CORRECTION_USER, false); casDoctor.analyze(project, correctionCas.getCas(), messageSet.messages); sd.getName() + " [" + CURATION_USER + "]"); try { JCas curationCas = casStorageService.readCas(sd, CURATION_USER, false); casDoctor.analyze(project, curationCas.getCas(), messageSet.messages); sd.getName() + " [" + ad.getUser() + "]"); try { JCas userCas = casStorageService.readCas(ad.getDocument(), ad.getUser(), false); casDoctor.analyze(project, userCas.getCas(), messageSet.messages);
@Test public void testWriteReadExistsDeleteCas() throws Exception { SourceDocument doc = makeSourceDocument(1l, 1l); JCas cas = JCasFactory.createText("This is a test"); String user = "test"; sut.writeCas(doc, cas, user); assertThat(sut.getCasFile(doc, user)).exists(); assertThat(sut.existsCas(doc, user)).isTrue(); JCas cas2 = sut.readCas(doc, user); assertThat(cas2.getDocumentText()).isEqualTo(cas.getDocumentText()); sut.deleteCas(doc, user); assertThat(sut.getCasFile(doc, user)).doesNotExist(); assertThat(sut.existsCas(doc, user)).isFalse(); }
sd.getName() + " [" + CORRECTION_USER + "]"); try { JCas correctionCas = casStorageService.readCas(sd, CORRECTION_USER, false); casDoctor.analyze(project, correctionCas.getCas(), messageSet.messages); sd.getName() + " [" + CURATION_USER + "]"); try { JCas curationCas = casStorageService.readCas(sd, CURATION_USER, false); casDoctor.analyze(project, curationCas.getCas(), messageSet.messages); sd.getName() + " [" + ad.getUser() + "]"); try { JCas userCas = casStorageService.readCas(ad.getDocument(), ad.getUser(), false); casDoctor.analyze(project, userCas.getCas(), messageSet.messages);
@Test public void testReadOrCreateCas() throws Exception { SourceDocument doc = makeSourceDocument(2l, 2l); String user = "test"; JCas cas = sut.readOrCreateCas(doc, user, () -> { try { return JCasFactory.createText("This is a test"); } catch (UIMAException e) { throw new IOException(e); } }); assertThat(sut.getCasFile(doc, user)).exists(); assertThat(sut.existsCas(doc, user)).isTrue(); JCas cas2 = sut.readCas(doc, user); assertThat(cas2.getDocumentText()).isEqualTo(cas.getDocumentText()); sut.deleteCas(doc, user); assertThat(sut.getCasFile(doc, user)).doesNotExist(); assertThat(sut.existsCas(doc, user)).isFalse(); }
sd.getName() + " [" + CORRECTION_USER + "]"); try { JCas correctionCas = casStorageService.readCas(sd, CORRECTION_USER, false); casDoctor.repair(project, correctionCas.getCas(), messageSet.messages); CasPersistenceUtils.writeSerializedCas(correctionCas, sd.getName() + " [" + CURATION_USER + "]"); try { JCas curationCas = casStorageService.readCas(sd, CURATION_USER, false); casDoctor.repair(project, curationCas.getCas(), messageSet.messages); CasPersistenceUtils.writeSerializedCas(curationCas, sd.getName() + " [" + ad.getUser() + "]"); try { JCas userCas = casStorageService.readCas(ad.getDocument(), ad.getUser(), false); casDoctor.repair(project, userCas.getCas(), messageSet.messages);
sd.getName() + " [" + CORRECTION_USER + "]"); try { JCas correctionCas = casStorageService.readCas(sd, CORRECTION_USER, false); casDoctor.repair(project, correctionCas.getCas(), messageSet.messages); CasPersistenceUtils.writeSerializedCas(correctionCas, sd.getName() + " [" + CURATION_USER + "]"); try { JCas curationCas = casStorageService.readCas(sd, CURATION_USER, false); casDoctor.repair(project, curationCas.getCas(), messageSet.messages); CasPersistenceUtils.writeSerializedCas(curationCas, sd.getName() + " [" + ad.getUser() + "]"); try { JCas userCas = casStorageService.readCas(ad.getDocument(), ad.getUser(), false); casDoctor.repair(project, userCas.getCas(), messageSet.messages);
for (AnnotationDocument ann : documentService.listAllAnnotationDocuments(doc)) { try { JCas cas = casStorageService.readCas(doc, ann.getUser()); annotationService.upgradeCas(cas.getCas(), doc, ann.getUser()); casStorageService.writeCas(doc, cas, ann.getUser()); JCas cas = casStorageService.readCas(doc, CURATION_USER); annotationService.upgradeCas(cas.getCas(), doc, CURATION_USER); casStorageService.writeCas(doc, cas, CURATION_USER);
for (AnnotationDocument ann : documentService.listAllAnnotationDocuments(doc)) { try { JCas cas = casStorageService.readCas(doc, ann.getUser()); annotationService.upgradeCas(cas.getCas(), doc, ann.getUser()); casStorageService.writeCas(doc, cas, ann.getUser()); JCas cas = casStorageService.readCas(doc, CURATION_USER); annotationService.upgradeCas(cas.getCas(), doc, CURATION_USER); casStorageService.writeCas(doc, cas, CURATION_USER);