use of pl.x3E.adInterface.ModelSetDocAction in project adempiere by adempiere.
the class ModelADServiceImpl method setDocAction.
/*
* Model oriented web service to change DocAction for documents, i.e. Complete a Material Receipt
* WARNING!!! This web service complete documents not via workflow, so it jump over any approval step considered in document workflow
* To complete documents using workflow it's better to use the runProcess web service
*/
public StandardResponseDocument setDocAction(ModelSetDocActionRequestDocument req) throws XFireFault {
StandardResponseDocument ret = StandardResponseDocument.Factory.newInstance();
StandardResponse resp = ret.addNewStandardResponse();
ModelSetDocAction modelSetDocAction = req.getModelSetDocActionRequest().getModelSetDocAction();
String serviceType = modelSetDocAction.getServiceType();
ADLoginRequest reqlogin = req.getModelSetDocActionRequest().getADLoginRequest();
String err = modelLogin(reqlogin, webServiceName, "setDocAction", serviceType);
if (err != null && err.length() > 0) {
resp.setError(err);
resp.setIsError(true);
return ret;
}
Properties ctx = m_cs.getM_ctx();
// Validate parameters
modelSetDocAction.setTableName(validateParameter("tableName", modelSetDocAction.getTableName()));
modelSetDocAction.setRecordID(validateParameter("recordID", modelSetDocAction.getRecordID()));
modelSetDocAction.setDocAction(validateParameter("docAction", modelSetDocAction.getDocAction()));
String tableName = modelSetDocAction.getTableName();
int recordID = modelSetDocAction.getRecordID();
String docAction = modelSetDocAction.getDocAction();
resp.setRecordID(recordID);
// start a trx
String trxName = Trx.createTrxName("ws_modelSetDocAction");
Trx trx = Trx.get(trxName, false);
// get the PO for the tablename and record ID
MTable table = MTable.get(ctx, tableName);
if (table == null)
return rollbackAndSetError(trx, resp, ret, true, "No table " + tableName);
PO po = table.getPO(recordID, trxName);
if (po == null)
return rollbackAndSetError(trx, resp, ret, true, "No Record " + recordID + " in " + tableName);
// set explicitly the column DocAction to avoid automatic process of default option
po.set_ValueOfColumn("DocAction", docAction);
if (!po.save())
return rollbackAndSetError(trx, resp, ret, true, "Cannot save before set docAction: " + CLogger.retrieveErrorString("no log message"));
// call process it
try {
if (!((org.compiere.process.DocAction) po).processIt(docAction))
return rollbackAndSetError(trx, resp, ret, true, "Couldn't set docAction: " + ((org.compiere.process.DocAction) po).getProcessMsg());
} catch (Exception e) {
return rollbackAndSetError(trx, resp, ret, true, e.toString());
}
// close the trx
if (!po.save())
return rollbackAndSetError(trx, resp, ret, true, "Cannot save after set docAction: " + CLogger.retrieveErrorString("no log message"));
if (!trx.commit())
return rollbackAndSetError(trx, resp, ret, true, "Cannot commit after docAction");
trx.close();
// resp.setError("");
resp.setIsError(false);
return ret;
}
Aggregations