示例#1
0
  @Override
  protected void onSearch(AjaxRequestTarget target) {
    target.add(feedbackPanel);

    // Set study in context
    Long studyId =
        (Long)
            SecurityUtils.getSubject()
                .getSession()
                .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
    // Get a list of all Fields for the Study in context
    Study study = iArkCommonService.getStudy(studyId);

    Upload searchUpload = getModelObject().getUpload();
    searchUpload.setStudy(study);
    searchUpload.setArkFunction(
        iArkCommonService.getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY));

    Collection<Upload> uploadCollection = iArkCommonService.searchUploads(searchUpload);

    if (uploadCollection != null && uploadCollection.size() == 0) {
      this.info("Uploads with the specified criteria does not exist in the system.");
      target.add(feedbackPanel);
    }

    getModelObject().setUploadCollection(uploadCollection);

    listView.removeAll();
    arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true);
    target.add(arkCrudContainerVO.getSearchResultPanelContainer());
  }
  public AffectionContainerPanel(String id, WebMarkupContainer arkContextMarkup) {
    super(id);
    this.arkContextMarkup = arkContextMarkup;

    cpModel = new CompoundPropertyModel<AffectionVO>(new AffectionVO());

    sessionStudyID =
        (Long) SecurityUtils.getSubject().getSession().getAttribute(Constants.STUDY_CONTEXT_ID);
    if (sessionStudyID != null) {
      study = iArkCommonService.getStudy(sessionStudyID);
    }

    Long subjectSessionID =
        (Long) SecurityUtils.getSubject().getSession().getAttribute(Constants.PERSON_CONTEXT_ID);
    try {
      linkSubjectStudy = iArkCommonService.getSubject(subjectSessionID, study);
    } catch (EntityNotFoundException e) {
      e.printStackTrace();
    }

    containerForm = new ContainerForm("containerForm", cpModel);
    containerForm.add(initialiseFeedBackPanel());
    containerForm.add(initialiseDetailPanel());
    containerForm.add(initialiseSearchResults());
    containerForm.add(initialiseSearchPanel());

    add(containerForm);
  }
示例#3
0
  /*
   * (non-Javadoc)
   *
   * @see au.org.theark.core.web.form.AbstractDetailForm#onSave(org.apache.wicket.markup.html.form.Form, org.apache.wicket.ajax.AjaxRequestTarget)
   */
  @Override
  protected void onSave(Form<CustomFieldGroupVO> containerForm, AjaxRequestTarget target) {
    if (getModelObject().getCustomFieldGroup().getId() == null) {
      // Create
      ArkFunction arkFunction =
          iArkCommonService.getArkFunctionByName(
              au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION);
      Long studyId =
          (Long)
              SecurityUtils.getSubject()
                  .getSession()
                  .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
      Study study = iArkCommonService.getStudy(studyId);
      getModelObject().getCustomFieldGroup().setArkFunction(arkFunction);
      getModelObject().getCustomFieldGroup().setStudy(study);

      try {
        iPhenotypicService.createCustomFieldGroup(getModelObject());
        initCustomFieldDataListPanel();
        this.info("Data Set has been created successfully.");
      } catch (EntityExistsException e) {
        this.error("A Data Set with the same name already exisits. Please choose a unique one.");
      } catch (ArkSystemException e) {
        this.error("A System error occured. Please contact Administrator.");
      }
    } else {

      try {
        iPhenotypicService.updateCustomFieldGroup(getModelObject());
        initCustomFieldDataListPanel();
        this.info("Data Set has been updated successfully.");

      } catch (EntityExistsException e) {
        this.error("A Data Set with the same name already exisits. Please choose a unique one.");
        e.printStackTrace();
      } catch (ArkSystemException e) {
        this.error("A System error occured. Please contact Administrator.");
        e.printStackTrace();
      }
    }
    target.add(
        arkCrudContainerVO
            .getWmcForCustomFieldDisplayListPanel()); // Repaint this List of Custom Field Displays
    onSavePostProcess(target); // Post process
  }
示例#4
0
  public void buildTabs(final WebMarkupContainer arkContextMarkup) {
    ArkModule arkModule =
        iArkCommonService.getArkModuleByName(au.org.theark.core.Constants.ARK_MODULE_PHENOTYPIC);
    List<ArkFunction> arkFunctionList = iArkCommonService.getModuleFunction(arkModule);
    for (final ArkFunction menuArkFunction : arkFunctionList) {
      AbstractTab tab =
          new AbstractTab(new StringResourceModel(menuArkFunction.getResourceKey(), this, null)) {
            @Override
            public Panel getPanel(final String panelId) {
              return panelToReturn(menuArkFunction, panelId);
            }
          };
      moduleSubTabsList.add(tab);
    }

    ArkAjaxTabbedPanel moduleTabbedPanel =
        new ArkAjaxTabbedPanel(Constants.PHENOTYPIC_SUBMENU, moduleSubTabsList);
    add(moduleTabbedPanel);
  }
示例#5
0
  @SuppressWarnings("unchecked")
  private void setSelectedCustomFieldsFromFile() {
    if (fileUploadField.getFileUpload() != null) {
      ArkFunction arkFunction =
          iArkCommonService.getArkFunctionByName(
              au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION);
      Long studyId =
          (Long)
              SecurityUtils.getSubject()
                  .getSession()
                  .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
      Study study = iArkCommonService.getStudy(studyId);
      ArrayList<CustomField> selectedCustomFields =
          (ArrayList<CustomField>)
              iArkCommonService.matchCustomFieldsFromInputFile(
                  fileUploadField.getFileUpload(), study, arkFunction);
      cpModel.getObject().setSelectedCustomFields(selectedCustomFields);
    }

    initCustomFieldPalette();
    arkCrudContainerVO.getDetailPanelFormContainer().addOrReplace(customFieldPalette);
  }
示例#6
0
  /** @param id */
  public SubjectSubMenuTab(String id, WebMarkupContainer arkContextMarkup) {
    super(id);
    this.arkContextMarkup = arkContextMarkup;
    new ArrayList<ITab>();
    buildTabs();

    Long sessionStudyId =
        (Long)
            SecurityUtils.getSubject()
                .getSession()
                .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
    Study study = iArkCommonService.getStudy(sessionStudyId);
    childStudy = study.getParentStudy() != null && (study != study.getParentStudy());
  }
示例#7
0
  public void initialiseDetailForm() {
    phoneIdTxtFld = new TextField<String>("phoneVo.phone.id");
    areaCodeTxtFld = new TextField<String>("phoneVo.phone.areaCode");
    phoneNumberTxtFld = new TextField<String>("phoneVo.phone.phoneNumber");

    source = new TextField<String>("phoneVo.phone.source");
    commentsTxtArea = new TextArea<String>("phoneVo.phone.comment");

    dateReceivedDp =
        new DateTextField("phoneVo.phone.dateReceived", au.org.theark.core.Constants.DD_MM_YYYY);
    ArkDatePicker datePicker = new ArkDatePicker();
    datePicker.bind(dateReceivedDp);
    dateReceivedDp.add(datePicker);

    List<PhoneStatus> phoneStatusSourceList = iArkCommonService.getPhoneStatus();
    ChoiceRenderer<PhoneStatus> phoneStatusRenderer =
        new ChoiceRenderer<PhoneStatus>(Constants.NAME, Constants.ID);
    phoneStatusChoice =
        new DropDownChoice<PhoneStatus>(
            "phoneVo.phone.phoneStatus", phoneStatusSourceList, phoneStatusRenderer);

    List<YesNo> yesNoListSource = iArkCommonService.getYesNoList();
    ChoiceRenderer<YesNo> yesNoRenderer = new ChoiceRenderer<YesNo>(Constants.NAME, Constants.ID);
    silentModeChoice =
        new DropDownChoice<YesNo>("phoneVo.phone.silentMode", yesNoListSource, yesNoRenderer);

    List<PhoneType> phoneTypeList = iArkCommonService.getListOfPhoneType();
    ChoiceRenderer<PhoneType> defaultChoiceRenderer =
        new ChoiceRenderer<PhoneType>(Constants.NAME, Constants.ID);
    phoneTypeChoice =
        new DropDownChoice<PhoneType>(
            "phoneVo.phone.phoneType", phoneTypeList, defaultChoiceRenderer);
    phoneTypeChoice.add(new ArkDefaultFormFocusBehavior());
    addDetailFormComponents();
    attachValidators();
  }
  protected boolean prerenderContextCheck() {
    Long sessionPersonId =
        (Long)
            SecurityUtils.getSubject()
                .getSession()
                .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);
    Long sessionStudyId =
        (Long)
            SecurityUtils.getSubject()
                .getSession()
                .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);

    boolean contextLoaded = false;
    if ((sessionStudyId != null) && (sessionPersonId != null)) {
      String sessionPersonType =
          (String)
              SecurityUtils.getSubject()
                  .getSession()
                  .getAttribute(au.org.theark.core.Constants.PERSON_TYPE);

      if (sessionPersonType.equals(au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT)) {
        LinkSubjectStudy lss;
        try {
          Study study = iArkCommonService.getStudy(sessionStudyId);
          lss = iArkCommonService.getSubject(sessionPersonId, study);
          contextLoaded = true;
        } catch (EntityNotFoundException e) {
          log.error(e.getMessage());
        }
        if (contextLoaded) {
          arkCrudContainerVO.getDetailPanelContainer().setVisible(true);
        }
      }
    }
    return contextLoaded;
  }
示例#9
0
 @SuppressWarnings("unchecked")
 private void initDropDownChoice() {
   // Initialise any drop-downs
   java.util.Collection<FileFormat> fileFormatCollection = iArkCommonService.getFileFormats();
   CompoundPropertyModel<CustomFieldUploadVO> uploadCpm = cpmModel;
   PropertyModel<Upload> uploadPm = new PropertyModel<Upload>(uploadCpm, Constants.UPLOAD);
   PropertyModel<FileFormat> fileFormatPm =
       new PropertyModel<FileFormat>(uploadPm, Constants.FILE_FORMAT);
   ChoiceRenderer fileFormatRenderer =
       new ChoiceRenderer(Constants.FILE_FORMAT_NAME, Constants.FILE_FORMAT_ID);
   fileFormatDdc =
       new DropDownChoice<FileFormat>(
           Constants.UPLOADVO_UPLOAD_FILE_FORMAT,
           fileFormatPm,
           (List) fileFormatCollection,
           fileFormatRenderer);
 }
  @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();
  }
示例#11
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);
  }
示例#12
0
  /*
   * (non-Javadoc)
   *
   * @see au.org.theark.core.web.form.AbstractDetailForm#onSave(org.apache.wicket.markup.html.form.Form, org.apache.wicket.ajax.AjaxRequestTarget)
   */
  @Override
  protected void onSave(Form<ContactVO> containerForm, AjaxRequestTarget target) {
    // Persist the phone number to the backend, associate the person in context with the phone
    // object
    Long personSessionId =
        (Long)
            SecurityUtils.getSubject()
                .getSession()
                .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);
    // Get the person and set it on the Phone object.
    try {
      boolean saveOk = true;
      Person person = studyService.getPerson(personSessionId);
      containerForm.getModelObject().getPhoneVo().getPhone().setPerson(person);

      /*
      // Make the area code mandatory only for landline phone (home/work) entries
      String phType = containerForm.getModelObject().getPhone().getPhoneType().getName().toLowerCase();

      if (!phType.equals("mobile")) {
      	// must be landline
      	if (containerForm.getModelObject().getPhone().getAreaCode() == null || containerForm.getModelObject().getPhone().getAreaCode().length() < 1) {
      		this.error("An area code must be entered for landline numbers");
      		saveOk = false;
      	}
      }
      */
      if (saveOk) {
        // Ok to save...
        String personType =
            (String)
                SecurityUtils.getSubject()
                    .getSession()
                    .getAttribute(au.org.theark.core.Constants.PERSON_TYPE);

        if (personType != null
            && personType.equalsIgnoreCase(
                au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT)) {
          Long studyId =
              (Long)
                  SecurityUtils.getSubject()
                      .getSession()
                      .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
          Study study = iArkCommonService.getStudy(studyId);
          LinkSubjectStudy subjectInContext =
              iArkCommonService.getSubject(
                  personSessionId, study); // This is fetched basically to display the
          // info
          // message along with the Subject UID or Contact ID
          if (containerForm.getModelObject().getPhoneVo().getPhone().getId() == null) {
            studyService.create(containerForm.getModelObject().getPhoneVo().getPhone());
            this.info(
                "Phone number was added and linked to Subject UID: "
                    + subjectInContext.getSubjectUID());
          } else {
            studyService.update(containerForm.getModelObject().getPhoneVo().getPhone());
            this.info(
                "Phone number was updated and linked to Subject UID: "
                    + subjectInContext.getSubjectUID());
          }
        } else if (personType != null
            && personType.equalsIgnoreCase(
                au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_CONTACT)) {
          // TODO: Contact Interface implementation
        }

        processErrors(target);
        onSavePostProcess(target);
      } else {

        processErrors(target);
      }
    } catch (ArkUniqueException aue) {
      this.error(aue.getMessage());
    } catch (EntityNotFoundException e) {
      this.error("The Subject/Participant is not available in the system anymore");
    } catch (ArkSystemException e) {
      this.error("A System Exception has occured please contact Support.");
    }
  }
示例#13
0
  public VelocityContext getBioCollectionLabelContext(BioCollection bioCollection) {
    VelocityContext velocityContext = new VelocityContext();
    LinkSubjectStudy linkSubjectStudy = null;
    try {
      linkSubjectStudy =
          iArkCommonService.getSubjectByUID(
              bioCollection.getLinkSubjectStudy().getSubjectUID(), bioCollection.getStudy());
    } catch (EntityNotFoundException e) {
      log.error(e.getMessage());
    }

    try {
      bioCollection = iBioCollectionDao.getBioCollection(bioCollection.getId());
    } catch (EntityNotFoundException e) {
      log.error(e.getMessage());
    }

    String subjectUid = linkSubjectStudy.getSubjectUID();

    // ArkFunction arkFunction =
    // iArkCommonService.getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_LIMS_COLLECTION);
    ArkFunction arkFunction =
        iArkCommonService.getArkFunctionByName(
            au.org.theark.core.Constants.FUNCTION_KEY_VALUE_LIMS_CUSTOM_FIELD);

    // Custom field name "FAMILYID"
    BioCollectionCustomFieldData bioCollectionCustomFieldData =
        iBioCollectionDao.getBioCollectionCustomFieldData(bioCollection, arkFunction, "FAMILYID");
    String familyId = bioCollectionCustomFieldData.getTextDataValue();

    // Custom field name "ASRBNO"
    bioCollectionCustomFieldData =
        iBioCollectionDao.getBioCollectionCustomFieldData(bioCollection, arkFunction, "ASRBNO");
    String asrbno = bioCollectionCustomFieldData.getTextDataValue();

    String collectionDate = new String();
    if (bioCollection.getCollectionDate() != null) {
      collectionDate = simpleDateFormat.format(bioCollection.getCollectionDate());
    }
    String refDoctor = new String();
    if (bioCollection.getRefDoctor() != null) {
      refDoctor = bioCollection.getRefDoctor();
    }
    String dateOfBirth = new String();
    if (bioCollection.getLinkSubjectStudy().getPerson().getDateOfBirth() != null) {
      dateOfBirth =
          simpleDateFormat.format(bioCollection.getLinkSubjectStudy().getPerson().getDateOfBirth());
    }
    String sex = new String();
    if (bioCollection.getLinkSubjectStudy().getPerson().getGenderType() != null) {
      sex = bioCollection.getLinkSubjectStudy().getPerson().getGenderType().getName();
    }
    String collectionID = bioCollection.getBiocollectionUid();
    String subjectFirstName = linkSubjectStudy.getPerson().getFirstName();
    String subjectLastName = linkSubjectStudy.getPerson().getLastName();
    String initials = subjectFirstName.charAt(0) + "" + subjectLastName.charAt(0);

    velocityContext.put("initials", initials);
    velocityContext.put("firstName", subjectFirstName);
    velocityContext.put("lastName", subjectLastName);
    velocityContext.put("collectionID", collectionID);
    velocityContext.put("subjectUid", subjectUid);
    velocityContext.put("familyId", familyId);
    velocityContext.put("asrbno", asrbno);
    velocityContext.put("collectionDate", collectionDate);
    velocityContext.put("refDoctor", refDoctor);
    velocityContext.put("dateOfBirth", dateOfBirth);
    velocityContext.put("sex", sex);

    return velocityContext;
  }
示例#14
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());
    }
  }
示例#15
0
  @SuppressWarnings({"serial", "unchecked"})
  public void buildTabs() {

    List<ITab> moduleSubTabsList = new ArrayList<ITab>();

    ArkModule arkModule = iArkCommonService.getArkModuleByName(Constants.ARK_MODULE_SUBJECT);
    List<ArkFunction> arkFunctionList =
        iArkCommonService.getModuleFunction(
            arkModule); // Gets a list of ArkFunctions for the given Module

    for (final ArkFunction menuArkFunction : arkFunctionList) {

      moduleSubTabsList.add(
          new AbstractTab(new StringResourceModel(menuArkFunction.getResourceKey(), this, null)) {
            @Override
            public Panel getPanel(String panelId) {
              Panel panelToReturn = null; // Set
              if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn =
                    new SubjectContainerPanel(
                        panelId, arkContextMarkup, null, null); // Note the constructor
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHONE)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn = new PhoneContainerPanel(panelId);
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_ADDRESS)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn = new AddressContainerPanel(panelId);
              }
              // Add contact panel
              else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_CONTACT)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn = new ContactContainerPanel(panelId);
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_CONSENT)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn = new ConsentContainerPanel(panelId);
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_ATTACHMENT)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn = new AttachmentsContainerPanel(panelId);
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(
                      au.org.theark.core.Constants.FUNCTION_KEY_VALUE_STUDY_STUDY_DATA_UPLOAD)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn = new SubjectUploadContainerPanel(panelId, menuArkFunction);
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(
                      au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CORRESPONDENCE)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn = new CorrespondenceContainerPanel(panelId);
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(
                      au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                // useCustomFieldDisplay = true
                panelToReturn =
                    new CustomFieldContainerPanel(
                        panelId,
                        true,
                        iArkCommonService.getArkFunctionByName(
                            au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD));
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(
                      au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_DATA)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn = new SubjectCustomDataContainerPanel(panelId).initialisePanel();
              } else if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(
                      au.org.theark.core.Constants
                          .FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD_UPLOAD)) {
                processAuthorizationCache(
                    au.org.theark.core.Constants.ARK_MODULE_SUBJECT, menuArkFunction);
                panelToReturn =
                    new CustomFieldUploadContainerPanel(
                        panelId,
                        iArkCommonService.getArkFunctionByName(
                            au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT));
              }
              return panelToReturn;
            }

            @Override
            public boolean isVisible() {
              // Subject Upload only visible to parent studies
              if (menuArkFunction
                  .getName()
                  .equalsIgnoreCase(
                      au.org.theark.core.Constants.FUNCTION_KEY_VALUE_STUDY_STUDY_DATA_UPLOAD)) {
                return (!childStudy);
              }
              return true;
            }
          });
    }

    ArkAjaxTabbedPanel moduleTabbedPanel =
        new ArkAjaxTabbedPanel(Constants.MENU_SUBJECT_SUBMENU, moduleSubTabsList);
    add(moduleTabbedPanel);
  }
示例#16
0
  /**
   * @param iModel
   * @return the pageableListView of Upload
   */
  @SuppressWarnings("unchecked")
  public PageableListView<Upload> buildPageableListView(IModel iModel) {
    PageableListView<Upload> sitePageableListView =
        new PageableListView<Upload>(
            Constants.RESULT_LIST,
            iModel,
            iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) {

          private static final long serialVersionUID = 1L;

          @Override
          protected void populateItem(final ListItem<Upload> item) {
            Upload upload = item.getModelObject();

            // The ID
            if (upload.getId() != null) {
              // Add the id component here
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_ID,
                      upload.getId().toString()));
            } else {
              item.add(new Label(au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_ID, ""));
            }

            // / The filename
            if (upload.getFilename() != null) {
              // Add the id component here
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FILENAME,
                      upload.getFilename()));
            } else {
              item.add(
                  new Label(au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FILENAME, ""));
            }

            // File Format
            if (upload.getFileFormat() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FILE_FORMAT,
                      upload.getFileFormat().getName()));
            } else {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FILE_FORMAT, ""));
            }

            // UserId
            if (upload.getUserId() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_USER_ID,
                      upload.getUserId()));
            } else {
              item.add(
                  new Label(au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_USER_ID, ""));
            }

            // Start time
            if (upload.getStartTime() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_START_TIME,
                      upload.getStartTime().toString()));
            } else {
              item.add(
                  new Label(au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_START_TIME, ""));
            }

            // Finish time
            if (upload.getFinishTime() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FINISH_TIME,
                      upload.getFinishTime().toString()));
            } else {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_FINISH_TIME, ""));
            }
            if (upload.getUploadStatus() != null
                && upload.getUploadStatus().getShortMessage() != null) {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME,
                      upload.getUploadStatus().getShortMessage()));
            } else {
              item.add(
                  new Label(
                      au.org.theark.phenotypic.web.Constants.UPLOADVO_UPLOAD_UPLOAD_STATUS_NAME,
                      ""));
            }

            // Download file link button
            item.add(buildDownloadButton(upload));

            // Download upload report button
            item.add(buildDownloadReportButton(upload));

            item.add(buildDeleteUploadButton(upload));
            // Delete the upload file
            // item.add(buildDeleteButton(upload));

            // For the alternative stripes
            item.add(
                new AttributeModifier(
                    "class",
                    new AbstractReadOnlyModel<String>() {

                      private static final long serialVersionUID = 1L;

                      @Override
                      public String getObject() {
                        return (item.getIndex() % 2 == 1) ? "even" : "odd";
                      }
                    }));
          }
        };
    return sitePageableListView;
  }
示例#17
0
  public StringBuffer uploadAndReportCustomDataFile(
      InputStream inputStream,
      long size,
      String fileFormat,
      char delimChar,
      List<String> listOfUIDsToUpdate,
      CustomFieldGroup customFieldGroup,
      PhenoCollection phenoCollection,
      boolean overwriteExisting)
      throws FileFormatException, ArkSystemException {
    List<PhenoCollection> phenoCollectionsWithTheirDataToInsert = new ArrayList<PhenoCollection>();

    delimiterCharacter = delimChar;
    uploadReport = new StringBuffer();

    InputStream convertedInputStream;
    if (fileFormat.equalsIgnoreCase(Constants.FileFormat.XLS.toString())) {
      XLStoCSV xlsToCSV = new XLStoCSV(delimiterCharacter);
      convertedInputStream = xlsToCSV.convertXlsInputStreamToCsv(inputStream);
    } else {
      convertedInputStream = inputStream;
    }

    InputStreamReader inputStreamReader = null;
    CsvReader csvReader = null;
    DecimalFormat decimalFormat = new DecimalFormat("0.00");

    int subjectCount = 0;
    long updateFieldsCount = 0L;
    long insertFieldsCount = 0L;
    long emptyDataCount = 0L;
    try {
      inputStreamReader = new InputStreamReader(convertedInputStream);
      csvReader = new CsvReader(inputStreamReader, delimiterCharacter);
      String[] stringLineArray;

      List<LinkSubjectStudy> allSubjectWhichWillBeUpdated = null;
      if (listOfUIDsToUpdate.size() > 0) {
        allSubjectWhichWillBeUpdated =
            iArkCommonService.getUniqueSubjectsWithTheseUIDs(study, listOfUIDsToUpdate);
      } else {
        allSubjectWhichWillBeUpdated = new ArrayList<LinkSubjectStudy>();
      }
      if (size <= 0) {
        uploadReport.append(
            "ERROR:  The input size was not greater than 0. Actual length reported: ");
        uploadReport.append(size);
        uploadReport.append("\n");
        throw new FileFormatException(
            "The input size was not greater than 0. Actual length reported: " + size);
      }

      csvReader.readHeaders();

      List<String> fieldNameCollection = Arrays.asList(csvReader.getHeaders());
      ArkFunction phenoCustomFieldArkFunction =
          iArkCommonService.getArkFunctionByName(
              Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION); // ");

      List<CustomFieldDisplay> cfdsThatWeNeed =
          iArkCommonService.getCustomFieldDisplaysIn(
              fieldNameCollection, study, phenoCustomFieldArkFunction, customFieldGroup);

      // Paul has requested - in pheno we only insert List<PhenoData> dataThatWeHave =
      // iArkCommonService.getCustomFieldDataFor(cfdsThatWeNeed, allSubjectWhichWillBeUpdated);
      // read one line which contains potentially many custom fields
      QuestionnaireStatus uploadingStatus =
          iPhenotypicService.getPhenoCollectionStatusByName(
              Constants.PHENO_COLLECTION_STATUS_UPLOADED);

      while (csvReader.readRecord()) {
        List<PhenoData> phenoDataToInsertForThisPhenoCollection = new ArrayList<PhenoData>();
        log.info("reading record " + subjectCount);
        stringLineArray = csvReader.getValues();
        String subjectUID = stringLineArray[0];
        String recordDate = stringLineArray[1];
        Date recordDate_asDate =
            (recordDate.isEmpty() ? new Date() : simpleDateFormat.parse(recordDate));
        LinkSubjectStudy subject =
            getSubjectByUIDFromExistList(allSubjectWhichWillBeUpdated, subjectUID);
        // log.info("get subject from list");
        CustomField customField = null;
        List<PhenoCollection> subjectExistingMatchingPhenoCollections =
            iPhenotypicService.getSubjectMatchingPhenoCollections(
                subject, customFieldGroup, recordDate_asDate);
        PhenoCollection phenoCollectionIntoDB = new PhenoCollection();
        if (subjectExistingMatchingPhenoCollections.size() == 0 || !overwriteExisting) {
          phenoCollectionIntoDB.setDescription(phenoCollection.getDescription());
          phenoCollectionIntoDB.setLinkSubjectStudy(subject);
          //				phenoCollectionIntoDB.setName(phenoCollection.getName());
          phenoCollectionIntoDB.setQuestionnaire(customFieldGroup);
          if (recordDate.isEmpty()) {
            phenoCollectionIntoDB.setRecordDate(new Date());
          } else {
            phenoCollectionIntoDB.setRecordDate(recordDate_asDate);
          }
          phenoCollectionIntoDB.setStatus(
              uploadingStatus); // TODO for this to be UPLOADED TYPE STATUS
        } else {
          if (subjectExistingMatchingPhenoCollections.size() == 1) {
            recordDate_asDate =
                (recordDate.isEmpty() ? new Date() : simpleDateFormat.parse(recordDate));
            phenoCollectionIntoDB = subjectExistingMatchingPhenoCollections.get(0);
          } else {
            subjectCount++;
            continue;
          }
        }

        for (CustomFieldDisplay cfd : cfdsThatWeNeed) {

          String theDataAsString = null;
          customField = cfd.getCustomField();

          if (csvReader.getIndex(cfd.getCustomField().getName()) < 0) {
            for (String nameAsSeenInFile : fieldNameCollection) {
              if (nameAsSeenInFile.equalsIgnoreCase(cfd.getCustomField().getName())) {
                theDataAsString = csvReader.get(nameAsSeenInFile);
              }
            }
          } else {
            theDataAsString = csvReader.get(cfd.getCustomField().getName());
          }

          if (theDataAsString != null && !theDataAsString.isEmpty()) {
            PhenoData dataToInsert = new PhenoData();
            dataToInsert.setCustomFieldDisplay(cfd);
            // as much as i disagree...pheno data isn't tied to subject....pheno collection is
            // dataToInsert.setLinkSubjectStudy(subject);
            setValue(customField, cfd, dataToInsert, theDataAsString);
            boolean flag = true;
            for (PhenoData phenoData : phenoCollectionIntoDB.getPhenoData()) {
              if (phenoData.getCustomFieldDisplay().getId() == cfd.getId()) {
                phenoData.setDateDataValue(dataToInsert.getDateDataValue());
                phenoData.setErrorDataValue(dataToInsert.getErrorDataValue());
                phenoData.setNumberDataValue(dataToInsert.getNumberDataValue());
                phenoData.setTextDataValue(dataToInsert.getTextDataValue());
                flag = false;
                break;
              }
            }
            if (flag) {
              phenoDataToInsertForThisPhenoCollection.add(dataToInsert);
            }
            insertFieldsCount++;
          } else {
            emptyDataCount++;
          }
        }
        phenoCollectionIntoDB.getPhenoData().addAll(phenoDataToInsertForThisPhenoCollection);
        log.info(phenoCollectionIntoDB.toString());
        phenoCollectionsWithTheirDataToInsert.add(phenoCollectionIntoDB);
        subjectCount++;
      }
      log.info(
          "finished message for "
              + subjectCount
              + "\n      DATA inserts = "
              + insertFieldsCount
              + "  phenocollections = "
              + phenoCollectionsWithTheirDataToInsert.size()
              + "  amount of empty scells ="
              + emptyDataCount);
    } catch (IOException ioe) {
      uploadReport.append(
          "SYSTEM ERROR:   Unexpected I/O exception whilst reading the subject data file\n");
      log.error("processMatrixSubjectFile IOException stacktrace:", ioe);
      throw new ArkSystemException("Unexpected I/O exception whilst reading the subject data file");
    } catch (Exception ex) {
      uploadReport.append(
          "SYSTEM ERROR:   Unexpected exception whilst reading the subject data file\n");
      log.error("processMatrixSubjectFile Exception stacktrace:", ex);
      throw new ArkSystemException(
          "Unexpected exception occurred when trying to process subject data file");
    } finally {
      uploadReport.append("Total file size: ");
      uploadReport.append(decimalFormat.format(size / 1024.0 / 1024.0));
      uploadReport.append(" MB");
      uploadReport.append("\n");

      if (csvReader != null) {
        try {
          csvReader.close();
        } catch (Exception ex) {
          log.error("Cleanup operation failed: csvRdr.close()", ex);
        }
      }
      if (inputStreamReader != null) {
        try {
          inputStreamReader.close();
        } catch (Exception ex) {
          log.error("Cleanup operation failed: isr.close()", ex);
        }
      }
    }
    uploadReport.append("Processed ");
    uploadReport.append(subjectCount);
    uploadReport.append(" rows.");
    uploadReport.append("\n");
    uploadReport.append("Inserted ");
    uploadReport.append(insertFieldsCount);
    uploadReport.append(" rows of data.");
    uploadReport.append("\n");
    uploadReport.append("Updated ");
    uploadReport.append(updateFieldsCount);
    uploadReport.append(" rows of data.");
    uploadReport.append("\n");

    // TODO better exceptionhandling
    iPhenotypicService.processPhenoCollectionsWithTheirDataToInsertBatch(
        phenoCollectionsWithTheirDataToInsert, study);
    return uploadReport;
  }