IDEMPIERE-908 Cannot report on window Product Costs / Team work between Richard, Juan and Carlos
This commit is contained in:
parent
a61ba2846c
commit
6d7fb18ed2
|
@ -238,7 +238,7 @@ public class AccessSqlParser
|
|||
index = from.indexOf(ON);
|
||||
while (index != -1)
|
||||
{
|
||||
int indexClose = from.indexOf(')'); // does not catch "IN (1,2)" in ON
|
||||
int indexClose = getIndexClose(from); // does not catch "IN (1,2)" in ON
|
||||
int indexNextOn = from.indexOf(ON, index+4);
|
||||
if (indexNextOn != -1)
|
||||
indexClose = from.lastIndexOf(')', indexNextOn);
|
||||
|
@ -384,6 +384,33 @@ public class AccessSqlParser
|
|||
return "";
|
||||
} // getMainSql
|
||||
|
||||
/**
|
||||
* Get index of ')'
|
||||
* @return index of ')'
|
||||
*/
|
||||
public int getIndexClose(String from)
|
||||
{
|
||||
int parenthesisLevel = 0;
|
||||
int indexOpen=from.indexOf('(');
|
||||
int index=-1;
|
||||
while(indexOpen!=-1)
|
||||
{
|
||||
parenthesisLevel++;
|
||||
int indexNextOpen = from.indexOf('(', indexOpen+1);
|
||||
int indexClose = from.indexOf(')',indexOpen+1);
|
||||
if (indexNextOpen==-1 || indexClose<indexNextOpen){
|
||||
break;
|
||||
}
|
||||
indexOpen=from.indexOf('(',indexNextOpen);
|
||||
}
|
||||
while(parenthesisLevel>0)
|
||||
{
|
||||
index = from.indexOf(')',index+1);
|
||||
parenthesisLevel--;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Table Info VO
|
||||
*/
|
||||
|
|
|
@ -111,7 +111,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1638364577972806113L;
|
||||
private static final long serialVersionUID = -4022944302529684348L;
|
||||
|
||||
public static final String DEFAULT_STATUS_MESSAGE = "NavigateOrUpdate";
|
||||
|
||||
|
@ -785,20 +785,20 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
if (query.getRestrictionCount() != 1)
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Ignored(More than 1 Restriction): " + query);
|
||||
return query.getWhereClause();
|
||||
return query.getWhereClause(true);
|
||||
}
|
||||
|
||||
String colName = query.getColumnName(0);
|
||||
if (colName == null)
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Ignored(No Column): " + query);
|
||||
return query.getWhereClause();
|
||||
return query.getWhereClause(true);
|
||||
}
|
||||
// a '(' in the name = function - don't try to resolve
|
||||
if (colName.indexOf('(') != -1)
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Ignored(Function): " + colName);
|
||||
return query.getWhereClause();
|
||||
return query.getWhereClause(true);
|
||||
}
|
||||
// OK - Query is valid
|
||||
|
||||
|
@ -806,7 +806,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
if (getField(colName) != null)
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Field Found: " + colName);
|
||||
return query.getWhereClause();
|
||||
return query.getWhereClause(true);
|
||||
}
|
||||
|
||||
String refColName = null;
|
||||
|
@ -845,7 +845,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
if (getField(refColName) != null)
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine("Column " + colName + " replaced with " + refColName);
|
||||
return query.getWhereClause();
|
||||
return query.getWhereClause(true);
|
||||
}
|
||||
colName = refColName;
|
||||
}
|
||||
|
@ -897,7 +897,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
if (log.isLoggable(Level.INFO)) log.info ("Not successfull - Column="
|
||||
+ colName + ", Key=" + tabKeyColumn
|
||||
+ ", Query=" + query);
|
||||
return query.getWhereClause();
|
||||
return query.getWhereClause(true);
|
||||
}
|
||||
|
||||
query.setTableName("xx");
|
||||
|
|
|
@ -100,7 +100,7 @@ public class GridTable extends AbstractTableModel
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5782826500266625861L;
|
||||
private static final long serialVersionUID = -2181155164268688340L;
|
||||
|
||||
public static final String DATA_REFRESH_MESSAGE = "Refreshed";
|
||||
|
||||
|
@ -2270,6 +2270,7 @@ public class GridTable extends AbstractTableModel
|
|||
int size = m_fields.size();
|
||||
StringBuffer singleRowWHERE = null;
|
||||
StringBuffer multiRowWHERE = null;
|
||||
String tableName = getTableName();
|
||||
for (int col = 0; col < size; col++)
|
||||
{
|
||||
GridField field = (GridField)m_fields.get (col);
|
||||
|
@ -2283,10 +2284,10 @@ public class GridTable extends AbstractTableModel
|
|||
return null;
|
||||
}
|
||||
if (columnName.endsWith ("_ID"))
|
||||
singleRowWHERE = new StringBuffer(columnName)
|
||||
singleRowWHERE = new StringBuffer(tableName).append(".").append(columnName)
|
||||
.append ("=").append (value);
|
||||
else
|
||||
singleRowWHERE = new StringBuffer(columnName)
|
||||
singleRowWHERE = new StringBuffer(tableName).append(".").append(columnName)
|
||||
.append ("=").append (DB.TO_STRING(value.toString()));
|
||||
}
|
||||
else if (field.isParentColumn())
|
||||
|
@ -2303,10 +2304,10 @@ public class GridTable extends AbstractTableModel
|
|||
else
|
||||
multiRowWHERE.append(" AND ");
|
||||
if (columnName.endsWith ("_ID"))
|
||||
multiRowWHERE.append (columnName)
|
||||
multiRowWHERE.append (tableName).append(".").append(columnName)
|
||||
.append ("=").append (value);
|
||||
else
|
||||
multiRowWHERE.append (columnName)
|
||||
multiRowWHERE.append (tableName).append(".").append(columnName)
|
||||
.append ("=").append (DB.TO_STRING(value.toString()));
|
||||
}
|
||||
} // for all columns
|
||||
|
@ -2889,13 +2890,13 @@ public class GridTable extends AbstractTableModel
|
|||
close(false);
|
||||
if (retainedWhere != null)
|
||||
{
|
||||
String whereClause = m_whereClause;
|
||||
// String whereClause = m_whereClause;
|
||||
if (m_whereClause != null && m_whereClause.trim().length() > 0)
|
||||
{
|
||||
m_whereClause = "((" + m_whereClause + ") OR (" + retainedWhere + ")) ";
|
||||
}
|
||||
open(m_maxRows);
|
||||
m_whereClause = whereClause;
|
||||
// m_whereClause = whereClause;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -247,21 +247,45 @@ public class ReportAction implements EventListener<Event>
|
|||
int Record_ID = 0;
|
||||
int[] RecordIDs = null;
|
||||
MQuery query = new MQuery(gridTab.getTableName());
|
||||
String whereClause;
|
||||
|
||||
if (currentRowOnly)
|
||||
{
|
||||
Record_ID = gridTab.getRecord_ID();
|
||||
query.addRestriction(query.getTableName() + "_ID", MQuery.EQUAL, Record_ID);
|
||||
whereClause = gridTab.getTableModel().getWhereClause(gridTab.getCurrentRow());
|
||||
if (whereClause==null)
|
||||
whereClause = gridTab.getTableModel().getSelectWhereClause();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
whereClause = gridTab.getTableModel().getSelectWhereClause();
|
||||
RecordIDs = new int[gridTab.getRowCount()];
|
||||
for(int i = 0; i < gridTab.getRowCount(); i++)
|
||||
{
|
||||
RecordIDs[i] = gridTab.getKeyID(i);
|
||||
query.addRestriction(query.getTableName() + "." + query.getTableName() + "_ID" + MQuery.EQUAL + RecordIDs[i], false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (whereClause!=null && whereClause.length() > 0)
|
||||
{
|
||||
if (whereClause.indexOf('@') != -1) //replace variables in context
|
||||
{
|
||||
String context = Env.parseContext(Env.getCtx(), panel.getWindowNo(), whereClause, false);
|
||||
if(context != null && context.trim().length() > 0)
|
||||
{
|
||||
whereClause = context;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.log(Level.WARNING, "Failed to parse where clause. whereClause= "+whereClause);
|
||||
whereClause = ("1 = 2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query.addRestriction(whereClause);
|
||||
|
||||
PrintInfo info = new PrintInfo(pf.getName(), pf.getAD_Table_ID(), Record_ID);
|
||||
info.setDescription(query.getInfo());
|
||||
|
||||
|
|
Loading…
Reference in New Issue