-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoAPI1.java
63 lines (54 loc) · 3.28 KB
/
DemoAPI1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.simplicite.extobjects.DemoAPIs;
import com.simplicite.util.tools.JSONTool;
import com.simplicite.util.tools.Parameters;
/**
* Custom mapped REST web services
*/
public class DemoAPI1 extends com.simplicite.webapp.services.RESTMappedObjectsExternalObject {
private static final long serialVersionUID = 1L;
// Embbed linked lists?
private static final boolean EMBED_LINKS = true;
private static final String SUPPLIERS = "suppliers";
private static final String PRODUCTS = "products";
private static final String ORDERS = "orders";
private static final String STATS = "stats";
@Override
public void init(Parameters params) {
setOpenAPISpec(JSONTool.OPENAPI_OAS2);
setOpenAPIDesc("This is a **simplified** variant of the demo API for the following business objects:\n\n- Suppliers\n- Products\n- Orders");
setOpenAPIVers("v1");
//addOperationDesc(null, OPERATION_PING, "This is the **ping** operation");
addObject(SUPPLIERS, "DemoSupplier", "Supplier");
addField(SUPPLIERS, "code", "demoSupCode");
addField(SUPPLIERS, "name", "demoSupName");
addObject(PRODUCTS, "DemoProduct", "Product");
addRefField(PRODUCTS, SUPPLIERS, "supplierId", "demoPrdSupId", "supplierProducts", EMBED_LINKS, "Reference to supplier's row ID");
addField(PRODUCTS, "supplierCode", "demoPrdSupId.demoSupCode", "Supplier code", null);
addField(PRODUCTS, "supplierName", "demoPrdSupId.demoSupName", "Supplier name", null);
addField(PRODUCTS, "reference", "demoPrdReference", "Product reference", "REFxxx");
addField(PRODUCTS, "type", "demoPrdType", "Product type", null);
addField(PRODUCTS, "name", "demoPrdName", "Product name", null);
addField(PRODUCTS, "available", "demoPrdAvailable", "Available product?", null);
addObject(ORDERS, "DemoOrder", "Order");
// or to force pagination (10 by 10): addObject(ORDERS, "DemoOrder", "Order", true, 10);
addRefField(ORDERS, PRODUCTS, "productId", "demoOrdPrdId", "productOrders", EMBED_LINKS, "Reference to product's row ID");
addField(ORDERS, "number", "demoOrdNumber");
addField(ORDERS, "date", "demoOrdDate");
addField(ORDERS, "status", "demoOrdStatus");
addField(ORDERS, "productReference", "demoOrdPrdId.demoPrdReference");
addField(ORDERS, "productName", "demoOrdPrdId.demoPrdName");
addField(ORDERS, "productType", "demoOrdPrdId.demoPrdType");
addField(ORDERS, "productSupplierCode", "demoOrdPrdId.demoPrdSupId.demoSupCode");
addField(ORDERS, "productSupplierName", "demoOrdPrdId.demoPrdSupId.demoSupName");
//addOperationDesc("products", OPERATION_SEARCH, "This is the **search** operation for the _product_ business object");
//addOperationDesc("products", OPERATION_GET, "This is the **get** operation for the _product_ business object");
//addOperationDesc("products", OPERATION_CREATE, "This is the **create** operation for the _product_ business object");
//addOperationDesc("products", OPERATION_UPDATE, "This is the **update** operation for the _product_ business object");
//addOperationDesc("products", OPERATION_DELETE, "This is the **delete** operation for the _product_ business object");
addObject(STATS, "DemoStats", DESC_HIDDEN_FROM_SCHEMA);
addField(STATS, "status", "demoOrdStatus");
addField(STATS, "count", "demoStsCount");
addField(STATS, "quantity", "demoStsQuantity");
addField(STATS, "total", "demoStsTotal");
}
}