Handle Transaction Rollback
This commit is contained in:
parent
2904e4a95c
commit
835ff26f95
|
|
@ -2,3 +2,4 @@
|
|||
syntax: glob
|
||||
*.class
|
||||
andromeida.midsuit.project/bin/andromedia/midsuit/factory/*.rej
|
||||
andromeida.midsuit.project/src/andromedia/midsuit/factory/*.orig
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import org.compiere.model.MRequisition;
|
|||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
import andromedia.midsuit.model.MID_MRequisitionTrx;
|
||||
|
||||
|
|
@ -40,48 +41,63 @@ public class MID_CompleteRecord extends SvrProcess{
|
|||
switch(tableName){
|
||||
case "C_Order" :
|
||||
MOrder o = new MOrder(getCtx(), record_ID, get_TrxName());
|
||||
if(!o.processIt(DocAct))
|
||||
throw new AdempiereException( "Failed to Complete Document !!!");
|
||||
if(!o.processIt(DocAct)) {
|
||||
Trx.get(get_TrxName(), false).rollback();
|
||||
throw new AdempiereException(o.getProcessMsg());
|
||||
}else
|
||||
o.saveEx();
|
||||
break;
|
||||
case "M_InOut" :
|
||||
MInOut io = new MInOut(getCtx(), record_ID, get_TrxName());
|
||||
if(!io.processIt(DocAct))
|
||||
throw new AdempiereException( "Failed to Complete Document !!!");
|
||||
if(!io.processIt(DocAct)) {
|
||||
Trx.get(get_TrxName(), false).rollback();
|
||||
throw new AdempiereException(io.getProcessMsg());
|
||||
}else
|
||||
io.saveEx();
|
||||
break;
|
||||
case "C_Invoice" :
|
||||
MInvoice inv = new MInvoice(getCtx(), record_ID, get_TrxName());
|
||||
if(!inv.processIt(DocAct))
|
||||
throw new AdempiereException( "Failed to Complete Document !!!");
|
||||
if(!inv.processIt(DocAct)) {
|
||||
Trx.get(get_TrxName(), false).rollback();
|
||||
throw new AdempiereException(inv.getProcessMsg());
|
||||
}else
|
||||
inv.saveEx();
|
||||
break;
|
||||
case "C_Payment" :
|
||||
MPayment p = new MPayment(getCtx(), record_ID, get_TrxName());
|
||||
if(!p.processIt(DocAct))
|
||||
throw new AdempiereException( "Failed to Complete Document !!!");
|
||||
if(!p.processIt(DocAct)) {
|
||||
Trx.get(get_TrxName(), false).rollback();
|
||||
throw new AdempiereException(p.getProcessMsg());
|
||||
}else
|
||||
p.saveEx();
|
||||
break;
|
||||
case "MID_Requisition" :
|
||||
MID_MRequisitionTrx rs = new MID_MRequisitionTrx(getCtx(), record_ID, get_TrxName());
|
||||
if(!rs.processIt(DocAct))
|
||||
throw new AdempiereException( "Failed to Complete Document !!!");
|
||||
if(!rs.processIt(DocAct)) {
|
||||
Trx.get(get_TrxName(), false).rollback();
|
||||
throw new AdempiereException(rs.getProcessMsg());
|
||||
}else
|
||||
rs.saveEx();
|
||||
break;
|
||||
case "M_Requisition" :
|
||||
MRequisition req = new MRequisition(getCtx(), record_ID, get_TrxName());
|
||||
if(!req.processIt(DocAct))
|
||||
throw new AdempiereException( "Failed to Complete Document !!!");
|
||||
if(!req.processIt(DocAct)) {
|
||||
Trx.get(get_TrxName(), false).rollback();
|
||||
throw new AdempiereException(req.getProcessMsg());
|
||||
}else
|
||||
req.saveEx();
|
||||
break;
|
||||
case "M_RMA" :
|
||||
MRMA rma = new MRMA(getCtx(), record_ID, get_TrxName());
|
||||
if(!rma.processIt(DocAct))
|
||||
throw new AdempiereException( "Failed to Complete Document !!!");
|
||||
if(!rma.processIt(DocAct)) {
|
||||
Trx.get(get_TrxName(), false).rollback();
|
||||
throw new AdempiereException(rma.getProcessMsg());
|
||||
}
|
||||
else
|
||||
rma.saveEx();
|
||||
break;
|
||||
|
||||
default : throw new AdempiereException( "Failed to Complete Document !!!");
|
||||
default : throw new AdempiereException( "Document For Table "+tableName+" Not Found !!!");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,10 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
}
|
||||
if(!po.save(get_TrxName()))
|
||||
throw new AdempiereException(po.get_Logger().retrieveError().getName());
|
||||
|
||||
else {
|
||||
po.saveEx();
|
||||
return String.valueOf(po.get_ValueAsInt(tableName+"_ID"));
|
||||
}
|
||||
// if(po.get_Value("DocAction")!=null) {
|
||||
// Class<?> clazz = getClass(tableName);
|
||||
// if (clazz == null)
|
||||
|
|
@ -177,10 +180,10 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
// }
|
||||
// }
|
||||
|
||||
if(Trx.get(get_TrxName(), false).commit()){
|
||||
return String.valueOf(po.get_ID());
|
||||
}else
|
||||
throw new AdempiereException(po.get_Logger().retrieveError().getName());
|
||||
// if(Trx.get(get_TrxName(), false).commit()){
|
||||
// return String.valueOf(po.get_ID());
|
||||
// }else
|
||||
// throw new AdempiereException(po.get_Logger().retrieveError().getName());
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue