IDEMPIERE-4373 Bug fixes for CSV Import loader (#174)
close trx in finally block. m_directNullKey interfere with CSV Import Loader due to trx that's not committed yet. insert mode: update window/tab context after save.
This commit is contained in:
parent
dd2b24aafa
commit
d3717bc1fa
|
@ -539,53 +539,52 @@ public class GridTabCSVImporter implements IGridTabImporter
|
|||
* @param childs
|
||||
*/
|
||||
private void manageMasterTrx(GridTab gridTab, List<GridTab> childs){
|
||||
if (trx != null) {
|
||||
try {
|
||||
if (isError()) {
|
||||
gridTab.dataDelete();
|
||||
rollbackTrx();
|
||||
setError(false);
|
||||
} else {
|
||||
boolean commit = false;
|
||||
if (isThereDocAction) {
|
||||
|
||||
if( trx != null ){
|
||||
boolean isError = false;
|
||||
int AD_Process_ID = MColumn.get(Env.getCtx(), gridTab.getField("DocAction").getAD_Column_ID()).getAD_Process_ID();
|
||||
|
||||
if( isError() ) {
|
||||
gridTab.dataDelete();
|
||||
rollbackTrx();
|
||||
setError(false);
|
||||
}else {
|
||||
if (AD_Process_ID > 0){
|
||||
String docResult = processDocAction(masterRecord, AD_Process_ID);
|
||||
|
||||
boolean commit = false;
|
||||
if( isThereDocAction ){
|
||||
if (docResult.contains("error"))
|
||||
isError = true;
|
||||
|
||||
boolean isError = false;
|
||||
int AD_Process_ID = MColumn.get(Env.getCtx(), gridTab.getField("DocAction").getAD_Column_ID()).getAD_Process_ID();
|
||||
rowsTmpResult.set(0,rowsTmpResult.get(0).replace(quoteChar + "\n",docResult + quoteChar + "\n"));
|
||||
} else {
|
||||
throwAdempiereException("No Process found for document action.");
|
||||
}
|
||||
|
||||
if( AD_Process_ID > 0 ){
|
||||
String docResult = processDocAction(masterRecord, AD_Process_ID);
|
||||
|
||||
if(docResult.contains("error"))
|
||||
isError = true;
|
||||
|
||||
rowsTmpResult.set(0,rowsTmpResult.get(0).replace(quoteChar + "\n",docResult + quoteChar + "\n"));
|
||||
}else {
|
||||
throwAdempiereException("No Process found for document action.");
|
||||
}
|
||||
|
||||
if( isError ){
|
||||
gridTab.dataDelete();
|
||||
rollbackTrx();
|
||||
}else{
|
||||
if (isError){
|
||||
gridTab.dataDelete();
|
||||
rollbackTrx();
|
||||
} else {
|
||||
commit = true;
|
||||
}
|
||||
} else {
|
||||
commit = true;
|
||||
}
|
||||
}else{
|
||||
commit = true;
|
||||
}
|
||||
if (commit) {
|
||||
String commitResult = commitTrx();
|
||||
if (isError()) {
|
||||
rowsTmpResult.set(0,rowsTmpResult.get(0).replace(quoteChar + "\n",commitResult + quoteChar + "\n"));
|
||||
gridTab.dataDelete();
|
||||
rollbackTrx();
|
||||
if (commit) {
|
||||
String commitResult = commitTrx();
|
||||
if (isError()) {
|
||||
rowsTmpResult.set(0,rowsTmpResult.get(0).replace(quoteChar + "\n",commitResult + quoteChar + "\n"));
|
||||
gridTab.dataDelete();
|
||||
rollbackTrx();
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
trx.close();
|
||||
trx=null;
|
||||
}
|
||||
|
||||
trx.close();
|
||||
trx=null;
|
||||
}
|
||||
|
||||
}//manageMasterTrx
|
||||
|
@ -687,9 +686,17 @@ public class GridTabCSVImporter implements IGridTabImporter
|
|||
if(currentGridTab.equals(gridTab))
|
||||
masterRecord = po;
|
||||
|
||||
if( isInsertMode() )
|
||||
if( isInsertMode() ) {
|
||||
logMsg = Msg.getMsg(Env.getCtx(), "Inserted") + " " + po.toString();
|
||||
else{
|
||||
if (!Util.isEmpty(currentGridTab.getKeyColumnName()) && currentGridTab.getKeyColumnName().endsWith("_ID")) {
|
||||
int recordId = currentGridTab.getRecord_ID();
|
||||
if (recordId > 0) {
|
||||
if (currentGridTab.getTabNo() == 0)
|
||||
Env.setContext(Env.getCtx(), currentGridTab.getWindowNo(), currentGridTab.getKeyColumnName(), recordId);
|
||||
Env.setContext(Env.getCtx(), currentGridTab.getWindowNo(), currentGridTab.getTabNo(), currentGridTab.getKeyColumnName(), Integer.toString(recordId));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logMsg = Msg.getMsg(Env.getCtx(), "Updated") + " " + po.toString();
|
||||
if( currentGridTab.equals(gridTab) && sortedtTabMapIndexes.size()>1 )
|
||||
currentGridTab.dataRefresh(true);
|
||||
|
|
|
@ -512,8 +512,6 @@ public final class MLookup extends Lookup implements Serializable
|
|||
|
||||
/** Save getDirect last return value */
|
||||
private HashMap<Object,Object> m_lookupDirect = null;
|
||||
/** Save last unsuccessful */
|
||||
private Object m_directNullKey = null;
|
||||
private Future<?> m_loaderFuture;
|
||||
|
||||
public NamePair getDirect (Object key, boolean saveInCache, boolean cacheLocal)
|
||||
|
@ -533,8 +531,6 @@ public final class MLookup extends Lookup implements Serializable
|
|||
// Nothing to query
|
||||
if (key == null || m_info.QueryDirect == null || m_info.QueryDirect.length() == 0)
|
||||
return null;
|
||||
if (key.equals(m_directNullKey))
|
||||
return null;
|
||||
if (key.toString().trim().length() == 0)
|
||||
return null;
|
||||
//
|
||||
|
@ -609,7 +605,6 @@ public final class MLookup extends Lookup implements Serializable
|
|||
}
|
||||
else
|
||||
{
|
||||
m_directNullKey = key;
|
||||
directValue = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue