package flow;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

import com.avaya.sce.runtime.Prompt;
import com.avaya.sce.runtime.PromptElement;
import com.avaya.sce.runtime.internal.PromptFinder;
import com.avaya.sce.runtimecommon.SCESession;

/**
 * Class that represents a form.  A form can contain prompts, fields  and links
 * as well as handlers for various events that may occur while the form is executing
 * Last generated by Orchestration Designer at: 2021年8月2日 下午12时40分52秒
 */
public class annTrans extends com.avaya.sce.runtime.Form {

	//{{START:CLASS:FIELDS
	//}}END:CLASS:FIELDS

	/**
	 * Default constructor
	 * Last generated by Orchestration Designer at: 2021年8月2日 下午12时40分52秒
	 */
	public annTrans() {
		//{{START:CLASS:CONSTRUCTOR
		super();
		//}}END:CLASS:CONSTRUCTOR
	}

	/**
	 * This method is generated automatically and should not be manually edited.
	 * To manually edit the links for the node, override:
	 *     void updateLinks(Collection links, SCESession mySession)
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 * @return a collection of links
	 */
	public java.util.Collection getLinks(com.avaya.sce.runtimecommon.SCESession mySession) {
		com.avaya.sce.runtime.Link link;
		java.util.List list;
		java.util.Collection grammarInfo = null;
		java.util.Collection<com.avaya.sce.runtime.CaptureExpression> captureExpr = null;
		// This item does not have any defined links
		list = new java.util.ArrayList();
		String ___tempGrammarName = null;

		return(list);
	}
	/**
	 * This method is generated automatically and should not be manually edited.
	 * To manually edit the properties for the node, override:
	 *     void updateProperties(Collection properties, SCESession mySession)
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 * @return a collection of properties
	 */
	public java.util.Collection getProperties(com.avaya.sce.runtimecommon.SCESession mySession) {
		com.avaya.sce.runtime.Property property;
		java.util.List list;
		// This item does not have any defined properties
		list = new java.util.ArrayList();

		return(list);
	}
	/**
	 * This method is generated automatically and should not be manually edited.
	 * To manually edit the event handlers for the node, override:
	 *    void updateEvents(Collection events, SCESession mySession)
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 * @return a collection of Events
	 */
	public java.util.Collection getEvents(com.avaya.sce.runtimecommon.SCESession mySession) {
		java.util.List list;
		com.avaya.sce.runtime.Event event;
		list = new java.util.ArrayList();
		java.util.List eventPromptNames = null;
		String ___tempPromptName = null;
		return(list);
	}
	/**
	 * Builds the list of fields for the form.  This list is built
	 * by the code generator based on items in the call flow editor.
	 * This method should not be manually edited as changes may be
	 * overwritten by the code generator.  <br>
	 * To update the fields for the form, override
	 *     public void updateFields(Collection fields, com.avaya.sce.runtimecommon.SCESession mySession)
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 */
	public java.util.Collection getFields(com.avaya.sce.runtimecommon.SCESession mySession) {
		java.util.List list = null;
		java.util.List promptNames = null;
		java.util.List eventPromptNames = null;
		java.util.List grammarInfo = null;
		java.util.List events = null;
		java.util.List properties = null;
		com.avaya.sce.runtime.Field field = null;
		com.avaya.sce.runtime.Event event = null;
		com.avaya.sce.runtime.Property property = null;

		// Form has no fields associated
		list = new java.util.ArrayList();

		return(list);
	}
	/**
	 * Builds the list of prompts that are used by this flow item<br>
	 * This method is generated automatically and changes to it may
	 * be overwritten next time code is generated.  To modify the list
	 * of prompts for the flow item, override:
	 *     updatePrompts(Collection prompts, SCESession mySession)
	 * @return list of prompts for the menu
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 */
	public java.util.Collection getPrompts(com.avaya.sce.runtimecommon.SCESession mySession) {
		java.util.List list = null;
		String ___tempPromptName = null;
		// build the list of prompt names
		list = new java.util.ArrayList(1);
		
		list.add(new com.avaya.sce.runtime.PromptRefInfo("pmpt_template", ""));

		return(list);
	}
	@Override
	public void updatePrompts(Collection prompts, SCESession mySession) {
		System.out.println("进入annTrans");
		prompts.clear();
		super.updatePrompts(prompts, mySession);
		Prompt pmpt = (Prompt) PromptFinder.load("pmpt_template",
				mySession.getCurrentLanguage(), mySession);
		int wavCount = 0;
		try {

			String NextNodeID = mySession.getVariableField(
					IProjectVariables.NEXT_MENU).getStringValue();
			String next_node = "end";
			HashMap<String, Object> hMapAll = (HashMap<String, Object>) mySession
					.getVariableField(IProjectVariables.MENU_ALL)
					.getObjectValue();
			HashMap<String, ArrayList<CMenuItemConfig>> hMapChild = (HashMap<String, ArrayList<CMenuItemConfig>>) mySession
					.getVariableField(IProjectVariables.MENU_CHILD)
					.getObjectValue();
			HashMap<String, CMenuConfig> hMapParent = (HashMap<String, CMenuConfig>) mySession
					.getVariableField(IProjectVariables.MENU_PARENT)
					.getObjectValue();
			if (hMapChild.containsKey(NextNodeID)) {
				ArrayList<CMenuItemConfig> list = hMapChild.get(NextNodeID);
				System.out.println(list.size());
				for (int i = 0; i < list.size(); i++) {
					java.util.Collection grammarInfo = new java.util.ArrayList();
					CMenuItemConfig CMenuItemConfig = list.get(i);
					System.out.println("ann动态语音："+CMenuItemConfig);
					String ID = CMenuItemConfig.getMenuItemId();
					int NodeType = CMenuItemConfig.getPlayType();
					String Filename = CMenuItemConfig.getPlayItem();
					int Enable = CMenuItemConfig.getBEnable();
					if (Enable == 1) {
						String files[] = Filename.split(",");
						for (int j = 0; j < files.length; j++) {
							String subfile = files[j];
							if (NodeType == 1)// 播放wav文件
							{
								System.out.println("语音文件：" + subfile);
								com.avaya.sce.runtime.Format format1 = new com.avaya.sce.runtime.Format();
								format1.add(
										com.avaya.sce.runtime.Format.FORMAT,
										com.avaya.sce.runtime.Format.FMT_FILENAME);
								PromptElement promptElement2 = new PromptElement(
										0, "aaa", format1);
								mySession.getVariableField("FilePath",
										"path" + wavCount).setValue(
										subfile + ".wav");
								promptElement2.setWaveFile(true);
								promptElement2
										.setType(PromptElement.VARIABLE_TEXT);
								promptElement2.setValue("FilePath:path"
										+ wavCount);
								pmpt.add(1 + wavCount, promptElement2);
								wavCount++;
								if (wavCount >= 40) {
									break;
								}
							} else// TT
							{
								PromptElement textele2 = Util
										.getTextElement(subfile);
								pmpt.add(1 + wavCount, textele2);
								wavCount++;
								if (wavCount >= 40) {
									break;
								}
							}

						}
					}

				}
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

		prompts.add(pmpt);

		super.updatePrompts(prompts, mySession);
	}
	/**
	 * Returns the submit item that identifies the next form to transition to.
	 * This method is generated automatically by the code generator
	 * and should not be manually edited.  Manual edits may be overwritten
	 * by the code generator.
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 */
	public com.avaya.sce.runtime.Submit getSubmit(com.avaya.sce.runtimecommon.SCESession mySession) {
		com.avaya.sce.runtime.Submit submit = null;
		submit = new com.avaya.sce.runtime.Submit("tran");
		return submit;
	}
	/**
	 * Returns the record item for the form.
	 * This method is generated automatically by the code generator
	 * and should not be manually edited.  Manual edits may be overwritten
	 * by the code generator.
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 */
	public com.avaya.sce.runtime.Record getRecord(com.avaya.sce.runtimecommon.SCESession mySession) {
		com.avaya.sce.runtime.Record record = null;
		java.util.Collection events = null;
		java.util.Collection promptNames = null;
		java.util.Collection eventPromptNames = null;
		java.util.Collection grammarInfo = null;
		com.avaya.sce.runtime.Event event = null;
		return record;
	}
	/**
	 * Returns the transfer item for the form.
	 * This method is generated automatically by the code generator
	 * and should not be manually edited.  Manual edits may be overwritten
	 * by the code generator.
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 */
	public com.avaya.sce.runtime.Transfer getTransfer(com.avaya.sce.runtimecommon.SCESession mySession) {
		com.avaya.sce.runtime.Transfer transfer = null;
		return transfer;
	}
	/**
	 * Returns a Throw object that will throw an event at runtime if set.
	 * This method is generated automatically by the code generator
	 * and should not be manually edited.  Manual edits may be overwritten
	 * by the code generator.
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 */
	public com.avaya.sce.runtime.Throw getThrow(com.avaya.sce.runtimecommon.SCESession mySession) {
		com.avaya.sce.runtime.Throw event = null;
		return event;
	}
	/**
	 * Builds the list of tracking items that are generated by this flow item<br>
	 * This method is generated automatically and changes to it may
	 * be overwritten next time code is generated.
	 * @return list of tracking items for the item
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 */
	public java.util.Collection getTrackingActions(com.avaya.sce.runtimecommon.SCESession mySession) {
		java.util.List list = null;

		// Item has no tracking items.
		list = new java.util.ArrayList();
		return(list);
	}
	/**
	 * Returns a collection of platform objects, or extensions to VXML.
	 * These objects result in the generation of the VXML object tag that
	 * the VXML platform attempts to use to load the runtime library that implements
	 * the extension.
	 * 
	 * This method is generated automatically by the code generator
	 * and should not be manually edited.  Manual edits may be overwritten
	 * by the code generator.
	 * Last generated by Orchestration Designer at: 2023年4月14日 下午05时14分30秒
	 */
	public java.util.Collection getPlatformObjects(com.avaya.sce.runtimecommon.SCESession mySession) {
		java.util.Collection objectList = null;
		java.util.Collection promptNames = null;
		com.avaya.sce.runtime.PlatformObject platformObject = null;

		// Form has no extension objects defined
		objectList = new java.util.ArrayList();
		return(objectList);
	}
}
