Exemplo n.º 1
0
  @Override
  protected void fillVoiceXmlDocument(
      Document document, Element formElement, VoiceXmlDialogueContext dialogueContext)
      throws VoiceXmlDocumentRenderingException {

    List<String> submitNameList = new ArrayList<String>();
    VariableList submitVariableList = mSubmitParameters;
    if (submitVariableList != null) {
      addVariables(formElement, submitVariableList);

      for (Entry<String, String> entry : mSubmitParameters) {
        submitNameList.add(entry.getKey());
      }
    }

    Element subdialogueElement = DomUtils.appendNewElement(formElement, SUBDIALOG_ELEMENT);
    subdialogueElement.setAttribute(NAME_ATTRIBUTE, SUBDIALOGUE_FORM_ITEM_NAME);
    subdialogueElement.setAttribute(SRC_ATTRIBUTE, mUri);

    if (!submitNameList.isEmpty()) {
      subdialogueElement.setAttribute(NAME_LIST_ATTRIBUTE, StringUtils.join(submitNameList, " "));
    }

    for (Parameter parameter : mParameters) {
      Element paramElement = DomUtils.appendNewElement(subdialogueElement, PARAM_ELEMENT);
      paramElement.setAttribute(NAME_ATTRIBUTE, parameter.getName());
      setAttribute(paramElement, VALUE_ATTRIBUTE, parameter.getValue());
      setAttribute(paramElement, EXPR_ATTRIBUTE, parameter.getExpression());
    }

    SubmitMethod submitMethod = mMethod;
    if (submitMethod != null) {
      subdialogueElement.setAttribute(METHOD_ATTRIBUTE, submitMethod.name());
    }

    DocumentFetchConfiguration fetchConfiguration = mFetchConfiguration;
    if (fetchConfiguration != null) {
      applyFetchAudio(subdialogueElement, fetchConfiguration.getFetchAudio());
      applyRessourceFetchConfiguration(subdialogueElement, fetchConfiguration);
    }

    Element filledElement = DomUtils.appendNewElement(subdialogueElement, FILLED_ELEMENT);

    createVarElement(
        filledElement, SUBDIALOGUE_RESULT_VARIABLE_NAME, "dialog." + SUBDIALOGUE_FORM_ITEM_NAME);

    if (mPostDialogueScript != null) {
      createScript(filledElement, mPostDialogueScript);
    }

    createScript(
        filledElement,
        RIVR_SCOPE_OBJECT + ".addValueResult(" + SUBDIALOGUE_RESULT_VARIABLE_NAME + ");");
    createGotoSubmit(filledElement);
  }
Exemplo n.º 2
0
 @Override
 protected void addTurnProperties(JsonObjectBuilder builder) {
   JsonUtils.add(builder, SUBMIT_URI_PROPERTY, mUri);
   JsonUtils.add(builder, SUBMIT_METHOD_PROPERTY, mMethod.name());
   JsonUtils.add(builder, SUBMIT_PARAMETERS_PROPERTY, mSubmitParameters);
   JsonUtils.add(builder, SUBDIALOGUE_PARAMETERS_PROPERTY, JsonUtils.toJson(mParameters));
   JsonUtils.add(builder, FETCH_CONFIGURATION_PROPERTY, mFetchConfiguration);
   JsonUtils.add(builder, POST_DIALOGUE_SCRIPT_PROPERTY, getPostDialogueScript());
 }