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

This commit is contained in:
Carlos Ruiz 2015-08-26 20:40:16 -05:00
commit 2eb0e245ac
9 changed files with 128 additions and 54 deletions

View File

@ -35,17 +35,22 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.IGridTabImporter; import org.adempiere.base.IGridTabImporter;
import org.adempiere.base.equinox.EquinoxExtensionLocator; import org.adempiere.base.equinox.EquinoxExtensionLocator;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.DataStatusEvent;
import org.compiere.model.DataStatusListener;
import org.compiere.model.GridField;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.GridWindow; import org.compiere.model.GridWindow;
import org.compiere.model.MImportTemplate; import org.compiere.model.MImportTemplate;
import org.compiere.model.MLookup;
import org.compiere.process.ProcessInfoParameter; import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess; import org.compiere.process.SvrProcess;
import org.compiere.util.Env; import org.compiere.util.Env;
public class ImportCSVProcess extends SvrProcess { public class ImportCSVProcess extends SvrProcess implements DataStatusListener {
private InputStream m_file_istream = null; private InputStream m_file_istream = null;
private int p_AD_ImportTemplate_ID = 0; private int p_AD_ImportTemplate_ID = 0;
@ -112,6 +117,7 @@ public class ImportCSVProcess extends SvrProcess {
if (m_gridTab == null) if (m_gridTab == null)
throw new Exception("No Active Tab"); throw new Exception("No Active Tab");
m_gridTab.addDataStatusListener(this);
} }
protected IGridTabImporter initImporter() throws Exception { protected IGridTabImporter initImporter() throws Exception {
@ -142,4 +148,44 @@ public class ImportCSVProcess extends SvrProcess {
m_file_istream.close(); m_file_istream.close();
} }
/**
* @param e
* @see DataStatusListener#dataStatusChanged(DataStatusEvent)
*/
public void dataStatusChanged(DataStatusEvent e)
{
int col = e.getChangedColumn();
if (log.isLoggable(Level.CONFIG)) log.config("(" + m_gridTab + ") Col=" + col + ": " + e.toString());
// Process Callout
GridField mField = m_gridTab.getField(col);
if (mField != null
&& (mField.getCallout().length() > 0
|| (Core.findCallout(m_gridTab.getTableName(), mField.getColumnName())).size()>0
|| m_gridTab.hasDependants(mField.getColumnName())))
{
String msg = m_gridTab.processFieldChange(mField); // Dependencies & Callout
if (msg.length() > 0)
{
log.warning(msg);
}
// Refresh the list on dependant fields
for (GridField dependentField : m_gridTab.getDependantFields(mField.getColumnName()))
{
// if the field has a lookup
if (dependentField != null && dependentField.getLookup() instanceof MLookup)
{
MLookup mLookup = (MLookup)dependentField.getLookup();
// if the lookup is dynamic (i.e. contains this columnName as variable)
if (mLookup.getValidation().indexOf("@"+mField.getColumnName()+"@") != -1)
{
mLookup.refresh();
}
}
} // for all dependent fields
}
}
} }

View File

@ -202,7 +202,6 @@ public class RequestEventHandler extends AbstractEventHandler implements Managed
// Update // Update
r.setDateLastAction(r.getUpdated()); r.setDateLastAction(r.getUpdated());
r.setLastResult(r.getResult()); r.setLastResult(r.getResult());
r.setDueType();
// Reset // Reset
r.setConfidentialTypeEntry (r.getConfidentialType()); r.setConfidentialTypeEntry (r.getConfidentialType());
// r.setStartDate(null); //red1 - bug [ 1743159 ] Requests - Start Date is not retained. // r.setStartDate(null); //red1 - bug [ 1743159 ] Requests - Start Date is not retained.
@ -239,10 +238,17 @@ public class RequestEventHandler extends AbstractEventHandler implements Managed
if (r.is_ValueChanged(columnName)) if (r.is_ValueChanged(columnName))
{ {
Object value = r.get_ValueOld(columnName); Object value = r.get_ValueOld(columnName);
if (value == null) if (value == null) {
ra.addNullColumn(columnName); ra.addNullColumn(columnName);
else } else {
ra.set_ValueNoCheck(columnName, value); if (value instanceof Boolean
&& ( MRequestAction.COLUMNNAME_IsEscalated.equals(columnName)
|| MRequestAction.COLUMNNAME_IsSelfService.equals(columnName))) {
ra.set_ValueNoCheck(columnName, ((Boolean)value).booleanValue() ? "Y" : "N");
} else {
ra.set_ValueNoCheck(columnName, value);
}
}
r.setIsChanged(true); r.setIsChanged(true);
return true; return true;
} }

View File

@ -114,7 +114,7 @@ public class GridTabCSVExporter implements IGridTabExporter
} else if (DisplayType.DateTime == field.getDisplayType()) { } else if (DisplayType.DateTime == field.getDisplayType()) {
procArray.add(new Optional(new FmtDate(DisplayType.DEFAULT_TIMESTAMP_FORMAT))); procArray.add(new Optional(new FmtDate(DisplayType.DEFAULT_TIMESTAMP_FORMAT)));
} else if (DisplayType.Time == field.getDisplayType()) { } else if (DisplayType.Time == field.getDisplayType()) {
procArray.add(new Optional(new FmtDate("DisplayType.DEFAULT_TIME_FORMAT"))); procArray.add(new Optional(new FmtDate(DisplayType.DEFAULT_TIME_FORMAT)));
} else if (DisplayType.Integer == field.getDisplayType() || DisplayType.isNumeric(field.getDisplayType())) { } else if (DisplayType.Integer == field.getDisplayType() || DisplayType.isNumeric(field.getDisplayType())) {
DecimalFormat nf = DisplayType.getNumberFormat(field.getDisplayType()); DecimalFormat nf = DisplayType.getNumberFormat(field.getDisplayType());
nf.setGroupingUsed(false); nf.setGroupingUsed(false);
@ -178,7 +178,7 @@ public class GridTabCSVExporter implements IGridTabExporter
} else if (DisplayType.DateTime == field.getDisplayType()) { } else if (DisplayType.DateTime == field.getDisplayType()) {
procArray.add(new Optional(new FmtDate(DisplayType.DEFAULT_TIMESTAMP_FORMAT))); procArray.add(new Optional(new FmtDate(DisplayType.DEFAULT_TIMESTAMP_FORMAT)));
} else if (DisplayType.Time == field.getDisplayType()) { } else if (DisplayType.Time == field.getDisplayType()) {
procArray.add(new Optional(new FmtDate("DisplayType.DEFAULT_TIME_FORMAT"))); procArray.add(new Optional(new FmtDate(DisplayType.DEFAULT_TIME_FORMAT)));
} else if (DisplayType.Integer == field.getDisplayType() || DisplayType.isNumeric(field.getDisplayType())) { } else if (DisplayType.Integer == field.getDisplayType() || DisplayType.isNumeric(field.getDisplayType())) {
DecimalFormat nf = DisplayType.getNumberFormat(field.getDisplayType()); DecimalFormat nf = DisplayType.getNumberFormat(field.getDisplayType());
nf.setGroupingUsed(false); nf.setGroupingUsed(false);
@ -223,7 +223,7 @@ public class GridTabCSVExporter implements IGridTabExporter
int rowDetail=0; int rowDetail=0;
int record_Id = 0; int record_Id = 0;
boolean isActiveRow = true; boolean isActiveRow = true;
gridTab.setCurrentRow(idxrow);
for(GridField field : getFields(gridTab)){ for(GridField field : getFields(gridTab)){
MColumn column = MColumn.get(Env.getCtx(), field.getAD_Column_ID()); MColumn column = MColumn.get(Env.getCtx(), field.getAD_Column_ID());
Object value = null; Object value = null;
@ -282,9 +282,17 @@ public class GridTabCSVExporter implements IGridTabExporter
} }
} }
while(true){ if(childs.size()>0){
if(childs.size()>0){ for (GridTab childTab:childs){
Map<String, Object> tmpRow = resolveMasterDetailRow(rowDetail,tabMapDetails,headArray,index,gridTab.getKeyID(idxrow), gridTab.getKeyColumnName()); if (!childTab.isLoadComplete()){
childTab.initTab(false);
}
childTab.query(false, 0, 0);
}
while(true){
Map<String, Object> tmpRow = resolveMasterDetailRow(rowDetail,tabMapDetails,headArray,index);
if(tmpRow!= null){ if(tmpRow!= null){
for(Map.Entry<String, Object> details : tmpRow.entrySet()) { for(Map.Entry<String, Object> details : tmpRow.entrySet()) {
String detailColumn = details.getKey(); String detailColumn = details.getKey();
@ -296,10 +304,9 @@ public class GridTabCSVExporter implements IGridTabExporter
}else{ }else{
break; break;
} }
}else{
break; }
} }
}
if(rowDetail==0) if(rowDetail==0)
mapWriter.write(row, header,processors); mapWriter.write(row, header,processors);
@ -334,7 +341,7 @@ public class GridTabCSVExporter implements IGridTabExporter
return result; return result;
} }
private Map<String, Object> resolveMasterDetailRow(int currentDetRow,Map<GridTab,GridField[]> tabMapDetails,List<String>headArray,int idxfld,int record_Id,String keyColumnParent){ private Map<String, Object> resolveMasterDetailRow(int currentDetRow,Map<GridTab,GridField[]> tabMapDetails,List<String>headArray,int idxfld){
Map<String,Object> activeRow = new HashMap<String,Object>(); Map<String,Object> activeRow = new HashMap<String,Object>();
Object value = null; Object value = null;
boolean hasDetails = false; boolean hasDetails = false;
@ -346,8 +353,8 @@ public class GridTabCSVExporter implements IGridTabExporter
for(Map.Entry<GridTab, GridField[]> childTabDetail : tabMapDetails.entrySet()) { for(Map.Entry<GridTab, GridField[]> childTabDetail : tabMapDetails.entrySet()) {
GridTab childTab = childTabDetail.getKey(); GridTab childTab = childTabDetail.getKey();
String whereCla = getWhereClause (childTab ,record_Id ,keyColumnParent); //String whereCla = getWhereClause (childTab, parentGrid, currentParentIndex);
childTab.getTableModel().dataRequery(whereCla, false, 0); //childTab.getTableModel().dataRequery(whereCla, false, 0);
Map<String,Object> row = new HashMap<String,Object>(); Map<String,Object> row = new HashMap<String,Object>();
boolean isActiveRow = true; boolean isActiveRow = true;
if (childTab.getRowCount() > 0) { if (childTab.getRowCount() > 0) {
@ -412,11 +419,20 @@ public class GridTabCSVExporter implements IGridTabExporter
return null; return null;
} }
public String getWhereClause (GridTab childTab, int record_Id , String keyColumnParent){ /**
* @param childTab
* @param parentGrid
* @param currentParentIndex
* @return
*/
@Deprecated // don't use any where, relate IDEMPIERE-2788
public String getWhereClause (GridTab childTab, GridTab parentGrid, int currentParentIndex){
String whereClau = null; String whereClau = null;
String linkColumn = childTab.getLinkColumnName(); String linkColumn = childTab.getLinkColumnName();
if (keyColumnParent.equals(linkColumn)){ if (parentGrid.getKeyColumnName().equals(linkColumn)){
whereClau= linkColumn+MQuery.EQUAL+record_Id; whereClau= linkColumn+MQuery.EQUAL + parentGrid.getKeyID(currentParentIndex);
}else{
whereClau= parentGrid.getKeyColumnName() + MQuery.EQUAL + parentGrid.getValue(currentParentIndex, parentGrid.getKeyColumnName());
} }
return whereClau; return whereClau;
} }

View File

@ -1172,7 +1172,7 @@ public class GridTabCSVImporter implements IGridTabImporter
} else if (DisplayType.DateTime == field.getDisplayType()) { } else if (DisplayType.DateTime == field.getDisplayType()) {
return (new Optional(new ParseDate(DisplayType.DEFAULT_TIMESTAMP_FORMAT))); return (new Optional(new ParseDate(DisplayType.DEFAULT_TIMESTAMP_FORMAT)));
} else if (DisplayType.Time == field.getDisplayType()) { } else if (DisplayType.Time == field.getDisplayType()) {
return (new Optional(new ParseDate("DisplayType.DEFAULT_TIME_FORMAT"))); return (new Optional(new ParseDate(DisplayType.DEFAULT_TIME_FORMAT)));
} else if (DisplayType.Integer == field.getDisplayType()) { } else if (DisplayType.Integer == field.getDisplayType()) {
return (new Optional(new ParseInt())); return (new Optional(new ParseInt()));
} else if (DisplayType.isNumeric(field.getDisplayType())) { } else if (DisplayType.isNumeric(field.getDisplayType())) {

View File

@ -281,8 +281,11 @@ public class GridField
*/ */
public boolean refreshLookup() public boolean refreshLookup()
{ {
// if there is a validation string, the lookup is unstable if (m_lookup == null)
if (m_lookup == null || m_lookup.getValidation().length() == 0) return true;
// if there is a validation string, the lookup is unstable - read-only fields are not loaded initially
if (m_lookup.getValidation().length() == 0 && m_lookup.isLoaded())
return true; return true;
// //
if (log.isLoggable(Level.FINE)) log.fine("(" + m_vo.ColumnName + ")"); if (log.isLoggable(Level.FINE)) log.fine("(" + m_vo.ColumnName + ")");
@ -1046,7 +1049,7 @@ public class GridField
// need to re-set invalid values - OK BPartner in PO Line - not OK SalesRep in Invoice // need to re-set invalid values - OK BPartner in PO Line - not OK SalesRep in Invoice
if (m_lookup.getDirect(m_value, false, true) == null) if (m_lookup.getDirect(m_value, false, true) == null)
{ {
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " Serach not valid - set to null"); if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " Search not valid - set to null");
setValue(null, m_inserting); setValue(null, m_inserting);
m_error = true; m_error = true;
return false; return false;
@ -1055,14 +1058,24 @@ public class GridField
} }
// cannot be validated // cannot be validated
if (!isLookup() if (!isLookup() || m_lookup == null)
|| m_lookup == null
|| m_lookup.containsKeyNoDirect(m_value))
return true; return true;
if (m_lookup.containsKeyNoDirect(m_value)) {
String name = m_lookup.get(m_value).getName();
if (! ( name.startsWith(MLookup.INACTIVE_S) && name.endsWith(MLookup.INACTIVE_E) ) ) {
return true;
}
}
// it's not null, a lookup and does not have the key // it's not null, a lookup and does not have the key
if (isKey() || isParentValue()) // parents/ket are not validated if (isKey() || isParentValue()) // parents/ket are not validated
return true; return true;
// special case for IDEMPIERE-2781
if ( "AD_Client_ID".equals(m_vo.ColumnName)
&& "0".equals(m_value.toString())
&& Env.getAD_Client_ID(Env.getCtx()) == 0)
return true;
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " - set to null"); if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " - set to null");
setValue(null, m_inserting); setValue(null, m_inserting);
m_error = true; m_error = true;
@ -1094,7 +1107,7 @@ public class GridField
// need to re-set invalid values - OK BPartner in PO Line - not OK SalesRep in Invoice // need to re-set invalid values - OK BPartner in PO Line - not OK SalesRep in Invoice
if (m_lookup.getDirect(m_value, false, true) == null) if (m_lookup.getDirect(m_value, false, true) == null)
{ {
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " Serach not valid - set to null"); if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " Search not valid - set to null");
setValue(null, m_inserting); setValue(null, m_inserting);
m_error = true; m_error = true;
return false; return false;

View File

@ -1145,7 +1145,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
if (log.isLoggable(Level.FINE)) log.fine("#" + m_vo.TabNo); if (log.isLoggable(Level.FINE)) log.fine("#" + m_vo.TabNo);
if (!isInsertRecord()) if (!isInsertRecord())
{ {
log.warning ("Inset Not allowed in TabNo=" + m_vo.TabNo); log.warning ("Insert Not allowed in TabNo=" + m_vo.TabNo);
return false; return false;
} }
// Prevent New Where Main Record is processed // Prevent New Where Main Record is processed
@ -1186,10 +1186,9 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
setCurrentRow(m_currentRow + 1, true); setCurrentRow(m_currentRow + 1, true);
// check validity of defaults // check validity of defaults
for (int i = 0; i < getFieldCount(); i++) for (GridField field : getFields()) {
{ field.refreshLookup();
getField(i).refreshLookup(); field.validateValueNoDirect();
getField(i).validateValueNoDirect();
} }
// process all Callouts (no dependency check - assumed that settings are valid) // process all Callouts (no dependency check - assumed that settings are valid)
for (int i = 0; i < getFieldCount(); i++) for (int i = 0; i < getFieldCount(); i++)

View File

@ -528,11 +528,16 @@ public final class MLookup extends Lookup implements Serializable
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
String name = rs.getString(3); StringBuilder name = new StringBuilder().append(rs.getString(3));
boolean isActive = rs.getString(4).equals("Y");
if (!isActive)
{
name.insert(0, INACTIVE_S).append(INACTIVE_E);
}
if (isNumber) if (isNumber)
{ {
int keyValue = rs.getInt(1); int keyValue = rs.getInt(1);
KeyNamePair p = new KeyNamePair(keyValue, name); KeyNamePair p = new KeyNamePair(keyValue, name.toString());
if (saveInCache) // save if if (saveInCache) // save if
m_lookup.put(new Integer(keyValue), p); m_lookup.put(new Integer(keyValue), p);
directValue = p; directValue = p;
@ -540,7 +545,7 @@ public final class MLookup extends Lookup implements Serializable
else else
{ {
String value = rs.getString(2); String value = rs.getString(2);
ValueNamePair p = new ValueNamePair(value, name); ValueNamePair p = new ValueNamePair(value, name.toString());
if (saveInCache) // save if if (saveInCache) // save if
m_lookup.put(value, p); m_lookup.put(value, p);
directValue = p; directValue = p;
@ -855,7 +860,7 @@ public final class MLookup extends Lookup implements Serializable
boolean isActive = rs.getString(4).equals("Y"); boolean isActive = rs.getString(4).equals("Y");
if (!isActive) if (!isActive)
{ {
name = new StringBuilder(INACTIVE_S).append(name).append(INACTIVE_E); name.insert(0, INACTIVE_S).append(INACTIVE_E);
m_hasInactive = true; m_hasInactive = true;
} }
// IDEMPIERE 90 // IDEMPIERE 90

View File

@ -1429,18 +1429,6 @@ public class FinReport extends SvrProcess
sb.append (")"); sb.append (")");
unionWhere.append(sb.toString ()); unionWhere.append(sb.toString ());
} }
// Posting Type
String PostingType = m_lines[line].getPostingType();
if (PostingType != null && PostingType.length() > 0)
{
if (unionWhere.length() > 0)
unionWhere.append(" AND ");
unionWhere.append("PostingType='" + PostingType + "'");
if (MReportLine.POSTINGTYPE_Budget.equals(PostingType)) {
if (m_lines[line].getGL_Budget_ID() > 0)
unionWhere.append(" AND GL_Budget_ID=" + m_lines[line].getGL_Budget_ID());
}
}
} }
// //

View File

@ -1337,6 +1337,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (!detailTab) if (!detailTab)
{ {
String dbInfo = e.getMessage(); String dbInfo = e.getMessage();
if (logger.isLoggable(Level.INFO)) logger.info(dbInfo);
if (adTabbox.getSelectedGridTab() != null && adTabbox.getSelectedGridTab().isQueryActive())
dbInfo = "[ " + dbInfo + " ]";
breadCrumb.setStatusDB(dbInfo, e);
String adInfo = e.getAD_Message(); String adInfo = e.getAD_Message();
if ( ! prevdbInfo.equals(dbInfo) if ( ! prevdbInfo.equals(dbInfo)
&& ( GridTab.DEFAULT_STATUS_MESSAGE.equals(adInfo) && ( GridTab.DEFAULT_STATUS_MESSAGE.equals(adInfo)
@ -1346,10 +1351,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
) )
) { ) {
prevdbInfo = dbInfo; prevdbInfo = dbInfo;
if (logger.isLoggable(Level.INFO)) logger.info(dbInfo);
if (adTabbox.getSelectedGridTab() != null && adTabbox.getSelectedGridTab().isQueryActive())
dbInfo = "[ " + dbInfo + " ]";
breadCrumb.setStatusDB(dbInfo, e);
String prefix = null; String prefix = null;
if (dbInfo.contains("*")) if (dbInfo.contains("*"))