Search in sources :

Example 1 with StandardResponseDocument

use of org.idempiere.adInterface.x10.StandardResponseDocument in project idempiere by idempiere.

the class ModelADServiceImpl method updateData.

public StandardResponseDocument updateData(ModelCRUDRequestDocument req) {
    Trx trx = null;
    try {
        getCompiereService().connect();
        StandardResponseDocument ret = StandardResponseDocument.Factory.newInstance();
        StandardResponse resp = ret.addNewStandardResponse();
        ModelCRUD modelCRUD = req.getModelCRUDRequest().getModelCRUD();
        String serviceType = modelCRUD.getServiceType();
        ADLoginRequest reqlogin = req.getModelCRUDRequest().getADLoginRequest();
        String err = login(reqlogin, webServiceName, "updateData", serviceType);
        if (err != null && err.length() > 0) {
            resp.setError(err);
            resp.setIsError(true);
            return ret;
        }
        // Validate parameters vs service type
        try {
            validateCRUD(modelCRUD);
        } catch (IdempiereServiceFault e) {
            resp.setError(e.getMessage());
            resp.setIsError(true);
            return ret;
        }
        String tableName = modelCRUD.getTableName();
        int recordID = modelCRUD.getRecordID();
        resp.setRecordID(recordID);
        CompiereService m_cs = getCompiereService();
        MWebServiceType m_webservicetype = getWebServiceType();
        Properties ctx = m_cs.getCtx();
        // start a trx
        String trxName = localTrxName;
        if (trxName == null) {
            trxName = Trx.createTrxName("ws_modelCreateData");
            manageTrx = true;
        }
        trx = Trx.get(trxName, true);
        if (manageTrx)
            trx.setDisplayName(getClass().getName() + "_" + webServiceName + "_updateData");
        // 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);
        POInfo poinfo = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
        if (po.get_ColumnIndex("Processed") >= 0 && po.get_ValueAsBoolean("Processed")) {
            resp.setError("Record is processed and can not be updated");
            resp.setIsError(true);
            return ret;
        }
        DataRow dr = modelCRUD.getDataRow();
        StandardResponseDocument retResp = scanFields(dr.getFieldArray(), m_webservicetype, po, poinfo, trx, resp, ret);
        if (retResp != null)
            return retResp;
        if (!po.validForeignKeys())
            return rollbackAndSetError(trx, resp, ret, true, "Cannot save record in " + tableName + ": " + CLogger.retrieveErrorString("no log message"));
        if (!po.save())
            return rollbackAndSetError(trx, resp, ret, true, "Cannot save record in " + tableName + ": " + CLogger.retrieveErrorString("no log message"));
        // close the trx
        if (manageTrx && !trx.commit())
            return rollbackAndSetError(trx, resp, ret, true, "Cannot commit transaction after create record " + recordID + " in " + tableName);
        setOuputFields(resp, m_webservicetype, po, poinfo);
        return ret;
    } finally {
        if (manageTrx && trx != null)
            trx.close();
        getCompiereService().disconnect();
    }
}
Also used : ADLoginRequest(org.idempiere.adInterface.x10.ADLoginRequest) MWebServiceType(org.idempiere.webservices.model.MWebServiceType) StandardResponse(org.idempiere.adInterface.x10.StandardResponse) IdempiereServiceFault(org.idempiere.webservices.fault.IdempiereServiceFault) Properties(java.util.Properties) DataRow(org.idempiere.adInterface.x10.DataRow) StandardResponseDocument(org.idempiere.adInterface.x10.StandardResponseDocument) POInfo(org.compiere.model.POInfo) MTable(org.compiere.model.MTable) ModelCRUD(org.idempiere.adInterface.x10.ModelCRUD) Trx(org.compiere.util.Trx) PO(org.compiere.model.PO)

Example 2 with StandardResponseDocument

use of org.idempiere.adInterface.x10.StandardResponseDocument in project idempiere by idempiere.

the class ModelADServiceImpl method queryData.

public WindowTabDataDocument queryData(ModelCRUDRequestDocument req) {
    Trx trx = null;
    try {
        getCompiereService().connect();
        CompiereService m_cs = getCompiereService();
        WindowTabDataDocument ret = WindowTabDataDocument.Factory.newInstance();
        WindowTabData resp = ret.addNewWindowTabData();
        ModelCRUD modelCRUD = req.getModelCRUDRequest().getModelCRUD();
        String serviceType = modelCRUD.getServiceType();
        ADLoginRequest reqlogin = req.getModelCRUDRequest().getADLoginRequest();
        String err = login(reqlogin, webServiceName, "queryData", serviceType);
        if (err != null && err.length() > 0) {
            resp.setError(err);
            return ret;
        }
        // Validate parameters vs service type
        validateCRUD(modelCRUD);
        Properties ctx = m_cs.getCtx();
        String tableName = modelCRUD.getTableName();
        Map<String, Object> reqCtx = getRequestCtx();
        MWebServiceType m_webservicetype = getWebServiceType();
        // get the PO for the tablename and record ID
        MTable table = MTable.get(ctx, tableName);
        if (table == null)
            throw new IdempiereServiceFault("Web service type " + m_webservicetype.getValue() + ": table " + tableName + " not found", new QName("queryData"));
        int roleid = reqlogin.getRoleID();
        MRole role = MRole.get(ctx, roleid);
        // start a trx
        String trxName = localTrxName;
        if (trxName == null) {
            trxName = Trx.createTrxName("ws_modelQueryData");
            manageTrx = true;
        }
        trx = Trx.get(trxName, true);
        if (manageTrx)
            trx.setDisplayName(getClass().getName() + "_" + webServiceName + "_queryData");
        StringBuilder sqlBuilder = new StringBuilder(role.addAccessSQL("SELECT * FROM " + tableName, tableName, true, MRole.SQL_RO));
        ArrayList<Object> sqlParaList = new ArrayList<Object>();
        PO holderPo = table.getPO(0, trxName);
        POInfo poinfo = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
        if (modelCRUD.getDataRow() != null) {
            DataRow dr = modelCRUD.getDataRow();
            DataField[] fields = dr.getFieldArray();
            StandardResponseDocument stdRet = StandardResponseDocument.Factory.newInstance();
            StandardResponse stdResp = stdRet.addNewStandardResponse();
            StandardResponseDocument retResp = invokeWSValidator(m_webservicetype, IWSValidator.TIMING_BEFORE_PARSE, holderPo, fields, trx, reqCtx, stdResp, stdRet);
            if (retResp != null) {
                throw new IdempiereServiceFault(retResp.getStandardResponse().getError(), new QName("queryData"));
            }
            retResp = scanFields(fields, m_webservicetype, holderPo, poinfo, trx, stdResp, stdRet);
            if (retResp != null) {
                throw new IdempiereServiceFault(retResp.getStandardResponse().getError(), new QName("queryData"));
            }
            for (DataField field : modelCRUD.getDataRow().getFieldArray()) {
                if (m_webservicetype.isInputColumnNameAllowed(field.getColumn())) {
                    // Jan Thielemann Solution for query using the sentence like
                    X_WS_WebServiceFieldInput inputField = m_webservicetype.getFieldInput(field.getColumn());
                    I_AD_Column col = inputField.getAD_Column();
                    String sqlType = DisplayType.getSQLDataType(col.getAD_Reference_ID(), col.getColumnName(), col.getFieldLength());
                    if (sqlType.contains("CHAR"))
                        sqlBuilder.append(" AND ").append(field.getColumn()).append(" LIKE ?");
                    else
                        sqlBuilder.append(" AND ").append(field.getColumn()).append("=?");
                    sqlParaList.add(holderPo.get_Value(field.getColumn()));
                // End Jan Thielemann Solution for query using the sentence like
                } else if (m_webservicetype.getFieldInput(field.getColumn()) == null) {
                    // If not even ctx variable column
                    throw new IdempiereServiceFault("Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " not allowed", new QName("queryData"));
                }
            }
        }
        if (modelCRUD.getFilter() != null && modelCRUD.getFilter().length() > 0) {
            String sql = parseSQL(" WHERE " + modelCRUD.getFilter(), sqlParaList, holderPo, poinfo, reqCtx);
            sqlBuilder.append(" AND ").append(sql.substring(6));
        }
        int cnt = 0;
        int rowCnt = 0;
        int offset = modelCRUD.getOffset();
        int limit = modelCRUD.getLimit();
        PreparedStatement pstmtquery = null;
        ResultSet rsquery = null;
        try {
            pstmtquery = DB.prepareStatement(sqlBuilder.toString(), trxName);
            DB.setParameters(pstmtquery, sqlParaList);
            rsquery = pstmtquery.executeQuery();
            // Angelo Dabala' (genied) must create just one DataSet, moved outside of the while loop
            DataSet ds = resp.addNewDataSet();
            while (rsquery.next()) {
                cnt++;
                if ((offset >= cnt) || (limit > 0 && offset + limit < cnt))
                    continue;
                rowCnt++;
                DataRow dr = ds.addNewDataRow();
                for (int i = 0; i < poinfo.getColumnCount(); i++) {
                    String columnName = poinfo.getColumnName(i);
                    if (m_webservicetype.isOutputColumnNameAllowed(columnName)) {
                        DataField dfid = dr.addNewField();
                        dfid.setColumn(columnName);
                        if (rsquery.getObject(columnName) instanceof byte[])
                            dfid.setVal(new String(Base64.encodeBase64(rsquery.getBytes(columnName))));
                        else
                            dfid.setVal(rsquery.getString(columnName));
                    }
                }
            }
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
            throw new IdempiereServiceFault(e);
        } finally {
            DB.close(rsquery, pstmtquery);
            rsquery = null;
            pstmtquery = null;
        }
        resp.setSuccess(true);
        resp.setRowCount(rowCnt);
        resp.setNumRows(rowCnt);
        resp.setTotalRows(cnt);
        resp.setStartRow(offset);
        return ret;
    } finally {
        if (manageTrx && trx != null)
            trx.close();
        getCompiereService().disconnect();
    }
}
Also used : ADLoginRequest(org.idempiere.adInterface.x10.ADLoginRequest) MWebServiceType(org.idempiere.webservices.model.MWebServiceType) DataSet(org.idempiere.adInterface.x10.DataSet) MRole(org.compiere.model.MRole) ArrayList(java.util.ArrayList) Properties(java.util.Properties) DataRow(org.idempiere.adInterface.x10.DataRow) StandardResponseDocument(org.idempiere.adInterface.x10.StandardResponseDocument) WindowTabDataDocument(org.idempiere.adInterface.x10.WindowTabDataDocument) ModelCRUD(org.idempiere.adInterface.x10.ModelCRUD) ResultSet(java.sql.ResultSet) Trx(org.compiere.util.Trx) X_WS_WebServiceFieldInput(org.idempiere.webservices.model.X_WS_WebServiceFieldInput) StandardResponse(org.idempiere.adInterface.x10.StandardResponse) IdempiereServiceFault(org.idempiere.webservices.fault.IdempiereServiceFault) QName(javax.xml.namespace.QName) I_AD_Column(org.compiere.model.I_AD_Column) WindowTabData(org.idempiere.adInterface.x10.WindowTabData) PreparedStatement(java.sql.PreparedStatement) SQLException(java.sql.SQLException) XmlValueOutOfRangeException(org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException) POInfo(org.compiere.model.POInfo) MTable(org.compiere.model.MTable) DataField(org.idempiere.adInterface.x10.DataField) PO(org.compiere.model.PO)

Example 3 with StandardResponseDocument

use of org.idempiere.adInterface.x10.StandardResponseDocument in project idempiere by idempiere.

the class ModelADServiceImpl method deleteData.

// getList
public StandardResponseDocument deleteData(ModelCRUDRequestDocument req) {
    Trx trx = null;
    try {
        getCompiereService().connect();
        StandardResponseDocument ret = StandardResponseDocument.Factory.newInstance();
        StandardResponse resp = ret.addNewStandardResponse();
        ModelCRUD modelCRUD = req.getModelCRUDRequest().getModelCRUD();
        String serviceType = modelCRUD.getServiceType();
        ADLoginRequest reqlogin = req.getModelCRUDRequest().getADLoginRequest();
        String err = login(reqlogin, webServiceName, "deleteData", serviceType);
        if (err != null && err.length() > 0) {
            resp.setError(err);
            resp.setIsError(true);
            return ret;
        }
        // Validate parameters vs service type
        try {
            validateCRUD(modelCRUD);
        } catch (IdempiereServiceFault e) {
            resp.setError(e.getMessage());
            resp.setIsError(true);
            return ret;
        }
        String tableName = modelCRUD.getTableName();
        int recordID = modelCRUD.getRecordID();
        resp.setRecordID(recordID);
        CompiereService m_cs = getCompiereService();
        Properties ctx = m_cs.getCtx();
        // start a trx
        String trxName = localTrxName;
        if (trxName == null) {
            trxName = Trx.createTrxName("ws_modelCreateData");
            manageTrx = true;
        }
        trx = Trx.get(trxName, true);
        if (manageTrx)
            trx.setDisplayName(getClass().getName() + "_" + webServiceName + "_deleteData");
        // 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);
        if (!po.delete(false))
            return rollbackAndSetError(trx, resp, ret, true, "Cannot delete record " + recordID + " in " + tableName + ": " + CLogger.retrieveErrorString("no log message"));
        // close the trx
        if (manageTrx && !trx.commit())
            return rollbackAndSetError(trx, resp, ret, true, "Cannot commit transaction after delete record " + recordID + " in " + tableName);
        return ret;
    } finally {
        if (manageTrx && trx != null)
            trx.close();
        getCompiereService().disconnect();
    }
}
Also used : ADLoginRequest(org.idempiere.adInterface.x10.ADLoginRequest) MTable(org.compiere.model.MTable) StandardResponse(org.idempiere.adInterface.x10.StandardResponse) ModelCRUD(org.idempiere.adInterface.x10.ModelCRUD) IdempiereServiceFault(org.idempiere.webservices.fault.IdempiereServiceFault) Trx(org.compiere.util.Trx) Properties(java.util.Properties) StandardResponseDocument(org.idempiere.adInterface.x10.StandardResponseDocument) PO(org.compiere.model.PO)

Example 4 with StandardResponseDocument

use of org.idempiere.adInterface.x10.StandardResponseDocument in project idempiere by idempiere.

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) {
    Trx trx = null;
    try {
        getCompiereService().connect();
        StandardResponseDocument ret = StandardResponseDocument.Factory.newInstance();
        StandardResponse resp = ret.addNewStandardResponse();
        ModelSetDocAction modelSetDocAction = req.getModelSetDocActionRequest().getModelSetDocAction();
        String serviceType = modelSetDocAction.getServiceType();
        ADLoginRequest reqlogin = req.getModelSetDocActionRequest().getADLoginRequest();
        CompiereService m_cs = getCompiereService();
        String err = login(reqlogin, webServiceName, "setDocAction", serviceType);
        if (err != null && err.length() > 0) {
            resp.setError(err);
            resp.setIsError(true);
            return ret;
        }
        try {
            // Validate parameters
            modelSetDocAction.setTableName(validateParameter("tableName", modelSetDocAction.getTableName()));
            modelSetDocAction.setRecordID(validateParameter("recordID", modelSetDocAction.getRecordID()));
            modelSetDocAction.setDocAction(validateParameter("docAction", modelSetDocAction.getDocAction()));
        } catch (IdempiereServiceFault e) {
            resp.setError(e.getMessage());
            resp.setIsError(true);
            return ret;
        }
        Properties ctx = m_cs.getCtx();
        // start a trx
        String trxName = localTrxName;
        if (trxName == null) {
            trxName = Trx.createTrxName("ws_modelSetDocAction");
            manageTrx = true;
        }
        trx = Trx.get(trxName, true);
        if (manageTrx)
            trx.setDisplayName(getClass().getName() + "_" + webServiceName + "_setDocAction");
        Map<String, Object> requestCtx = getRequestCtx();
        String tableName = modelSetDocAction.getTableName();
        String recordIDVar = modelSetDocAction.getRecordIDVariable();
        int recordID = modelSetDocAction.getRecordID();
        if (recordIDVar != null && recordIDVar.startsWith("@")) {
            Integer retVal = (Integer) parseVariable(recordIDVar, null, null, requestCtx);
            if (retVal == null) {
                return rollbackAndSetError(trx, resp, ret, true, "Cannot resolve variable: " + recordIDVar);
            }
            recordID = retVal;
        }
        String docAction = modelSetDocAction.getDocAction();
        resp.setRecordID(recordID);
        // 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"));
        MWebServiceType m_webservicetype = getWebServiceType();
        // For passing action to validators
        requestCtx.put("DocAction", docAction);
        // Fire Event
        StandardResponseDocument retResp = invokeWSValidator(m_webservicetype, IWSValidator.TIMING_BEFORE_PARSE, po, null, trx, requestCtx, resp, ret);
        if (retResp != null)
            return retResp;
        // call process it
        try {
            if (!((org.compiere.process.DocAction) po).processIt(docAction))
                return rollbackAndSetError(trx, resp, ret, true, Msg.parseTranslation(ctx, "@FailedProcessingDocument@: " + ((org.compiere.process.DocAction) po).getProcessMsg()));
        } catch (Exception e) {
            return rollbackAndSetError(trx, resp, ret, true, e.toString());
        }
        // Fire Event
        retResp = invokeWSValidator(m_webservicetype, IWSValidator.TIMING_BEFORE_SAVE, po, null, trx, requestCtx, resp, ret);
        if (retResp != null)
            return retResp;
        // close the trx
        if (!po.save())
            return rollbackAndSetError(trx, resp, ret, true, "Cannot save after set docAction: " + CLogger.retrieveErrorString("no log message"));
        // Fire Event
        retResp = invokeWSValidator(m_webservicetype, IWSValidator.TIMING_AFTER_SAVE, po, null, trx, requestCtx, resp, ret);
        if (retResp != null)
            return retResp;
        if (manageTrx && !trx.commit())
            return rollbackAndSetError(trx, resp, ret, true, "Cannot commit after docAction");
        // resp.setError("");
        resp.setIsError(false);
        POInfo poinfo = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
        setOuputFields(resp, m_webservicetype, po, poinfo);
        return ret;
    } finally {
        if (manageTrx && trx != null)
            trx.close();
        getCompiereService().disconnect();
    }
}
Also used : ADLoginRequest(org.idempiere.adInterface.x10.ADLoginRequest) MWebServiceType(org.idempiere.webservices.model.MWebServiceType) ModelSetDocAction(org.idempiere.adInterface.x10.ModelSetDocAction) StandardResponse(org.idempiere.adInterface.x10.StandardResponse) IdempiereServiceFault(org.idempiere.webservices.fault.IdempiereServiceFault) Properties(java.util.Properties) ModelSetDocAction(org.idempiere.adInterface.x10.ModelSetDocAction) SQLException(java.sql.SQLException) XmlValueOutOfRangeException(org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException) StandardResponseDocument(org.idempiere.adInterface.x10.StandardResponseDocument) POInfo(org.compiere.model.POInfo) MTable(org.compiere.model.MTable) Trx(org.compiere.util.Trx) PO(org.compiere.model.PO)

Example 5 with StandardResponseDocument

use of org.idempiere.adInterface.x10.StandardResponseDocument in project idempiere by idempiere.

the class CompositeServiceImpl method performOperations.

/**
 * Perform operation
 * @param trx
 * @param ops
 * @param modelADService
 * @param compResp
 * @param respAggregator
 * @param reqlogin
 * @return isError
 */
private boolean performOperations(Trx trx, Operation[] ops, ModelADServiceImpl modelADService, CompositeResponse compResp, ArrayList<StandardResponse> respAggregator, ADLoginRequest reqlogin) {
    for (Operation operation : ops) {
        if (operation.getPreCommit()) {
            if (!commitTrx(trx, compResp, respAggregator, "Cannot commit before Operation", true)) {
                return false;
            }
        }
        modelADService.setManageTrx(false);
        TargetPort.Enum portEnum = operation.getTargetPort();
        StandardResponseDocument respDoc = null;
        if (portEnum == TargetPort.CREATE_DATA) {
            ModelCRUDRequestDocument wrapperDoc = getWrappedCRUD(operation, reqlogin);
            if (wrapperDoc == null) {
                rollbackAndSetError(trx, compResp, respAggregator, "Operation createData must required ModelCRUD");
                return false;
            } else {
                respDoc = modelADService.createData(wrapperDoc);
            }
        } else if (portEnum == TargetPort.DELETE_DATA) {
            ModelCRUDRequestDocument wrapperDoc = getWrappedCRUD(operation, reqlogin);
            if (wrapperDoc == null) {
                rollbackAndSetError(trx, compResp, respAggregator, "Operation deleteData must required ModelCRUD");
                return false;
            } else {
                respDoc = modelADService.deleteData(wrapperDoc);
            }
        } else if (portEnum == TargetPort.CREATE_UPDATE_DATA) {
            ModelCRUDRequestDocument wrapperDoc = getWrappedCRUD(operation, reqlogin);
            if (wrapperDoc == null) {
                rollbackAndSetError(trx, compResp, respAggregator, "Operation createUpdateData must required ModelCRUD");
                return false;
            } else {
                respDoc = modelADService.createUpdateData(wrapperDoc);
            }
        } else if (portEnum == TargetPort.READ_DATA) {
            ModelCRUDRequestDocument wrapperDoc = getWrappedCRUD(operation, reqlogin);
            if (wrapperDoc == null) {
                // Do not rollback, Continue with consecutive operations
                respDoc = StandardResponseDocument.Factory.newInstance();
                StandardResponse resp = respDoc.addNewStandardResponse();
                resp.setIsError(false);
                resp.setError("Operation readData must required ModelCRUD");
            } else {
                WindowTabDataDocument dataResponse = modelADService.readData(wrapperDoc);
                if (dataResponse != null) {
                    respDoc = StandardResponseDocument.Factory.newInstance();
                    StandardResponse resp = respDoc.addNewStandardResponse();
                    // Do not fail though read is failed
                    resp.setIsError(false);
                    resp.setWindowTabData(dataResponse.getWindowTabData());
                }
            }
        } else if (portEnum == TargetPort.RUN_PROCESS) {
            if (operation.getModelRunProcess() == null) {
                rollbackAndSetError(trx, compResp, respAggregator, "Operation runProcess must required ModelRunProcess");
                return false;
            }
            ModelRunProcessRequestDocument wrapperDoc = ModelRunProcessRequestDocument.Factory.newInstance();
            ModelRunProcessRequest runProcessReq = wrapperDoc.addNewModelRunProcessRequest();
            runProcessReq.setADLoginRequest(reqlogin);
            runProcessReq.setModelRunProcess(operation.getModelRunProcess());
            RunProcessResponseDocument runResponse = modelADService.runProcess(wrapperDoc);
            if (runResponse != null) {
                respDoc = StandardResponseDocument.Factory.newInstance();
                StandardResponse resp = respDoc.addNewStandardResponse();
                resp.setIsError(runResponse.getRunProcessResponse().getIsError());
                resp.setRunProcessResponse(runResponse.getRunProcessResponse());
            }
        } else if (portEnum == TargetPort.SET_DOC_ACTION) {
            if (operation.getModelSetDocAction() == null) {
                rollbackAndSetError(trx, compResp, respAggregator, "Operation updateData must required ModelSetDocAction");
                return false;
            }
            ModelSetDocActionRequestDocument wrapperDoc = ModelSetDocActionRequestDocument.Factory.newInstance();
            ModelSetDocActionRequest actionReq = wrapperDoc.addNewModelSetDocActionRequest();
            actionReq.setADLoginRequest(reqlogin);
            actionReq.setModelSetDocAction(operation.getModelSetDocAction());
            respDoc = modelADService.setDocAction(wrapperDoc);
        } else if (portEnum == TargetPort.UPDATE_DATA) {
            ModelCRUDRequestDocument wrapperDoc = getWrappedCRUD(operation, reqlogin);
            if (wrapperDoc == null) {
                rollbackAndSetError(trx, compResp, respAggregator, "Operation updateData must required ModelCRUD");
                return false;
            } else {
                respDoc = modelADService.updateData(wrapperDoc);
            }
        }
        if (respDoc != null)
            respAggregator.add(respDoc.getStandardResponse());
        if (respDoc != null && respDoc.getStandardResponse().getIsError()) {
            rollbackAndSetError(trx, compResp, respAggregator, null);
            return false;
        }
        if (operation.getPostCommit()) {
            if (!commitTrx(trx, compResp, respAggregator, "Cannot commit after operation", false)) {
                return false;
            }
        }
    }
    return true;
}
Also used : ModelRunProcessRequestDocument(org.idempiere.adInterface.x10.ModelRunProcessRequestDocument) TargetPort(org.idempiere.adInterface.x10.Operation.TargetPort) WindowTabDataDocument(org.idempiere.adInterface.x10.WindowTabDataDocument) StandardResponse(org.idempiere.adInterface.x10.StandardResponse) ModelSetDocActionRequest(org.idempiere.adInterface.x10.ModelSetDocActionRequest) ModelSetDocActionRequestDocument(org.idempiere.adInterface.x10.ModelSetDocActionRequestDocument) ModelRunProcessRequest(org.idempiere.adInterface.x10.ModelRunProcessRequest) Operation(org.idempiere.adInterface.x10.Operation) ModelCRUDRequestDocument(org.idempiere.adInterface.x10.ModelCRUDRequestDocument) StandardResponseDocument(org.idempiere.adInterface.x10.StandardResponseDocument) RunProcessResponseDocument(org.idempiere.adInterface.x10.RunProcessResponseDocument)

Aggregations

StandardResponse (org.idempiere.adInterface.x10.StandardResponse)7 StandardResponseDocument (org.idempiere.adInterface.x10.StandardResponseDocument)7 IdempiereServiceFault (org.idempiere.webservices.fault.IdempiereServiceFault)7 Properties (java.util.Properties)6 MTable (org.compiere.model.MTable)6 PO (org.compiere.model.PO)6 Trx (org.compiere.util.Trx)6 ADLoginRequest (org.idempiere.adInterface.x10.ADLoginRequest)6 POInfo (org.compiere.model.POInfo)5 ModelCRUD (org.idempiere.adInterface.x10.ModelCRUD)5 MWebServiceType (org.idempiere.webservices.model.MWebServiceType)5 DataField (org.idempiere.adInterface.x10.DataField)4 DataRow (org.idempiere.adInterface.x10.DataRow)4 SQLException (java.sql.SQLException)3 XmlValueOutOfRangeException (org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException)3 X_WS_WebServiceFieldInput (org.idempiere.webservices.model.X_WS_WebServiceFieldInput)3 ArrayList (java.util.ArrayList)2 WindowTabDataDocument (org.idempiere.adInterface.x10.WindowTabDataDocument)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1