2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* A map container for many Sql.Object
|
|
|
|
**/
|
|
|
|
Sql.Batch = new Class
|
|
|
|
({
|
|
|
|
Extends: Sql.Object
|
|
|
|
,Tag: 'sql-batch'
|
2015-07-07 15:27:47 +00:00
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
blocked:
|
|
|
|
{
|
|
|
|
type: Boolean
|
|
|
|
,set: function (x)
|
|
|
|
{
|
|
|
|
this._blocked = x;
|
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._blocked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,params: {}
|
2015-07-07 15:27:47 +00:00
|
|
|
,_blocked: false
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,loadXml: function (builder, node)
|
|
|
|
{
|
|
|
|
this.parent (builder, node);
|
|
|
|
|
|
|
|
var childs = node.childNodes;
|
|
|
|
|
|
|
|
for (var i = 0; i < childs.length; i++)
|
|
|
|
if (childs[i].tagName && childs[i].tagName.toLowerCase () == 'item')
|
|
|
|
{
|
|
|
|
var object;
|
|
|
|
var id = childs[i].getAttribute ('name');
|
|
|
|
|
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
if (object = builder.get (childs[i].getAttribute ('param')))
|
|
|
|
this.addParam (id, object);
|
|
|
|
else if (object = builder.get (childs[i].getAttribute ('object')))
|
|
|
|
this.addObject (id, object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,get: function (id)
|
|
|
|
{
|
|
|
|
if (this.params[id])
|
|
|
|
return this.params[id];
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
,add: function (id)
|
|
|
|
{
|
|
|
|
if (!this.params[id])
|
|
|
|
this.params[id] = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
,remove: function (id)
|
|
|
|
{
|
|
|
|
if (this.params[id])
|
|
|
|
{
|
2015-07-07 15:27:47 +00:00
|
|
|
this.params[id].disconnect ('changed', this.emitChanged, this);
|
2015-01-23 13:09:30 +00:00
|
|
|
delete this.params[id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,addObject: function (id, object)
|
|
|
|
{
|
|
|
|
this.remove (id);
|
|
|
|
this.params[id] = object;
|
2015-07-07 15:27:47 +00:00
|
|
|
object.on ('changed', this.emitChanged, this);
|
|
|
|
this.emitChanged ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,addValue: function (id, value)
|
|
|
|
{
|
|
|
|
this.addObject (id,
|
|
|
|
new Sql.Value ({value: value}));
|
|
|
|
}
|
|
|
|
|
|
|
|
,addParam: function (id, param)
|
|
|
|
{
|
|
|
|
this.addObject (id,
|
|
|
|
new Sql.Value ({param: param}));
|
|
|
|
}
|
|
|
|
|
2015-02-08 15:38:38 +00:00
|
|
|
,block: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2015-07-07 15:27:47 +00:00
|
|
|
this._blocked = true;
|
2015-02-08 15:38:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,unblock: function ()
|
|
|
|
{
|
2015-07-07 15:27:47 +00:00
|
|
|
this._blocked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
,emitChanged: function ()
|
|
|
|
{
|
|
|
|
if (!this._blocked)
|
|
|
|
this.signalEmit ('changed');
|
2015-02-08 15:38:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,changed: function ()
|
|
|
|
{
|
2015-07-07 15:27:47 +00:00
|
|
|
this.signalEmit ('changed');
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,isReady: function ()
|
|
|
|
{
|
|
|
|
for (id in this.params)
|
|
|
|
if (!(this.params[id] && this.params[id].isReady ()))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|