Example #1
0
  private WizardStepPanel setupWizardFlow() {
    // get the consent mode variable value
    EnumSet<ConsentMode> supportedConsentMode = consentService.getSupportedConsentModes();
    List<Locale> supportedConsentLocale = consentService.getSupportedConsentLocales();
    WizardStepPanel startStep;

    if (supportedConsentMode.containsAll(EnumSet.allOf(ConsentMode.class))
        || supportedConsentMode.contains(ConsentMode.MANUAL) && supportedConsentLocale.size() > 1) {
      startStep = consentModeSelectionStep;
      startStep.setPreviousStep(startStep);
      electronicConsentStep.setPreviousStep(startStep);
    } else {
      consentConfirmationStep.setPreviousStep(null);
      startStep = consentConfirmationStep;
    }

    return startStep;
  }
Example #2
0
  public void onFinish(AjaxRequestTarget target, Form form) {
    Boolean consentIsSubmitted = activeConsentService.isConsentFormSubmitted();
    Boolean consentIsAccepted = activeConsentService.getConsent().isAccepted();
    Boolean consentIsElectronic =
        activeConsentService.getConsent().getMode() == ConsentMode.ELECTRONIC ? true : false;

    // Consent not submitted, inform the user that the submit button (PDF form) has to be clicked.
    if (!consentIsSubmitted) {
      error(getString("MissingConsentForm"));
      onError(target, form);

      // Invalid electronic consent.
    } else if (consentIsAccepted
        && consentIsElectronic
        && !activeConsentService.validateElectronicConsent()) {
      error(getString("InvalidConsentForm"));
      getElectronicConsentStep().setNextStep(null);
      gotoNext(target);
      this.changeWizardFormStyle("wizard-consent");
      onError(target, form);

      // Valid electronic consent, refused electronic consent, or manual consent.
    } else {
      IStageExecution exec =
          activeInterviewService.getStageExecution((Stage) stageModel.getObject());
      ActionDefinition actionDef = exec.getSystemActionDefinition(ActionType.COMPLETE);

      // Delete previous consent (if exist) for that interview
      Consent existingConsent = consentService.getConsent(activeInterviewService.getInterview());
      if (existingConsent != null) {
        consentService.deletePreviousConsent(activeInterviewService.getInterview());
      }

      // Save the consent
      consentService.saveConsent(activeConsentService.getConsent());

      if (actionDef != null) {
        getActionWindow().show(target, stageModel, actionDef);
      }
    }

    target.appendJavascript("Resizer.resizeWizard();");
    target.appendJavascript("Resizer.resizeConsentFrame();");
  }