Пример #1
0
  @Override
  protected WebMarkupContainer initialiseSearchResults() {
    searchResultsPanel =
        new SearchResultListPanel(
            "searchResults", arkContextMarkup, containerForm, arkCrudContainerVO);
    searchResultsPanel.setOutputMarkupId(true);

    affectionProvider =
        new ArkDataProvider<AffectionVO, IArkDiseaseService>(iArkDiseaseService) {
          private static final long serialVersionUID = 1L;

          public int size() {
            int count = service.getAffectionCount(containerForm.getModelObject());
            return count;
          }

          public Iterator<? extends AffectionVO> iterator(int first, int count) {
            List<AffectionVO> affectionVOs =
                service.searchPageableAffections(containerForm.getModelObject(), first, count);
            return affectionVOs.iterator();
          }
        };
    affectionProvider.setModel(this.cpModel);

    dataView = searchResultsPanel.buildDataView(affectionProvider);
    dataView.setItemsPerPage(iArkCommonService.getRowsPerPage());

    AjaxPagingNavigator pageNavigator =
        new AjaxPagingNavigator("navigator", dataView) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(searchResultsPanel);
          }
        };
    resultsWmc.add(pageNavigator);

    resultsWmc.add(dataView);
    searchResultsPanel.add(resultsWmc);
    arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultsPanel);
    return arkCrudContainerVO.getSearchResultPanelContainer();
  }
Пример #2
0
  private void initCustomFieldDataListPanel() {
    cfdProvider.setCriteriaModel(
        new PropertyModel<CustomFieldDisplay>(cpModel, "customFieldGroup"));
    List<CustomField> selectedList =
        iPhenotypicService.getCustomFieldsLinkedToCustomFieldGroup(
            getModelObject().getCustomFieldGroup());
    Boolean disableEditButton = false;
    if (getModelObject().getCustomFieldGroup().getPublished()) {
      for (CustomField customField : selectedList) {
        if (customField.getCustomFieldHasData()) {
          disableEditButton = true;
          break;
        }
      }
    }

    CustomFieldDisplayListPanel cfdListPanel =
        new CustomFieldDisplayListPanel(
            "cfdListPanel", feedBackPanel, arkCrudContainerVO, disableEditButton);
    cfdListPanel.setOutputMarkupId(true);
    cfdListPanel.initialisePanel();
    dataView = cfdListPanel.buildDataView(cfdProvider);
    dataView.setItemsPerPage(iArkCommonService.getRowsPerPage());

    AjaxPagingNavigator pageNavigator =
        new AjaxPagingNavigator("cfDisplayNavigator", dataView) {

          private static final long serialVersionUID = 1L;

          @Override
          protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(arkCrudContainerVO.getWmcForCustomFieldDisplayListPanel());
          }
        };
    cfdListPanel.addOrReplace(pageNavigator);
    cfdListPanel.addOrReplace(dataView);
    arkCrudContainerVO.getWmcForCustomFieldDisplayListPanel().addOrReplace(cfdListPanel);
  }
Пример #3
0
  @Override
  public void onStepInNext(AbstractWizardForm<?> form, AjaxRequestTarget target) {
    try {
      InputStream inputStream = containerForm.getModelObject().getFileUpload().getInputStream();
      FileUpload fileUpload = containerForm.getModelObject().getFileUpload();
      String uploadType = containerForm.getModelObject().getUploadType();
      log.info("so what is the upload type =" + uploadType);

      String filename = containerForm.getModelObject().getFileUpload().getClientFileName();
      String fileFormat = filename.substring(filename.lastIndexOf('.') + 1).toUpperCase();
      char delimChar =
          containerForm.getModelObject().getUpload().getDelimiterType().getDelimiterCharacter();

      // Only allow csv, txt or xls
      if (!(fileFormat.equalsIgnoreCase("CSV")
          || fileFormat.equalsIgnoreCase("TXT")
          || fileFormat.equalsIgnoreCase("XLS"))) {
        throw new FileFormatException();
      }

      BiospecimenUploadValidator biospecimenUploadValidator =
          new BiospecimenUploadValidator(
              containerForm.getModelObject().getUpload().getStudy(),
              iArkCommonService,
              iLimsService,
              iInventoryService);

      if (uploadType.equalsIgnoreCase(Constants.UPLOAD_TYPE_FOR_LOCATION_UPLOADER)) {
        validationMessages =
            biospecimenUploadValidator.validateLocationFileFormat(containerForm.getModelObject());
      } else { // TODO : i dont see biocollection uploader, so let's kill it in the database for now
        validationMessages =
            biospecimenUploadValidator.validateSubjectFileFormat(containerForm.getModelObject());
      }
      containerForm.getModelObject().setValidationMessages(validationMessages);
      validationMessage = containerForm.getModelObject().getValidationMessagesAsString();
      addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage));

      ArkExcelWorkSheetAsGrid arkExcelWorkSheetAsGrid =
          new ArkExcelWorkSheetAsGrid(
              "gridView",
              inputStream,
              fileFormat,
              delimChar,
              fileUpload,
              iArkCommonService.getRowsPerPage());
      arkExcelWorkSheetAsGrid.setOutputMarkupId(true);
      WebMarkupContainer wizardDataGridKeyContainer =
          new WebMarkupContainer("wizardDataGridKeyContainer");
      wizardDataGridKeyContainer.setVisible(false);
      wizardDataGridKeyContainer.setOutputMarkupId(true);
      form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid);
      form.getWizardPanelFormContainer().addOrReplace(arkExcelWorkSheetAsGrid);
      form.setArkExcelWorkSheetAsGrid(arkExcelWorkSheetAsGrid);
      form.getWizardPanelFormContainer().addOrReplace(wizardDataGridKeyContainer);
      target.add(form.getWizardPanelFormContainer());

      containerForm.getModelObject().setValidationMessages(validationMessages);
      validationMessage = containerForm.getModelObject().getValidationMessagesAsString();
      addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage));

      if (validationMessage != null && validationMessage.length() > 0) {

        this.containerForm
            .getModelObject()
            .getUpload()
            .setUploadStatus(
                iArkCommonService.getUploadStatusFor(
                    au.org.theark.lims.web.Constants.UPLOAD_STATUS_OF_ERROR_IN_FILE_VALIDATION));
        this.containerForm
            .getModelObject()
            .getUpload()
            .setFilename(
                filename); // have to reset this because the container has the file name...luckily
                           // it never changes
        iArkCommonService.updateUpload(this.containerForm.getModelObject().getUpload());

        form.getNextButton().setEnabled(false);
        target.add(form.getWizardButtonContainer());
        downloadValMsgButton =
            new ArkDownloadAjaxButton(
                "downloadValMsg", "ValidationMessage", validationMessage, "txt") {

              private static final long serialVersionUID = 1L;

              @Override
              protected void onError(AjaxRequestTarget target, Form<?> form) {
                this.error("Unexpected Error: Download request could not be processed");
              }
            };
        addOrReplace(downloadValMsgButton);
        target.add(downloadValMsgButton);
      }
    } catch (IOException e) {
      validationMessage =
          "Error attempting to display the file. Please check the file and try again.";
      addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage));
      form.getNextButton().setEnabled(false);
      target.add(form.getWizardButtonContainer());
    } catch (FileFormatException ffe) {
      validationMessage =
          "Error uploading file. You can only upload files of type: CSV (comma separated values), TXT (text), or XLS (Microsoft Excel file)";
      addOrReplace(new MultiLineLabel("multiLineLabel", validationMessage));
      form.getNextButton().setEnabled(false);
      target.add(form.getWizardButtonContainer());
    }
  }