{
  "{d}demo": {
    "{d}connections": {
      "{f}ReadMe.md": "This folder contains definitions for connections"
    },
    "{d}listeners": {
      "{f}ReadMe.md": "This folder contains definitions for listeners"
    },
    "{d}custom_endpoints": {
      "{f}ReadMe.md": "This folder contains definitions for custom_endpoints"
    },
    "{f}relationships.json": [
      {
        "parentEntity": "demo:customer",
        "childEntity": "demo:PurchaseOrder",
        "roleToParent": "customer",
        "roleToChild": "PurchaseOrderList",
        "deleteRule": "Cascade",
        "updateRule": "No Action",
        "parentColumns": [
          "name"
        ],
        "childColumns": [
          "customer_name"
        ]
      },
      {
        "parentEntity": "demo:customer",
        "childEntity": "finance:orders",
        "roleToParent": "demoCustomer",
        "roleToChild": "financeOrders",
        "deleteRule": "No Action",
        "updateRule": "No Action",
        "parentColumns": [
          "name"
        ],
        "childColumns": [
          "customer_name"
        ]
      },
      {
        "parentEntity": "demo:employee",
        "childEntity": "demo:employee_picture",
        "roleToParent": "employee_picture",
        "roleToChild": "employee_pictureList",
        "deleteRule": "Cascade",
        "updateRule": "No Action",
        "parentColumns": [
          "employee_id"
        ],
        "childColumns": [
          "employee_id"
        ]
      },
      {
        "parentEntity": "demo:employee",
        "childEntity": "demo:PurchaseOrder",
        "roleToParent": "salesrep",
        "roleToChild": "PurchaseOrderList",
        "deleteRule": "Cascade",
        "updateRule": "No Action",
        "parentColumns": [
          "employee_id"
        ],
        "childColumns": [
          "salesrep_id"
        ]
      },
      {
        "parentEntity": "demo:product",
        "childEntity": "demo:LineItem",
        "roleToParent": "product",
        "roleToChild": "LineItemList",
        "deleteRule": "No Action",
        "updateRule": "No Action",
        "parentColumns": [
          "product_number"
        ],
        "childColumns": [
          "product_number"
        ]
      },
      {
        "parentEntity": "demo:PurchaseOrder",
        "childEntity": "demo:LineItem",
        "roleToParent": "lineitem_purchaseorder",
        "roleToChild": "LineItemList",
        "deleteRule": "Cascade",
        "updateRule": "No Action",
        "parentColumns": [
          "order_number"
        ],
        "childColumns": [
          "order_number"
        ]
      },
      {
        "parentEntity": "demo:PurchaseOrder",
        "childEntity": "demo:purchaseorder_audit",
        "roleToParent": "purchaseorder_audit",
        "roleToChild": "purchaseorder_auditList",
        "deleteRule": "Cascade",
        "updateRule": "No Action",
        "parentColumns": [
          "order_number"
        ],
        "childColumns": [
          "order_number"
        ]
      }
    ],
    "{d}data_sources": {
      "{f}ReadMe.md": "This folder contains definitions for data sources",
      "{f}demo_oiz.json": {
        "name": "demo_oiz",
        "prefix": "demo",
        "title": "Demo",
        "databaseType": "DERBY",
        "comments": null,
        "isActive": true,
        "isLogErrors": false,
        "isSchemaEditable": false,
        "isSupportBoolean": false,
        "isReadOnly": false,
        "useJNDIDataSource": false,
        "url": "jdbc:derby:directory:/Users/banty01/derbytest/Demo",
        "catalog": null,
        "schema": "\"DEMO\"",
        "username": "\"DEMO\"",
        "encryptedPassword": "2:Gk/KCM6biX7bDGcsFfT2OgNZu/rGw0HFH9vqVCFXCvFOU48m3hIpGw==",
        "encryptedPasswordSalt": "hDwBB6Scn+tPF6nhFH9g13fWvMoyr3DbYPebKb9z",
        "maximumConnections": 20,
        "tableExcludes": null,
        "tableIncludes": null,
        "procedureExcludes": null,
        "procedureIncludes": null,
        "nonPersistentAttributes": {},
        "tableInfos": {},
        "viewInfos": {}
      },
      "{f}finance_fde.json": {
        "name": "finance_fde",
        "prefix": "finance",
        "title": "Finance",
        "databaseType": "DERBY",
        "comments": null,
        "isActive": true,
        "isLogErrors": false,
        "isSchemaEditable": false,
        "isSupportBoolean": false,
        "isReadOnly": false,
        "useJNDIDataSource": false,
        "url": "jdbc:derby:directory:/Users/banty01/derbytest/Finance",
        "catalog": null,
        "schema": "\"FINANCE\"",
        "username": "\"FINANCE\"",
        "encryptedPassword": "2:6Q6TxY04hsSyO9m/ZAjBCs1+kYJBhMAmQqzyQwdzEuF2sIGn1O4oVg==",
        "encryptedPasswordSalt": "ktBWh1Vzxvl5FHBTq92RZrAqnzpIiRDqEfUpFqwF",
        "maximumConnections": 20,
        "tableExcludes": null,
        "tableIncludes": null,
        "procedureExcludes": null,
        "procedureIncludes": null,
        "nonPersistentAttributes": {},
        "tableInfos": {},
        "viewInfos": {}
      }
    },
    "{d}filters": {
      "{f}ReadMe.md": "This folder contains definitions for filters"
    },
    "{d}functions": {
      "{f}ReadMe.md": "This folder contains definitions for functions",
      "{f}gcd.json": {
        "name": "gcd",
        "isActive": true,
        "comments": "Simple function that takes two parameters and returns the greatest common divisor.\nThis function is not associated with any tables or resources, so it must be called on the API, with a URL that looks like:\n\n.../v1/gcd?n1=256&n2=512",
        "returnType": "{\n  \"n1\":6,\n  \"n2\":9,\n  \"gcd\":3\n}",
        "parameters": {
          "n1": {
            "parameterType": "number",
            "isRequired": true,
            "comments": "First number"
          },
          "n2": {
            "parameterType": "number",
            "isRequired": true,
            "comments": "Second number"
          }
        },
        "functionType": "apiLevel"
      },
      "{f}gcd.js": "// Trivial example: find greatest common divisor for two positive numbers\nvar div = 2\nvar gcd = 1;\n\nif (parameters.n1 < 2 || parameters.n2 < 2) {\n    return {\n        n1: parameters.n1,\n        n2: parameters.n2,\n        gcd: 1,\n        message: \"One or both of your parameters were less than 2, so the result is 1\"\n    };\n}\n    \nif (parameters.n1 > 1000000000000 || parameters.n2 > 1000000000000) {\n    return {\n        n1: parameters.n1,\n        n2: parameters.n2,\n        gcd: null,\n        message: \"One or both of your parameters were greater than 1,000,000,000,000, so the result is too expensive to compute\"\n    };\n}\n \nwhile (parameters.n1 >= div && parameters.n2 >= div) {\n    if (parameters.n1%div === 0 && parameters.n2%div === 0) {\n        gcd = div;      \n    }\n    div++;\n}\n\nreturn {\n    n1: parameters.n1,\n    n2: parameters.n2,\n    gcd: gcd\n};\n"
    },
    "{d}libraries": {
      "{f}ReadMe.md": "This folder contains definitions for libraries and whether they are used.\n",
      "{f}SystemLibraryUsage.json": []
    },
    "{d}request_events": {
      "{f}ReadMe.md": "This folder contains definitions for request events"
    },
    "{d}resources": {
      "{f}ReadMe.md": "This folder contains definitions for resources",
      "{f}apiversions.json": {
        "v1": {
          "name": "v1",
          "comments": null
        }
      },
      "{d}v1": {
        "{d}AllCustomers": {
          "{f}AllCustomers.json": {
            "name": "AllCustomers",
            "description": "Query for all customers",
            "siblingRank": 100,
            "resourceType": "TableBased",
            "prefix": "demo",
            "entity": "customer",
            "isCollection": true,
            "isCombined": false,
            "filter": null,
            "order": null,
            "useSchemaAttributes": false,
            "attributes": [
              {
                "attribute": "name",
                "alias": "name",
                "description": "",
                "isKey": false
              },
              {
                "attribute": "balance",
                "alias": "balance",
                "description": "",
                "isKey": false
              }
            ]
          },
          "{f}AllCustomers.js": ""
        },
        "{d}CustomerBusinessObject": {
          "{f}CustomerBusinessObject.json": {
            "name": "CustomerBusinessObject",
            "description": "all customer attributes and related child data",
            "siblingRank": 100,
            "resourceType": "TableBased",
            "prefix": "demo",
            "entity": "customer",
            "isCollection": true,
            "isCombined": false,
            "filter": null,
            "order": "\"name\" asc",
            "useSchemaAttributes": false,
            "attributes": [
              {
                "attribute": "name",
                "alias": "name",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "balance",
                "alias": "balance",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "credit_limit",
                "alias": "credit_limit",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "comments",
                "alias": "comments",
                "description": null,
                "isKey": false
              }
            ]
          },
          "{f}CustomerBusinessObject.js": "",
          "{d}Orders": {
            "{f}Orders.json": {
              "name": "Orders",
              "description": "Orders of Customer",
              "siblingRank": 100,
              "resourceType": "TableBased",
              "prefix": "demo",
              "entity": "PurchaseOrder",
              "join": "\"customer_name\" = [name]",
              "isCollection": true,
              "isCombined": false,
              "filter": null,
              "order": "\"order_number\" desc",
              "useSchemaAttributes": false,
              "attributes": [
                {
                  "attribute": "order_number",
                  "alias": "order_number",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "amount_total",
                  "alias": "amount_total",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "paid",
                  "alias": "paid",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "notes",
                  "alias": "notes",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "customer_name",
                  "alias": "customer_name",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "salesrep_id",
                  "alias": "salesrep_id",
                  "description": null,
                  "isKey": false
                }
              ]
            },
            "{f}Orders.js": "",
            "{d}LineItems": {
              "{f}LineItems.json": {
                "name": "LineItems",
                "description": "LineItems of Order",
                "siblingRank": 100,
                "resourceType": "TableBased",
                "prefix": "demo",
                "entity": "LineItem",
                "join": "\"order_number\" = [order_number]",
                "isCollection": true,
                "isCombined": false,
                "filter": null,
                "order": "\"product_number\" asc",
                "useSchemaAttributes": false,
                "attributes": [
                  {
                    "attribute": "lineitem_id",
                    "alias": "lineitem_id",
                    "description": null,
                    "isKey": false
                  },
                  {
                    "attribute": "product_number",
                    "alias": "product_number",
                    "description": null,
                    "isKey": false
                  },
                  {
                    "attribute": "order_number",
                    "alias": "order_number",
                    "description": null,
                    "isKey": false
                  },
                  {
                    "attribute": "qty_ordered",
                    "alias": "qty_ordered",
                    "description": null,
                    "isKey": false
                  },
                  {
                    "attribute": "product_price",
                    "alias": "product_price",
                    "description": null,
                    "isKey": false
                  },
                  {
                    "attribute": "amount",
                    "alias": "amount",
                    "description": null,
                    "isKey": false
                  }
                ]
              },
              "{f}LineItems.js": "",
              "{d}OrderAudits": {
                "{f}OrderAudits.json": {
                  "name": "OrderAudits",
                  "description": "Audits of Order",
                  "siblingRank": 100,
                  "resourceType": "TableBased",
                  "prefix": "demo",
                  "entity": "purchaseorder_audit",
                  "join": "\"order_number\" = [order_number]",
                  "isCollection": true,
                  "isCombined": false,
                  "filter": null,
                  "order": null,
                  "useSchemaAttributes": false,
                  "attributes": [
                    {
                      "attribute": "audit_number",
                      "alias": "audit_number",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "order_number",
                      "alias": "order_number",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "amount_total",
                      "alias": "amount_total",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "paid",
                      "alias": "paid",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "notes",
                      "alias": "notes",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "audit_time",
                      "alias": "audit_time",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "customer_name",
                      "alias": "customer_name",
                      "description": null,
                      "isKey": false
                    }
                  ]
                },
                "{f}OrderAudits.js": ""
              },
              "{d}Product": {
                "{f}Product.json": {
                  "name": "Product",
                  "description": "Product for LineItem",
                  "siblingRank": 100,
                  "resourceType": "TableBased",
                  "prefix": "demo",
                  "entity": "product",
                  "join": "\"product_number\" = [product_number]",
                  "isCollection": false,
                  "isCombined": false,
                  "filter": null,
                  "order": null,
                  "useSchemaAttributes": false,
                  "attributes": [
                    {
                      "attribute": "product_number",
                      "alias": "product_number",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "name",
                      "alias": "name",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "price",
                      "alias": "price",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "icon",
                      "alias": "icon",
                      "description": null,
                      "isKey": false
                    },
                    {
                      "attribute": "full_image",
                      "alias": "full_image",
                      "description": null,
                      "isKey": false
                    }
                  ]
                },
                "{f}Product.js": ""
              }
            }
          }
        },
        "{d}CustomerJSOrdersREST": {
          "{f}CustomerJSOrdersREST.json": {
            "name": "CustomerJSOrdersREST",
            "description": "RESTful Orders from a REST call\nMake a SQL Call for each customer and then make a REST call to another REST Endpoint to create a compound document resource.",
            "siblingRank": 100,
            "resourceType": "TableBased",
            "prefix": "demo",
            "entity": "customer",
            "isCollection": true,
            "isCombined": false,
            "filter": null,
            "order": null,
            "useSchemaAttributes": false,
            "attributes": [
              {
                "attribute": "name",
                "alias": "name",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "balance",
                "alias": "balance",
                "description": null,
                "isKey": false
              }
            ]
          },
          "{f}CustomerJSOrdersREST.js": "",
          "{d}OrdersRest": {
            "{f}OrdersRest.json": {
              "name": "OrdersRest",
              "description": "Make a REST call to another REST Endpoint (PurchaseOrders)t to create a compound document resource. Test this in the REST Lab",
              "siblingRank": 100,
              "resourceType": "JavaScript",
              "isCollection": true,
              "joinCondition": null
            },
            "{f}OrdersRest.js": "var url = req.baseUrl;\nlog.debug(url); // this is the base URL for this server\nurl = url.replace(\"/demo/\",\"/sample/\");// compute baseURL of target system\nurl = url + \"v1/orders\";   // add version/ resource endPoint on target\nvar key = containingRow.name;      // containingRow is system supplied\nlog.debug(\"..using key: \" + key + \", and url: \" + url);\nkey = JSON.stringify(key, null, 0);\nvar params= {\n   sysfilter: \"equal(customer_name:\" + key + \")\"\n};\n//special Auth Token in this project to allow access from url (?auth=AdminKey:1)\nvar settings = {\n   headers: {\n      Authorization: \"CALiveAPICreator AdminKey:1\"\n   }\n}\n//////////// Built in utility to make REST GET call\nvar response =  SysUtility.restGet(url, params, settings);\nreturn JSON.parse(response);\n"
          }
        },
        "{d}Customers": {
          "{f}Customers.json": {
            "name": "Customers",
            "description": "API example - illustrates attribute aliasing / projection",
            "siblingRank": 100,
            "resourceType": "TableBased",
            "prefix": "demo",
            "entity": "customer",
            "isCollection": true,
            "isCombined": false,
            "filter": null,
            "order": null,
            "useSchemaAttributes": false,
            "attributes": [
              {
                "attribute": "name",
                "alias": "Name",
                "description": "",
                "isKey": false
              },
              {
                "attribute": "balance",
                "alias": "Balance",
                "description": "",
                "isKey": false
              },
              {
                "attribute": "credit_limit",
                "alias": "CreditLimit",
                "description": "",
                "isKey": false
              }
            ]
          },
          "{f}Customers.js": "",
          "{d}Orders": {
            "{f}Orders.json": {
              "name": "Orders",
              "description": "API example",
              "siblingRank": 100,
              "resourceType": "TableBased",
              "prefix": "demo",
              "entity": "PurchaseOrder",
              "join": "\"customer_name\" = [name]",
              "isCollection": true,
              "isCombined": false,
              "filter": null,
              "order": "\"order_number\" desc",
              "useSchemaAttributes": false,
              "attributes": [
                {
                  "attribute": "order_number",
                  "alias": "OrderNumber",
                  "description": "",
                  "isKey": false
                },
                {
                  "attribute": "amount_total",
                  "alias": "TotalAmount",
                  "description": "",
                  "isKey": false
                },
                {
                  "attribute": "paid",
                  "alias": "Paid",
                  "description": "",
                  "isKey": false
                },
                {
                  "attribute": "notes",
                  "alias": "Notes",
                  "description": "",
                  "isKey": false
                }
              ]
            },
            "{f}Orders.js": "",
            "{d}LineItems": {
              "{f}LineItems.json": {
                "name": "LineItems",
                "description": "API example",
                "siblingRank": 100,
                "resourceType": "TableBased",
                "prefix": "demo",
                "entity": "LineItem",
                "join": "\"order_number\" = [order_number]",
                "isCollection": true,
                "isCombined": false,
                "filter": null,
                "order": "\"product_number\" asc",
                "useSchemaAttributes": false,
                "attributes": [
                  {
                    "attribute": "product_number",
                    "alias": "ProductNumber",
                    "description": "",
                    "isKey": false
                  },
                  {
                    "attribute": "order_number",
                    "alias": "OrderNumber",
                    "description": "",
                    "isKey": false
                  },
                  {
                    "attribute": "qty_ordered",
                    "alias": "Quantity",
                    "description": "",
                    "isKey": false
                  },
                  {
                    "attribute": "product_price",
                    "alias": "Price",
                    "description": "",
                    "isKey": false
                  },
                  {
                    "attribute": "amount",
                    "alias": "Amount",
                    "description": "",
                    "isKey": false
                  }
                ]
              },
              "{f}LineItems.js": "",
              "{d}Product": {
                "{f}Product.json": {
                  "name": "Product",
                  "description": "Query for product",
                  "siblingRank": 100,
                  "resourceType": "TableBased",
                  "prefix": "demo",
                  "entity": "product",
                  "join": "\"product_number\" = [product_number]",
                  "isCollection": false,
                  "isCombined": false,
                  "filter": null,
                  "order": null,
                  "useSchemaAttributes": false,
                  "attributes": [
                    {
                      "attribute": "name",
                      "alias": "Name",
                      "description": "",
                      "isKey": false
                    },
                    {
                      "attribute": "price",
                      "alias": "Price",
                      "description": "",
                      "isKey": false
                    },
                    {
                      "attribute": "product_number",
                      "alias": "ProductId",
                      "description": "",
                      "isKey": false
                    }
                  ]
                },
                "{f}Product.js": ""
              }
            }
          }
        },
        "{d}MDBDemoCustomers": {
          "{f}MDBDemoCustomers.json": {
            "name": "MDBDemoCustomers",
            "description": "Multiple Database join, see the relationships to children under Schema.",
            "siblingRank": 100,
            "resourceType": "TableBased",
            "prefix": "demo",
            "entity": "customer",
            "isCollection": true,
            "isCombined": false,
            "filter": null,
            "order": null,
            "useSchemaAttributes": false,
            "attributes": [
              {
                "attribute": "name",
                "alias": "name",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "balance",
                "alias": "balance",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "credit_limit",
                "alias": "credit_limit",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "comments",
                "alias": "comments",
                "description": null,
                "isKey": false
              }
            ]
          },
          "{f}MDBDemoCustomers.js": "",
          "{d}financeOrders": {
            "{f}financeOrders.json": {
              "name": "financeOrders",
              "description": null,
              "siblingRank": 100,
              "resourceType": "TableBased",
              "prefix": "finance",
              "entity": "orders",
              "join": "customer_name = [name]",
              "isCollection": true,
              "isCombined": false,
              "filter": null,
              "order": null,
              "useSchemaAttributes": false,
              "attributes": [
                {
                  "attribute": "cloned_from_order_ident",
                  "alias": "cloned_from_order_ident",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "ident",
                  "alias": "ident",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "ts",
                  "alias": "ts",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "amount_total",
                  "alias": "amountTotal",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "amount_discounted",
                  "alias": "amountDiscounted",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "amount_paid",
                  "alias": "amountPaid",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "amount_un_paid",
                  "alias": "amountNn_paid",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "is_ready",
                  "alias": "is_ready",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "approving_officer",
                  "alias": "approving_officer",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "officer_item_usage_approval",
                  "alias": "officer_item_usage_approval",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "unresolved_usage_count",
                  "alias": "unresolved_usage_count",
                  "description": null,
                  "isKey": false
                }
              ]
            },
            "{f}financeOrders.js": ""
          }
        },
        "{d}OrderLookupParent": {
          "{f}OrderLookupParent.json": {
            "name": "OrderLookupParent",
            "description": "PUT this object to see LOOKUP in action.\n{ \"@metadata\":  {\"action\":\"INSERT\"}, \"Customer\": { \"@metadata\": { \"action\":\"LOOKUP\",  \"key\":\"Name\"}, \"Name\":\"Alpha and Sons\"}, \"Items\":[ { \"Product\": { \"@metadata\": {\"action\":\"LOOKUP\", \"key\":\"ProductName\"}, \"ProductName\":\"Hammer\"}, \"Quantity\": 1} ]}",
            "siblingRank": 100,
            "resourceType": "TableBased",
            "prefix": "demo",
            "entity": "PurchaseOrder",
            "isCollection": true,
            "isCombined": false,
            "filter": null,
            "order": null,
            "useSchemaAttributes": false,
            "attributes": [
              {
                "attribute": "order_number",
                "alias": "order_number",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "amount_total",
                "alias": "amount_total",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "paid",
                "alias": "paid",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "notes",
                "alias": "notes",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "customer_name",
                "alias": "customer_name",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "salesrep_id",
                "alias": "salesrep_id",
                "description": null,
                "isKey": false
              }
            ]
          },
          "{f}OrderLookupParent.js": "",
          "{d}Customer": {
            "{f}Customer.json": {
              "name": "Customer",
              "description": null,
              "siblingRank": 100,
              "resourceType": "TableBased",
              "prefix": "demo",
              "entity": "customer",
              "join": "\"name\" = [customer_name]",
              "isCollection": false,
              "isCombined": false,
              "filter": null,
              "order": null,
              "useSchemaAttributes": false,
              "attributes": [
                {
                  "attribute": "name",
                  "alias": "Name",
                  "description": null,
                  "isKey": false
                }
              ]
            },
            "{f}Customer.js": ""
          },
          "{d}Items": {
            "{f}Items.json": {
              "name": "Items",
              "description": null,
              "siblingRank": 100,
              "resourceType": "TableBased",
              "prefix": "demo",
              "entity": "LineItem",
              "join": "\"order_number\" = [order_number]",
              "isCollection": true,
              "isCombined": false,
              "filter": null,
              "order": null,
              "useSchemaAttributes": false,
              "attributes": [
                {
                  "attribute": "qty_ordered",
                  "alias": "Quantity",
                  "description": null,
                  "isKey": false
                }
              ]
            },
            "{f}Items.js": "",
            "{d}Product": {
              "{f}Product.json": {
                "name": "Product",
                "description": null,
                "siblingRank": 100,
                "resourceType": "TableBased",
                "prefix": "demo",
                "entity": "product",
                "join": "\"product_number\" = [product_number]",
                "isCollection": false,
                "isCombined": false,
                "filter": null,
                "order": null,
                "useSchemaAttributes": false,
                "attributes": [
                  {
                    "attribute": "name",
                    "alias": "ProductName",
                    "description": null,
                    "isKey": false
                  },
                  {
                    "attribute": "price",
                    "alias": "Price",
                    "description": null,
                    "isKey": false
                  }
                ]
              },
              "{f}Product.js": ""
            }
          }
        },
        "{d}Products": {
          "{f}Products.json": {
            "name": "Products",
            "description": "Query for all products",
            "siblingRank": 100,
            "resourceType": "TableBased",
            "prefix": "demo",
            "entity": "product",
            "isCollection": true,
            "isCombined": false,
            "filter": null,
            "order": null,
            "useSchemaAttributes": false,
            "attributes": [
              {
                "attribute": "name",
                "alias": "name",
                "description": "",
                "isKey": false
              },
              {
                "attribute": "price",
                "alias": "price",
                "description": "",
                "isKey": false
              }
            ]
          },
          "{f}Products.js": ""
        },
        "{d}PurchaseOrders": {
          "{f}PurchaseOrders.json": {
            "name": "PurchaseOrders",
            "description": "Query for all orders with line items",
            "siblingRank": 100,
            "resourceType": "TableBased",
            "prefix": "demo",
            "entity": "PurchaseOrder",
            "isCollection": true,
            "isCombined": false,
            "filter": null,
            "order": null,
            "useSchemaAttributes": false,
            "attributes": [
              {
                "attribute": "order_number",
                "alias": "order_number",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "amount_total",
                "alias": "amount_total",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "paid",
                "alias": "paid",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "notes",
                "alias": "notes",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "customer_name",
                "alias": "customer_name",
                "description": null,
                "isKey": false
              },
              {
                "attribute": "salesrep_id",
                "alias": "salesrep_id",
                "description": null,
                "isKey": false
              }
            ]
          },
          "{f}PurchaseOrders.js": "",
          "{d}LineItems": {
            "{f}LineItems.json": {
              "name": "LineItems",
              "description": "API example",
              "siblingRank": 100,
              "resourceType": "TableBased",
              "prefix": "demo",
              "entity": "LineItem",
              "join": "\"order_number\" = [order_number]",
              "isCollection": true,
              "isCombined": false,
              "filter": null,
              "order": "\"product_number\" asc",
              "useSchemaAttributes": false,
              "attributes": [
                {
                  "attribute": "lineitem_id",
                  "alias": "lineitem_id",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "product_number",
                  "alias": "product_number",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "order_number",
                  "alias": "order_number",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "qty_ordered",
                  "alias": "qty_ordered",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "product_price",
                  "alias": "product_price",
                  "description": null,
                  "isKey": false
                },
                {
                  "attribute": "amount",
                  "alias": "amount",
                  "description": null,
                  "isKey": false
                }
              ]
            },
            "{f}LineItems.js": ""
          }
        },
        "{d}PurchaseOrdersFreeSQL": {
          "{f}PurchaseOrdersFreeSQL.json": {
            "name": "PurchaseOrdersFreeSQL",
            "description": "Using FreeSQL - you can create complex sql statements. This is a group by find sales reps with large quantity (>20) lineitem sales.",
            "siblingRank": 100,
            "resourceType": "FreeSQL",
            "prefix": "demo",
            "isCollection": true
          },
          "{f}PurchaseOrdersFreeSQL.sql": "SELECT sum(\"amount_total\") as SUM_AMOUNT\n      ,\"salesrep_id\"\n  FROM \"@{SCHEMA}\".\"PurchaseOrder\" o\n inner join \"@{SCHEMA}\".\"LineItem\" i\n    on o.\"order_number\" = i.\"order_number\"\n where \"paid\" = true\n   and i.\"product_number\" in\n  (SELECT l.\"product_number\"\n     FROM \"@{SCHEMA}\".\"LineItem\" l\n     group by l.\"product_number\"\n   having count(*) > 20)\n group by \"salesrep_id\"",
          "{f}PurchaseOrdersFreeSQL.js": "row.foo = 'these reps have sold more than 20 items';\n"
        }
      }
    },
    "{d}rules": {
      "{f}ReadMe.md": "This folder contains definitions for rules",
      "{d}demo": {
        "{f}ReadMe.md": "Rules for entities in prefix demo",
        "{d}customer": {
          "{f}?????????.json": {
            "name": "?????????",
            "isActive": true,
            "ruleType": "validation",
            "codeType": "JavaScript",
            "errorMessage": "Customer {name}'s balance: {balance|#,##0.00} exceeds their credit limit: {credit_limit|#,##0.00}",
            "problemAttributes": [],
            "isAutoTitle": true,
            "title": "Validation: return row.balance <= row.credit_limit;\n",
            "comments": "balance cannot exceed credit limit, else throw exception",
            "topics": [
              "Check Credit"
            ]
          },
          "{f}?????????.js": "return row.balance <= row.credit_limit;\n",
          "{f}event_ibuiu.json": {
            "name": "event_ibuiu",
            "isActive": false,
            "ruleType": "event",
            "asynchronous": false,
            "appliesTo": {
              "insert": true,
              "update": true,
              "delete": false
            },
            "codeType": "JavaScript",
            "isAutoTitle": false,
            "title": "Lookup city and state from zip code",
            "comments": null,
            "topics": []
          },
          "{f}event_ibuiu.js": "var detail = {\n        filter: \"{_id: \\\"32751\\\"}\" ,\n        order: \"\",\n        pagesize: 30,\n        offset: 0,\n        verbose: false\n};\n\nvar response =  SysUtility.getResource('zipcodes', detail);\nlog.debug(JSON.stringify(response,null,2));\nlog.debug(response[0].state);\nlog.debug(response[0].city);\n//log.debug(response[0].loc);",
          "{f}sum_balance.json": {
            "name": "sum_balance",
            "isActive": true,
            "ruleType": "sum",
            "attribute": "balance",
            "roleToChildren": "PurchaseOrderList",
            "childAttribute": "amount_total",
            "qualification": "paid = false",
            "isJIT": false,
            "isAutoTitle": true,
            "title": "balance = sum(PurchaseOrderList.amount_total where paid = false)",
            "comments": "A rule is like a spreadsheet cell formula... it *reacts\" to changes in referenced data...\n* increased when order placed\n* decreased when order deleted... or paid\n* adjusted when order changed... or assigned to a new customer",
            "topics": [
              "Check Credit"
            ]
          }
        },
        "{d}LineItem": {
          "{f}formula_amount.json": {
            "name": "formula_amount",
            "isActive": true,
            "ruleType": "formula",
            "attribute": "amount",
            "codeType": "JavaScript",
            "isJIT": false,
            "isAutoTitle": false,
            "title": "Discounted price*qty",
            "comments": "Reactive Logic is expressed in JavaScript, so you use...\n- conditional logic (as above),\n- standard JavaScript services (e.g., moment date functions - enable in Project > Libraries),\n- SQL / external services.... whatever is required.",
            "topics": [
              "Check Credit"
            ]
          },
          "{f}formula_amount.js": "if (row.qty_ordered <= 6)  // discount (using conditional JavaScript logic)\n   return row.product_price * row.qty_ordered;\nelse\n   return row.product_price * row.qty_ordered * 0.8;\n",
          "{f}parentCopy_product_price.json": {
            "name": "parentCopy_product_price",
            "isActive": true,
            "ruleType": "parentCopy",
            "attribute": "product_price",
            "roleToParent": "product",
            "parentAttribute": "price",
            "isAutoTitle": true,
            "title": "product_price = parentcopy(product.price)",
            "comments": "Parent copy means order unaffected by product price changes",
            "topics": [
              "Check Credit"
            ]
          }
        },
        "{d}PurchaseOrder": {
          "{f}event_naqnj.json": {
            "name": "event_naqnj",
            "isActive": true,
            "ruleType": "event",
            "asynchronous": false,
            "appliesTo": {
              "insert": false,
              "update": true,
              "delete": false
            },
            "codeType": "JavaScript",
            "isAutoTitle": false,
            "title": "Audit Purchase Order amount changes",
            "comments": "row, logicContext passed in from engine; initialVerb is *client* action (e.g., POST), irrespective of subsequent updates (e.g., from item adjustments)\nearly events execute before reactive expressions, events execute after reactive expressions, commit events execute after all rows are processed",
            "topics": [
              "Audit Orders"
            ]
          },
          "{f}event_naqnj.js": "if (row.amount_total != oldRow.amount_total) {\n  var newPurchaseorder_audit = logicContext.createPersistentBean(\"purchaseorder_audit\");\n  newPurchaseorder_audit.amount_total = oldRow.amount_total;  // set attributes from old values\n  newPurchaseorder_audit.paid = oldRow.paid;\n  newPurchaseorder_audit.customer_name = oldRow.customer_name;\n  newPurchaseorder_audit.order_number = oldRow.order_number;  // set the foreign key\n  logicContext.insert(newPurchaseorder_audit);                // saves (fires logic)\n}\n// better: re-use alternative using Loadable Libraries\n// if (row.amount_total != oldRow.amount_total)\n//   SysLogic.insertChildFrom(\"purchaseorder_audit\", logicContext);",
          "{f}sum_amount_total.json": {
            "name": "sum_amount_total",
            "isActive": true,
            "ruleType": "sum",
            "attribute": "amount_total",
            "roleToChildren": "LineItemList",
            "childAttribute": "amount",
            "qualification": null,
            "isJIT": false,
            "isAutoTitle": true,
            "title": "amount_total = sum(LineItemList.amount)",
            "comments": "sum of line item amounts",
            "topics": [
              "Check Credit"
            ]
          }
        }
      },
      "{d}finance": {
        "{f}ReadMe.md": "Rules for entities in prefix finance"
      }
    },
    "{d}security": {
      "{f}ReadMe.md": "This folder contains definitions for security",
      "{d}authtokens": {
        "{f}ReadMe.md": "This contains statically defined API Keys (Auth Tokens) for this project.\nDynamically created keys (using @authentication service) are NOT affected by these.",
        "{f}Broad access.json": {
          "name": "Broad access",
          "authToken": "demo_full",
          "description": null,
          "userIdentifier": "sam",
          "isActive": true,
          "expiration": null,
          "logging": "*=FINE",
          "roles": [
            "API Owner"
          ],
          "globals": {}
        },
        "{f}Restricted access.json": {
          "name": "Restricted access",
          "authToken": "demo_restricted",
          "description": null,
          "userIdentifier": null,
          "isActive": true,
          "expiration": null,
          "logging": null,
          "roles": [
            "API User"
          ],
          "globals": {
            "customerName": "Bravo Hardware"
          }
        },
        "{f}SalesRep.json": {
          "name": "SalesRep",
          "authToken": "SalesRepApiKey",
          "description": null,
          "userIdentifier": "sam",
          "isActive": true,
          "expiration": null,
          "logging": "*=FINE",
          "roles": [
            "Sales Rep"
          ],
          "globals": {}
        }
      },
      "{d}roles": {
        "{f}ReadMe.md": "This contains Roles defined for the project.\nRoles define which server features are available and what the permissions\non each feature is enabled.",
        "{f}API Documentation.json": {
          "name": "API Documentation",
          "description": "Full permissions on the entire API, special documentation role",
          "defaultTablePermission": "A",
          "defaultViewPermission": "A",
          "globals": {},
          "apiVisibility": {
            "table": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "view": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "resource": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "procedure": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "metatable": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "function": {
              "isRestricted": false,
              "restrictedTo": null
            }
          },
          "entityPermission": {},
          "functionPermission": null
        },
        "{f}API Owner.json": {
          "name": "API Owner",
          "description": "Full permissions on the entire API",
          "defaultTablePermission": "A",
          "defaultViewPermission": "A",
          "globals": {},
          "apiVisibility": {
            "table": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "view": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "resource": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "procedure": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "metatable": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "function": {
              "isRestricted": false,
              "restrictedTo": null
            }
          },
          "entityPermission": {},
          "functionPermission": null
        },
        "{f}API User.json": {
          "name": "API User",
          "description": "Limited permissions on the entire API",
          "defaultTablePermission": "N",
          "defaultViewPermission": "N",
          "globals": {},
          "apiVisibility": {
            "table": {
              "isRestricted": true,
              "restrictedTo": []
            },
            "view": {
              "isRestricted": true,
              "restrictedTo": []
            },
            "resource": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "procedure": {
              "isRestricted": true,
              "restrictedTo": []
            },
            "metatable": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "function": {
              "isRestricted": true,
              "restrictedTo": []
            }
          },
          "entityPermission": {
            "Access customers": {
              "entity": "demo:customer",
              "description": "only customers associated with current user, per Auth Token (see Details tab, Globals)",
              "accessLevels": [
                "READ"
              ],
              "rowFilter": "\"name\" = '@{customerName}'",
              "columnFilter": {
                "isRestricted": false,
                "restrictedTo": null
              }
            },
            "Access lineitems": {
              "entity": "demo:LineItem",
              "description": "only line items associated with customer(s) for current user, per Auth Token (see Details tab, Globals)",
              "accessLevels": [
                "ALL"
              ],
              "rowFilter": "lineitem_purchaseorder.customer_name = '@{customerName}'",
              "columnFilter": {
                "isRestricted": false,
                "restrictedTo": null
              }
            },
            "Access orders": {
              "entity": "demo:PurchaseOrder",
              "description": "only orders associated with customer(s) for current user, per Auth Token (see Details tab, Globals)",
              "accessLevels": [
                "READ"
              ],
              "rowFilter": "\"customer_name\" = '@{customerName}'",
              "columnFilter": {
                "isRestricted": false,
                "restrictedTo": null
              }
            },
            "Access products 2 full": {
              "entity": "demo:product",
              "description": "column security - product_number & name visible to all with insert, product 2 only",
              "accessLevels": [
                "ALL"
              ],
              "rowFilter": "\"product_number\" = 2",
              "columnFilter": {
                "isRestricted": false,
                "restrictedTo": null
              }
            },
            "Access products all restricted": {
              "entity": "demo:product",
              "description": "column security - product_number & name visible to all, but not insert",
              "accessLevels": [
                "READ",
                "UPDATE"
              ],
              "rowFilter": null,
              "columnFilter": {
                "isRestricted": true,
                "restrictedTo": [
                  "product_number",
                  "name"
                ]
              }
            }
          },
          "functionPermission": null
        },
        "{f}Sales Rep.json": {
          "name": "Sales Rep",
          "description": "Preselects orders",
          "defaultTablePermission": "N",
          "defaultViewPermission": "N",
          "globals": {
            "current_employee_row": {
              "name": "current_employee_row",
              "description": null,
              "isRequired": true,
              "executionOrder": 1,
              "codeType": "SQL",
              "prefix": "demo",
              "sqlFragment": "* from \"employee\" where \"login\" = '@{_apikey.user_identifier}'"
            }
          },
          "apiVisibility": {
            "table": {
              "isRestricted": true,
              "restrictedTo": []
            },
            "view": {
              "isRestricted": true,
              "restrictedTo": []
            },
            "resource": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "procedure": {
              "isRestricted": true,
              "restrictedTo": []
            },
            "metatable": {
              "isRestricted": false,
              "restrictedTo": null
            },
            "function": {
              "isRestricted": true,
              "restrictedTo": []
            }
          },
          "entityPermission": {
            "My Orders - no update of paid flag": {
              "entity": "demo:PurchaseOrder",
              "description": "Read, insert and delete my orders (see Globals tab), cannot update paid flag",
              "accessLevels": [
                "READ",
                "INSERT",
                "DELETE"
              ],
              "rowFilter": "\"salesrep_id\" = @{current_employee_row.employee_id}",
              "columnFilter": {
                "isRestricted": true,
                "restrictedTo": [
                  "paid"
                ]
              }
            },
            "My Orders Write": {
              "entity": "demo:PurchaseOrder",
              "description": "read, insert and delete my orders (see Globals tab), any columns",
              "accessLevels": [
                "ALL"
              ],
              "rowFilter": "\"salesrep_id\" = @{current_employee_row.employee_id}",
              "columnFilter": {
                "isRestricted": true,
                "restrictedTo": [
                  "order_number",
                  "amount_total",
                  "notes",
                  "customer_name",
                  "salesrep_id"
                ]
              }
            }
          },
          "functionPermission": null
        }
      },
      "{d}users": {
        "{f}ReadMe.md": "This contains Users defined for the system when using the default authentication provider.\nWhile this can be used for production systems, typically the authentication provider is LDAP\nor some other mechanism.",
        "{f}admin.json": {
          "name": "admin",
          "fullname": "Demo user (admin)",
          "email": "admin@ca.com",
          "isActive": true,
          "comments": null,
          "keyLifetimeSeconds": null,
          "passwordHash": "EdjunGe7M4Jg7uizPHcV4Maroq7o7aU9zqN1JKXiI263/sRz9bq+qtuguhcPA2fV7I98d5JRaWLOAeN4bji8Sg==",
          "passwordSalt": "AP4Eo+W4+TduzYO2w5MXW0Fi0WotRaTf8+y5X/nC",
          "roles": [
            "API Owner"
          ],
          "globals": {}
        },
        "{f}demo.json": {
          "name": "demo",
          "fullname": "Demo user",
          "email": "admin@ca.com",
          "isActive": true,
          "comments": null,
          "keyLifetimeSeconds": null,
          "passwordHash": "nOFrhJ2nHhTlvqhLop40wxkLoa6ldXdk/w4D2Orb02QXKX+ywbBWpxbzBRPauG/FC7zS2HfUhPxzfNBkKW03Ww==",
          "passwordSalt": "BtTcwIdJeVjIA9kB4mxVOMqQ6voMrCoD+t4EeZ7a",
          "roles": [
            "API Owner"
          ],
          "globals": {}
        }
      }
    },
    "{d}sorts": {
      "{f}ReadMe.md": "This folder contains definitions for sorts"
    },
    "{d}timers": {
      "{f}ReadMe.md": "This folder contains definitions for timers"
    },
    "{d}topics": {
      "{f}ReadMe.md": "This folder contains definitions for topics",
      "{f}Audit Orders.json": {
        "name": "Audit Orders",
        "color": "#00fcee",
        "summary": "If amount changes"
      },
      "{f}Audit Orders.html": "<p>This examples illustrates that your logic is a combination of Reactive Programming Rules, and JavaScript.</p>\n\n<p>Note your JavaScript can use LIbraries of Java/JavaScript code. &nbsp;Upload these to your project in Project properties.</p>\n\n<p>&nbsp;</p>\n",
      "{f}Check Credit.json": {
        "name": "Check Credit",
        "color": "#96f90d",
        "summary": "Ensure the balance does not exceed the credit limit."
      },
      "{f}Check Credit.html": "<h2>Business Context</h2>\n\n<p>Story: <strong>Place Order.</strong> &nbsp;</p>\n\n<p>Task/Requirement: <strong>Check Credit.</strong>&nbsp;&nbsp;(or, your methodology / terminology).</p>\n\n<p>&nbsp;</p>\n\n<h2>Business view</h2>\n\n<p>When placing&nbsp;an order, <em>check credit</em> - elaborated as follows (the <cite>&quot;cocktail napkin spec&quot;</cite>)...&nbsp;</p>\n\n<ul>\n\t<li>the Balance must be less than or equal to the Credit Limit, where... &nbsp;(step-wise definition of terms)</li>\n\t<li>the Balance is the sum of the unpaid Order Amount Totals, where...</li>\n\t<li>the Amount Total is the sum of the LineItem Amounts, where...</li>\n\t<li>the Amount is the discounted Price * Quantity, where...</li>\n\t<li>the Price is obtained from the Product</li>\n</ul>\n\n<p>A good spec - clear, concise.</p>\n\n<p>&nbsp;</p>\n\n<hr />\n<h2>Conventional Design</h2>\n\n<p>In a conventional approach, you might design the following <strong>pseudocode</strong>:</p>\n\n<ol>\n\t<li>Compute the LineItem.amount\n\t<ol>\n\t\t<li>Read the Product to get the Price</li>\n\t\t<li>Multiply by qty_ordered to compute the amount</li>\n\t</ol>\n\t</li>\n\t<li>Update the PurchaseOrder.amount_total\n\t<ol>\n\t\t<li>Read the PurchaseOrder</li>\n\t\t<li>Increase the amount_total</li>\n\t\t<li>Update the PurchaseOrder (to cache)</li>\n\t</ol>\n\t</li>\n\t<li>Update the Customer.balance\n\t<ol>\n\t\t<li>Read the Customer,</li>\n\t\t<li>Increase the balance</li>\n\t\t<li>Update the Customer (to cache)</li>\n\t</ol>\n\t</li>\n\t<li>Check that&nbsp;balance &lt;= credit_limit\n\t<ol>\n\t\t<li>Throw exception with error message for UI handling</li>\n\t\t<li>Rollback the transaction</li>\n\t</ol>\n\t</li>\n</ol>\n\n<p>But Place Order is&nbsp;<em><strong>just one Story</strong>.</em>&nbsp;&nbsp;We need analogous logic for <em>all the related</em> Stories (Detete Order, Pay Order, etc etc).</p>\n\n<p>&nbsp;</p>\n\n<hr />\n<h2>Reactive Rule Approach</h2>\n\n<p>And that&#39;s the power of declarative reactive logic. &nbsp;You simply state the rules below (nearly the same as the cocktail napkin).</p>\n\n<p>&nbsp;</p>\n\n<h2>Reactive Rule Execution: Watch, React and&nbsp;Chain</h2>\n\n<p>And (as in a spreadsheet), the rules&nbsp;are <em>automatically</em> applied to all incoming transactions:</p>\n\n<ol>\n\t<li>They <strong><em>watch</em></strong>&nbsp;for changes in data referenced by rules</li>\n\t<li>They&nbsp;<em><strong>react</strong></em>&nbsp;to changes in referenced data. &nbsp;Execution order is dictated by dependencies. &nbsp;</li>\n\t<li>They&nbsp;<em><strong>chain</strong></em>&nbsp;- including across tables. &nbsp;So changes to line items affect their order, which affect their customer</li>\n</ol>\n\n<p>Note it works across tables. &nbsp;Consider&nbsp;the customer balance - the sum of the unpaid order amounts.<br />\nIt works rather like a spreadsheet. &nbsp;Order changes are watched, and the balance is</p>\n\n<ul>\n\t<li>increased when order inserted</li>\n\t<li>decreased when order deleted... or paid</li>\n\t<li>adjusted when the order amount total is changed... or assigned to a new customer... or the line items are altered</li>\n</ul>\n\n<p>Observe persistence is automated (no need to read/write the customer, or deal with transactions). &nbsp;And it&#39;s optimized:</p>\n\n<ul>\n\t<li>adjustments are 1 row updates, not select sum queries</li>\n\t<li>sql is averted if the watched data is not changed</li>\n\t<li>caching is provided (inserting multiple line items results in just 1 adjustment to order and customer)</li>\n</ul>\n\n<p>&nbsp;</p>\n\n<hr />\n<h2>Bottom Line</h2>\n\n<p>That means the following Stories are&nbsp;<em>automatically</em>&nbsp;addressed with our 5 &quot;cocktail napkin&quot;&nbsp;rules:</p>\n\n<ul>\n\t<li>Delete Order - the balance is reduced</li>\n\t<li>Pay Order - the balance is reduced</li>\n\t<li>UnPay the Order - balance is increased</li>\n\t<li>Reassign Order to a new customer - new customer balance increased, old balance decreased (for unpaid Orders)</li>\n\t<li>Reassign a Line Item to a different Product - adjusts the order&#39;s amount total</li>\n\t<li>Add a Line Item</li>\n\t<li>Delete a Line Item</li>\n\t<li>Change Line Item Quantity</li>\n\t<li>Reassign Product to Line Item</li>\n\t<li>Do <em>multiple</em> of these, in combination (&quot;no, 2 hammers, not 1 shovel&quot;)</li>\n</ul>\n\n<p>A conventional approach would require hundreds of lines of code, might easily miss corner cases, and be tedious to maintain.</p>\n\n<p>&nbsp;</p>\n"
    },
    "{f}apioptions.json": {
      "Aggregate Default Override": {
        "dataType": "boolean",
        "value": false,
        "defaultValue": false
      },
      "Allow Swagger without authentication": {
        "dataType": "boolean",
        "value": true,
        "defaultValue": false
      },
      "Audit User Transactions": {
        "dataType": "boolean",
        "value": false,
        "defaultValue": false
      },
      "Binary Output Encoding": {
        "dataType": "enum",
        "value": "base64",
        "defaultValue": "hex"
      },
      "Checksum Size Limit": {
        "dataType": "integer",
        "value": 2000,
        "defaultValue": 2000
      },
      "Chunk Size Default": {
        "dataType": "integer",
        "value": 20,
        "defaultValue": 20
      },
      "Default response format": {
        "dataType": "enum",
        "value": "json",
        "defaultValue": "json"
      },
      "Disallow free-form filters and sorts": {
        "dataType": "boolean",
        "value": false,
        "defaultValue": false
      },
      "Enable HTTP Basic Authentication": {
        "dataType": "boolean",
        "value": true,
        "defaultValue": true
      },
      "Force Binary Data as an Object": {
        "dataType": "boolean",
        "value": true,
        "defaultValue": false
      },
      "Force Consistent Pagination when no primary key": {
        "dataType": "boolean",
        "value": false,
        "defaultValue": false
      },
      "HTTPS only": {
        "dataType": "boolean",
        "value": false,
        "defaultValue": false
      },
      "Inline Limit Default": {
        "dataType": "integer",
        "value": 6000,
        "defaultValue": 2000
      },
      "JSON NaN (Quiet)": {
        "dataType": "string",
        "value": "null",
        "defaultValue": "null"
      },
      "JSON NaN (Signaling)": {
        "dataType": "string",
        "value": "null",
        "defaultValue": "null"
      },
      "JSON Negative Infinity": {
        "dataType": "string",
        "value": "null",
        "defaultValue": "null"
      },
      "JSON Positive Infinity": {
        "dataType": "string",
        "value": "null",
        "defaultValue": "null"
      },
      "Maximum Page Size": {
        "dataType": "integer",
        "value": 5000,
        "defaultValue": 5000
      },
      "Metadata name": {
        "dataType": "string",
        "value": "@metadata",
        "defaultValue": "@metadata"
      },
      "Page Size Default": {
        "dataType": "integer",
        "value": 20,
        "defaultValue": 20
      },
      "Permit Authorization parameter in URL": {
        "dataType": "boolean",
        "value": true,
        "defaultValue": false
      },
      "Provide detailed security debugging": {
        "dataType": "enum",
        "value": "0",
        "defaultValue": "0"
      },
      "Realm for HTTP Basic Authentication": {
        "dataType": "string",
        "value": null,
        "defaultValue": null
      },
      "Stored Procedure Inline Limit": {
        "dataType": "integer",
        "value": 2000,
        "defaultValue": 2000
      },
      "Stored Procedure Row Limit": {
        "dataType": "integer",
        "value": 100,
        "defaultValue": 100
      },
      "Tech docs URL": {
        "dataType": "string",
        "value": "http://ca-doc.espressologic.com/docs/tutorial/business-logic-demo",
        "defaultValue": null
      },
      "Type base URI": {
        "dataType": "string",
        "value": "urn:caliveapicreator:examples:demo:",
        "defaultValue": "urn:caliveapicreator:"
      },
      "User docs URL": {
        "dataType": "string",
        "value": null,
        "defaultValue": null
      },
      "XML Document Root Element Tag Name": {
        "dataType": "string",
        "value": "root",
        "defaultValue": "root"
      }
    },
    "{f}project.json": {
      "name": "Demo",
      "urlFragment": "demo",
      "comments": "Welcome examples.",
      "isEnabled": true,
      "authProviderName": "Built-in authentication"
    },
    "{f}exportoptions.json": {
      "passwordStyle": "ENCRYPTED"
    }
  }
}