/******************************************************************************* * IBM Confidential * * OCO Source Materials * * A and PM: PD * * (c) Copyright IBM Corp. 2014 * * The source code for this program is not published or otherwise divested of * its trade secrets, irrespective of what has been deposited with the U.S. * Copyright Office. ******************************************************************************/ define([ "dojo/_base/declare", "dojo/store/Memory", "dojox/xml/parser", "dojo/_base/array", "dojo/query", "pd/model/pdSpec" ],function(declare, store, xmlParser, array, query, model){ return declare("pd/data/PdSpecStore", [store], { constructor: function(args) { if (!args.xmlInput){ throw new Error(PDMSG.ERR.IDS_ERR_MISSING_XMLDOC_PARAM); } if (typeof(args.xmlInput) == "string"){ this.xmlDoc = xmlParser.parse(dojo.trim(args.xmlInput)); } else { this.xmlDoc = args.xmlInput; } this.data = this.generateDataFromXml(); this.inherited(arguments); }, generateDataFromXml: function() { var data = { identifier: 'id', items: [] }; var dataList = []; var xmlDoc = this.xmlDoc.selectSingleNode("/pdSpec/personalData"); if (xmlDoc){ array.forEach( query("item", xmlDoc), function(node, index, arr){ var dataItem = {}; array.forEach(model, function(item, idx){ var value; if (node.getAttribute(item.itemName) != null){ value = node.getAttribute(item.itemName); } else { value = item.defaultValue; node.setAttribute(item.itemName, value); } dataItem[item.itemName] = value; }); dataList.push(dataItem); } ); for(var i=0; i" + xmlParser.innerXML(this.xmlDoc) + ""); } }); });