Example #1
0
  private void update(AjaxRequestTarget target) {
    JCas jCas = null;
    try {
      CuratorUtil.updatePanel(
          target,
          automateView,
          curationContainer,
          mergeVisualizer,
          repository,
          annotationSelectionByUsernameAndAddress,
          curationSegment,
          annotationService,
          userRepository);

      jCas = repository.readCorrectionCas(bModel.getDocument());
    } catch (UIMAException e) {
      error(ExceptionUtils.getRootCauseMessage(e));
    } catch (ClassNotFoundException e) {
      error(e.getMessage());
    } catch (IOException e) {
      error(e.getMessage());
    } catch (BratAnnotationException e) {
      error(e.getMessage());
    }

    gotoPageTextField.setModelObject(getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1);
    gotoPageAddress = getSentenceAddress(jCas, gotoPageTextField.getModelObject());

    target.add(gotoPageTextField);
    target.add(automateView);
    target.add(numberOfPages);
  }
  /**
   * Fetches the CAS that the user will be able to edit. In AUTOMATION/CORRECTION mode, this is the
   * CAS for the CORRECTION_USER and in CURATION mode it is the CAS for the CURATION user.
   *
   * @param aBratAnnotatorModel the model.
   * @param aDocument the source document.
   * @param jCases the JCases.
   * @param randomAnnotationDocument an annotation document.
   * @return the JCas.
   * @throws UIMAException hum?
   * @throws ClassNotFoundException hum?
   * @throws IOException if an I/O error occurs.
   * @throws BratAnnotationException hum?
   */
  public JCas getMergeCas(
      BratAnnotatorModel aBratAnnotatorModel,
      SourceDocument aDocument,
      Map<String, JCas> jCases,
      AnnotationDocument randomAnnotationDocument)
      throws UIMAException, ClassNotFoundException, IOException, BratAnnotationException {
    JCas mergeJCas = null;
    try {
      if (aBratAnnotatorModel.getMode().equals(Mode.AUTOMATION)
          || aBratAnnotatorModel.getMode().equals(Mode.CORRECTION)) {
        // 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, aBratAnnotatorModel.getMode(),
        // aBratAnnotatorModel.getUser().getUsername());
        mergeJCas = repository.readCorrectionCas(aDocument);
      } else {
        // 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, aBratAnnotatorModel.getMode(),
        // aBratAnnotatorModel.getUser().getUsername());
        mergeJCas = repository.readCurationCas(aDocument);
      }
    }
    // Create jcas, if it could not be loaded from the file system
    catch (Exception e) {

      if (aBratAnnotatorModel.getMode().equals(Mode.AUTOMATION)
          || aBratAnnotatorModel.getMode().equals(Mode.CORRECTION)) {
        mergeJCas = createCorrectionCas(mergeJCas, aBratAnnotatorModel, randomAnnotationDocument);
      } else {
        mergeJCas =
            createCurationCas(
                aBratAnnotatorModel.getProject(),
                randomAnnotationDocument,
                jCases,
                aBratAnnotatorModel.getAnnotationLayers());
      }
    }
    return mergeJCas;
  }