Search in sources :

Example 1 with StandardResponseDocument

use of pl.x3E.adInterface.StandardResponseDocument in project adempiere by adempiere.

the class ADServiceImpl method setDocAction.

public StandardResponseDocument setDocAction(int WindowNo, int TabNo, int RowNo, String ColName, String docAction) throws XFireFault {
    authenticate(webServiceName, "setDocAction");
    StandardResponseDocument ret = StandardResponseDocument.Factory.newInstance();
    StandardResponse sr = ret.addNewStandardResponse();
    WWindowStatus ws = WWindowStatus.get(WindowStatusMap, WindowNo, true, TabNo, true, RowNo);
    if (ws != null) {
        ws.curTab.setValue("DocAction", docAction);
        boolean result = false;
        if (//slain - do not dispose of error, if not write musiales
        ws.curTab.needSave(true, false)) {
            if (!(result = ws.curTab.dataSave(true)))
                ws.curTab.dataIgnore();
        }
        sr.setIsError(!result);
    } else
        sr.setIsError(true);
    return ret;
}
Also used : StandardResponse(pl.x3E.adInterface.StandardResponse) StandardResponseDocument(pl.x3E.adInterface.StandardResponseDocument)

Example 2 with StandardResponseDocument

use of pl.x3E.adInterface.StandardResponseDocument in project adempiere by adempiere.

the class ModelADServiceImpl method updateData.

public StandardResponseDocument updateData(ModelCRUDRequestDocument req) throws XFireFault {
    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 = modelLogin(reqlogin, webServiceName, "updateData", serviceType);
    if (err != null && err.length() > 0) {
        resp.setError(err);
        resp.setIsError(true);
        return ret;
    }
    // Validate parameters vs service type
    validateCRUD(modelCRUD);
    String tableName = modelCRUD.getTableName();
    int recordID = modelCRUD.getRecordID();
    resp.setRecordID(recordID);
    Properties ctx = m_cs.getM_ctx();
    // start a trx
    String trxName = Trx.createTrxName("ws_modelUpdateData");
    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);
    POInfo poinfo = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
    DataRow dr = modelCRUD.getDataRow();
    for (DataField field : dr.getFieldList()) {
        // TODO: Implement lookup
        if (m_webservicetype.isInputColumnNameAllowed(field.getColumn())) {
            int idxcol = po.get_ColumnIndex(field.getColumn());
            if (idxcol < 0) {
                // The column doesn't exist - it must exist as it's defined in security
                return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " does not exist");
            } else {
                try {
                    setValueAccordingToClass(po, poinfo, field, idxcol);
                } catch (XFireFault e) {
                    log.log(Level.WARNING, "Error setting value", e);
                    return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " value could not be set: " + e.getLocalizedMessage());
                }
            }
        } else {
            return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " not allowed");
        }
    }
    if (!po.save())
        return rollbackAndSetError(trx, resp, ret, true, "Cannot save record in " + tableName + ": " + CLogger.retrieveErrorString("no log message"));
    // close the trx
    if (!trx.commit())
        return rollbackAndSetError(trx, resp, ret, true, "Cannot commit transaction after delete record " + recordID + " in " + tableName);
    trx.close();
    return ret;
}
Also used : ADLoginRequest(pl.x3E.adInterface.ADLoginRequest) StandardResponse(pl.x3E.adInterface.StandardResponse) Properties(java.util.Properties) XFireFault(org.codehaus.xfire.fault.XFireFault) DataRow(pl.x3E.adInterface.DataRow) StandardResponseDocument(pl.x3E.adInterface.StandardResponseDocument) POInfo(org.compiere.model.POInfo) MTable(org.compiere.model.MTable) DataField(pl.x3E.adInterface.DataField) ModelCRUD(pl.x3E.adInterface.ModelCRUD) Trx(org.compiere.util.Trx) PO(org.compiere.model.PO)

Example 3 with StandardResponseDocument

use of pl.x3E.adInterface.StandardResponseDocument in project adempiere by adempiere.

the class ModelADServiceImpl method deleteData.

// getList
public StandardResponseDocument deleteData(ModelCRUDRequestDocument req) throws XFireFault {
    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 = modelLogin(reqlogin, webServiceName, "deleteData", serviceType);
    if (err != null && err.length() > 0) {
        resp.setError(err);
        resp.setIsError(true);
        return ret;
    }
    // Validate parameters vs service type
    validateCRUD(modelCRUD);
    String tableName = modelCRUD.getTableName();
    int recordID = modelCRUD.getRecordID();
    resp.setRecordID(recordID);
    Properties ctx = m_cs.getM_ctx();
    // start a trx
    String trxName = Trx.createTrxName("ws_modelDeleteData");
    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);
    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 (!trx.commit())
        return rollbackAndSetError(trx, resp, ret, true, "Cannot commit transaction after delete record " + recordID + " in " + tableName);
    trx.close();
    return ret;
}
Also used : ADLoginRequest(pl.x3E.adInterface.ADLoginRequest) MTable(org.compiere.model.MTable) StandardResponse(pl.x3E.adInterface.StandardResponse) ModelCRUD(pl.x3E.adInterface.ModelCRUD) Trx(org.compiere.util.Trx) Properties(java.util.Properties) StandardResponseDocument(pl.x3E.adInterface.StandardResponseDocument) PO(org.compiere.model.PO)

Example 4 with StandardResponseDocument

use of pl.x3E.adInterface.StandardResponseDocument in project adempiere by adempiere.

the class ModelADServiceImpl method createData.

public StandardResponseDocument createData(ModelCRUDRequestDocument req) throws XFireFault {
    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 = modelLogin(reqlogin, webServiceName, "createData", serviceType);
    if (err != null && err.length() > 0) {
        resp.setError(err);
        resp.setIsError(true);
        return ret;
    }
    // Validate parameters vs service type
    validateCRUD(modelCRUD);
    String tableName = modelCRUD.getTableName();
    Properties ctx = m_cs.getM_ctx();
    // start a trx
    String trxName = Trx.createTrxName("ws_modelCreateData");
    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(0, trxName);
    if (po == null)
        return rollbackAndSetError(trx, resp, ret, true, "Cannot create PO for " + tableName);
    POInfo poinfo = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
    DataRow dr = modelCRUD.getDataRow();
    for (DataField field : dr.getFieldList()) {
        // TODO: Implement lookup
        if (m_webservicetype.isInputColumnNameAllowed(field.getColumn())) {
            int idxcol = po.get_ColumnIndex(field.getColumn());
            if (idxcol < 0) {
                // The column doesn't exist - it must exist as it's defined in security
                return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " does not exist");
            } else {
                try {
                    setValueAccordingToClass(po, poinfo, field, idxcol);
                } catch (XFireFault e) {
                    log.log(Level.WARNING, "Error setting value", e);
                    return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " value could not be set: " + e.getLocalizedMessage());
                }
            }
        } else {
            return rollbackAndSetError(trx, resp, ret, true, "Web service type " + m_webservicetype.getValue() + ": input column " + field.getColumn() + " not allowed");
        }
    }
    if (!po.save())
        return rollbackAndSetError(trx, resp, ret, true, "Cannot save record in " + tableName + ": " + CLogger.retrieveErrorString("no log message"));
    int recordID = po.get_ID();
    resp.setRecordID(recordID);
    // close the trx
    if (!trx.commit())
        return rollbackAndSetError(trx, resp, ret, true, "Cannot commit transaction after create record " + recordID + " in " + tableName);
    trx.close();
    return ret;
}
Also used : ADLoginRequest(pl.x3E.adInterface.ADLoginRequest) StandardResponse(pl.x3E.adInterface.StandardResponse) Properties(java.util.Properties) XFireFault(org.codehaus.xfire.fault.XFireFault) DataRow(pl.x3E.adInterface.DataRow) StandardResponseDocument(pl.x3E.adInterface.StandardResponseDocument) POInfo(org.compiere.model.POInfo) MTable(org.compiere.model.MTable) DataField(pl.x3E.adInterface.DataField) ModelCRUD(pl.x3E.adInterface.ModelCRUD) Trx(org.compiere.util.Trx) PO(org.compiere.model.PO)

Example 5 with StandardResponseDocument

use of pl.x3E.adInterface.StandardResponseDocument 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;
}
Also used : ADLoginRequest(pl.x3E.adInterface.ADLoginRequest) StandardResponse(pl.x3E.adInterface.StandardResponse) Properties(java.util.Properties) ModelSetDocAction(pl.x3E.adInterface.ModelSetDocAction) SQLException(java.sql.SQLException) StandardResponseDocument(pl.x3E.adInterface.StandardResponseDocument) MTable(org.compiere.model.MTable) Trx(org.compiere.util.Trx) PO(org.compiere.model.PO)

Aggregations

StandardResponse (pl.x3E.adInterface.StandardResponse)6 StandardResponseDocument (pl.x3E.adInterface.StandardResponseDocument)6 Properties (java.util.Properties)4 MTable (org.compiere.model.MTable)4 PO (org.compiere.model.PO)4 Trx (org.compiere.util.Trx)4 ADLoginRequest (pl.x3E.adInterface.ADLoginRequest)4 ModelCRUD (pl.x3E.adInterface.ModelCRUD)3 XFireFault (org.codehaus.xfire.fault.XFireFault)2 POInfo (org.compiere.model.POInfo)2 DataField (pl.x3E.adInterface.DataField)2 DataRow (pl.x3E.adInterface.DataRow)2 SQLException (java.sql.SQLException)1 MLocation (org.compiere.model.MLocation)1 Location (pl.x3E.adInterface.Location)1 ModelSetDocAction (pl.x3E.adInterface.ModelSetDocAction)1