forked from verdnatura/hedera-web
90 lines
1.5 KiB
JavaScript
90 lines
1.5 KiB
JavaScript
|
/**
|
||
|
* A map container for many Sql.Object
|
||
|
**/
|
||
|
Sql.Batch = new Class
|
||
|
({
|
||
|
Extends: Sql.Object
|
||
|
,Tag: 'sql-batch'
|
||
|
|
||
|
,params: {}
|
||
|
|
||
|
,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])
|
||
|
{
|
||
|
this.params[id].disconnect ('changed', this.onObjectChange, this);
|
||
|
delete this.params[id];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
,addObject: function (id, object)
|
||
|
{
|
||
|
this.remove (id);
|
||
|
this.params[id] = object;
|
||
|
object.on ('changed', this.onObjectChange, this);
|
||
|
this.onObjectChange ();
|
||
|
}
|
||
|
|
||
|
,addValue: function (id, value)
|
||
|
{
|
||
|
this.addObject (id,
|
||
|
new Sql.Value ({value: value}));
|
||
|
}
|
||
|
|
||
|
,addParam: function (id, param)
|
||
|
{
|
||
|
this.addObject (id,
|
||
|
new Sql.Value ({param: param}));
|
||
|
}
|
||
|
|
||
|
,onObjectChange: function ()
|
||
|
{
|
||
|
this.signalEmit ('changed');
|
||
|
}
|
||
|
|
||
|
,isReady: function ()
|
||
|
{
|
||
|
for (id in this.params)
|
||
|
if (!(this.params[id] && this.params[id].isReady ()))
|
||
|
return false;
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
});
|