hg merge release-2.1 (merge release2.1 into development)

This commit is contained in:
Carlos Ruiz 2015-03-14 16:05:56 -05:00
commit 133250f6d6
5 changed files with 69 additions and 43 deletions

View File

@ -85,12 +85,22 @@ public class MImportTemplate extends X_AD_ImportTemplate
return retValue;
final String where = ""
+ "IsActive='Y' AND AD_Client_ID IN (0, ?) AND AD_Tab_ID=? "
+ "IsActive = 'Y' "
+ "AND AD_Client_ID IN ( 0, ? ) "
+ "AND AD_Tab_ID = ? "
+ "AND EXISTS (SELECT 1 "
+ " FROM AD_ImportTemplateAccess ita "
+ " WHERE ita.AD_ImportTemplate_ID=AD_ImportTemplate.AD_ImportTemplate_ID AND ita.IsActive='Y' AND ita.AD_Role_ID=? AND (IsAllowInsert='Y' OR IsAllowMerge='Y' OR IsAllowUpdate='Y'))";
+ " FROM AD_ImportTemplateAccess ita "
+ " WHERE ita.AD_ImportTemplate_ID = AD_ImportTemplate.AD_ImportTemplate_ID "
+ " AND ita.IsActive = 'Y' "
+ " AND ( ita.AD_Role_ID = ? "
+ " OR ita.AD_Role_ID IN (SELECT Included_Role_ID "
+ " FROM AD_Role_Included "
+ " WHERE AD_Role_ID = ? AND IsActive = 'Y') ) "
+ " AND ( IsAllowInsert = 'Y' "
+ " OR IsAllowMerge = 'Y' "
+ " OR IsAllowUpdate = 'Y' ))";
retValue = new Query(Env.getCtx(), MImportTemplate.Table_Name, where, null)
.setParameters(Env.getAD_Client_ID(Env.getCtx()), tabid, roleid)
.setParameters(Env.getAD_Client_ID(Env.getCtx()), tabid, roleid, roleid)
.setOrderBy("Name")
.list();
s_cacheRoleTab.put(key, retValue);
@ -98,8 +108,17 @@ public class MImportTemplate extends X_AD_ImportTemplate
}
public boolean isAllowed(String importMode, int roleID) {
StringBuilder sql= new StringBuilder(
"SELECT COUNT(*) FROM AD_ImportTemplateAccess WHERE IsActive='Y' AND AD_ImportTemplate_ID=? AND AD_Role_ID=? AND IsAllow");
StringBuilder sql= new StringBuilder(""
+ "SELECT COUNT(*) "
+ "FROM AD_ImportTemplateaccess "
+ "WHERE IsActive = 'Y' "
+ " AND AD_ImportTemplate_ID = ? "
+ " AND ( AD_Role_ID = ? "
+ " OR AD_Role_ID IN (SELECT Included_Role_ID "
+ " FROM AD_Role_Included "
+ " WHERE AD_Role_id = ? "
+ " AND IsActive = 'Y') ) "
+ " AND IsAllow");
if ("I".equals(importMode))
sql.append("Insert");
else if ("U".equals(importMode))
@ -110,7 +129,7 @@ public class MImportTemplate extends X_AD_ImportTemplate
return false;
sql.append("='Y'");
int cnt = DB.getSQLValueEx(get_TrxName(), sql.toString(), getAD_ImportTemplate_ID(), roleID);
int cnt = DB.getSQLValueEx(get_TrxName(), sql.toString(), getAD_ImportTemplate_ID(), roleID, roleID);
return cnt > 0;
}

View File

@ -338,9 +338,9 @@ public class ReportEngine implements PrintServiceAttributeListener
*/
public Properties getCtx()
{
return getLayout().getCtx();
return m_ctx;
} // getCtx
/**
* Get Row Count
* @return row count

View File

@ -247,18 +247,30 @@ public class CSVImportAction implements EventListener<Event>
private void fillImportMode() {
final String sql= ""
+ "SELECT IsAllowInsert, IsAllowUpdate, IsAllowMerge "
+ "FROM AD_ImportTemplateAccess "
+ "WHERE IsActive='Y' AND AD_ImportTemplate_ID=? AND AD_Role_ID=? AND (IsAllowInsert='Y' OR IsAllowMerge='Y' OR IsAllowUpdate='Y')";
List<Object> flags = DB.getSQLValueObjectsEx(null, sql, theTemplate.getAD_ImportTemplate_ID(), Env.getAD_Role_ID(Env.getCtx()));
+ "SELECT MAX(IsAllowInsert), "
+ " MAX(IsAllowUpdate), "
+ " MAX(IsAllowMerge) "
+ "FROM AD_ImportTemplateAccess "
+ "WHERE IsActive = 'Y' "
+ " AND AD_ImportTemplate_ID = ? "
+ " AND ( AD_Role_ID = ? "
+ " OR AD_Role_ID IN (SELECT Included_Role_ID "
+ " FROM AD_Role_Included "
+ " WHERE AD_Role_ID = ? "
+ " AND IsActive = 'Y') ) "
+ " AND ( IsAllowInsert = 'Y' "
+ " OR IsAllowMerge = 'Y' "
+ " OR IsAllowUpdate = 'Y' )";
List<Object> flags = DB.getSQLValueObjectsEx(null, sql, theTemplate.getAD_ImportTemplate_ID(), Env.getAD_Role_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx()));
fImportMode.removeAllItems();
if (flags.get(0) != null && "Y".equals(flags.get(0).toString()))
fImportMode.appendItem("Insert","I");
if (flags.get(1) != null && "Y".equals(flags.get(0).toString()))
if (flags.get(1) != null && "Y".equals(flags.get(1).toString()))
fImportMode.appendItem("Update","U");
if (flags.get(2) != null && "Y".equals(flags.get(0).toString()))
if (flags.get(2) != null && "Y".equals(flags.get(2).toString()))
fImportMode.appendItem("Merge","M");
fImportMode.setSelectedIndex(0);
if (fImportMode.getItemCount() == 1)
fImportMode.setSelectedIndex(0);
}
private void processUploadMedia(Media media) {

View File

@ -229,9 +229,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
m_ctx = m_reportEngine.getCtx();
init();
dynInit();
if (!ArchiveEngine.isValid(m_reportEngine.getLayout()))
log.warning("Cannot archive Document");
}
catch(Exception e)
{
@ -469,7 +466,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new XLSRendererRunnable(this),getDesktop()));
}
}
private void onPreviewReport() {
try {
if (future != null) {
@ -1308,6 +1305,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
@Override
protected void doRun() {
try {
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
log.warning("Cannot archive Document");
String path = System.getProperty("java.io.tmpdir");
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
if (log.isLoggable(Level.FINE))
@ -1353,6 +1352,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
@Override
protected void doRun() {
try {
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
log.warning("Cannot archive Document");
String path = System.getProperty("java.io.tmpdir");
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
if (log.isLoggable(Level.FINE))
@ -1397,6 +1398,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
@Override
protected void doRun() {
try {
if (!ArchiveEngine.isValid(viewer.m_reportEngine.getLayout()))
log.warning("Cannot archive Document");
String path = System.getProperty("java.io.tmpdir");
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
if (log.isLoggable(Level.FINE))

View File

@ -16,12 +16,10 @@
*****************************************************************************/
package org.adempiere.webui.window;
import org.adempiere.util.ContextRunnable;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.session.SessionManager;
import org.compiere.Adempiere;
import org.compiere.print.ReportEngine;
import org.compiere.print.ReportViewerProvider;
import org.zkoss.zk.ui.Executions;
@ -34,32 +32,26 @@ import org.zkoss.zk.ui.Executions;
public class ZkReportViewerProvider implements ReportViewerProvider {
public void openViewer(final ReportEngine report) {
final Runnable runnable = new Runnable() {
@Override
public void run() {
Window viewer = new ZkReportViewer(report, report.getName());
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
viewer.setAttribute(WindowContainer.DEFER_SET_SELECTED_TAB, Boolean.TRUE);
SessionManager.getAppDesktop().showWindow(viewer);
}
};
// IDEMPIERE-2499
// detect ui thread by value of Executions.getCurrent(), not office method but work
if (Executions.getCurrent() != null){
Adempiere.getThreadPoolExecutor().submit(new ContextRunnable(){
protected void doRun(){
// load layout, with big report it's heavy job, do in non ui thread to don't lock gui
report.getLayout();
AEnv.executeAsyncDesktopTask(runnable);
openReportViewWindow (report);
}else {
AEnv.executeAsyncDesktopTask(new Runnable() {
@Override
public void run() {
openReportViewWindow (report);
}
});
}else{
// load layout in non ui thread before run into ui thread
report.getLayout();
AEnv.executeAsyncDesktopTask(runnable);
}
}
protected void openReportViewWindow (ReportEngine report) {
Window viewer = new ZkReportViewer(report, report.getName());
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
viewer.setAttribute(WindowContainer.DEFER_SET_SELECTED_TAB, Boolean.TRUE);
SessionManager.getAppDesktop().showWindow(viewer);
}
}