예제 #1
0
  public void addEmbargoDateSimpleForm(DSpaceObject dso, List form, int errorFlag)
      throws SQLException, WingException {

    String date = null;

    if (dso != null) {
      java.util.List<ResourcePolicy> policies =
          authorizeService.findPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);
      if (policies.size() > 0) {
        ResourcePolicy rp = policies.get(0);
        if (rp.getStartDate() != null) {
          date = DateFormatUtils.format(rp.getStartDate(), "yyyy-MM-dd");
        }
        globalReason = rp.getRpDescription();
      }
    }
    //        CheckBox privateCheckbox = form.addItem().addCheckBox("emabrgo_option");
    //        privateCheckbox.setLabel(T_item_embargoed);
    //        if(date!=null){
    //            privateCheckbox.addOption(true, CB_EMBARGOED, "");
    //        }
    //        else{
    //            privateCheckbox.addOption(false, CB_EMBARGOED, "");
    //        }

    // Date
    Text startDate = form.addItem().addText("embargo_until_date");
    startDate.setLabel(T_item_embargoed);
    if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_FORMAT_DATE) {
      startDate.addError(T_error_date_format);
    } else if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_MISSING_DATE) {
      startDate.addError(T_error_missing_date);
    }

    if (date != null) {
      startDate.setValue(date);
    }
    startDate.setHelp(T_label_date_help);
  }
예제 #2
0
  public void addAccessRadios(
      String selectedRadio, String date, List form, int errorFlag, DSpaceObject dso)
      throws WingException, SQLException {

    if (!isAdvancedFormEnabled) {
      addEmbargoDateSimpleForm(dso, form, errorFlag);
    } else {

      org.dspace.app.xmlui.wing.element.Item radiosAndDate = form.addItem();
      Radio openAccessRadios = radiosAndDate.addRadio("open_access_radios");
      openAccessRadios.setLabel(T_radios_embargo);
      if (selectedRadio != null
          && Integer.parseInt(selectedRadio) == RADIO_OPEN_ACCESS_ITEM_EMBARGOED
          && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE) {
        openAccessRadios.addOption(RADIO_OPEN_ACCESS_ITEM_VISIBLE, T_item_will_be_visible);
        openAccessRadios.addOption(true, RADIO_OPEN_ACCESS_ITEM_EMBARGOED, T_item_embargoed);
      } else {
        openAccessRadios.addOption(true, RADIO_OPEN_ACCESS_ITEM_VISIBLE, T_item_will_be_visible);
        openAccessRadios.addOption(RADIO_OPEN_ACCESS_ITEM_EMBARGOED, T_item_embargoed);
      }

      // Date
      Text startDate = radiosAndDate.addText("embargo_until_date");
      startDate.setLabel("");
      startDate.setHelp(T_label_date_help);
      if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_FORMAT_DATE) {
        startDate.addError(T_error_date_format);
      } else if (errorFlag == org.dspace.submit.step.AccessStep.STATUS_ERROR_MISSING_DATE) {
        startDate.addError(T_error_missing_date);
      }

      if (date != null && errorFlag != org.dspace.submit.step.AccessStep.STATUS_COMPLETE) {
        startDate.setValue(date);
      }
    }
  }