{
  "includeFiles":[
  ],
  "metadata":{
    "amiScriptMethods":[
      "{\n",
      "  Datamodel getPortfolioDatamodel() {\n",
      "    for (Datamodel model: session.getDatamodels()){\n",
      "      if (model.getId() == \"Portfolio\") {\n",
      "        return model;\n",
      "      }\n",
      "    }\n",
      "    return null;\n",
      "  };\n",
      "}"
    ],
    "customPrefsImportMode":"reject",
    "dm":{
    },
    "fileVersion":3,
    "menubarPosition":"top",
    "rt":{
      "processors":[
      ]
    },
    "stm":{
      "styles":[
        {
          "id":"LAYOUT_DEFAULT",
          "lb":"Layout Default",
          "pt":"DEFAULT"
        }
      ]
    },
    "transientIdPrefix":"TRANSIENT_"
  },
  "portletConfigs":[
    {
      "portletBuilderId":"amidesktop",
      "portletConfig":{
        "amiPanelId":"@DESKTOP",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "windows":[
          {
            "header":true,
            "heightDflt":428,
            "hidden":false,
            "leftDflt":40,
            "portlet":"Html1",
            "pos":0,
            "stateDflt":"flt",
            "title":"Tutorial Controls",
            "topDflt":60,
            "widthDflt":573,
            "zindexDflt":1
          }
        ]
      }
    },
    {
      "portletBuilderId":"amiform",
      "portletConfig":{
        "amiPanelId":"Html1",
        "amiStyle":{
          "pt":"LAYOUT_DEFAULT"
        },
        "fields":[
          {
            "bgColor":"#f7ff6dff",
            "borderColor":"#ffdd00",
            "borderRadius":8,
            "borderWidth":2,
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "Datamodel portfolio = getPortfolioDatamodel();\n",
                    "\n",
                    "if ( null != portfolio ) {\n",
                    "  if (portfolio.getNextExecutionTime() == null) {\n",
                    "    this.setValue (\"AutoRun not enabled\");\n",
                    "  } else {\n",
                    "    long next = portfolio.getNextExecutionTime() - session.now();\n",
                    "    this.setValue (\"Next Run in: \" + (next / 1000) + \"s\");  \n",
                    "  } \n",
                    "} else {\n",
                    "  session.alert(\"Datamodel not found. Ensure you have a datamodel called 'Portfolio'.\")\n",
                    "}\n",
                    "\n",
                    "\n",
                    "\n"
                  ],
                  "linkedVariables":[
                  ],
                  "name":"onChange"
                }
              ]
            },
            "fieldFontSize":33,
            "heightPx":60,
            "l":"Next Datamodel Run",
            "labelHidden":true,
            "leftPosPx":20,
            "n":"button",
            "t":"buttonField",
            "topPosPx":180,
            "widthPx":500,
            "zidx":3
          },
          {
            "bgColor":"#42f448ff",
            "borderColor":"#04d82e",
            "borderRadius":9,
            "borderWidth":2,
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "{\n",
                    "  use ds=\"AMI\" execute DROP TABLE Portfolio;\n",
                    "} catch (Error error) {\n",
                    "  // Swallow the error as it will be due to the table not existing\n",
                    "}\n",
                    "\n",
                    "String toExec = \"CREATE TABLE Portfolio(ticker String, amount double, value double);\\nINSERT INTO Portfolio VALUES(\\\"GOOG\\\", 100, 158),(\\\"AAPL\\\", 100, 216.1),(\\\"MSFT\\\", 40.4, 430.2), (\\\"ORCL\\\", 100, 170);\";\n",
                    "\n",
                    "session.alert(toExec);"
                  ],
                  "linkedVariables":[
                  ],
                  "name":"onChange"
                }
              ]
            },
            "fieldFontFamily":"Segoe UI",
            "fieldFontSize":39,
            "fontColor":"#000000",
            "heightPx":60,
            "l":"Clear Portfolio Tables",
            "labelHidden":true,
            "leftPosPx":20,
            "n":"clearTables",
            "t":"buttonField",
            "topPosPx":20,
            "widthPx":500,
            "zidx":1
          },
          {
            "bgColor":"#94c9f7ff",
            "borderColor":"#00a5ff",
            "borderRadius":8,
            "borderWidth":2,
            "callbacks":{
              "entries":[
                {
                  "amiscript":[
                    "Datamodel portfolio = getPortfolioDatamodel();\n",
                    "\n",
                    "if ( null != portfolio ) {\n",
                    "  portfolio.reprocess();  \n",
                    "} else {\n",
                    "  session.alert(\"Datamodel not found. Ensure you have a datamodel called 'Portfolio'.\")\n",
                    "}\n"
                  ],
                  "linkedVariables":[
                    {
                      "ari":"PANEL:Html1",
                      "varName":"panel"
                    }
                  ],
                  "name":"onChange"
                }
              ]
            },
            "fieldFontSize":35,
            "fontColor":"#000000",
            "heightPx":60,
            "l":"Reprocess Portfolio Datamodel",
            "labelHidden":true,
            "leftPosPx":20,
            "n":"rerun",
            "t":"buttonField",
            "topPosPx":100,
            "widthPx":500,
            "zidx":2
          }
        ],
        "snap":20,
        "upid":"Html1"
      }
    }
  ]
}