IDEMPIERE-3521 InfoWindow problem on other SQL when make a register count / peer review and integrate patch from Orlando

This commit is contained in:
Carlos Ruiz 2017-10-20 19:41:57 +02:00
parent 60c4dc7306
commit f8cf23f2cb
5 changed files with 56 additions and 23 deletions

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3521 InfoWindow problem on other SQL when make a register count
-- Oct 20, 2017 12:13:41 PM CEST
UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-10-20 12:13:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201634
;
-- Oct 20, 2017 12:13:43 PM CEST
UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-10-20 12:13:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13579
;
SELECT register_migration_script('201710201214_IDEMPIERE-3521.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-3521 InfoWindow problem on other SQL when make a register count
-- Oct 20, 2017 12:13:41 PM CEST
UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-10-20 12:13:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201634
;
-- Oct 20, 2017 12:13:43 PM CEST
UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-10-20 12:13:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13579
;
SELECT register_migration_script('201710201214_IDEMPIERE-3521.sql') FROM dual
;

View File

@ -24,6 +24,7 @@ import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.model.MInfoProcess;
import org.adempiere.model.MInfoRelated;
import org.compiere.model.AccessSqlParser.TableInfo;
@ -446,7 +447,7 @@ public class MInfoWindow extends X_AD_InfoWindow
pstmt.executeQuery();
}catch (Exception ex){
log.log(Level.WARNING, ex.getMessage());
return;
throw new AdempiereException(ex);
} finally {
DB.close(pstmt);
}

View File

@ -106,11 +106,11 @@ import org.zkoss.zul.Vbox;
* @contributor xolali IDEMPIERE-1045 Sub-Info Tabs (reviewed by red1)
*/
public class InfoWindow extends InfoPanel implements ValueChangeListener, EventListener<Event> {
/**
*
*/
private static final long serialVersionUID = 8358292103127594383L;
private static final long serialVersionUID = 1672005382454423850L;
protected Grid parameterGrid;
private Borderlayout layout;
private Vbox southBody;
@ -1474,16 +1474,8 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
dataSql = MRole.getDefault().addAccessSQL(dataSql, getTableName(),
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
if (infoWindow.getOtherClause() != null && infoWindow.getOtherClause().trim().length() > 0) {
String otherClause = infoWindow.getOtherClause();
if (otherClause.indexOf("@") >= 0) {
String s = Env.parseContext(infoContext, p_WindowNo, otherClause, true, false);
if (s.length() == 0) {
log.severe("Failed to parse other clause. " + otherClause);
} else {
otherClause = s;
}
}
String otherClause = getOtherClauseParsed();
if (otherClause.length() > 0) {
dataSql = dataSql + " " + otherClause;
}
@ -1499,6 +1491,22 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
return dataSql;
}
private String getOtherClauseParsed() {
String otherClause = "";
if (infoWindow != null && infoWindow.getOtherClause() != null && infoWindow.getOtherClause().trim().length() > 0) {
otherClause = infoWindow.getOtherClause();
if (otherClause.indexOf("@") >= 0) {
String s = Env.parseContext(infoContext, p_WindowNo, otherClause, true, false);
if (s.length() == 0) {
log.severe("Failed to parse other clause. " + otherClause);
} else {
otherClause = s;
}
}
}
return otherClause;
}
@Override
protected void executeQuery() {
prepareTable();
@ -1705,10 +1713,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
}
countSql = MRole.getDefault().addAccessSQL (countSql, getTableName(),
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
// Fix GroupBy On InfoWindow
String otherClause = infoWindow.getOtherClause();
if (otherClause !=null)
// IDEMPIERE-3521
String otherClause = getOtherClauseParsed();
if (otherClause.length() > 0) {
countSql = countSql + " " + otherClause;
}
countSql = "SELECT COUNT(*) FROM ( " + countSql + " ) a";

View File

@ -1065,10 +1065,6 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
countSql = countSql.trim();
countSql = countSql.substring(0, countSql.length() - 5);
}
String otherClause = infoWindow.getOtherClause(); // Fix otherClause on count
if (otherClause != null)
countSql = countSql+" "+otherClause;
countSql = MRole.getDefault().addAccessSQL (countSql, getTableName(),
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
if (log.isLoggable(Level.FINER))