Пример #1
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
  }