package flow;

/**
 * The Data class handles many types of server-side operations including data
 * collection (from a data sources such as a database, or web service), variable
 * assignments and operations (like copying variable values, performing mathematic
 * operations, and collection iteration), conditional evaluation to control callflow
 * execution based on variable values, and logging/tracing statements.
 * 
 * Items created in the getDataActions() method are executed/evaluated in order
 * and if a condional branch condition evaluates to "true" then the branch is
 * activated and the execution of data actions is halted.  If no "true" conditions
 * are encountered, then all data actions will be executed/evaluated and the 
 * application will proceed to the "Default" servlet.
 * Last generated by Orchestration Designer at: (timestamp generation disabled)
 */
public class GetCustomer extends com.avaya.sce.runtime.Data {

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

	/**
	 * Default constructor
	 * Last generated by Orchestration Designer at: (timestamp generation disabled)
	 */
	public GetCustomer() {
		//{{START:CLASS:CONSTRUCTOR
		super();
		//}}END:CLASS:CONSTRUCTOR
	}

	/**
	 * Returns the Next item which will forward application execution
	 * to the next form in the call flow.
	 * Last generated by Orchestration Designer at: (timestamp generation disabled)
	 */
	public com.avaya.sce.runtime.Next getNext(com.avaya.sce.runtimecommon.SCESession mySession) {
		com.avaya.sce.runtime.Next next = new com.avaya.sce.runtime.Next("PrepareContext", "Default");
		next.setDebugId(948);
		return next;
	}
	/**
	 * Create a list of local variables used by items in the data node.
	 * 
	 * 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: (timestamp generation disabled)
	 */
	public java.util.Collection<VariableInfo> getLocalVariables(){
		java.util.Collection<VariableInfo> variables = new java.util.ArrayList<VariableInfo>();

		return variables;
	}
	/**
	 * Creates and conditionally executes operations that have been configured
	 * in the Callflow.  This method will build a collection of operations and
	 * have the framework execute the operations by calling evaluateActions().
	 * If the evaluation causes the framework to forward to a different servlet
	 * then execution stops.
	 * Returning true from this method means that the framework has forwarded the
	 * request to a different servlet.  Returning false means that the default
	 * Next will be invoked.
	 * 
	 * 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: (timestamp generation disabled)
	 */
	public boolean executeDataActions(com.avaya.sce.runtimecommon.SCESession mySession) throws Exception {
		java.util.Collection actions = null;

		actions = new java.util.ArrayList(1);
		if(evaluateActions(actions, mySession)) {
			return true;
		}
		actions = null;

		if(((com.avaya.sce.runtime.Condition)new com.avaya.sce.runtime.Condition("condition1", "Properties:UseCustomerAPI", com.avaya.sce.runtime.Expression.STRING_EQUAL, "true", false).setDebugId(965)).evaluate(mySession)) {

			if(((com.avaya.sce.runtime.Condition)new com.avaya.sce.runtime.Condition("condition2", "Context:ContextId", com.avaya.sce.runtime.Expression.IS_EMPTY).setDebugId(1008)).evaluate(mySession)) {

				if(((com.avaya.sce.runtime.Condition)new com.avaya.sce.runtime.Condition("condition3", "TrafficBypass:TrafficProfileBEnabled", com.avaya.sce.runtime.Expression.STRING_EQUAL, "true", false).setDebugId(1025)).evaluate(mySession)) {
					actions = new java.util.ArrayList(1);
					actions.add(new com.avaya.sce.runtime.varoperations.Assign("Customer:Phone", "", true).setDebugId(996));
					if(evaluateActions(actions, mySession)) {
						return true;
					}
					actions = null;

					if(((com.avaya.sce.runtime.Condition)new com.avaya.sce.runtime.Condition("condition4", "TrafficBypass:UseCRM", com.avaya.sce.runtime.Expression.STRING_EQUAL, "true", false).setDebugId(1030)).evaluate(mySession)) {
						actions = new java.util.ArrayList(1);
						actions.add(new com.avaya.sce.runtime.varoperations.Assign("Properties:CRMIdentifier", "CollectCustomerID:value", false).setDebugId(1031));
						if(evaluateActions(actions, mySession)) {
							return true;
						}
						actions = null;

					}

				} else {
					actions = new java.util.ArrayList(1);
					actions.add(new com.avaya.sce.runtime.varoperations.Assign("Customer:Phone", "session:ani", false).setDebugId(1028));
					if(evaluateActions(actions, mySession)) {
						return true;
					}
					actions = null;
				}


				actions = new java.util.ArrayList(4);
				actions.add(new com.avaya.sce.runtime.varoperations.Assign("Customer:AccountId", "CollectCustomerID:value", false).setDebugId(993));
				actions.add(new com.avaya.sce.runtime.varoperations.Assign("Customer:AccountType", "Properties:AccountType", false).setDebugId(994));
				actions.add(new com.avaya.sce.runtime.varoperations.Assign("Customer:ExternalID", "Properties:CRMIdentifier", false).setDebugId(995));
				actions.add(new com.avaya.sce.runtime.tracking.TraceInfo(com.avaya.sce.runtimecommon.ITraceInfo.TRACE_LEVEL_INFO, "Retrieving Customer details", "Customer:AccountId").setDebugId(1020));
				if(evaluateActions(actions, mySession)) {
					return true;
				}
				actions = null;
				try {
					actions = new java.util.ArrayList(1);

					//{{START:CODEGEN:EXTENSIONPOINT:com.avaya.sce.pdc.oceanaservices.findcustomerid
					actions.add(new com.avaya.sce.pdc.oceanaservices.operations.FindCustomerId("SelectedDataCenter", "CMClusterIP" , false, "", "", "Customer", "Phone", "Customer", "ExternalID", "Customer", "AccountType", "Customer", "AccountId", "", "", "", "", "GetCustomerResponse", "").setDebugId(952));
					//}}END:CODEGEN:EXTENSIONPOINT:com.avaya.sce.pdc.oceanaservices.findcustomerid

					if(evaluateActions(actions, mySession)) {
						return true;
					}
					actions = null;
				} catch (com.avaya.sce.runtimecommon.SCERuntimeException e1) {
					actions = new java.util.ArrayList(5);
					actions.add(new com.avaya.sce.runtime.varoperations.CaptureException(e1).setDebugId(-1));
					actions.add(new com.avaya.sce.runtime.tracking.TraceInfo(com.avaya.sce.runtimecommon.ITraceInfo.TRACE_LEVEL_ERROR, "Problem encountered with Customer Management", "ddLastException:message").setDebugId(960));
					actions.add(new com.avaya.sce.runtime.tracking.ReportInfo(com.avaya.sce.runtimecommon.IReportInfo.REPORT_TYPE_PROGRESS, com.avaya.sce.runtimecommon.IReportInfo.ALARM_LEVEL_MAJOR, "Oceana SSA", "Problem encountered with Customer Management", "ddLastException:message").setDebugId(961));
					actions.add(new com.avaya.sce.runtime.varoperations.Assign("Prompts:ErrorMessage", "Prompts:GetCustFailed", false).setDebugId(962));
					actions.add(new com.avaya.sce.runtime.Next("DefaultErrorTransfer", "Get Customer Error").setDebugId(963));
					if(evaluateActions(actions, mySession)) {
						return true;
					}
					actions = null;
				} catch (com.avaya.sce.pdc.oceanaservices.OceanaServicesException e2) {
					actions = new java.util.ArrayList(5);
					actions.add(new com.avaya.sce.runtime.varoperations.CaptureException(e2).setDebugId(-1));
					actions.add(new com.avaya.sce.runtime.tracking.TraceInfo(com.avaya.sce.runtimecommon.ITraceInfo.TRACE_LEVEL_ERROR, "Problem encountered with Customer Management", "ddLastException:message").setDebugId(960));
					actions.add(new com.avaya.sce.runtime.tracking.ReportInfo(com.avaya.sce.runtimecommon.IReportInfo.REPORT_TYPE_PROGRESS, com.avaya.sce.runtimecommon.IReportInfo.ALARM_LEVEL_MAJOR, "Oceana SSA", "Problem encountered with Customer Management", "ddLastException:message").setDebugId(961));
					actions.add(new com.avaya.sce.runtime.varoperations.Assign("Prompts:ErrorMessage", "Prompts:GetCustFailed", false).setDebugId(962));
					actions.add(new com.avaya.sce.runtime.Next("DefaultErrorTransfer", "Get Customer Error").setDebugId(963));
					if(evaluateActions(actions, mySession)) {
						return true;
					}
					actions = null;
				}

			} else {
				actions = new java.util.ArrayList(1);
				actions.add(new com.avaya.sce.runtime.tracking.TraceInfo(com.avaya.sce.runtimecommon.ITraceInfo.TRACE_LEVEL_INFO, "Customer already known, no need to look up again", "").setDebugId(1003));
				if(evaluateActions(actions, mySession)) {
					return true;
				}
				actions = null;
			}


		}

		// return false if the evaluation of actions did not cause a servlet forward or redirect
		return false;
	}
}
