PdSpecStore.js 1.8 KB

12
  1. //>>built
  2. define("pd/data/PdSpecStore",["dojo/_base/declare","dojo/store/Memory","dojox/xml/parser","dojo/_base/array","dojo/query","pd/model/pdSpec"],function(_1,_2,_3,_4,_5,_6){return _1("pd/data/PdSpecStore",[_2],{constructor:function(_7){if(!_7.xmlInput){throw new Error(PDMSG.ERR.IDS_ERR_MISSING_XMLDOC_PARAM);}if(typeof (_7.xmlInput)=="string"){this.xmlDoc=_3.parse(dojo.trim(_7.xmlInput));}else{this.xmlDoc=_7.xmlInput;}this.data=this.generateDataFromXml();this.inherited(arguments);},generateDataFromXml:function(){var _8={identifier:"id",items:[]};var _9=[];var _a=this.xmlDoc.selectSingleNode("/pdSpec/personalData");if(_a){_4.forEach(_5("item",_a),function(_b,_c,_d){var _e={};_4.forEach(_6,function(_f,idx){var _10;if(_b.getAttribute(_f.itemName)!=null){_10=_b.getAttribute(_f.itemName);}else{_10=_f.defaultValue;_b.setAttribute(_f.itemName,_10);}_e[_f.itemName]=_10;});_9.push(_e);});for(var i=0;i<_9.length;i++){_8.items.push(dojo.mixin({id:i},_9[i]));}}return _8;},generateXmlFromData:function(_11){var _12=this.xmlDoc.selectSingleNode("/pdSpec/personalData");for(var i=0;i<_11.length;i++){_12.childNodes[i].setAttribute("hidden",this.data[i].hidden);if(this.data[i].__isDirty){_12.childNodes[i].setAttribute("name",this.data[i].name);_12.childNodes[i].setAttribute("regularAggregate",this.data[i].regularAggregate);_12.childNodes[i].setAttribute("semiAggregate",this.data[i].regularAggregate);if(this.data[i].regularAggregate=="unsupported"){_12.childNodes[i].setAttribute("usage","attribute");}else{_12.childNodes[i].setAttribute("usage","fact");}}}var _13=this.xmlDoc.selectSingleNode("/pdSpec/personalPreview");if(_13){_13.parentNode.removeChild(_13);}return _3.parse("<addLOBData><input><pdCollection>"+_3.innerXML(this.xmlDoc)+"</pdCollection></input></addLOBData>");}});});