String strCommand = null;
ProcessExecutionData[] data=null;
XmlDocument xmlDocument=null;
FieldProvider dataField = vars.getEditionData(tabId);
vars.removeEditionData(tabId);
String strParamStatus = vars.getSessionValue(tabId + "|paramStatus");
String strParamStart_Time = vars.getSessionValue(tabId + "|paramStart_Time");
String strParamAD_User_ID = vars.getSessionValue(tabId + "|paramAD_User_ID");
String strParamAD_Process_ID = vars.getSessionValue(tabId + "|paramAD_Process_ID");
String strParamEnd_Time = vars.getSessionValue(tabId + "|paramEnd_Time");
String strParamStart_Time_f = vars.getSessionValue(tabId + "|paramStart_Time_f");
String strParamEnd_Time_f = vars.getSessionValue(tabId + "|paramEnd_Time_f");
boolean hasSearchCondition=false;
if (!(strParamStatus.equals("") && strParamStart_Time.equals("") && strParamAD_User_ID.equals("") && strParamAD_Process_ID.equals("") && strParamEnd_Time.equals("") && strParamStart_Time_f.equals("") && strParamEnd_Time_f.equals(""))) hasSearchCondition=true;
String strParamSessionDate = vars.getGlobalVariable("inpParamSessionDate", Utility.getTransactionalDate(this, vars, windowId), "");
String buscador = "";
String[] discard = {"", "isNotTest"};
if (vars.getSessionValue("#ShowTest", "N").equals("Y")) discard[1] = new String("isTest");
if (dataField==null) {
if (!boolNew) {
discard[0] = new String("newDiscard");
data = ProcessExecutionData.selectEdit(this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage(), strAD_Process_Run_ID, Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel));
if (!strAD_Process_Run_ID.equals("") && (data == null || data.length==0)) {
response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
return;
}
refreshSessionEdit(vars, data);
strCommand = "EDIT";
}
if (data==null || data.length==0) {
strAD_Process_Run_ID = firstElement(vars, tableSQL);
if (strAD_Process_Run_ID.equals("")) {
response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
return;
} else {
data = ProcessExecutionData.selectEdit(this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage(), strAD_Process_Run_ID, Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel));
}
}
if (boolNew || data==null || data.length==0) {
discard[0] = new String ("editDiscard");
strCommand = "NEW";
data = new ProcessExecutionData[0];
} else {
discard[0] = new String ("newDiscard");
}
} else {
if (dataField.getField("adProcessRunId") == null || dataField.getField("adProcessRunId").equals("")) {
discard[0] = new String ("editDiscard");
strCommand = "NEW";
boolNew = true;
} else {
discard[0] = new String ("newDiscard");
strCommand = "EDIT";
}
}
if (dataField==null) {
if (boolNew || data==null || data.length==0) {
refreshSessionNew(vars);
data = ProcessExecutionData.set("", Utility.getDefault(this, vars, "AD_Client_ID", "@AD_CLIENT_ID@", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), "0", "Y", Utility.getDefault(this, vars, "Createdby", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), ProcessExecutionData.selectDef57B98D87940DA967E040007F01013153_0(this, Utility.getDefault(this, vars, "Createdby", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField)), Utility.getDefault(this, vars, "Updatedby", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), ProcessExecutionData.selectDef57B98D87940FA967E040007F01013153_1(this, Utility.getDefault(this, vars, "Updatedby", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField)), Utility.getDefault(this, vars, "Status", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "Start_Time", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "Runtime", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "Log", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "Result", "", "EF3E837705944F4DBF398D683D36ACE0", "N", dataField), Utility.getDefault(this, vars, "AD_Process_Request_ID", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "AD_User_ID", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "Report", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "Params", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "Channel", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "AD_Process_ID", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "End_Time", "", "EF3E837705944F4DBF398D683D36ACE0", "", dataField), Utility.getDefault(this, vars, "Isrolesecurity", "", "EF3E837705944F4DBF398D683D36ACE0", "N", dataField));
}
}
String currentOrg = (boolNew?"":(dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId")));
if (!currentOrg.equals("") && !currentOrg.startsWith("'")) currentOrg = "'"+currentOrg+"'";
String currentClient = (boolNew?"":(dataField!=null?dataField.getField("adClientId"):data[0].getField("adClientId")));
if (!currentClient.equals("") && !currentClient.startsWith("'")) currentClient = "'"+currentClient+"'";
boolean editableTab = (!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this, vars.getRole(), tabId) && (currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId, accesslevel),currentOrg)) && (currentClient.equals("") || Utility.isElementInList(Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), currentClient)));
if (editableTab)
xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpWindows/ProcessMonitor/ProcessExecution_Edition",discard).createXmlDocument();
else
xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpWindows/ProcessMonitor/ProcessExecution_NonEditable",discard).createXmlDocument();
xmlDocument.setParameter("tabId", tabId);
ToolBar toolbar = new ToolBar(this, editableTab, vars.getLanguage(), "ProcessExecution", (strCommand.equals("NEW") || boolNew || (dataField==null && (data==null || data.length==0))), "document.frmMain.inpadProcessRunId", "", "..", "".equals("Y"), "ProcessMonitor", strReplaceWith, true, false, false, Utility.hasTabAttachments(this, vars, tabId, strAD_Process_Run_ID));
toolbar.prepareEditionTemplate("N".equals("Y"), hasSearchCondition, vars.getSessionValue("#ShowTest", "N").equals("Y"), "RO", Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
xmlDocument.setParameter("toolbar", toolbar.toString());
try {
WindowTabs tabs = new WindowTabs(this, vars, tabId, windowId, true, (strCommand.equalsIgnoreCase("NEW")));
xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
// if (!strAD_Process_Run_ID.equals("")) xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
// else xmlDocument.setParameter("childTabContainer", tabs.childTabs(true));
xmlDocument.setParameter("childTabContainer", tabs.childTabs(false));
NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ProcessExecution_Relation.html", "ProcessMonitor", "W", strReplaceWith, tabs.breadcrumb());
xmlDocument.setParameter("navigationBar", nav.toString());
LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ProcessExecution_Relation.html", strReplaceWith);
xmlDocument.setParameter("leftTabs", lBar.editionTemplate(strCommand.equals("NEW")));
} catch (Exception ex) {
throw new ServletException(ex);
}
xmlDocument.setParameter("commandType", strCommand);
xmlDocument.setParameter("buscador",buscador);
xmlDocument.setParameter("windowId", windowId);
xmlDocument.setParameter("changed", "");
xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
xmlDocument.setParameter("theme", vars.getTheme());
final String strMappingName = UtilityData.selectObjectMapping(this, tabId);
xmlDocument.setParameter("mappingName", strMappingName);
xmlDocument.setParameter("confirmOnChanges", Utility.getJSConfirmOnChanges(vars, windowId));
//xmlDocument.setParameter("buttonReference", Utility.messageBD(this, "Reference", vars.getLanguage()));
xmlDocument.setParameter("paramSessionDate", strParamSessionDate);
xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
OBError myMessage = vars.getMessage(tabId);
vars.removeMessage(tabId);
if (myMessage!=null) {
xmlDocument.setParameter("messageType", myMessage.getType());
xmlDocument.setParameter("messageTitle", myMessage.getTitle());
xmlDocument.setParameter("messageMessage", myMessage.getMessage());
}
xmlDocument.setParameter("displayLogic", getDisplayLogicContext(vars, boolNew));
if (dataField==null) {
xmlDocument.setData("structure1",data);
} else {
FieldProvider[] dataAux = new FieldProvider[1];
dataAux[0] = dataField;
xmlDocument.setData("structure1",dataAux);
}
try {
ComboTableData comboTableData = null;
String userClientList = "";
if (editableTab)
userClientList=Utility.getContext(this, vars, "#User_Client", windowId, accesslevel); //editable record
else
userClientList=currentClient;
comboTableData = new ComboTableData(vars, this, "19", "AD_Client_ID", "", "103", null, userClientList, 0);
Utility.fillSQLParameters(this, vars, (dataField==null?data[0]:dataField), comboTableData, windowId, (dataField==null?data[0].getField("adClientId"):dataField.getField("adClientId")));
xmlDocument.setData("reportAD_Client_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
String userOrgList = "";
if (editableTab)
userOrgList=Utility.getContext(this, vars, "#User_Org", windowId, accesslevel); //editable record
else
userOrgList=currentOrg;
comboTableData = new ComboTableData(vars, this, "19", "AD_Org_ID", "", "104", userOrgList, Utility.getContext(this, vars, "#User_Client", windowId), 0);
Utility.fillSQLParameters(this, vars, (dataField==null?data[0]:dataField), comboTableData, windowId, (dataField==null?data[0].getField("adOrgId"):dataField.getField("adOrgId")));
xmlDocument.setData("reportAD_Org_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "19", "AD_Process_ID", "", "", Utility.getReferenceableOrg(vars, (dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId").equals("")?vars.getOrg():data[0].getField("adOrgId"))), Utility.getContext(this, vars, "#User_Client", windowId), 0);
Utility.fillSQLParameters(this, vars, (dataField==null?data[0]:dataField), comboTableData, windowId, (dataField==null?data[0].getField("adProcessId"):dataField.getField("adProcessId")));
xmlDocument.setData("reportAD_Process_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "19", "AD_User_ID", "", "", Utility.getReferenceableOrg(vars, (dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId").equals("")?vars.getOrg():data[0].getField("adOrgId"))), Utility.getContext(this, vars, "#User_Client", windowId), 0);
Utility.fillSQLParameters(this, vars, (dataField==null?data[0]:dataField), comboTableData, windowId, (dataField==null?data[0].getField("adUserId"):dataField.getField("adUserId")));
xmlDocument.setData("reportAD_User_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
xmlDocument.setParameter("Start_Time_Format", vars.getSessionValue("#AD_SqlDateTimeFormat"));xmlDocument.setParameter("Start_Time_Maxlength", Integer.toString(vars.getSessionValue("#AD_SqlDateTimeFormat").length()));
xmlDocument.setParameter("End_Time_Format", vars.getSessionValue("#AD_SqlDateTimeFormat"));xmlDocument.setParameter("End_Time_Maxlength", Integer.toString(vars.getSessionValue("#AD_SqlDateTimeFormat").length()));
comboTableData = new ComboTableData(vars, this, "17", "Status", "7DB6D4792CDC4ED297C70A4F4282A52E", "", Utility.getReferenceableOrg(vars, (dataField!=null?dataField.getField("adOrgId"):data[0].getField("adOrgId").equals("")?vars.getOrg():data[0].getField("adOrgId"))), Utility.getContext(this, vars, "#User_Client", windowId), 0);
Utility.fillSQLParameters(this, vars, (dataField==null?data[0]:dataField), comboTableData, windowId, (dataField==null?data[0].getField("status"):dataField.getField("status")));
xmlDocument.setData("reportStatus","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
xmlDocument.setParameter("Result_BTNname", Utility.getButtonName(this, vars, "57B98D879425A967E040007F01013153", "Result_linkBTN", usedButtonShortCuts, reservedButtonShortCuts));
xmlDocument.setParameter("Created_Format", vars.getSessionValue("#AD_SqlDateTimeFormat"));xmlDocument.setParameter("Created_Maxlength", Integer.toString(vars.getSessionValue("#AD_SqlDateTimeFormat").length()));
xmlDocument.setParameter("Updated_Format", vars.getSessionValue("#AD_SqlDateTimeFormat"));xmlDocument.setParameter("Updated_Maxlength", Integer.toString(vars.getSessionValue("#AD_SqlDateTimeFormat").length()));