{
  "includeFiles":[
  ],
  "metadata":{
    "customPrefsImportMode":"reject",
    "dm":{
      "dms":[
        {
          "callbacks":{
            "entries":[
              {
                "amiscript":[
                  "{\n",
                  "  CREATE TABLE Portfolio AS EXECUTE SELECT ticker, amount, value FROM Portfolio WHERE ${WHERE};\n",
                  "}\n"
                ],
                "defaultDs":"AMI",
                "hasDatamodel":true,
                "linkedVariables":[
                ],
                "name":"onProcess",
                "schema":{
                  "tbl":[
                    {
                      "cols":[
                        {
                          "nm":"ticker",
                          "tp":"String"
                        },
                        {
                          "nm":"amount",
                          "tp":"Double"
                        },
                        {
                          "nm":"value",
                          "tp":"Double"
                        }
                      ],
                      "nm":"Portfolio",
                      "oc":"ask"
                    }
                  ]
                }
              }
            ]
          },
          "datasources":[
            "AMI"
          ],
          "lbl":"Portfolio",
          "queryMode":"startup",
          "test_input_type":"OPEN",
          "test_input_vars":"String WHERE=\"true\";"
        }
      ]
    },
    "fileVersion":3,
    "menubarPosition":"top",
    "rt":{
    },
    "stm":{
      "styles":[
        {
          "id":"LAYOUT_DEFAULT",
          "lb":"Layout Default",
          "pt":"DEFAULT"
        }
      ]
    },
    "titleBarHtml":"AMI Center & AMI DB",
    "transientIdPrefix":"TRANSIENT_"
  },
  "portletConfigs":[
    {
      "portletBuilderId":"amidesktop",
      "portletConfig":{
        "amiPanelId":"@DESKTOP",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "windows":[
          {
            "header":true,
            "heightDflt":512,
            "hidden":false,
            "leftDflt":6,
            "portlet":"Div1",
            "pos":0,
            "stateDflt":"flt",
            "title":"Window",
            "topDflt":21,
            "widthDflt":1196,
            "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":"Div2",
        "dir":"v",
        "locked":false,
        "offset":0.40909,
        "upid":"Div1"
      }
    },
    {
      "portletBuilderId":"div",
      "portletConfig":{
        "amiPanelId":"Div2",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "child1":"Blank2",
        "child2":"Html1",
        "dir":"v",
        "locked":false,
        "offset":0.67638,
        "upid":"Div2"
      }
    },
    {
      "portletBuilderId":"amiform",
      "portletConfig":{
        "amiPanelId":"Html1",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "fields":[
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "\n",
                    "if(isOn){ //only run when turning the checkox on\n",
                    "  USE ds=\"AMI\" EXECUTE CREATE PUBLIC TABLE IF NOT EXISTS \n",
                    "                       Portfolio ( ticker String, amount double, value double)\n",
                    "                       USE PersistEngine=\"FAST\";\n",
                    "  \n",
                    "  //retrieve the table\n",
                    "  Long count = USE ds=\"AMI\" EXECUTE SELECT count(*) FROM Portfolio;\n",
                    "\n",
                    "  //populate the table if no rows are found\n",
                    "  if(count<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",
                    "  // obtain the table and assign to a variable t\n",
                    "  Table t  = USE ds=\"AMI\" EXECUTE SELECT * FROM Portfolio;\n",
                    "  //display the result in an alert\n",
                    "  session.alert(\"Created a Portfolio\"+ t );\n",
                    "\n",
                    "} else { // on turning the checkbox off\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":59,
            "style":{
              "fldLblAlign":"center",
              "fldLblSide":"left",
              "fontSz":25.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"checkbox",
            "topPosPct":0.28761061946902655,
            "topPosPx":-10,
            "vCenterOffsetPct":-0.21238938053097345,
            "widthPx":20,
            "zidx":1
          },
          {
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "if(isOn){ \n",
                    "  USE ds=\"AMI\" EXECUTE CREATE TIMER IF NOT EXISTS increment \n",
                    "                       OFTYPE AMISCRIPT ON \"300\" \n",
                    "                       USE script=\"UPDATE Portfolio SET amount = amount + 1 WHERE ticker == \\\"GOOGL\\\"\";\n",
                    "}else{\n",
                    "  USE ds=\"AMI\" EXECUTE DROP TIMER increment;\n",
                    "}\n",
                    "\n",
                    "\n"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"FIELDVALUE:Html1?checkbox_t?",
                      "varName":"isOn"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "heightPx":20,
            "l":"Timer",
            "n":"checkbox_t",
            "rightPosPx":61,
            "style":{
              "fontSz":23.0,
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"checkbox",
            "topPosPct":0.1969026548672566,
            "topPosPx":-10,
            "vCenterOffsetPct":-0.3030973451327434,
            "widthPx":18,
            "zidx":2
          },
          {
            "hCenterOffsetPct":0.035555555555555556,
            "heightPx":80,
            "l":"",
            "leftPosPct":0.5355555555555556,
            "leftPosPx":-60,
            "n":"title",
            "style":{
              "fldBorderWd":0.0,
              "fldFontCl":"#0d4b63",
              "fldLblAlign":"center",
              "pt":"LAYOUT_DEFAULT"
            },
            "t":"divField",
            "template":"<h1>Controls</h1>",
            "topPosPct":0.078125,
            "topPosPx":-40,
            "vCenterOffsetPct":-0.421875,
            "widthPx":120,
            "zidx":3
          }
        ],
        "snap":20,
        "upid":"Html1"
      }
    }
  ]
}