IDEMPIERE-4980 Update model factory of org.idempiere.webservices (#899)

This commit is contained in:
hengsin 2021-09-27 18:50:59 +08:00 committed by GitHub
parent 557c483fc9
commit 338fecb344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 137 additions and 47 deletions

View File

@ -27,7 +27,8 @@ Require-Bundle: org.adempiere.base;bundle-version="9.0.0",
org.adempiere.base.callout;bundle-version="9.0.0",
org.adempiere.base.process;bundle-version="9.0.0",
org.adempiere.payment.processor;bundle-version="9.0.0",
org.compiere.db.postgresql.provider;bundle-version="9.0.0"
org.compiere.db.postgresql.provider;bundle-version="9.0.0",
org.idempiere.webservices;bundle-version="9.0.0"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.idempiere.test.TestActivator
Bundle-RequiredExecutionEnvironment: JavaSE-11

View File

@ -344,6 +344,7 @@
<setEntry value="org.compiere.db.postgresql.provider@default:default"/>
<setEntry value="org.idempiere.hazelcast.service@default:default"/>
<setEntry value="org.idempiere.test@default:default"/>
<setEntry value="org.idempiere.webservices@default:default"/>
</setAttribute>
<booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>

View File

@ -67,6 +67,7 @@ Import-Package: javax.activation,
org.apache.xerces.xs.datatypes;version="2.9.0",
org.apache.xml.serialize;version="2.9.0",
org.osgi.framework;version="1.6.0",
org.osgi.service.component.annotations;version="1.3.0",
org.w3c.dom
Require-Bundle: org.adempiere.base;bundle-version="0.0.0",
org.adempiere.ui;bundle-version="0.0.0",

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.compiere.model.WS_ModelFactory">
<implementation class="org.compiere.model.WS_ModelFactory"/>
<property name="service.ranking" type="Integer" value="5"/>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.compiere.model.WS_ModelFactory">
<property name="service.ranking" type="Integer" value="1"/>
<service>
<provide interface="org.adempiere.base.IModelFactory"/>
</service>
<implementation class="org.compiere.model.WS_ModelFactory"/>
</scr:component>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE scr:component>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.idempiere.webservices.process.WebServicesProcessFactory">
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.idempiere.webservices.process.WebServicesProcessFactory">
<implementation class="org.idempiere.webservices.process.WebServicesProcessFactory"/>
<property name="service.ranking" type="Integer" value="1"/>
<service>

View File

@ -47,6 +47,7 @@ import org.idempiere.cache.ImmutablePOSupport;
*
* @author Carlos Ruiz
*/
@org.adempiere.base.Model(table = X_WS_WebService.Table_Name)
public class MWebService extends X_WS_WebService implements ImmutablePOSupport
{
/**

View File

@ -35,6 +35,7 @@ import org.idempiere.cache.ImmutablePOSupport;
* @author hengsin
*
*/
@org.adempiere.base.Model(table = X_WS_WebServiceMethod.Table_Name)
public class MWebServiceMethod extends X_WS_WebServiceMethod implements ImmutablePOSupport {
/**

View File

@ -39,6 +39,7 @@ import org.compiere.util.Env;
*
* @author Carlos Ruiz
*/
@org.adempiere.base.Model(table = X_WS_WebService_Para.Table_Name)
public class MWebServicePara extends X_WS_WebService_Para
{
/**

View File

@ -48,6 +48,7 @@ import org.idempiere.cache.ImmutablePOSupport;
* @author Carlos Ruiz
* @author Deepak Pansheriya - Updated to support CreateUpdate service
*/
@org.adempiere.base.Model(table = X_WS_WebServiceType.Table_Name)
public class MWebServiceType extends X_WS_WebServiceType implements ImmutablePOSupport
{
/**

View File

@ -25,50 +25,22 @@
package org.compiere.model;
import java.sql.ResultSet;
import org.adempiere.base.AnnotationBasedModelFactory;
import org.adempiere.base.IModelFactory;
import org.compiere.util.Env;
import org.osgi.service.component.annotations.Component;
public class WS_ModelFactory implements IModelFactory {
/**
*
* @author globalqss
* @author hengsin
*
*/
@Component(immediate = true, service = IModelFactory.class, property = "service.ranking:Integer=1")
public class WS_ModelFactory extends AnnotationBasedModelFactory {
@Override
public Class<?> getClass(String tableName) {
if (X_WS_WebService_Para.Table_Name.equals(tableName))
return MWebServicePara.class;
if (X_WS_WebServiceType.Table_Name.equals(tableName))
return MWebServiceType.class;
if (X_WS_WebService.Table_Name.equals(tableName))
return MWebService.class;
if (MWebServiceMethod.Table_Name.equals(tableName))
return MWebServiceMethod.class;
return null;
}
@Override
public PO getPO(String tableName, int Record_ID, String trxName) {
if (X_WS_WebService_Para.Table_Name.equals(tableName))
return new MWebServicePara(Env.getCtx(), Record_ID, trxName);
if (X_WS_WebServiceType.Table_Name.equals(tableName))
return new MWebServiceType(Env.getCtx(), Record_ID, trxName);
if (X_WS_WebService.Table_Name.equals(tableName))
return new MWebService(Env.getCtx(), Record_ID, trxName);
if (MWebServiceMethod.Table_Name.equals(tableName))
return new MWebServiceMethod(Env.getCtx(), Record_ID, trxName);
return null;
}
@Override
public PO getPO(String tableName, ResultSet rs, String trxName) {
if (X_WS_WebService_Para.Table_Name.equals(tableName))
return new MWebServicePara(Env.getCtx(), rs, trxName);
if (X_WS_WebServiceType.Table_Name.equals(tableName))
return new MWebServiceType(Env.getCtx(), rs, trxName);
if (X_WS_WebService.Table_Name.equals(tableName))
return new MWebService(Env.getCtx(), rs, trxName);
if (MWebServiceMethod.Table_Name.equals(tableName))
return new MWebServiceMethod(Env.getCtx(), rs, trxName);
return null;
protected String[] getPackages() {
return new String[] {MWebService.class.getPackageName()};
}
}

View File

@ -0,0 +1,59 @@
{
"id": "b633c534-ed2b-449e-88b9-69d8cbf74498",
"name": "https://localhost:8443 WebService",
"values": [
{
"key": "protocol",
"value": "https",
"enabled": true
},
{
"key": "host",
"value": "localhost",
"enabled": true
},
{
"key": "port",
"value": "8443",
"enabled": true
},
{
"key": "userName",
"value": "WebService",
"enabled": true
},
{
"key": "password",
"value": "WebService",
"enabled": true
},
{
"key": "clientId",
"value": "11",
"enabled": true
},
{
"key": "roleId",
"value": "50004",
"enabled": true
},
{
"key": "organizationId",
"value": "11",
"enabled": true
},
{
"key": "warehouseId",
"value": "103",
"enabled": true
},
{
"key": "language",
"value": "en_US",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2021-09-14T11:48:44.727Z",
"_postman_exported_using": "Postman/8.12.1"
}

View File

@ -0,0 +1,52 @@
{
"info": {
"_postman_id": "1223b193-dce3-405c-8cf5-be7ba996bbe2",
"name": "idempiere-soap-as-rest",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "query_data",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"ModelCRUDRequest\": {\n \"ModelCRUD\": {\n \"serviceType\": \"QueryBPartner\",\n \"TableName\": \"C_BPartner\",\n \"Filter\": \"name < 'S'\",\n \"Action\": \"Read\",\n \"DataRow\": { //optional filter by column values\n \"field\": [\n {\n \"@column\": \"C_BP_Group_ID\",\n \"val\": \"103\"\n }\n ]\n }\n },\n \"ADLoginRequest\": {\n \"user\": \"{{userName}}\",\n \"pass\": \"{{password}}\",\n \"lang\": \"{{language}}\",\n \"ClientID\": \"{{clientId}}\",\n \"RoleID\": \"{{roleId}}\",\n \"OrgID\": \"{{organizationId}}\",\n \"WarehouseID\": \"{{warehouseId}}\",\n \"stage\": \"9\"\n }\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{protocol}}://{{host}}:{{port}}/ADInterface/services/rest/model_adservice/query_data",
"protocol": "{{protocol}}",
"host": [
"{{host}}"
],
"port": "{{port}}",
"path": [
"ADInterface",
"services",
"rest",
"model_adservice",
"query_data"
]
}
},
"response": []
}
]
}