Esempio n. 1
0
  private void addJCas(List<JCas> jCases, User user, SourceDocument sourceDocument) {
    try {
      // Check if there is an annotation document entry in the database. If there is none,
      // create one.
      AnnotationDocument annotationDocument =
          repository.createOrGetAnnotationDocument(sourceDocument, user);

      // Read the CAS
      JCas jcas = repository.readAnnotationCas(annotationDocument);

      // Update the annotation document CAS
      repository.upgradeCas(jcas.getCas(), annotationDocument);

      // After creating an new CAS or upgrading the CAS, we need to save it
      repository.writeAnnotationCas(
          jcas.getCas().getJCas(), annotationDocument.getDocument(), user);

      jCases.add(jcas);
    } catch (UIMAException e) {
      error(e.getMessage() + " : " + ExceptionUtils.getRootCauseMessage(e));
    } catch (IOException e) {
      error(e.getMessage());
    }
  }