Fix bug when checking if the process is already configured

Reported by AFalcone and suggested fix here -> http://red1.org/adempiere/viewtopic.php?f=34&t=1193
Also refactored the generation of the process to make it smart in case a new tab is added to a window and it requires to configure new processes
This commit is contained in:
Carlos Ruiz 2011-03-26 01:53:28 -05:00
parent 7cb32f8039
commit cf96e249c8
1 changed files with 32 additions and 27 deletions

View File

@ -178,17 +178,23 @@ public class ASPGenerateLevel extends SvrProcess
} }
// tabs // tabs
for (MTab tab : window.getTabs(true, get_TrxName())) { for (MTab tab : window.getTabs(true, get_TrxName())) {
if (DB.getSQLValueEx( int asp_tab_id = DB.getSQLValueEx(get_TrxName(),
get_TrxName(), "SELECT ASP_Tab_ID FROM ASP_Tab WHERE ASP_Window_ID = ? AND AD_Tab_ID = ?",
"SELECT COUNT(*) FROM ASP_Tab WHERE ASP_Window_ID = ? AND AD_Tab_ID = ?", asp_window_id, tab.getAD_Tab_ID());
asp_window_id, tab.getAD_Tab_ID()) < 1) { X_ASP_Tab aspTab = null;
X_ASP_Tab aspTab = new X_ASP_Tab(getCtx(), 0, get_TrxName()); if (asp_tab_id < 1) {
aspTab = new X_ASP_Tab(getCtx(), 0, get_TrxName());
aspTab.setASP_Window_ID(asp_window_id); aspTab.setASP_Window_ID(asp_window_id);
aspTab.setAD_Tab_ID(tab.getAD_Tab_ID()); aspTab.setAD_Tab_ID(tab.getAD_Tab_ID());
aspTab.setASP_Status(p_ASP_Status); aspTab.setASP_Status(p_ASP_Status);
aspTab.setAllFields(! p_IsGenerateFields); aspTab.setAllFields(! p_IsGenerateFields);
if (aspTab.save()) if (aspTab.save()) {
noTabs++; noTabs++;
asp_tab_id = aspTab.getASP_Tab_ID();
}
} else {
aspTab = new X_ASP_Tab(getCtx(), asp_tab_id, get_TrxName());
}
// fields // fields
for (MField field : tab.getFields(true, get_TrxName())) { for (MField field : tab.getFields(true, get_TrxName())) {
if (p_IsGenerateFields) { if (p_IsGenerateFields) {
@ -213,7 +219,6 @@ public class ASPGenerateLevel extends SvrProcess
} }
} }
} }
}
} else if (menu.getAction().equals(MMenu.ACTION_Process) } else if (menu.getAction().equals(MMenu.ACTION_Process)
|| menu.getAction().equals(MMenu.ACTION_Report)) { || menu.getAction().equals(MMenu.ACTION_Report)) {
generateProcess(menu.getAD_Process_ID()); generateProcess(menu.getAD_Process_ID());
@ -254,7 +259,7 @@ public class ASPGenerateLevel extends SvrProcess
// Add Process and Parameters // Add Process and Parameters
MProcess process = new MProcess(getCtx(), p_AD_Process_ID, get_TrxName()); MProcess process = new MProcess(getCtx(), p_AD_Process_ID, get_TrxName());
int asp_process_id = DB.getSQLValueEx(get_TrxName(), int asp_process_id = DB.getSQLValueEx(get_TrxName(),
"SELECT COUNT(*) FROM ASP_Process WHERE ASP_Level_ID = ? AND AD_Process_ID = ?", "SELECT ASP_Process_ID FROM ASP_Process WHERE ASP_Level_ID = ? AND AD_Process_ID = ?",
p_ASP_Level_ID, process.getAD_Process_ID()); p_ASP_Level_ID, process.getAD_Process_ID());
X_ASP_Process aspProcess = null; X_ASP_Process aspProcess = null;
if (asp_process_id < 1) { if (asp_process_id < 1) {