Ext.define("Portfolio.ux.sql.template.controller.Main", {
	extend: "Ext.app.ViewController",

	alias: "controller.sql.template.controller.main",

  getMetaInfo: function(f_callback) {

      var i_controller = this;
      var i_view = i_controller.getView();

			var s_file = i_view.getTemplate();
			var o_file = ip2.getEvaled(s_file);

      f_callback = f_callback || Ext.emptyFn;

			i_view.setSqlCmd(o_file.sql);

			var a_batch = [{
				cmd: o_file.sql,
				limit: 1,
				meta: true,
				start: 0,
				type: "sql"
			}];

      Ext.Ajax.request({
        method: "POST",
        url: "/ip2-services/ip2dmdproxy.aspx",
        jsonData: {
            batch: a_batch
        },
        success: function(i_response) {

          var o_result = Ext.decode(i_response.responseText);

					var a_batches = o_result.batch || [];

					var o_data = a_batches[0];

          f_callback(o_data);
        }
      });
  }

});
