12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /*******************************************************************************
- * 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",
- "dojox/xml/parser",
- "dojo/_base/array",
- "dojo/query",
- "pd/model/deltaSpec"
- ],function(declare, xmlParser, array, query, deltaSpec){
- var PdColumnAnalyser = declare("pd/data/PdColumnAnalyser", [], {
- constructor: function(args) {
- if (!args.xmlInput){
- throw new Error(PDMSG.ERR.IDS_ERR_MISSING_XMLDOC_PARAM);
- }
- this.xmlInput = args.xmlInput;
- if (typeof(args.xmlInput) == "string"){
- this.xmlDoc = xmlParser.parse(dojo.trim(args.xmlInput));
- } else {
- this.xmlDoc = args.xmlInput;
- }
- this.inherited(arguments);
- },
-
- getDeltaFromXml: function() {
- var delta = {};
-
- for (var i=0; i<deltaSpec.length; i++){
- var section = [];
- var xmlDoc = this.xmlDoc.selectSingleNode("/pdSpec/delta/" + deltaSpec[i].name);
- if (xmlDoc != null) {
- array.some(
- xmlDoc.childNodes, function(rowNode, index, arr){
- section[index] = {
- name: rowNode.getAttribute("name"),
- simpletype: rowNode.getAttribute("simpletype"),
- previoustype: rowNode.getAttribute("previoustype")
- };
- }
- );
- }
- delta[deltaSpec[i].name] = section;
- }
- return delta;
- },
-
- getSpecFromXml: function() {
- //prune off preview and delta blob
- prunedNodes = ["personalPreview", "delta"];
- var xmlDoc = xmlParser.parse(dojo.trim(this.xmlInput));
- for (var i=0; i<prunedNodes.length; i++){
- var prunedNode = xmlDoc.selectSingleNode("/pdSpec/" + prunedNodes[i]);
- if (prunedNode){
- prunedNode.parentNode.removeChild(prunedNode);
- }
- }
- return xmlParser.innerXML(xmlDoc);
- }
- });
-
- return PdColumnAnalyser;
- });
|