IDEMPIERE-3800 Improvements to CSV Export - fix and integrate improvements from Heng Sin
This commit is contained in:
parent
428e00ae86
commit
f70f76d732
|
@ -148,7 +148,7 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
if(detail.getDisplayLogic()!=null){
|
if(detail.getDisplayLogic()!=null){
|
||||||
//if(!currentRowOnly)
|
//if(!currentRowOnly)
|
||||||
//numOfTabs--;
|
//numOfTabs--;
|
||||||
//TODO: it's need? DisplayLogic is evaluated when call detail.isDisplayed()
|
//TODO: it's need? DisplayLogic is evaluated when call detail.isDisplayed()
|
||||||
if(currentRowOnly && !Evaluator.evaluateLogic(detail,detail.getDisplayLogic()))
|
if(currentRowOnly && !Evaluator.evaluateLogic(detail,detail.getDisplayLogic()))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
int index =0;
|
int index =0;
|
||||||
int rowDetail=0;
|
int rowDetail=0;
|
||||||
int record_Id = 0;
|
int record_Id = 0;
|
||||||
boolean isActiveRow = true;
|
// boolean isActiveRow = true;
|
||||||
gridTab.setCurrentRow(idxrow);
|
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());
|
||||||
|
@ -241,16 +241,16 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
value = resolveValue(gridTab, table, column, idxrow, headName);
|
value = resolveValue(gridTab, table, column, idxrow, headName);
|
||||||
}
|
}
|
||||||
//Ignore row
|
//Ignore row
|
||||||
if("IsActive".equals(headName) && value!=null && Boolean.valueOf((Boolean)value)==false){
|
// if("IsActive".equals(headName) && value!=null && Boolean.valueOf((Boolean)value)==false){
|
||||||
isActiveRow=false;
|
// isActiveRow=false;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
row.put(headName,value);
|
row.put(headName,value);
|
||||||
idxfld++;
|
idxfld++;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if(!isActiveRow)
|
// if(!isActiveRow)
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
if(specialHDispayType > 0 && record_Id > 0){
|
if(specialHDispayType > 0 && record_Id > 0){
|
||||||
switch(specialHDispayType) {
|
switch(specialHDispayType) {
|
||||||
|
@ -336,8 +336,8 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
if (tab.isReadOnly())
|
if (tab.isReadOnly())
|
||||||
result = Msg.getMsg(Env.getCtx(),"FieldIsReadOnly", new Object[] {gridTab.getName()});
|
result = Msg.getMsg(Env.getCtx(),"FieldIsReadOnly", new Object[] {gridTab.getName()});
|
||||||
|
|
||||||
if (gridTab.getTableName().endsWith("_Acct"))
|
// if (gridTab.getTableName().endsWith("_Acct"))
|
||||||
result = "Accounting Tab are not exported by default: "+ gridTab.getName();
|
// result = "Accounting Tab are not exported by default: "+ gridTab.getName();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -354,10 +354,10 @@ 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, parentGrid, currentParentIndex);
|
//String whereCla = getWhereClause (childTab ,record_Id ,keyColumnParent);
|
||||||
//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) {
|
||||||
int specialRecordId = 0;
|
int specialRecordId = 0;
|
||||||
for(GridField field : childTabDetail.getValue()){
|
for(GridField field : childTabDetail.getValue()){
|
||||||
|
@ -374,19 +374,19 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
String headName = headArray.get(headArray.indexOf(childTab.getTableName()+">"+resolveColumnName(tableDetail,column)));
|
String headName = headArray.get(headArray.indexOf(childTab.getTableName()+">"+resolveColumnName(tableDetail,column)));
|
||||||
value = resolveValue(childTab, MTable.get(Env.getCtx(),childTab.getTableName()), column, currentDetRow, headName.substring(headName.indexOf(">")+ 1,headName.length()));
|
value = resolveValue(childTab, MTable.get(Env.getCtx(),childTab.getTableName()), column, currentDetRow, headName.substring(headName.indexOf(">")+ 1,headName.length()));
|
||||||
|
|
||||||
if(DisplayType.Payment == field.getDisplayType())
|
if(DisplayType.Payment == field.getDisplayType() && value != null)
|
||||||
value = MRefList.getListName(Env.getCtx(),REFERENCE_PAYMENTRULE, value.toString());
|
value = MRefList.getListName(Env.getCtx(),REFERENCE_PAYMENTRULE, value.toString());
|
||||||
|
|
||||||
row.put(headName,value);
|
row.put(headName,value);
|
||||||
if(value!=null)
|
if(value!=null)
|
||||||
hasDetails = true;
|
hasDetails = true;
|
||||||
//Ignore row
|
//Ignore row
|
||||||
if(headName.contains("IsActive")&& value!=null && Boolean.valueOf((Boolean)value)==false){
|
// if(headName.contains("IsActive")&& value!=null && Boolean.valueOf((Boolean)value)==false){
|
||||||
isActiveRow=false;
|
// isActiveRow=false;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
if(isActiveRow && specialDetDispayType > 0 && specialRecordId > 0){
|
if(/* isActiveRow && */ specialDetDispayType > 0 && specialRecordId > 0){
|
||||||
MLocation address = new MLocation (Env.getCtx(),specialRecordId,null);
|
MLocation address = new MLocation (Env.getCtx(),specialRecordId,null);
|
||||||
for(String specialHeader:resolveSpecialColumnName(specialDetDispayType)){
|
for(String specialHeader:resolveSpecialColumnName(specialDetDispayType)){
|
||||||
String columnName = specialHeader.substring(specialHeader.indexOf(">")+1,specialHeader.length());
|
String columnName = specialHeader.substring(specialHeader.indexOf(">")+1,specialHeader.length());
|
||||||
|
@ -411,7 +411,7 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isActiveRow)
|
// if(isActiveRow)
|
||||||
activeRow.putAll(row);
|
activeRow.putAll(row);
|
||||||
}
|
}
|
||||||
if (hasDetails)
|
if (hasDetails)
|
||||||
|
@ -495,6 +495,8 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
name.append("[DocumentNo]");
|
name.append("[DocumentNo]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (DisplayType.Account == column.getAD_Reference_ID()) {
|
||||||
|
name.append("[Combination]");
|
||||||
}
|
}
|
||||||
return name.toString();
|
return name.toString();
|
||||||
}
|
}
|
||||||
|
@ -588,11 +590,11 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
if (DisplayType.Button == MColumn.get(Env.getCtx(),field.getAD_Column_ID()).getAD_Reference_ID())
|
if (DisplayType.Button == MColumn.get(Env.getCtx(),field.getAD_Column_ID()).getAD_Reference_ID())
|
||||||
continue;
|
continue;
|
||||||
if ( field.isVirtualColumn()
|
if ( field.isVirtualColumn()
|
||||||
|| field.isEncrypted()
|
|| field.isEncrypted()
|
||||||
|| field.isEncryptedColumn()
|
|| field.isEncryptedColumn()
|
||||||
|| !(field.isDisplayed() || field.isDisplayedGrid()))
|
|| !(field.isDisplayed() || field.isDisplayedGrid()))
|
||||||
continue;
|
continue;
|
||||||
if (field.isParentValue() || (!field.isReadOnly() && field.isDisplayedGrid()))
|
if (field.isParentValue() || (!field.isReadOnly() && field.isDisplayedGrid()) || field.isParentColumn())
|
||||||
gridFieldList.add(field);
|
gridFieldList.add(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
@ -905,16 +906,20 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
String columnName = header.get(i);
|
String columnName = header.get(i);
|
||||||
Object value = tmpRow.get(i);
|
Object value = tmpRow.get(i);
|
||||||
//Validate Address
|
//Validate Address
|
||||||
if(header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID)) && !isAddressValidated){
|
if (!"C_Location".equals(gridTab.getTableName()))
|
||||||
StringBuilder specialColumns = new StringBuilder();
|
{
|
||||||
specialColumns = validateSpecialFields(gridTab,header,tmpRow,i,"C_Location_ID");
|
//Validate Address
|
||||||
isAddressValidated = true;
|
if(header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID)) && !isAddressValidated){
|
||||||
if(specialColumns==null)
|
StringBuilder specialColumns = new StringBuilder();
|
||||||
continue;
|
specialColumns = validateSpecialFields(gridTab,header,tmpRow,i,"C_Location_ID");
|
||||||
else
|
isAddressValidated = true;
|
||||||
return specialColumns;
|
if(specialColumns==null)
|
||||||
}else if (header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID)) && isAddressValidated){
|
continue;
|
||||||
continue;
|
else
|
||||||
|
return specialColumns;
|
||||||
|
}else if (header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID)) && isAddressValidated){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(value!=null)
|
if(value!=null)
|
||||||
|
@ -1067,7 +1072,7 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
if(isForeing)
|
if(isForeing)
|
||||||
foreignColumn = header.get(i).substring(header.get(i).indexOf("[")+1,header.get(i).indexOf("]"));
|
foreignColumn = header.get(i).substring(header.get(i).indexOf("[")+1,header.get(i).indexOf("]"));
|
||||||
|
|
||||||
if(header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID))){
|
if(!"C_Location".equals(gridTab.getTableName()) && header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID))){
|
||||||
|
|
||||||
if(address == null){
|
if(address == null){
|
||||||
if(isInsertMode()){
|
if(isInsertMode()){
|
||||||
|
@ -1173,7 +1178,7 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int id = resolveForeign(foreignTable, foreignColumn, value,field,trx);
|
int id = resolveForeign(foreignTable, foreignColumn, value,field,trx);
|
||||||
if (id < 0)
|
if(id < 0)
|
||||||
return Msg.getMsg(Env.getCtx(),id==-2?"ForeignMultipleResolved":"ForeignNotResolved",new Object[]{header.get(i),value});
|
return Msg.getMsg(Env.getCtx(),id==-2?"ForeignMultipleResolved":"ForeignNotResolved",new Object[]{header.get(i),value});
|
||||||
|
|
||||||
setValue = id;
|
setValue = id;
|
||||||
|
@ -1219,6 +1224,16 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
}else{
|
}else{
|
||||||
return Msg.getMsg(Env.getCtx(),"Invalid") + " Column ["+column.getColumnName()+"]";
|
return Msg.getMsg(Env.getCtx(),"Invalid") + " Column ["+column.getColumnName()+"]";
|
||||||
}
|
}
|
||||||
|
} else if (DisplayType.isNumeric(field.getDisplayType()) || DisplayType.isID(field.getDisplayType())) {
|
||||||
|
if (columnName.endsWith("_ID")) {
|
||||||
|
if (!(value instanceof Integer)) {
|
||||||
|
Integer idValue = Integer.valueOf(value.toString());
|
||||||
|
value = idValue;
|
||||||
|
}
|
||||||
|
} else if (!(value instanceof BigDecimal)) {
|
||||||
|
BigDecimal decValue = new BigDecimal(value.toString());
|
||||||
|
value = decValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setValue = value;
|
setValue = value;
|
||||||
isThereRow =true;
|
isThereRow =true;
|
||||||
|
@ -1349,7 +1364,7 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
//Process columnKeys + Foreign to add restrictions.
|
//Process columnKeys + Foreign to add restrictions.
|
||||||
for (int i = startindx ; i < endindx + 1 ; i++){
|
for (int i = startindx ; i < endindx + 1 ; i++){
|
||||||
boolean isKeyColumn = header.get(i).indexOf("/") > 0 && ( header.get(i).endsWith("K") || header.get(i).endsWith("KT"));
|
boolean isKeyColumn = header.get(i).indexOf("/") > 0 && ( header.get(i).endsWith("K") || header.get(i).endsWith("KT"));
|
||||||
if(isKeyColumn && !header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID))){
|
if(isKeyColumn && ("C_Location".equals(gridTab.getTableName()) || !header.get(i).contains(MTable.getTableName(Env.getCtx(),MLocation.Table_ID)))){
|
||||||
boolean isForeing = header.get(i).indexOf("[") > 0 && header.get(i).indexOf("]")>0;
|
boolean isForeing = header.get(i).indexOf("[") > 0 && header.get(i).indexOf("]")>0;
|
||||||
boolean isDetail = header.get(i).indexOf(">") > 0;
|
boolean isDetail = header.get(i).indexOf(">") > 0;
|
||||||
columnwithKey = getColumnName(isKeyColumn,isForeing,isDetail,header.get(i));
|
columnwithKey = getColumnName(isKeyColumn,isForeing,isDetail,header.get(i));
|
||||||
|
|
Loading…
Reference in New Issue