{
  "includeFiles":[
  ],
  "metadata":{
    "amiCustomCss":[
      ".title {\n",
      "  font-size: 40px;\n",
      "  padding: 0 24px;\n",
      "  color: black; /* Change my color to yellow */\n",
      "  margin: 0;\n",
      "  justify-content: center;\n",
      "\n",
      "}"
    ],
    "customPrefsImportMode":"reject",
    "dm":{
    },
    "fileVersion":3,
    "menubarPosition":"top",
    "rt":{
    },
    "stm":{
      "styles":[
        {
          "id":"LAYOUT_DEFAULT",
          "lb":"Layout Default",
          "pt":"DEFAULT"
        }
      ]
    },
    "titleBarHtml":"AMI Center Tutorial",
    "transientIdPrefix":"TRANSIENT_"
  },
  "portletConfigs":[
    {
      "portletBuilderId":"amidesktop",
      "portletConfig":{
        "amiPanelId":"@DESKTOP",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "windows":[
          {
            "header":true,
            "heightDflt":712,
            "hidden":false,
            "leftDflt":216,
            "portlet":"Div2",
            "pos":0,
            "stateDflt":"flt",
            "title":"Window",
            "topDflt":73,
            "widthDflt":1172,
            "zindexDflt":1
          }
        ]
      }
    },
    {
      "portletBuilderId":"amiblank",
      "portletConfig":{
        "amiPanelId":"Blank1",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "upid":"Blank1"
      }
    },
    {
      "portletBuilderId":"amiblank",
      "portletConfig":{
        "amiPanelId":"Blank2",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "upid":"Blank2"
      }
    },
    {
      "portletBuilderId":"div",
      "portletConfig":{
        "amiPanelId":"Div1",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "child1":"Blank1",
        "child2":"Blank2",
        "dir":"v",
        "locked":false,
        "offset":0.46068,
        "upid":"Div1"
      }
    },
    {
      "portletBuilderId":"div",
      "portletConfig":{
        "amiPanelId":"Div2",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "child1":"Div1",
        "child2":"Html1",
        "dir":"v",
        "locked":true,
        "offset":0.74488,
        "upid":"Div2"
      }
    },
    {
      "portletBuilderId":"amiform",
      "portletConfig":{
        "amiPanelId":"Html1",
        "amiStyle":{
          "bgCl":"#f8f9fa",
          "pt":"LAYOUT_DEFAULT"
        },
        "fields":[
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    " if(isOn){ // If the checkbox is now checked\n",
                    "  USE ds=\"AMI\" EXECUTE CREATE PUBLIC TABLE IF NOT EXISTS Portfolio \n",
                    "                       (ticker String, amount double, value double) \n",
                    "                       USE PersistEngine=\"FAST\";\n",
                    "  \n",
                    "  // Count how many rows there are\n",
                    "  Long rows = USE ds=\"AMI\" EXECUTE SELECT count(ticker) FROM Portfolio;\n",
                    "  \n",
                    "  // Populate the table if no rows are found\n",
                    "  if(rows<1){ \n",
                    "    USE ds=\"AMI\" EXECUTE INSERT INTO Portfolio VALUES\n",
                    "                         (\"GOOGL\", 100, 158),\n",
                    "                         ( \"AAPL\", 100, 216.1),\n",
                    "                         (\"MSFT\", 40.4, 430.2),\n",
                    "                         (\"ORCL\", 100, 170);\n",
                    "  }\n",
                    "  \n",
                    "  // Obtain the table and assign to a variable t\n",
                    "  Table t = USE ds=\"AMI\" EXECUTE SELECT * FROM Portfolio;\n",
                    "  \n",
                    "  // Display the result in an alert\n",
                    "  session.alert(\"Created a Portfolio\"+ t );\n",
                    "\n",
                    "} else { // If the checkbox is now unchecked\n",
                    "  // Drop/delete the table\n",
                    "  USE ds=\"AMI\" EXECUTE DROP TABLE Portfolio;\n",
                    "  session.alert(\"Dropped table Portfolio\");\n",
                    "}\n"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELDVALUE:Html1?Portfolio?",
                      "varName":"isOn"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":20,
            "l":"Portfolio",
            "n":"Portfolio",
            "rightPosPx":258,
            "style":{
              "fldBdrCl":"#dce4ea",
              "fldBorderRad":4.0,
              "fldBorderWd":2.0,
              "fldFocusBorderCl":"#0073f9",
              "fldLblSide":"right",
              "fontFam":"Segoe UI",
              "fontSz":21.0,
              "lblPd":8.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"checkbox",
            "topPosPct":0.2668539325842697,
            "topPosPx":-10,
            "vCenterOffsetPct":-0.23314606741573032,
            "widthPx":18,
            "zidx":1
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "if(isOn){ \n",
                    "  USE ds=\"AMI\" EXECUTE CREATE TIMER IF NOT EXISTS increment OFTYPE AMISCRIPT ON \"300\" USE script=\"UPDATE Portfolio SET amount = amount + 100 WHERE ticker == \\\"GOOGL\\\"\";\n",
                    "}else{\n",
                    "  USE ds=\"AMI\" EXECUTE DROP TIMER increment;\n",
                    "}"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELDVALUE:Html1?checkbox_t?",
                      "varName":"isOn"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":20,
            "l":"Timer",
            "n":"checkbox_t",
            "rightPosPx":258,
            "style":{
              "fldBdrCl":"#dce4ea",
              "fldBgCl":"#ffffff",
              "fldBorderRad":4.0,
              "fldBorderWd":2.0,
              "fldFocusBorderCl":"#0073f9",
              "fldLblSide":"right",
              "fontCl":"#000000",
              "fontFam":"Segoe UI",
              "fontSz":21.0,
              "lblPd":8.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"checkbox",
            "topPosPct":0.18258426966292135,
            "topPosPx":-10,
            "vCenterOffsetPct":-0.31741573033707865,
            "widthPx":18,
            "zidx":2
          },
          {
            "heightPx":60,
            "l":"",
            "leftPosPx":40,
            "n":"controlsDiv",
            "style":{
              "bold":true,
              "fldBgCl":"#00000000",
              "fldBorderWd":0.0,
              "fldCss":"title",
              "fldFontCl":"#000000",
              "fldFontFam":"Segoe UI",
              "fldFontSz":19.0,
              "fldLblAlign":"center",
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"divField",
            "template":"Controls",
            "topPosPx":40,
            "widthPx":200,
            "zidx":4
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "String label = \"Reprocess Datamodels\";\n",
                    "\n",
                    "List datamodels = session.getDatamodels();\n",
                    "int count = 0;\n",
                    "int numModels = datamodels.size();\n",
                    "for (Datamodel datamodel : datamodels) {\n",
                    "  datamodel.reprocess();\n",
                    "  this.setValue(label + \"\\n(\" + ++count + \"/\" + numModels +  \")\");  \n",
                    "}\n",
                    "\n",
                    "  this.setValue(label);  \n"
                  ],
                  "linkedVariables":[
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":60,
            "l":"Reprocess Datamodels",
            "leftPosPx":20,
            "n":"reprocessButton",
            "style":{
              "fldBgCl":"#0073f9",
              "fldBorderRad":9.0,
              "fldBorderWd":0.0,
              "fldFontCl":"#ffffff",
              "fldFontFam":"Segoe UI",
              "fldFontSz":22.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"buttonField",
            "topPosPx":300,
            "widthPx":260,
            "zidx":3
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "if(isOn){ // If the checkbox is now checked\n",
                    "  // Create the SecretPortfolio Table\n",
                    "  USE ds=\"AMI\" EXECUTE CREATE PUBLIC TABLE IF NOT EXISTS SecretPortfolio \n",
                    "                       (ticker String, amount double)\n",
                    "                       USE PersistEngine=\"FAST\";\n",
                    "  \n",
                    "  // Check how many rows it has\n",
                    "  Long rows = USE ds=\"AMI\" EXECUTE SELECT count(*) FROM SecretPortfolio;\n",
                    "  \n",
                    "  // Populate the table if no rows are found\n",
                    "  if(rows < 1){ \n",
                    "    USE ds=\"AMI\" EXECUTE INSERT INTO SecretPortfolio VALUES\n",
                    "                         (\"GOOGL\", 30),\n",
                    "                         (\"LMT\", 500),\n",
                    "                         (\"EA\", 110);\n",
                    "  }\n",
                    "\n",
                    "  \n",
                    "  // Create a matching Portfolio\n",
                    "  USE ds=\"AMI\" EXECUTE CREATE PUBLIC TABLE IF NOT EXISTS MatchingPortfolio \n",
                    "                       (ticker String, amount double, value double)\n",
                    "                       USE PersistEngine=\"FAST\";\n",
                    "  \n",
                    "  // Check how many rows it has\n",
                    "  rows = USE ds=\"AMI\" EXECUTE SELECT count(*) FROM MatchingPortfolio;\n",
                    "  \n",
                    "  // Populate the table if no rows are found\n",
                    "  if(rows < 1){ \n",
                    "    USE ds=\"AMI\" EXECUTE INSERT INTO MatchingPortfolio VALUES\n",
                    "                         (\"GOOGL\", 30, NULL),\n",
                    "                         (\"LMT\", 500, NULL),\n",
                    "                         (\"EA\", 110, NULL);\n",
                    "  }\n",
                    "\n",
                    "  // Get the Secret Portfolio table and assign to a variable t\n",
                    "  Table t = USE ds=\"AMI\" EXECUTE SELECT * FROM SecretPortfolio;\n",
                    "  session.alert(\"Created a Secret Portfolio\"+ t );\n",
                    "\n",
                    "} else { // If the checkbox is now unchecked\n",
                    "\n",
                    "  // Drop tables\n",
                    "  USE ds=\"AMI\" EXECUTE DROP TABLE SecretPortfolio;\n",
                    "  USE ds=\"AMI\" EXECUTE DROP TABLE MatchingPortfolio;\n",
                    "  session.alert(\"Dropped SecretPortfolio and MatchingPortfolio\");\n",
                    "}"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELDVALUE:Html1?sp_checkbox?",
                      "varName":"isOn"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":20,
            "l":"Secret Portfolio",
            "n":"sp_checkbox",
            "rightPosPx":258,
            "style":{
              "fldBdrCl":"#dce4ea",
              "fldBgCl":"#ffffff",
              "fldBorderRad":4.0,
              "fldBorderWd":2.0,
              "fldFocusBorderCl":"#0073f9",
              "fldLblSide":"right",
              "fontFam":"Segoe UI",
              "fontSz":21.0,
              "lblPd":8.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"checkbox",
            "topPosPct":0.351123595505618,
            "topPosPx":-10,
            "vCenterOffsetPct":-0.14887640449438203,
            "widthPx":18,
            "zidx":1
          }
        ],
        "snap":20,
        "upid":"Html1"
      }
    }
  ]
}