{
  "includeFiles":[
  ],
  "metadata":{
    "amiCustomCss":[
      "\n",
      ".error {\n",
      "  color: red;\n",
      "}\n",
      "\n",
      "\n",
      ".noerror {\n",
      "  color: black;\n",
      "}\n",
      ".material {\n",
      "  background: #f5f5f5;\n",
      "  border: none;\n",
      "  border-bottom: 1px solid #1a1b1f;\n",
      "  -moz-border-radius: 0px;\n",
      "  -webkit-border-radius: 10px 10px 0px 0px;\n",
      "  border-radius: 10px 10px 0px 0px; \n",
      "}\n",
      ".material_button {\n",
      "  background-color: #3c55b2;\n",
      "  color: white;\n",
      "  border: none;\n",
      "  border-radius: 20px 20px 20px 20px; \n",
      "  box-shadow: 1px 1px 10px rgb(117, 115, 115);\n",
      "}"
    ],
    "amiScriptMethods":[
      "{\n",
      "  boolean validDouble(String input) {\n",
      "    return (null != ((Double)input));\n",
      "  };\n",
      "  \n",
      "  boolean validInteger(String input) {\n",
      "    Double asDouble = input;\n",
      "    if (null == asDouble) {\n",
      "      return false;\n",
      "    }\n",
      "    Integer asInteger = input;\n",
      "      \n",
      "    if (asInteger  != asDouble) {\n",
      "      return false;\n",
      "    }\n",
      "    return true;\n",
      "  };\n",
      "  \n",
      "  boolean validateGreaterThanZero(Double number) {\n",
      "    return (number > 0);\n",
      "  };\n",
      "}"
    ],
    "customPrefsImportMode":"reject",
    "dm":{
      "dms":[
        {
          "callbacks":{
            "entries":[
              {
                "amiscript":[
                  "{\n",
                  "  CREATE TABLE accounts AS EXECUTE SELECT * FROM `tutorial_accounts` WHERE ${WHERE};\n",
                  "}\n"
                ],
                "defaultDs":"AMI",
                "hasDatamodel":true,
                "linkedVariables":[
                ],
                "name":"onProcess",
                "schema":{
                  "tbl":[
                    {
                      "cols":[
                        {
                          "nm":"id",
                          "tp":"String"
                        },
                        {
                          "nm":"name",
                          "tp":"String"
                        }
                      ],
                      "nm":"accounts",
                      "oc":"ask"
                    }
                  ]
                }
              }
            ]
          },
          "datasources":[
            "AMI"
          ],
          "lbl":"accounts",
          "queryMode":"startup",
          "test_input_type":"OPEN",
          "test_input_vars":"String WHERE=\"true\";"
        },
        {
          "callbacks":{
            "entries":[
              {
                "amiscript":[
                  "{\n",
                  "  CREATE TABLE orders AS  SELECT * FROM orders WHERE ${WHERE};\n",
                  "}\n"
                ],
                "hasDatamodel":true,
                "inputDm":[
                  "orders"
                ],
                "linkedVariables":[
                ],
                "name":"onProcess",
                "schema":{
                  "tbl":[
                    {
                      "cols":[
                        {
                          "nm":"id",
                          "tp":"String"
                        },
                        {
                          "nm":"qty",
                          "tp":"Integer"
                        },
                        {
                          "nm":"price",
                          "tp":"Double"
                        },
                        {
                          "nm":"account_id",
                          "tp":"String"
                        },
                        {
                          "nm":"side",
                          "tp":"String"
                        },
                        {
                          "nm":"ticker",
                          "tp":"String"
                        },
                        {
                          "nm":"status",
                          "tp":"String"
                        },
                        {
                          "nm":"timestamp",
                          "tp":"Long"
                        },
                        {
                          "nm":"tutorial_accounts_id",
                          "tp":"String"
                        },
                        {
                          "nm":"name",
                          "tp":"String"
                        }
                      ],
                      "nm":"orders",
                      "oc":"apply"
                    }
                  ]
                }
              }
            ]
          },
          "lbl":"order_details",
          "test_input_type":"OPEN",
          "test_input_vars":"String WHERE=\"true\";"
        },
        {
          "callbacks":{
            "entries":[
              {
                "amiscript":[
                  "{\n",
                  "  CREATE TABLE orders AS EXECUTE SELECT * FROM `tutorial_orders` JOIN `tutorial_accounts` ON `tutorial_orders`.account_id==`tutorial_accounts`.id WHERE ${WHERE};\n",
                  "\n",
                  "\n",
                  "  \n",
                  "}\n",
                  "\n"
                ],
                "defaultDs":"AMI",
                "hasDatamodel":true,
                "linkedVariables":[
                ],
                "name":"onProcess",
                "schema":{
                  "tbl":[
                    {
                      "cols":[
                        {
                          "nm":"id",
                          "tp":"String"
                        },
                        {
                          "nm":"qty",
                          "tp":"Integer"
                        },
                        {
                          "nm":"price",
                          "tp":"Double"
                        },
                        {
                          "nm":"account_id",
                          "tp":"String"
                        },
                        {
                          "nm":"side",
                          "tp":"String"
                        },
                        {
                          "nm":"ticker",
                          "tp":"String"
                        },
                        {
                          "nm":"status",
                          "tp":"String"
                        },
                        {
                          "nm":"timestamp",
                          "tp":"Long"
                        },
                        {
                          "nm":"tutorial_accounts_id",
                          "tp":"String"
                        },
                        {
                          "nm":"name",
                          "tp":"String"
                        }
                      ],
                      "nm":"orders",
                      "oc":"apply"
                    }
                  ]
                }
              }
            ]
          },
          "datasources":[
            "AMI"
          ],
          "lbl":"orders",
          "test_input_type":"OPEN",
          "test_input_vars":"String WHERE=\"true\";"
        }
      ],
      "lnk":[
        {
          "awcs":[
            {
              "fl":"FALSE",
              "fo":"",
              "j":") or (",
              "pf":"((",
              "sf":"))",
              "to":"",
              "tr":"TRUE",
              "vn":"WHERE",
              "wh":"account_id == \"${Source_id}\""
            }
          ],
          "callbacks":{
          },
          "op":7,
          "relid":"accounts_to_orders",
          "sdmadn":"accounts",
          "sdmtb":"accounts",
          "spadn":"accounts",
          "tdmadn":"orders",
          "title":"Show orders",
          "tpadn":"orders"
        },
        {
          "awcs":[
            {
              "fl":"FALSE",
              "fo":"",
              "j":") or (",
              "pf":"((",
              "sf":"))",
              "to":"",
              "tr":"TRUE",
              "vn":"WHERE",
              "wh":"account_id == \"${Source_account_id}\" && ticker == \"${Source_ticker}\""
            }
          ],
          "callbacks":{
          },
          "op":7,
          "relid":"orders_to_order_details",
          "sdmadn":"orders",
          "sdmtb":"orders",
          "spadn":"orders",
          "tdmadn":"order_details",
          "title":"Show orders",
          "tpadn":"order_details"
        }
      ]
    },
    "fileVersion":3,
    "menubarPosition":"top",
    "rt":{
    },
    "stm":{
      "styles":[
        {
          "id":"LAYOUT_DEFAULT",
          "lb":"Layout Default",
          "pt":"DEFAULT",
          "vl":{
            "table":{
              "columnFilterHide":false,
              "headerDivHide":true,
              "vtAlign":"center"
            },
            "treegrid":{
              "vtAlign":"center"
            }
          }
        },
        {
          "id":"CLAIRESTYLE",
          "lb":"ClaireStyle",
          "pt":"DARK1"
        }
      ]
    },
    "titleBarHtml":"My Dashboard",
    "transientIdPrefix":"TRANSIENT_"
  },
  "portletConfigs":[
    {
      "portletBuilderId":"amidesktop",
      "portletConfig":{
        "amiPanelId":"@DESKTOP",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "windows":[
          {
            "header":true,
            "heightDflt":1216,
            "hidden":false,
            "leftDflt":40,
            "portlet":"Tabs1",
            "pos":0,
            "stateDflt":"flt",
            "title":"Order Explorer",
            "topDflt":65,
            "widthDflt":1230,
            "zindexDflt":1
          },
          {
            "header":true,
            "heightDflt":566,
            "hidden":false,
            "leftDflt":168,
            "portlet":"Html1",
            "pos":1,
            "stateDflt":"flt",
            "title":"Generate Data",
            "topDflt":114,
            "widthDflt":821,
            "zindexDflt":2
          },
          {
            "header":true,
            "heightDflt":650,
            "hidden":false,
            "leftDflt":141,
            "portlet":"Div3",
            "pos":2,
            "stateDflt":"flt",
            "title":"New Accounts and Orders",
            "topDflt":395,
            "widthDflt":1122,
            "zindexDflt":3
          }
        ]
      }
    },
    {
      "portletBuilderId":"amiform",
      "portletConfig":{
        "amiPanelId":"CreateNewAccountForm",
        "amiStyle":{
          "bgCl":"#fafafa",
          "pt":"LAYOUT_DEFAULT"
        },
        "amiTitle":"Create New Account",
        "fields":[
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "if (this.getValue().trim() == \"\") {\n",
                    "  this.setValue(\"Account ID\");\n",
                    "    accountIdLabel.setVisible(false);\n",
                    "} else {\n",
                    "    accountIdLabel.setVisible(true);\n",
                    "}"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELD:CreateNewAccountForm?accountIdLabel",
                      "varName":"accountIdLabel"
                    }
                  ],
                  "name":"onChange"
                },
                {
                  "amiscript":[
                    "if (this.getValue() == \"Account ID\") {\n",
                    "  this.setValue(\"\");\n",
                    "}"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELD:CreateNewAccountForm?accountIdLabel",
                      "varName":"accountIdLabel"
                    }
                  ],
                  "name":"onFocus"
                }
              ]
            },
            "dme":"\"Account ID\"",
            "heightPx":60,
            "l":"",
            "leftPosPx":260,
            "n":"accountIdField",
            "style":{
              "fldCss":"material",
              "fldFontCl":"#3d474e",
              "fldFontFam":"Segoe UI",
              "fldFontSz":16.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"textField",
            "topPosPx":80,
            "widthPx":200,
            "zidx":2
          },
          {
            "heightPx":20,
            "hide":true,
            "l":"",
            "leftPosPx":260,
            "n":"accountIdLabel",
            "style":{
              "fldBgCl":"#00000000",
              "fldBorderWd":0.0,
              "fldFontCl":"#6d6d6d",
              "fldFontFam":"Segoe UI",
              "fldFontSz":10.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"divField",
            "template":"Account ID",
            "topPosPx":80,
            "widthPx":80,
            "zidx":6
          },
          {
            "heightPx":20,
            "hide":true,
            "l":"",
            "leftPosPx":60,
            "n":"accountName",
            "style":{
              "fldBgCl":"#00000000",
              "fldBorderWd":0.0,
              "fldFontCl":"#6d6d6d",
              "fldFontFam":"Segoe UI",
              "fldFontSz":10.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"divField",
            "template":"Account Name",
            "topPosPx":80,
            "widthPx":80,
            "zidx":5
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "if (this.getValue().trim() == \"\") {\n",
                    "  this.setValue(\"Account Name\");\n",
                    "    accountName.setVisible(false);\n",
                    "} else {\n",
                    "    accountName.setVisible(true);\n",
                    "}"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELD:CreateNewAccountForm?accountName",
                      "varName":"accountName"
                    }
                  ],
                  "name":"onChange"
                },
                {
                  "amiscript":[
                    "if (this.getValue() == \"Account Name\") {\n",
                    "  this.setValue(\"\");\n",
                    "}"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELD:CreateNewAccountForm?accountName",
                      "varName":"accountName"
                    }
                  ],
                  "name":"onFocus"
                }
              ]
            },
            "dme":"\"Account Name\"",
            "heightPx":60,
            "l":"",
            "leftPosPx":60,
            "n":"accountNameField",
            "style":{
              "fldBgCl":"#e0e2ec",
              "fldCss":"material",
              "fldFontCl":"#3d474e",
              "fldFontFam":"Segoe UI",
              "fldFontSz":16.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"textField",
            "topPosPx":80,
            "widthPx":180,
            "zidx":1
          },
          {
            "heightPx":60,
            "hide":true,
            "l":"",
            "leftPosPx":100,
            "n":"div",
            "style":{
              "fldBorderWd":0.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"divField",
            "template":"<h1> Create New Account</h1>",
            "topPosPx":20,
            "widthPx":300,
            "zidx":4
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "if (accountName != \"Account Name\" && accountId != \"Account ID\") {\n",
                    "  if (accountId.trim().length() > 0 && accountName.trim().length() > 0) {\n",
                    "    USE DS=\"AMI\" INSERT INTO tutorial_accounts(id, name) VALUES (accountId, accountName);\n",
                    "    accountNameLabel.setVisible(false);\n",
                    "    accountNameField.setValue(\"Account Name\");\n",
                    "    accountIdField.setValue(\"Account ID\");\n",
                    "    accountIdLabel.setVisible(false);\n",
                    "    \n",
                    "  } else {\n",
                    "    session.alert(\"Account Name and Account ID must contain non null values\");\n",
                    "  }\n",
                    "} else {\n",
                    "    session.alert(\"Account Name and Account ID must contain non null values\");\n",
                    "  }\n",
                    "\n",
                    "accounts.reprocess();"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELDVALUE:CreateNewAccountForm?accountIdField?",
                      "varName":"accountId"
                    },
                    {
                      "ari":"FIELD:CreateNewAccountForm?accountIdField",
                      "varName":"accountIdField"
                    },
                    {
                      "ari":"FIELD:CreateNewAccountForm?accountIdLabel",
                      "varName":"accountIdLabel"
                    },
                    {
                      "ari":"FIELDVALUE:CreateNewAccountForm?accountNameField?",
                      "varName":"accountName"
                    },
                    {
                      "ari":"FIELD:CreateNewAccountForm?accountNameField",
                      "varName":"accountNameField"
                    },
                    {
                      "ari":"FIELD:CreateNewAccountForm?accountName",
                      "varName":"accountNameLabel"
                    },
                    {
                      "ari":"DATAMODEL:accounts",
                      "varName":"accounts"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":40,
            "l":"SUBMIT",
            "leftPosPx":260,
            "n":"submitAccount",
            "style":{
              "fldCss":"material_button",
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"buttonField",
            "topPosPx":160,
            "widthPx":200,
            "zidx":3
          }
        ],
        "snap":20,
        "titlePnl":{
          "title":"Create New Account"
        },
        "upid":"CreateNewAccountForm"
      }
    },
    {
      "portletBuilderId":"amiform",
      "portletConfig":{
        "amiPanelId":"CreateNewOrderForm",
        "amiStyle":{
          "bgCl":"#f8f9fa",
          "pt":"LAYOUT_DEFAULT"
        },
        "fields":[
          {
            "dmid":"accounts",
            "dmtbid":"accounts",
            "dscid":"id",
            "dsrt":"asc",
            "dsvid":"name",
            "heightPx":40,
            "l":"Account",
            "leftPosPx":60,
            "n":"accountField",
            "style":{
              "bold":false,
              "fldBdrCl":"#ebedf0",
              "fldBgCl":"#ffffff",
              "fldBorderRad":8.0,
              "fldBorderWd":2.0,
              "fldFontFam":"Segoe UI",
              "fldFontSz":18.0,
              "fldLblAlign":"start",
              "fldLblSide":"top",
              "fontFam":"Segoe UI",
              "fontSz":18.0,
              "lblPd":7.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"selectField",
            "topPosPx":80,
            "widthPx":280,
            "zidx":5
          },
          {
            "heightPx":20,
            "hide":true,
            "l":"",
            "leftPosPx":360,
            "n":"errorPrice",
            "style":{
              "fldBgCl":"#00000000",
              "fldBorderWd":0.0,
              "fldCssHelp":"",
              "fldCssLbl":"",
              "fldFontCl":"#ff0000",
              "fldFontFam":"Segoe UI",
              "fldFontSz":9.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"divField",
            "template":"Price must be a valid decimal",
            "topPosPx":220,
            "widthPx":140,
            "zidx":6
          },
          {
            "heightPx":20,
            "hide":true,
            "l":"",
            "leftPosPx":200,
            "n":"errorQuantity",
            "style":{
              "fldBgCl":"#00000000",
              "fldBorderWd":0.0,
              "fldFontCl":"#ff2323",
              "fldFontFam":"Segoe UI",
              "fldFontSz":9.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"divField",
            "template":"Quantity must be a whole number",
            "topPosPx":220,
            "widthPx":140,
            "zidx":7
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "if (this.getValue() == \"\") {\n",
                    "  this.setCssClass(\"noerror\");\n",
                    "  errorPrice.setVisible(false);\n",
                    "}"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELD:CreateNewOrderForm?errorPrice",
                      "varName":"errorPrice"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":40,
            "l":"Price",
            "leftPosPx":360,
            "n":"priceField",
            "style":{
              "fldBdrCl":"#ebedf0",
              "fldBorderRad":8.0,
              "fldBorderWd":2.0,
              "fldFontFam":"Segoe UI",
              "fldFontSz":18.0,
              "fldLblAlign":"start",
              "fldLblSide":"top",
              "fontCl":"#000000",
              "fontFam":"Segoe UI",
              "fontSz":18.0,
              "lblPd":7.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"textField",
            "topPosPx":180,
            "widthPx":160,
            "zidx":7
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "if (this.getValue() == \"\") {\n",
                    "  this.setCssClass(\"noerror\");\n",
                    "  errorQuantity.setVisible(false);\n",
                    "}\n"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELD:CreateNewOrderForm?errorQuantity",
                      "varName":"errorQuantity"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":40,
            "l":"Quantity",
            "leftPosPx":200,
            "n":"quantityField",
            "style":{
              "fldBdrCl":"#ebedf0",
              "fldBorderRad":8.0,
              "fldBorderWd":2.0,
              "fldFontFam":"Segoe UI",
              "fldFontSz":18.0,
              "fldLblAlign":"start",
              "fldLblSide":"top",
              "fontFam":"Segoe UI",
              "fontSz":18.0,
              "lblPd":7.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"textField",
            "topPosPx":180,
            "widthPx":140,
            "zidx":3
          },
          {
            "heightPx":40,
            "l":"Side",
            "leftPosPx":60,
            "n":"sideField",
            "style":{
              "fldBdrCl":"#ebedf0",
              "fldBorderRad":9.0,
              "fldBorderWd":2.0,
              "fldFontCl":"#000000",
              "fldFontFam":"Segoe UI",
              "fldFontSz":18.0,
              "fldLblAlign":"start",
              "fldLblSide":"top",
              "fontFam":"Segoe UI",
              "fontSz":18.0,
              "lblPd":7.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"selectField",
            "topPosPx":180,
            "v":[
              {
                "k":"buy",
                "v":"buy"
              },
              {
                "k":" sell",
                "v":" sell"
              }
            ],
            "widthPx":120,
            "zidx":2
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "String orderId = new UUID();\n",
                    "Long timestamp = session.now() / 1000;\n",
                    "\n",
                    "Double price = priceFieldValue;\n",
                    "Integer quantity = quantityFieldValue;\n",
                    "errorPrice.setVisible(false);\n",
                    "errorQuantity.setVisible(false);\n",
                    "quantityField.setCssClass(\"noerror\");\n",
                    " priceField.setCssClass(\"noerror\");\n",
                    "boolean valid = true;\n",
                    "\n",
                    "if (!validDouble(priceFieldValue) || !validateGreaterThanZero((Double)price)) {\n",
                    "  errorPrice.setVisible(true);\n",
                    "  priceField.setCssClass(\"error\");\n",
                    "  valid = false;\n",
                    "} \n",
                    "if (!validInteger(quantityFieldValue) || !validateGreaterThanZero((Double)quantity)) {\n",
                    "  errorQuantity.setVisible(true);\n",
                    "  quantityField.setCssClass(\"error\");\n",
                    "  valid = false;\n",
                    "}\n",
                    "\n",
                    "if (valid) {\n",
                    "  USE DS =\"AMI\" INSERT INTO tutorial_orders(id, qty, price, account_id, side, ticker, status, timestamp) \n",
                    "          VALUES(orderId, quantity, price, accountFieldValue, sideFieldValue, symbolFieldValue, \"OPEN\", timestamp);\n",
                    "          \n",
                    "  orders.reprocess();  \n",
                    "  session.alert(\"Order submitted with account: \" + accountFieldValue +\n",
                    "                \"\\n symbol: \"+ symbolFieldValue +\n",
                    "                \"\\n side: \" + sideFieldValue +\n",
                    "                \"\\n price: \" + price +\n",
                    "                \"\\n quantity: \" + quantity +\n",
                    "                \"\\n timestamp: \" + timestamp +\n",
                    "                \"\\n id:\" + orderId);  \n",
                    "}\n",
                    "\n"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELDVALUE:CreateNewOrderForm?accountField?",
                      "varName":"accountFieldValue"
                    },
                    {
                      "ari":"FIELD:CreateNewOrderForm?errorPrice",
                      "varName":"errorPrice"
                    },
                    {
                      "ari":"FIELD:CreateNewOrderForm?errorQuantity",
                      "varName":"errorQuantity"
                    },
                    {
                      "ari":"DATAMODEL:orders",
                      "varName":"orders"
                    },
                    {
                      "ari":"FIELD:CreateNewOrderForm?priceField",
                      "varName":"priceField"
                    },
                    {
                      "ari":"FIELDVALUE:CreateNewOrderForm?priceField?",
                      "varName":"priceFieldValue"
                    },
                    {
                      "ari":"FIELD:CreateNewOrderForm?quantityField",
                      "varName":"quantityField"
                    },
                    {
                      "ari":"FIELDVALUE:CreateNewOrderForm?quantityField?",
                      "varName":"quantityFieldValue"
                    },
                    {
                      "ari":"FIELDVALUE:CreateNewOrderForm?sideField?",
                      "varName":"sideFieldValue"
                    },
                    {
                      "ari":"FIELDVALUE:CreateNewOrderForm?symbolField?",
                      "varName":"symbolFieldValue"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":40,
            "l":"Submit Order",
            "leftPosPx":60,
            "n":"submitButton",
            "style":{
              "fldBgCl":"#316cf4",
              "fldBorderRad":10.0,
              "fldBorderWd":0.0,
              "fldFontCl":"#ffffff",
              "fldFontFam":"Segoe UI",
              "fldFontSz":18.0,
              "fontFam":"Segoe UI",
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"buttonField",
            "topPosPx":260,
            "widthPx":460,
            "zidx":4
          },
          {
            "dmid":"orders",
            "dmtbid":"orders",
            "dscid":"ticker",
            "dsrt":"asc",
            "dsvid":"ticker",
            "heightPx":40,
            "l":"Symbol",
            "leftPosPx":360,
            "n":"symbolField",
            "style":{
              "fldBdrCl":"#ebedf0",
              "fldBgCl":"#ffffff",
              "fldBorderRad":8.0,
              "fldBorderWd":2.0,
              "fldFontFam":"Segoe UI",
              "fldFontSz":18.0,
              "fldLblAlign":"start",
              "fldLblSide":"top",
              "fontFam":"Segoe UI",
              "fontSz":18.0,
              "lblPd":7.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"selectField",
            "topPosPx":80,
            "widthPx":160,
            "zidx":1
          }
        ],
        "snap":20,
        "upid":"CreateNewOrderForm"
      }
    },
    {
      "portletBuilderId":"div",
      "portletConfig":{
        "amiPanelId":"Div1",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "child1":"accounts",
        "child2":"Div2",
        "dir":"v",
        "locked":false,
        "offset":0.24634,
        "upid":"Div1"
      }
    },
    {
      "portletBuilderId":"div",
      "portletConfig":{
        "amiPanelId":"Div2",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "child1":"orders",
        "child2":"order_details",
        "dir":"h",
        "locked":false,
        "offset":0.47392,
        "upid":"Div2"
      }
    },
    {
      "portletBuilderId":"div",
      "portletConfig":{
        "amiPanelId":"Div3",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "child1":"CreateNewAccountForm",
        "child2":"CreateNewOrderForm",
        "dir":"v",
        "locked":false,
        "offset":0.45543,
        "upid":"Div3"
      }
    },
    {
      "portletBuilderId":"amiform",
      "portletConfig":{
        "amiPanelId":"Html1",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "fields":[
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "// Accounts\n",
                    "List accounts = new List();\n",
                    "accounts.add(\"cbe863c8-0f5d-429b-824e-10d515deefe4\", \"Financial First\");\n",
                    "accounts.add(\"a519e7ab-89e0-41fb-ab66-cafffc3d1fdc\", \"Capital Core\");\n",
                    "accounts.add(\"41892d4d-63ab-423e-a3e0-84b36e37fe44\", \"Money Matters\");\n",
                    "accounts.add(\"5aa1102a-5593-4d60-95a2-51b31f22c65e\", \"Dollar Dynamics\");\n",
                    "accounts.add(\"d35e9e02-32e7-4142-880c-15b3283e849f\", \"Cash Compass\");\n",
                    "accounts.add(\"2902ecc7-1762-4ca1-89a4-8adf86aa5875\", \"Financiers Inc\");\n",
                    "accounts.add(\"80b05dca-da8f-4626-abce-d1c4563118c6\", \"Balance Point\");\n",
                    "accounts.add(\"099586fd-03d6-4bf3-80f2-b231e58b380d\", \"Invest Wise\");\n",
                    "accounts.add(\"2a67decd-8181-481e-83d2-d421a94c84ca\", \"Wealth Wisdom\");\n",
                    "accounts.add(\"30509808-4f52-4794-9afc-c6d63e969b23\", \"Financial Boost\");\n",
                    "accounts.add(\"cee51b74-4c9e-483b-a4dc-216fcd12a576\", \"FinancingFlex\");\n",
                    "accounts.add(\"3cdab9d2-103a-4008-895f-4e5f0f2ecfcb\", \"CapitalPlus\");\n",
                    "accounts.add(\"c930b8ef-011e-4a01-8439-4d9564fae84d\", \"CashflowCo\");\n",
                    "accounts.add(\"68c1bb7c-6838-4099-b344-753dc91978c1\", \"BankersEdge\");\n",
                    "accounts.add(\"f5ee7a13-f932-48ca-ab01-058ee6cfe119\", \"MoneyMax\");\n",
                    "accounts.add(\"e26a5794-03b4-4639-a34c-eed2b66c5370\", \"InvestmentsX\");\n",
                    "accounts.add(\"b2117d4c-4aa2-4058-932f-b681f09a9365\", \"MoneyMentors\");\n",
                    "\n",
                    "// Data for orders\n",
                    "Long initialTimestamp = 1672563166;\n",
                    "List tickers = new List(\"AAPL\",\"AMD\",\"AMZN\",\"CSCO\",\"GOOG\",\"IBM\",\"INTC\",\"META\",\"MSFT\",\"NTLX\",\"SBUX\",\"TSLA\");\n",
                    "Rand r = new Rand(1);\n",
                    "int qtyMin = 10;\n",
                    "int qtyMax = 200000;\n",
                    "Double pmin = 31;\n",
                    "Double pmax = 750;\n",
                    "Long ordersPerSymbolAccount = 10;\n",
                    "\n",
                    "// Create tables in center\n",
                    "use DS=\"AMI\" EXECUTE DROP TABLE IF EXISTS tutorial_accounts;\n",
                    "use DS=\"AMI\" EXECUTE DROP TABLE IF EXISTS  tutorial_orders;\n",
                    "\n",
                    "use DS=\"AMI\" EXECUTE CREATE PUBLIC TABLE IF NOT EXISTS tutorial_accounts(id String, name String);\n",
                    "use DS=\"AMI\" EXECUTE CREATE PUBLIC TABLE IF NOT EXISTS tutorial_orders(id String, qty int, price double, account_id String, side String, ticker String, status String, timestamp Long);\n",
                    "\n",
                    "\n",
                    "Double totalInserts = tickers.size() * ordersPerSymbolAccount * (accounts.size()/2);\n",
                    "Long count = 0;\n",
                    "Long percent = 0;\n",
                    " progress.setValue(0);\n",
                    "genData.setDisabled(true);\n",
                    "for (int i = 0; i < accounts.size(); i+=2) {\n",
                    "  String accountId = accounts.get(i);\n",
                    "  String name = accounts.get(i+1);\n",
                    "      \n",
                    "  USE DS=\"AMI\" EXECUTE INSERT INTO tutorial_accounts(id, name) values(\"${accountId}\",\"${name}\");\n",
                    "  \n",
                    "  for (String ticker:tickers) {\n",
                    "    for (int j = 0; j < ordersPerSymbolAccount; ++j) {\n",
                    "      count++;\n",
                    "      percent = (Long)((((Double)count)  /  totalInserts) * 100.00);\n",
                    "      progress.setValue(percent);\n",
                    "      String id = new UUID();\n",
                    "      int qty = r.nextInt(qtyMin, qtyMax);\n",
                    "      Double price = r.nextDouble(pmin, pmax);\n",
                    "      String side = (r.nextBoolean()?\"buy\": \"sell\");\n",
                    "      initialTimestamp += 1;\n",
                    "      \n",
                    "      USE DS=\"AMI\" EXECUTE INSERT INTO tutorial_orders(id, qty, price, account_id, side, ticker, status, timestamp) values(\"${id}\",${qty}, ${price},\"${accountId}\",\"${side}\",\"${ticker}\",\"Filled\",${initialTimestamp});\n",
                    "\n",
                    "    }\n",
                    "  }\n",
                    "}\n",
                    "\n",
                    "accountsDM.reprocess();\n",
                    "genData.setDisabled(false);"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"DATAMODEL:accounts",
                      "varName":"accountsDM"
                    },
                    {
                      "ari":"FIELD:Html1?genData",
                      "varName":"genData"
                    },
                    {
                      "ari":"FIELD:Html1?progress",
                      "varName":"progress"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":80,
            "l":"Generate Data",
            "leftPosPx":240,
            "n":"genData",
            "style":{
              "fldBdrCl":"#000000",
              "fldBgCl":"#80f7aa",
              "fldBorderRad":8.0,
              "fldBorderWd":2.0,
              "fldFontFam":"Roboto",
              "fldFontSz":53.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"buttonField",
            "topPosPx":180,
            "widthPx":360,
            "zidx":1
          },
          {
            "disabled":true,
            "heightPx":20,
            "l":"Progress",
            "leftPosPx":240,
            "max":100.0,
            "min":0.0,
            "n":"progress",
            "s":1.0,
            "style":{
              "fldLblSide":"top",
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"numericRange",
            "topPosPx":320,
            "widthPx":360,
            "zidx":2
          }
        ],
        "snap":20,
        "upid":"Html1"
      }
    },
    {
      "portletBuilderId":"tab",
      "portletConfig":{
        "amiPanelId":"Tabs1",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "defaultTab":"accounts_orders_tab",
        "tabs":[
          {
            "child":"Div1",
            "id":"accounts_orders_tab",
            "nf":"\"Accounts and Orders\""
          },
          {
            "child":"order_details1",
            "id":"order_details_chart_tab",
            "nf":"\"Order Details Chart\""
          }
        ],
        "upid":"Tabs1"
      }
    },
    {
      "portletBuilderId":"amistatictable",
      "portletConfig":{
        "amiCols":[
          {
            "ei":"",
            "eof":"",
            "fm":"name",
            "fw":false,
            "hs":"",
            "id":"name",
            "lnd":0,
            "location":0,
            "tl":"Name",
            "tp":"text",
            "width":104
          },
          {
            "ei":"",
            "eof":"",
            "fm":"id",
            "fw":false,
            "hs":"",
            "id":"id",
            "lnd":0,
            "location":1,
            "tl":"Account Id",
            "tp":"text",
            "width":257
          },
          {
            "id":"D",
            "width":100
          }
        ],
        "amiPanelId":"accounts",
        "amiStyle":{
          "columnFilterHide":true,
          "pt":"LAYOUT_DEFAULT"
        },
        "amiTitle":"accounts",
        "curtimeUpdateFrequency":1000,
        "dm":[
          {
            "dmadn":"accounts",
            "dmtbid":[
              "accounts"
            ]
          }
        ],
        "dynamicColumns":"false",
        "editDblClk":true,
        "editInplace":false,
        "editMenuTitle":"Edit Row(s)",
        "editMode":0,
        "editRerunDM":true,
        "filters":{
        },
        "pinCnt":0,
        "rollupEnabled":false,
        "scrollToBottomOnAppend":false,
        "showCommandMenu":true,
        "showLastRuntime":true,
        "titlePnl":{
          "title":"accounts"
        },
        "upid":"accounts",
        "varTypes":{
          "id":"String",
          "name":"String"
        }
      }
    },
    {
      "portletBuilderId":"amistatictable",
      "portletConfig":{
        "amiCols":[
          {
            "ei":"",
            "eof":"",
            "fm":"((Long)timestamp)*1000",
            "fw":false,
            "hs":"",
            "id":"timestamp",
            "lnd":0,
            "location":0,
            "pc":0,
            "sy":"\"left\"",
            "tl":"Timestamp",
            "tooltip":"",
            "tp":"datetime_sec",
            "width":122
          },
          {
            "fm":"symbol",
            "fw":false,
            "id":"symbol",
            "lnd":0,
            "location":1,
            "tl":"Symbol",
            "tp":"text",
            "width":53
          },
          {
            "fm":"side",
            "fw":false,
            "id":"side",
            "lnd":0,
            "location":2,
            "tl":"Side",
            "tp":"text",
            "width":40
          },
          {
            "ei":"",
            "eof":"",
            "fm":"qty",
            "fw":false,
            "hs":"",
            "id":"qty",
            "lnd":0,
            "location":3,
            "pc":0,
            "tl":"Quantity",
            "tooltip":"",
            "tp":"numeric",
            "width":110
          },
          {
            "fm":"price",
            "fw":false,
            "id":"price",
            "lnd":0,
            "location":4,
            "tl":"Price",
            "tp":"numeric",
            "width":56
          },
          {
            "fm":"status",
            "fw":false,
            "id":"status",
            "lnd":0,
            "location":5,
            "tl":"Status",
            "tp":"text",
            "width":59
          },
          {
            "ei":"",
            "eof":"",
            "fm":"id",
            "fw":false,
            "hs":"",
            "id":"id",
            "lnd":0,
            "location":6,
            "tl":"Id",
            "tp":"text",
            "width":256
          },
          {
            "fm":"account_id",
            "fw":false,
            "id":"account_id",
            "lnd":0,
            "location":7,
            "tl":"Account Id",
            "tp":"text",
            "width":247
          },
          {
            "id":"D",
            "width":100
          }
        ],
        "amiPanelId":"order_details",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "amiTitle":"orders",
        "curtimeUpdateFrequency":1000,
        "dm":[
          {
            "dmadn":"order_details",
            "dmtbid":[
              "orders"
            ]
          }
        ],
        "dynamicColumns":"false",
        "editDblClk":true,
        "editInplace":false,
        "editMenuTitle":"Edit Row(s)",
        "editMode":0,
        "editRerunDM":true,
        "filters":{
        },
        "pinCnt":0,
        "rollupEnabled":false,
        "scrollToBottomOnAppend":false,
        "showCommandMenu":true,
        "showLastRuntime":false,
        "sorting":[
          {
            "id":"qty",
            "order":"dsc"
          }
        ],
        "titlePnl":{
          "title":"orders"
        },
        "upid":"order_details",
        "varTypes":{
          "account_id":"String",
          "id":"String",
          "price":"Float",
          "qty":"Integer",
          "side":"String",
          "status":"String",
          "symbol":"String",
          "timestamp":"Integer"
        }
      }
    },
    {
      "portletBuilderId":"amichartgrid",
      "portletConfig":{
        "amiPanelId":"order_details1",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "amiTitle":"orders",
        "axisBcnts":[
          1
        ],
        "axisConfig":{
          "B_0_0":{
            "amiStyle":{
              "pt":"LAYOUT_DEFAULT"
            },
            "autoMajorValue":true,
            "autoMaxValue":true,
            "autoMinValue":true,
            "autoMinorValue":true,
            "axisId":3,
            "fontStyle":"",
            "format":null,
            "formatType":1,
            "isGroupOrdered":true,
            "orientation":"T",
            "reverse":false,
            "title":"Timestamp"
          },
          "L_0_0":{
            "amiStyle":{
              "pt":"LAYOUT_DEFAULT"
            },
            "autoMajorValue":true,
            "autoMaxValue":true,
            "autoMinValue":true,
            "autoMinorValue":true,
            "axisId":2,
            "fontStyle":"",
            "format":null,
            "formatType":5,
            "isGroupOrdered":true,
            "orientation":"R",
            "reverse":true,
            "title":"Price"
          }
        },
        "axisLcnts":[
          1
        ],
        "axisRcnts":[
          0
        ],
        "axisTcnts":[
          0
        ],
        "colsCount":1,
        "dm":[
          {
            "dmadn":"order_details",
            "dmtbid":[
              "orders"
            ]
          }
        ],
        "mdivs":[
          {
            "mdivs":[
              {
                "mdivs":[
                  {
                    "p":-1,
                    "w":1.0
                  }
                ],
                "p":70,
                "w":1.0
              },
              {
                "p":-1,
                "w":1.0
              }
            ],
            "p":-1,
            "w":1.0
          },
          {
            "mdivs":[
              {
                "mdivs":[
                  {
                    "p":-1,
                    "w":1.0
                  }
                ],
                "p":70,
                "w":1.0
              },
              {
                "mdivs":[
                  {
                    "p":-1,
                    "w":1.0
                  }
                ],
                "p":-1,
                "w":1.0
              }
            ],
            "p":70,
            "w":1.0
          }
        ],
        "plotConfig":{
          "0_0":{
            "bgColor":"#ffffff",
            "layers":[
              {
                "amiStyle":{
                  "pt":"LAYOUT_DEFAULT"
                },
                "dmTableName":"orders",
                "dmadn":"order_details",
                "id":0,
                "layers":[
                  {
                    "editorType":"2dLine",
                    "id":4,
                    "lineColor":{
                      "type":"series",
                      "value":"__series_num"
                    },
                    "lineSize":"2",
                    "mBorderColor":{
                      "type":"series",
                      "value":"__series_num"
                    },
                    "mBorderSize":"1",
                    "mColor":{
                      "type":"series",
                      "value":"__series_num"
                    },
                    "mHeight":"4",
                    "mShape":"\"circle\"",
                    "mWidth":"4",
                    "orderBy":"timestamp",
                    "seriesName":"Layer",
                    "xPos":"((Long)timestamp)*1000",
                    "yPos":"price"
                  }
                ],
                "name":"Layer",
                "opac":100,
                "type":"Chart",
                "xAxisId":3,
                "yAxisId":2
              },
              {
                "amiStyle":{
                  "pt":"LAYOUT_DEFAULT"
                },
                "id":5,
                "name":"Legend",
                "opac":100,
                "ser":[
                  4
                ],
                "type":"Legend"
              }
            ],
            "plotId":1,
            "selBoxBorderColor":"#404040ef",
            "selBoxFillColor":"#40404007",
            "selColor":"#bacbfb6e"
          }
        },
        "rowsCount":1,
        "titlePnl":{
          "title":"orders"
        },
        "upid":"order_details1"
      }
    },
    {
      "portletBuilderId":"amitree",
      "portletConfig":{
        "amiPanelId":"orders",
        "amiStyle":{
          "columnFilterHide":true,
          "pt":"LAYOUT_DEFAULT",
          "searchHide":true
        },
        "amiTitle":"orders",
        "customMenu":[
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":"order_details_chart_tab.showTab();",
                  "linkedVariables":[
                    {
                      "ari":"TAB_ENTRY:Tabs1?order_details_chart_tab",
                      "varName":"order_details_chart_tab"
                    }
                  ],
                  "name":"onSelected"
                }
              ]
            },
            "display":"\"View Chart\"",
            "icon":"",
            "id":"foreground_orders_chart",
            "position":0,
            "status":"\"enabled\""
          }
        ],
        "dm":[
          {
            "dmadn":"orders",
            "dmtbid":[
              "orders"
            ]
          }
        ],
        "filters":{
        },
        "formulas":[
          {
            "b":"",
            "c":"",
            "d":"name",
            "f":"account_id",
            "id":"accountId",
            "l":false,
            "o":"",
            "pg":"",
            "rb":"",
            "rc":"",
            "rs":"",
            "s":""
          },
          {
            "b":"",
            "c":"",
            "d":"ticker",
            "f":"ticker",
            "id":"ticker",
            "l":false,
            "o":"",
            "pg":"",
            "rb":"",
            "rc":"",
            "rs":"",
            "s":""
          },
          {
            "d":"side",
            "f":"side",
            "id":"side",
            "l":false
          }
        ],
        "hcols":[
        ],
        "pins":2,
        "rn":null,
        "sm":1,
        "tcoln":"",
        "tcolw":223,
        "titlePnl":{
          "title":"orders"
        },
        "upid":"orders",
        "varTypes":{
          "account_id":"String",
          "name":"String",
          "price":"Double",
          "qty":"Integer",
          "side":"String",
          "ticker":"String"
        },
        "vcols":[
          {
            "b":"",
            "c":"",
            "d":"count(1)",
            "h":"",
            "hs":"",
            "i":1,
            "id":"count",
            "n":"Order Count",
            "o":"",
            "pc":0,
            "s":"",
            "w":100,
            "y":"numeric"
          },
          {
            "b":"",
            "c":"",
            "d":"sum(qty)",
            "h":"",
            "hs":"",
            "i":2,
            "id":"qty",
            "n":"Total Quantity",
            "o":"",
            "pc":0,
            "s":"",
            "w":100,
            "y":"numeric"
          },
          {
            "b":"",
            "c":"",
            "d":"max(price)",
            "h":"",
            "hs":"",
            "i":3,
            "id":"price",
            "n":"Max Price",
            "o":"",
            "s":"",
            "w":100,
            "y":"numeric"
          },
          {
            "d":"min(price)",
            "i":4,
            "id":"minPrice",
            "n":"Min Price",
            "w":100,
            "y":"text"
          }
        ]
      }
    }
  ]
}