IDEMPIERE-4958 Performance improvement for the opening of process dialog (#874)
* IDEMPIERE-4958 Performance improvement for the opening of process dialog * IDEMPIERE-4958 Performance improvement for the opening of process dialog Query.scroll and Query.list has similar db performance, the previous change is not needed.
This commit is contained in:
parent
4b8af33c4e
commit
21c07785e8
|
|
@ -412,6 +412,12 @@ public class MPInstance extends X_AD_PInstance
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public I_AD_Process getAD_Process() throws RuntimeException {
|
||||||
|
return MProcess.get(getAD_Process_ID());
|
||||||
|
}
|
||||||
|
|
||||||
public static void publishChangedEvent(int AD_User_ID) {
|
public static void publishChangedEvent(int AD_User_ID) {
|
||||||
IMessageService service = Core.getMessageService();
|
IMessageService service = Core.getMessageService();
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
|
|
@ -447,13 +453,15 @@ public class MPInstance extends X_AD_PInstance
|
||||||
// unnamed instances
|
// unnamed instances
|
||||||
int lastRunCount = MSysConfig.getIntValue(MSysConfig.LASTRUN_RECORD_COUNT, 5, Env.getAD_Client_ID(ctx));
|
int lastRunCount = MSysConfig.getIntValue(MSysConfig.LASTRUN_RECORD_COUNT, 5, Env.getAD_Client_ID(ctx));
|
||||||
if (lastRunCount > 0) {
|
if (lastRunCount > 0) {
|
||||||
|
int maxLoopCount = 10 * lastRunCount;
|
||||||
// using JDBC instead of Query for performance reasons, AD_PInstance can be huge
|
// using JDBC instead of Query for performance reasons, AD_PInstance can be huge
|
||||||
String sql = "SELECT * FROM AD_PInstance "
|
String sql = "SELECT * FROM AD_PInstance "
|
||||||
+ " WHERE AD_Process_ID=? AND AD_User_ID=? AND IsActive='Y' AND AD_Client_ID=? AND Name IS NULL"
|
+ " WHERE AD_Process_ID=? AND AD_User_ID=? AND IsActive='Y' AND AD_Client_ID=? AND Name IS NULL"
|
||||||
+ " ORDER BY Created DESC";
|
+ " ORDER BY Created DESC";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
int cnt = 0;
|
int runCount = 0;
|
||||||
|
int loopCount = 0;
|
||||||
try {
|
try {
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setFetchSize(lastRunCount);
|
pstmt.setFetchSize(lastRunCount);
|
||||||
|
|
@ -462,16 +470,19 @@ public class MPInstance extends X_AD_PInstance
|
||||||
pstmt.setInt(3, Env.getAD_Client_ID(ctx));
|
pstmt.setInt(3, Env.getAD_Client_ID(ctx));
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
loopCount++;
|
||||||
MPInstance unnamedInstance = new MPInstance(ctx, rs, null);
|
MPInstance unnamedInstance = new MPInstance(ctx, rs, null);
|
||||||
String paramsStr = unnamedInstance.getParamsStr();
|
String paramsStr = unnamedInstance.getParamsStr();
|
||||||
if (! paramsStrAdded.contains(paramsStr)) {
|
if (! paramsStrAdded.contains(paramsStr)) {
|
||||||
unnamedInstance.setName(Msg.getMsg(ctx, "LastRun") + " " + unnamedInstance.getCreated());
|
unnamedInstance.setName(Msg.getMsg(ctx, "LastRun") + " " + unnamedInstance.getCreated());
|
||||||
list.add(unnamedInstance);
|
list.add(unnamedInstance);
|
||||||
paramsStrAdded.add(paramsStr);
|
paramsStrAdded.add(paramsStr);
|
||||||
cnt++;
|
runCount++;
|
||||||
if (cnt == lastRunCount)
|
if (runCount == lastRunCount)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (loopCount == maxLoopCount)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import org.compiere.util.DB;
|
||||||
* <li>FR [ 1984834 ] Add POResultSet.hasNext convenient method
|
* <li>FR [ 1984834 ] Add POResultSet.hasNext convenient method
|
||||||
* <li>FR [ 1985134 ] POResultSet improvements
|
* <li>FR [ 1985134 ] POResultSet improvements
|
||||||
*/
|
*/
|
||||||
public class POResultSet<T extends PO> {
|
public class POResultSet<T extends PO> implements AutoCloseable {
|
||||||
|
|
||||||
private String trxName;
|
private String trxName;
|
||||||
private ResultSet resultSet;
|
private ResultSet resultSet;
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ package org.adempiere.webui.apps;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
@ -82,7 +79,6 @@ import org.compiere.process.ProcessInfoUtil;
|
||||||
import org.compiere.process.ServerProcessCtl;
|
import org.compiere.process.ServerProcessCtl;
|
||||||
import org.compiere.util.AdempiereSystemError;
|
import org.compiere.util.AdempiereSystemError;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
@ -169,65 +165,35 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
|
||||||
|
|
||||||
log.config("");
|
log.config("");
|
||||||
//
|
//
|
||||||
|
StringBuilder buildMsg = new StringBuilder();
|
||||||
boolean trl = !Env.isBaseLanguage(m_ctx, "AD_Process");
|
boolean trl = !Env.isBaseLanguage(m_ctx, "AD_Process");
|
||||||
String sql = "SELECT Name, Description, Help, IsReport, ShowHelp, AD_Process_UU "
|
MProcess process = MProcess.get(AD_Process_ID);
|
||||||
+ "FROM AD_Process "
|
m_Name = trl ? process.get_Translation(MProcess.COLUMNNAME_Name) : process.getName();
|
||||||
+ "WHERE AD_Process_ID=?";
|
m_Description = trl ? process.get_Translation(MProcess.COLUMNNAME_Description) : process.getDescription();
|
||||||
if (trl)
|
m_Help = trl ? process.get_Translation(MProcess.COLUMNNAME_Help) : process.getHelp();
|
||||||
sql = "SELECT t.Name, t.Description, t.Help, p.IsReport, p.ShowHelp, AD_Process_UU "
|
m_ShowHelp = process.getShowHelp();
|
||||||
+ "FROM AD_Process p, AD_Process_Trl t "
|
|
||||||
+ "WHERE p.AD_Process_ID=t.AD_Process_ID"
|
|
||||||
+ " AND p.AD_Process_ID=? AND t.AD_Language=?";
|
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
// User Customization
|
||||||
ResultSet rs = null;
|
MUserDefProc userDef = MUserDefProc.getBestMatch(ctx, AD_Process_ID);
|
||||||
try
|
if (userDef != null) {
|
||||||
{
|
if (userDef.getName() != null)
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
m_Name = userDef.getName();
|
||||||
pstmt.setInt(1, AD_Process_ID);
|
if (userDef.getDescription() != null)
|
||||||
if (trl)
|
m_Description = userDef.getDescription();
|
||||||
pstmt.setString(2, Env.getAD_Language(m_ctx));
|
if (userDef.getHelp() != null)
|
||||||
rs = pstmt.executeQuery();
|
m_Help = userDef.getHelp();
|
||||||
StringBuilder buildMsg = new StringBuilder();
|
|
||||||
if (rs.next())
|
|
||||||
{
|
|
||||||
m_Name = rs.getString(1);
|
|
||||||
m_Description = rs.getString(2);
|
|
||||||
m_Help = rs.getString(3);
|
|
||||||
m_ShowHelp = rs.getString(5);
|
|
||||||
|
|
||||||
// User Customization
|
|
||||||
MUserDefProc userDef = MUserDefProc.getBestMatch(ctx, AD_Process_ID);
|
|
||||||
if (userDef != null) {
|
|
||||||
if (userDef.getName() != null)
|
|
||||||
m_Name = userDef.getName();
|
|
||||||
if (userDef.getDescription() != null)
|
|
||||||
m_Description = userDef.getDescription();
|
|
||||||
if (userDef.getHelp() != null)
|
|
||||||
m_Help = userDef.getHelp();
|
|
||||||
}
|
|
||||||
|
|
||||||
buildMsg.append("<b>");
|
|
||||||
buildMsg.append(Util.isEmpty(m_Description) ? Msg.getMsg(m_ctx, "StartProcess?") : m_Description);
|
|
||||||
buildMsg.append("</b>");
|
|
||||||
|
|
||||||
if (!Util.isEmpty(m_Help))
|
|
||||||
buildMsg.append("<p>").append(m_Help).append("</p>");
|
|
||||||
m_AD_Process_UU = rs.getString(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialMessage = buildMsg.toString();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, sql, e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildMsg.append("<b>");
|
||||||
|
buildMsg.append(Util.isEmpty(m_Description) ? Msg.getMsg(m_ctx, "StartProcess?") : m_Description);
|
||||||
|
buildMsg.append("</b>");
|
||||||
|
|
||||||
|
if (!Util.isEmpty(m_Help))
|
||||||
|
buildMsg.append("<p>").append(m_Help).append("</p>");
|
||||||
|
m_AD_Process_UU = process.getAD_Process_UU();
|
||||||
|
|
||||||
|
initialMessage = buildMsg.toString();
|
||||||
|
|
||||||
if (m_Name == null)
|
if (m_Name == null)
|
||||||
return false;
|
return false;
|
||||||
//
|
//
|
||||||
|
|
@ -472,12 +438,12 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isReport () {
|
protected boolean isReport () {
|
||||||
MProcess pr = new MProcess(m_ctx, m_AD_Process_ID, null);
|
MProcess pr = MProcess.get(m_ctx, m_AD_Process_ID);
|
||||||
return pr.isReport() && pr.getJasperReport() == null;
|
return pr.isReport() && pr.getJasperReport() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isJasperReport () {
|
protected boolean isJasperReport () {
|
||||||
MProcess pr = new MProcess(m_ctx, m_AD_Process_ID, null);
|
MProcess pr = MProcess.get(m_ctx, m_AD_Process_ID);
|
||||||
return pr.isReport() && pr.getJasperReport() != null;
|
return pr.isReport() && pr.getJasperReport() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -548,7 +514,7 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
|
||||||
int AD_Column_ID = 0;
|
int AD_Column_ID = 0;
|
||||||
boolean m_isCanExport = false;
|
boolean m_isCanExport = false;
|
||||||
|
|
||||||
MProcess pr = new MProcess(m_ctx, m_AD_Process_ID, null);
|
MProcess pr = MProcess.get(m_ctx, m_AD_Process_ID);
|
||||||
int table_ID = 0;
|
int table_ID = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
|
||||||
*/
|
*/
|
||||||
public void onMenuSelected(int menuId)
|
public void onMenuSelected(int menuId)
|
||||||
{
|
{
|
||||||
MMenu menu = new MMenu(Env.getCtx(), menuId, null);
|
MMenu menu = MMenu.get(menuId);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue