String strCommand = null;
ColumnData[] data=null;
XmlDocument xmlDocument=null;
FieldProvider dataField = vars.getEditionData(tabId);
vars.removeEditionData(tabId);
String strParamColumnName = vars.getSessionValue(tabId + "|paramColumnName");
boolean hasSearchCondition=false;
if (!(strParamColumnName.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 = ColumnData.selectEdit(this, vars.getSessionValue("#AD_SqlDateTimeFormat"), vars.getLanguage(), strPAD_Table_ID, strAD_Column_ID, Utility.getContext(this, vars, "#User_Client", windowId), Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel));
if (!strAD_Column_ID.equals("") && (data == null || data.length==0)) {
response.sendRedirect(strDireccion + request.getServletPath() + "?Command=RELATION");
return;
}
refreshSessionEdit(vars, data);
strCommand = "EDIT";
}
if (boolNew || data==null || data.length==0) {
discard[0] = new String ("editDiscard");
strCommand = "NEW";
data = new ColumnData[0];
} else {
discard[0] = new String ("newDiscard");
}
} else {
if (dataField.getField("adColumnId") == null || dataField.getField("adColumnId").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, strPAD_Table_ID);
data = ColumnData.set(strPAD_Table_ID, "", Utility.getDefault(this, vars, "Name", "", "100", "", dataField), Utility.getDefault(this, vars, "Description", "", "100", "", dataField), Utility.getDefault(this, vars, "Help", "", "100", "", dataField), Utility.getDefault(this, vars, "AD_Val_Rule_ID", "", "100", "", dataField), Utility.getDefault(this, vars, "ColumnName", "", "100", "", dataField), Utility.getDefault(this, vars, "DefaultValue", "", "100", "", dataField), Utility.getDefault(this, vars, "VFormat", "", "100", "", dataField), Utility.getDefault(this, vars, "FieldLength", "", "100", "0", dataField), Utility.getDefault(this, vars, "IsKey", "", "100", "N", dataField), Utility.getDefault(this, vars, "IsParent", "", "100", "N", dataField), Utility.getDefault(this, vars, "IsMandatory", "", "100", "N", dataField), Utility.getDefault(this, vars, "IsTranslated", "", "100", "N", dataField), Utility.getDefault(this, vars, "IsIdentifier", "", "100", "N", dataField), ColumnData.selectDef127(this, strPAD_Table_ID), Utility.getDefault(this, vars, "IsEncrypted", "", "100", "N", dataField), Utility.getDefault(this, vars, "AD_Reference_ID", "", "100", "", dataField), Utility.getDefault(this, vars, "AD_Reference_Value_ID", "", "100", "", dataField), Utility.getDefault(this, vars, "AD_Element_ID", "", "100", "", dataField), Utility.getDefault(this, vars, "IsUpdateable", "Y", "100", "N", dataField), Utility.getDefault(this, vars, "AD_Process_ID", "", "100", "", dataField), Utility.getDefault(this, vars, "ValueMin", "", "100", "", dataField), Utility.getDefault(this, vars, "ValueMax", "", "100", "", dataField), "0", "0", "Y", Utility.getDefault(this, vars, "CreatedBy", "", "100", "", dataField), ColumnData.selectDef550_0(this, Utility.getDefault(this, vars, "CreatedBy", "", "100", "", dataField)), Utility.getDefault(this, vars, "UpdatedBy", "", "100", "", dataField), ColumnData.selectDef552_1(this, Utility.getDefault(this, vars, "UpdatedBy", "", "100", "", dataField)), ColumnData.selectDef5661DEEC430BFC21E040007F01004C04(this, strPAD_Table_ID), Utility.getDefault(this, vars, "Position", "", "100", "0", dataField), Utility.getDefault(this, vars, "IsSelectionColumn", "", "100", "N", dataField), Utility.getDefault(this, vars, "ReadOnlyLogic", "", "100", "", dataField), Utility.getDefault(this, vars, "IsSessionAttr", "", "100", "N", dataField), Utility.getDefault(this, vars, "IsSecondaryKey", "N", "100", "N", dataField), Utility.getDefault(this, vars, "IsDesencryptable", "N", "100", "N", dataField), Utility.getDefault(this, vars, "AD_Callout_ID", "", "100", "", dataField), Utility.getDefault(this, vars, "Callout", "", "100", "", dataField), Utility.getDefault(this, vars, "Developmentstatus", "RE", "100", "", dataField), Utility.getDefault(this, vars, "IsTransient", "N", "100", "N", dataField), Utility.getDefault(this, vars, "isTransientCondition", "", "100", "", dataField));
}
}
String currentPOrg=TableData.selectOrg(this, strPAD_Table_ID);
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/TablesandColumns/Column_Edition",discard).createXmlDocument();
else
xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpWindows/TablesandColumns/Column_NonEditable",discard).createXmlDocument();
xmlDocument.setParameter("tabId", tabId);
ToolBar toolbar = new ToolBar(this, editableTab, vars.getLanguage(), "Column", (strCommand.equals("NEW") || boolNew || (dataField==null && (data==null || data.length==0))), "document.frmMain.inpadColumnId", "", "..", "".equals("Y"), "TablesandColumns", strReplaceWith, true, false, false, Utility.hasTabAttachments(this, vars, tabId, strAD_Column_ID));
toolbar.prepareEditionTemplate("N".equals("Y"), hasSearchCondition, vars.getSessionValue("#ShowTest", "N").equals("Y"), "STD", 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_Column_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(), "Column_Relation.html", "TablesandColumns", "W", strReplaceWith, tabs.breadcrumb());
xmlDocument.setParameter("navigationBar", nav.toString());
LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "Column_Relation.html", strReplaceWith);
xmlDocument.setParameter("leftTabs", lBar.editionTemplate(strCommand.equals("NEW")));
} catch (Exception ex) {
throw new ServletException(ex);
}
xmlDocument.setParameter("parentOrg", currentPOrg);
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.getReferenceableOrg(this, vars, currentPOrg, windowId, accesslevel); //referenceable from parent org, only the writeable orgs
else
userOrgList=currentOrg;
comboTableData = new ComboTableData(vars, this, "19", "AD_Org_ID", "", "", 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_Table_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("adTableId"):dataField.getField("adTableId")));
xmlDocument.setData("reportAD_Table_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "19", "AD_Module_ID", "", "C45CFD74FF5145B0A356E9233D49996F", 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("adModuleId"):dataField.getField("adModuleId")));
xmlDocument.setData("reportAD_Module_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "19", "AD_Element_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("adElementId"):dataField.getField("adElementId")));
xmlDocument.setData("reportAD_Element_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "18", "AD_Reference_ID", "1", "", 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("adReferenceId"):dataField.getField("adReferenceId")));
xmlDocument.setData("reportAD_Reference_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "19", "AD_Val_Rule_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("adValRuleId"):dataField.getField("adValRuleId")));
xmlDocument.setData("reportAD_Val_Rule_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, "18", "AD_Reference_Value_ID", "4", "115", 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("adReferenceValueId"):dataField.getField("adReferenceValueId")));
xmlDocument.setData("reportAD_Reference_Value_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "19", "AD_Callout_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("adCalloutId"):dataField.getField("adCalloutId")));
xmlDocument.setData("reportAD_Callout_ID","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
comboTableData = new ComboTableData(vars, this, "17", "Developmentstatus", "800103", "", 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("developmentstatus"):dataField.getField("developmentstatus")));
xmlDocument.setData("reportDevelopmentstatus","liststructure", comboTableData.select(!strCommand.equals("NEW")));
comboTableData = null;
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()));
} catch (Exception ex) {