/// <summary> /// Saves form data to the data set. </summary> /// <param name="worksheetData"> the data in the worksheet to save. </param> /// <returns> a list of data objects created from the data in the worksheet. </returns> public virtual IList <StateMod_GraphNode> formSaveData(IList <StateMod_GraphNode> worksheetData) { int rows = worksheetData.Count; if (rows == 0) { return(new List <StateMod_GraphNode>()); } // gnw will be a node used to read data FROM the _W_orksheet nodes StateMod_GraphNode gnw = worksheetData[0]; string pfile = gnw.getFileName().Trim(); string ptype = gnw.getType().Trim(); string pdtype = gnw.getDtype().Trim(); string pyear = gnw.getYrAve().Trim(); string pid = gnw.getID().Trim(); string file = null; string type = null; string dtype = null; string year = null; string id = null; // gno will be a node used for creating the _O_utput nodes StateMod_GraphNode gno = new StateMod_GraphNode(); gno.setFileName(pfile); gno.setType(ptype); gno.setDtype(pdtype); gno.setYrAve(pyear); int paren = pid.IndexOf("(", StringComparison.Ordinal); if (paren > -1) { gno.addID(pid.Substring(0, paren).Trim()); } else { gno.addID(pid); } IList <StateMod_GraphNode> v = new List <StateMod_GraphNode>(); for (int i = 1; i < rows; i++) { gnw = worksheetData[i]; file = gnw.getFileName().Trim(); if (file.Equals("")) { file = pfile; } type = gnw.getType().Trim(); if (type.Equals("")) { type = ptype; } dtype = gnw.getDtype().Trim(); if (dtype.Equals("")) { dtype = pdtype; } year = gnw.getYrAve().Trim(); if (year.Equals("")) { year = pyear; } id = gnw.getID().Trim(); if (id.Equals("")) { id = pid; } if (file.Equals(pfile) && type.Equals(ptype) && dtype.Equals(pdtype) && year.Equals(pyear)) { // all the fields match, so this is a different ID // added to the Vector of IDs in the node's vector. paren = id.IndexOf("(", StringComparison.Ordinal); if (paren > -1) { gno.addID(id.Substring(0, paren).Trim()); } else { gno.addID(id); } } else { // otherwise, values other than just the ID are // different, so a new node needs created v.Add(gno); gno = new StateMod_GraphNode(); gno.setFileName(file); gno.setType(type); gno.setDtype(dtype); gno.setYrAve(year); paren = id.IndexOf("(", StringComparison.Ordinal); if (paren > -1) { gno.addID(id.Substring(0, paren).Trim()); } else { gno.addID(id); } } pfile = file; ptype = type; pdtype = dtype; pyear = year; pid = id; } v.Add(gno); return(v); }