IDEMPIERE-4339 Web Services : Automatically fill records on Parameters table (#175)

peer review and tests
This commit is contained in:
Carlos Ruiz 2020-07-21 11:41:11 +02:00 committed by GitHub
parent b473111bab
commit 087b6e62d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 19 deletions

View File

@ -0,0 +1,26 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jul 21, 2020, 11:03:05 AM CEST
UPDATE AD_Process SET Name='Create Default Parameters',Updated=TO_DATE('2020-07-21 11:03:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=200119
;
-- Jul 21, 2020, 11:03:20 AM CEST
UPDATE AD_Element SET Name='Create Default Parameters', PrintName='Create Default Parameters',Updated=TO_DATE('2020-07-21 11:03:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203423
;
-- Jul 21, 2020, 11:03:20 AM CEST
UPDATE AD_Column SET ColumnName='InsertParameters', Name='Create Default Parameters', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Element_ID=203423
;
-- Jul 21, 2020, 11:03:20 AM CEST
UPDATE AD_Field SET Name='Create Default Parameters', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=203423) AND IsCentrallyMaintained='Y'
;
-- Jul 21, 2020, 11:22:14 AM CEST
UPDATE AD_Field SET DisplayLogic='@WS_WebService_ID.Value@=''ModelADService''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-07-21 11:22:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206417
;
SELECT register_migration_script('202007211126_IDEMPIERE-4339_PR.sql') FROM dual
;

View File

@ -0,0 +1,23 @@
-- Jul 21, 2020, 11:03:05 AM CEST
UPDATE AD_Process SET Name='Create Default Parameters',Updated=TO_TIMESTAMP('2020-07-21 11:03:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=200119
;
-- Jul 21, 2020, 11:03:20 AM CEST
UPDATE AD_Element SET Name='Create Default Parameters', PrintName='Create Default Parameters',Updated=TO_TIMESTAMP('2020-07-21 11:03:20','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203423
;
-- Jul 21, 2020, 11:03:20 AM CEST
UPDATE AD_Column SET ColumnName='InsertParameters', Name='Create Default Parameters', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Element_ID=203423
;
-- Jul 21, 2020, 11:03:20 AM CEST
UPDATE AD_Field SET Name='Create Default Parameters', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=203423) AND IsCentrallyMaintained='Y'
;
-- Jul 21, 2020, 11:22:14 AM CEST
UPDATE AD_Field SET DisplayLogic='@WS_WebService_ID.Value@=''ModelADService''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-07-21 11:22:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206417
;
SELECT register_migration_script('202007211126_IDEMPIERE-4339_PR.sql') FROM dual
;

View File

@ -50,7 +50,7 @@ public class MWebServiceType extends X_WS_WebServiceType
/**
*
*/
private static final long serialVersionUID = 7216001796414414950L;
private static final long serialVersionUID = -2713868996404459577L;
/** Parameters */
private MWebServicePara[] m_para = null;
@ -287,20 +287,20 @@ public class MWebServiceType extends X_WS_WebServiceType
return m_inputFieldMap.get(colName);
}
public static void insertParameters (Properties ctx, MWebServiceType ws, String trxName) {
public void insertParameters() {
if ("ModelADService".equals(ws.getWS_WebService().getValue())) {
String method = ws.getWS_WebServiceMethod().getValue();
MWebService ws = MWebService.get(getCtx(), getWS_WebService_ID());
if (ws != null && "ModelADService".equals(ws.getValue())) {
X_WS_WebServiceMethod wsm = new X_WS_WebServiceMethod(getCtx(), getWS_WebServiceMethod_ID(), get_TrxName());
String method = wsm.getValue();
if ("getList".equals(method)) {
ws.addWsParameter("AD_Reference_ID", X_WS_WebService_Para.PARAMETERTYPE_Free, "");
}
else if ("runProcess".equals(method)) {
ws.addWsParameter("AD_Process_ID", X_WS_WebService_Para.PARAMETERTYPE_Constant, ""); // can't fill it as the process is unknown
ws.addWsParameter("AD_Menu_ID", X_WS_WebService_Para.PARAMETERTYPE_Constant, "0");
ws.addWsParameter("AD_Record_ID", X_WS_WebService_Para.PARAMETERTYPE_Free, "");
}
else {
addWsParameter("AD_Reference_ID", X_WS_WebService_Para.PARAMETERTYPE_Free, "");
} else if ("runProcess".equals(method)) {
addWsParameter("AD_Process_ID", X_WS_WebService_Para.PARAMETERTYPE_Constant, ""); // can't fill it as the process is unknown
addWsParameter("AD_Menu_ID", X_WS_WebService_Para.PARAMETERTYPE_Constant, "0");
addWsParameter("AD_Record_ID", X_WS_WebService_Para.PARAMETERTYPE_Free, "");
} else {
String value = "";
if ("createData".equals(method))
value = "Create";
@ -313,9 +313,9 @@ public class MWebServiceType extends X_WS_WebServiceType
else if ("updateData".equals(method))
value = "Update";
ws.addWsParameter("TableName", X_WS_WebService_Para.PARAMETERTYPE_Constant, MTable.get(ctx, ws.getAD_Table_ID()).getTableName());
ws.addWsParameter("Action", X_WS_WebService_Para.PARAMETERTYPE_Constant, value);
ws.addWsParameter("RecordID", X_WS_WebService_Para.PARAMETERTYPE_Free, "");
addWsParameter("TableName", X_WS_WebService_Para.PARAMETERTYPE_Constant, MTable.get(getCtx(), getAD_Table_ID()).getTableName());
addWsParameter("Action", X_WS_WebService_Para.PARAMETERTYPE_Constant, value);
addWsParameter("RecordID", X_WS_WebService_Para.PARAMETERTYPE_Free, "");
}
}
}

View File

@ -33,19 +33,24 @@ import org.compiere.process.SvrProcess;
*/
public class WebServiceTypeCreateParameters extends SvrProcess {
// The web service type (record on screen)
private int p_WS_WebServiceType_ID;
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare() {}
protected void prepare() {
p_WS_WebServiceType_ID = getRecord_ID();
}
/**
* Perform process.
* @return Message
* @throws Exception
*/
protected String doIt() throws Exception
{
MWebServiceType.insertParameters(getCtx(), new MWebServiceType(getCtx(), getRecord_ID(), get_TrxName()), get_TrxName());
protected String doIt() throws Exception {
MWebServiceType ws = new MWebServiceType(getCtx(), p_WS_WebServiceType_ID, get_TrxName());
ws.insertParameters();
return "@ProcessOK@";
} // doIt