Beispiel #1
0
        /// <summary>
        ///     Converts a list of data list item view models to a binary data list.
        /// </summary>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        private IBinaryDataList ConvertIDataListItemModelsToIBinaryDataList(out string errorString)
        {
            errorString = string.Empty;
            IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList();

            IList <IDataListItemModel> filledScalars =
                ScalarCollection != null?ScalarCollection.Where(scalar => !scalar.IsBlank && !scalar.HasError).ToList() : new List <IDataListItemModel>();

            foreach (var scalar in filledScalars)
            {
                result.TryCreateScalarTemplate
                    (string.Empty, scalar.Name, scalar.Description
                    , true, scalar.IsEditable, scalar.ColumnIODirection, out errorString);
            }

            foreach (var recset in RecsetCollection ?? new OptomizedObservableCollection <IDataListItemModel>())
            {
                if (recset.IsBlank)
                {
                    continue;
                }
                IEnumerable <IDataListItemModel> filledRecordSets = recset.Children.Where(c => !c.IsBlank && !c.HasError);
                IList <Dev2Column> cols = filledRecordSets.Select(child => DataListFactory.CreateDev2Column(child.Name, child.Description, child.IsEditable, child.ColumnIODirection))
                                          .ToList();

                result.TryCreateRecordsetTemplate(recset.Name, recset.Description, cols, true, recset.IsEditable, recset.ColumnIODirection, out errorString);
            }

            return(result);
        }
Beispiel #2
0
        public void DeSerializeToXMLInputsOnlyFromBinary_ValidXML_Expect_Sucess()
        {
            IBinaryDataList   dl    = Dev2BinaryDataListFactory.CreateDataList();
            List <Dev2Column> cols1 = new List <Dev2Column>
            {
                DataListFactory.CreateDev2Column("f1", ""),
            };
            List <Dev2Column> cols2 = new List <Dev2Column>
            {
                DataListFactory.CreateDev2Column("f2", ""),
            };
            string        error;
            ErrorResultTO errors;


            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormatInputsOnly);

            dl.TryCreateRecordsetTemplate("rs1", "", cols1, true, out error);
            dl.TryCreateRecordsetTemplate("rs2", "", cols2, true, true, enDev2ColumnArgumentDirection.Input, out error);
            dl.TryCreateScalarTemplate("", "scalar1", "", true, true, enDev2ColumnArgumentDirection.Input, out error);
            dl.TryCreateScalarTemplate("", "scalar2", "", true, true, enDev2ColumnArgumentDirection.Output, out error);
            dl.TryCreateScalarValue("scalar1Value", "scalar1", out error);
            dl.TryCreateScalarValue("scalar2Value", "scalar2", out error);
            dl.TryCreateRecordsetValue("rec1.f1.value", "f1", "rs1", 1, out error);
            dl.TryCreateRecordsetValue("rec1.f2.value", "f2", "rs2", 1, out error);
            dl.TryCreateRecordsetValue("rec2.f1.value", "f1", "rs1", 2, out error);
            dl.TryCreateRecordsetValue("rec2.f2.value", "f2", "rs2", 2, out error);

            DataListTranslatedPayloadTO tmp = xmlConverter.ConvertFrom(dl, out errors);

            string result = tmp.FetchAsString().ToString();

            Assert.AreEqual("<DataList><scalar1>scalar1Value</scalar1></DataList>", result);
        }
Beispiel #3
0
        public void XmlTranslator_ConvertAndFilter_WhenRecordsetWithGaps_ExpectRowAnnotations()
        {
            //------------Setup for test--------------------------
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormatWithoutSystemTags);
            IBinaryDataList     dl1          = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            string error;
            var    cols = new List <Dev2Column> {
                DataListFactory.CreateDev2Column("val", string.Empty)
            };

            dl1.TryCreateRecordsetTemplate("rs", string.Empty, cols, true, out error);

            dl1.TryCreateRecordsetValue("1", "val", "rs", 1, out error);
            dl1.TryCreateRecordsetValue("3", "val", "rs", 3, out error);

            //------------Execute Test---------------------------
            ErrorResultTO errors;
            var           actual = xmlConverter.ConvertAndFilter(dl1, "<root><rs><val/></rs></root>".ToStringBuilder(), out errors);

            actual = actual.Replace("\r", "").Replace("\n", "");

            //------------Assert Results-------------------------
            const string expected = "<rs index=\"1\"><val>1</val></rs><rs index=\"3\"><val>3</val></rs>";

            StringAssert.Contains(actual.ToString(), expected, "rowID attribute not present");
        }
Beispiel #4
0
        public IBinaryDataList DeSerialize(string data, string targetShape, enTranslationTypes typeOf, out string error)
        {
            error = string.Empty;
            IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList();

            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

            if (typeOf == enTranslationTypes.XML)
            {
                ErrorResultTO errors;


                Guid resultId = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._Studio_Debug_XML),
                                                   data.ToStringBuilder(),
                                                   new StringBuilder(targetShape), out errors);
                if (errors.HasErrors())
                {
                    error = errors.FetchErrors()[0]; // take the first error ;)
                }
                else
                {
                    if (result != null)
                    {
                        compiler.ForceDeleteDataListByID(result.UID);
                    }
                    result = compiler.FetchBinaryDataList(resultId, out errors);
                    if (errors.HasErrors())
                    {
                        error = errors.FetchErrors()[0]; // take the first error ;)
                    }
                }
            }

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Converts a list of data list item view models to a binary data list.
        /// </summary>
        /// <param name="listToConvert">The list to convert.</param>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        private IBinaryDataList ConvertIDataListItemModelsToIBinaryDataList(out string errorString)
        {
            errorString = string.Empty;
            IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList();

            foreach (IDataListItemModel scalar in ScalarCollection)
            {
                if (!scalar.IsBlank && !scalar.HasError)
                {
                    result.TryCreateScalarTemplate(string.Empty, scalar.Name, scalar.Description, true, scalar.IsEditable, scalar.ColumnIODirection, out errorString);
                }
            }

            foreach (IDataListItemModel recset in RecsetCollection)
            {
                if (!recset.IsBlank && !recset.HasError)
                {
                    IList <Dev2Column> cols = new List <Dev2Column>();
                    foreach (IDataListItemModel child in recset.Children.Where(c => !c.IsBlank && !c.HasError))
                    {
                        cols.Add(DataListFactory.CreateDev2Column(child.Name, child.Description, child.IsEditable, child.ColumnIODirection));
                    }

                    result.TryCreateRecordsetTemplate(recset.Name, recset.Description, cols, true, recset.IsEditable, recset.ColumnIODirection, out errorString);
                }
            }
            return(result);
        }
        public void TryFetchLastIndexedRecordsetUpsertPayload_ColumnName_FetchesForColumn()
        {
            //------------Setup for test--------------------------
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder();

            toUpsert.Add("[[rec().f1]]", new List <string> {
                "test11", "test12"
            });
            toUpsert.Add("[[rec().f2]]", new List <string> {
                "test21", "test22"
            });
            IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList();
            string          creationError;

            dataList.TryCreateRecordsetTemplate("rec", "recset", new List <Dev2Column> {
                DataListFactory.CreateDev2Column("f1", "f1"), DataListFactory.CreateDev2Column("f2", "f2")
            }, true, out creationError);
            ErrorResultTO localErrors;

            compiler.PushBinaryDataList(dataList.UID, dataList, out localErrors);
            compiler.Upsert(dataList.UID, toUpsert, out _errors);
            IBinaryDataListEntry recEntry;
            string error;

            dataList.TryGetEntry("rec", out recEntry, out error);
            //------------Assert Preconditions-------------------
            Assert.IsNotNull(recEntry);
            //------------Execute Test---------------------------
            var listItem = recEntry.TryFetchLastIndexedRecordsetUpsertPayload(out error, "f2");

            //------------Assert Results-------------------------
            Assert.AreEqual("test22", listItem.TheValue);
        }
        public void FetchFromList_Expected_NonNullDisplayName()
        {
            string error;

            IBinaryDataList dl1;

            dl1 = Dev2BinaryDataListFactory.CreateDataList();

            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("field1"));

            dl1.TryCreateRecordsetTemplate("recset", "", cols, true, out error);

            dl1.TryCreateRecordsetValue("value", "field1", "recset", 1, out error);

            IBinaryDataListEntry entry;

            dl1.TryGetEntry("recset", out entry, out error);

            // DataList Cleanup ;)

            Assert.AreEqual("recset(1).field1", entry.FetchRecordAt(1, out error).First().DisplayValue);
            Assert.AreEqual(error, "");
        }
Beispiel #8
0
        public void DeSerializeToXMLFromBinary_InvertedIndexInsert_ValidXML_Expect_Sucess()
        {
            IBinaryDataList   dl = Dev2BinaryDataListFactory.CreateDataList();
            string            error;
            List <Dev2Column> cols = new List <Dev2Column>();
            ErrorResultTO     errors;

            cols.Add(DataListFactory.CreateDev2Column("f1", ""));
            cols.Add(DataListFactory.CreateDev2Column("f2", ""));
            cols.Add(DataListFactory.CreateDev2Column("f3", ""));
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat);


            dl.TryCreateRecordsetTemplate("rs1", "", cols, true, out error);
            dl.TryCreateScalarTemplate(string.Empty, "scalar1", "", true, out error);
            dl.TryCreateScalarValue("scalar1Value", "scalar1", out error);
            dl.TryCreateRecordsetValue("rec1.f2.vale", "f2", "rs1", 1, out error);
            dl.TryCreateRecordsetValue("rec1.f1.vale", "f1", "rs1", 1, out error);
            dl.TryCreateRecordsetValue("rec1.f3.vale", "f3", "rs1", 1, out error);
            dl.TryCreateRecordsetValue("rec2.f1.vale", "f1", "rs1", 2, out error);
            dl.TryCreateRecordsetValue("rec2.f2.vale", "f2", "rs1", 2, out error);
            dl.TryCreateRecordsetValue("rec2.f3.vale", "f3", "rs1", 2, out error);

            DataListTranslatedPayloadTO tmp = xmlConverter.ConvertFrom(dl, out errors);

            string result = tmp.FetchAsString().ToString();

            Assert.AreEqual("<DataList><rs1><f1>rec1.f1.vale</f1><f2>rec1.f2.vale</f2><f3>rec1.f3.vale</f3></rs1><rs1><f1>rec2.f1.vale</f1><f2>rec2.f2.vale</f2><f3>rec2.f3.vale</f3></rs1><scalar1>scalar1Value</scalar1></DataList>", result);
        }
        public void MyTestInitialize()
        {
            string error;

            var dataListCompiler = DataListFactory.CreateDataListCompiler();

            _dl1 = Dev2BinaryDataListFactory.CreateDataList();
            _dl1.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("[[otherScalar]]", "myScalar", out error);

            _dl1.TryCreateScalarTemplate(string.Empty, "otherScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("testRegion", "otherScalar", out error);

            _dl1.TryCreateScalarTemplate(string.Empty, "scalar1", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("foobar", "scalar1", out error);

            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));

            _dl1.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl1.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl1.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            // skip 3 ;)

            _dl1.TryCreateRecordsetValue("r4.f1.value", "f1", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f2.value", "f2", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f3.value", "f3", "recset", 4, out error);

            dataListCompiler.PushBinaryDataList(_dl1.UID, _dl1, out _errors);
            //_compiler.UpsertSystemTag(dl1.UID, enSystemTag.EvaluateIteration, "true", out errors);

            /*  list 2 */
            _dl2 = Dev2BinaryDataListFactory.CreateDataList();
            _dl2.TryCreateScalarTemplate(string.Empty, "idx", "A scalar", true, out error);
            _dl2.TryCreateScalarValue("1", "idx", out error);

            _dl2.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl2.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl2.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            dataListCompiler.PushBinaryDataList(_dl2.UID, _dl2, out _errors);
            //_compiler.UpsertSystemTag(dl2.UID, enSystemTag.EvaluateIteration, "true", out errors);
        }
Beispiel #10
0
 static ISimulationResult CreateResult(ISimulationKey key)
 {
     return(new SimulationResult
     {
         Key = key,
         Value = Dev2BinaryDataListFactory.CreateDataList()
     });
 }
Beispiel #11
0
        static string ExtractKeyValuePairs(NameValueCollection pairs)
        {
            IBinaryDataList bdl = Dev2BinaryDataListFactory.CreateDataList();

            // Extract request keys ;)
            foreach (var key in pairs.AllKeys)
            {
                if (key == "wid") //Don't add the Workspace ID to DataList
                {
                    continue;
                }
                if (key.IsXml())
                {
                    return(key); //We have a workspace id and XML DataList
                }
                string error;
                bdl.TryCreateScalarTemplate(string.Empty, key, string.Empty, true, out error);
                if (!string.IsNullOrEmpty(error))
                {
                    Dev2Logger.Log.Error(error);
                }

                IBinaryDataListEntry entry;
                if (bdl.TryGetEntry(key, out entry, out error))
                {
                    var item = Dev2BinaryDataListFactory.CreateBinaryItem(pairs[key], key);
                    entry.TryPutScalar(item, out error);
                    if (!string.IsNullOrEmpty(error))
                    {
                        Dev2Logger.Log.Error(error);
                    }
                }
                else
                {
                    Dev2Logger.Log.Error(error);
                }
            }

            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            ErrorResultTO     errors;
            Guid pushedId = compiler.PushBinaryDataList(bdl.UID, bdl, out errors);

            if (pushedId != Guid.Empty)
            {
                var result = compiler.ConvertFrom(pushedId, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors);
                if (errors.HasErrors())
                {
                    Dev2Logger.Log.Error(errors.MakeDisplayReady());
                }

                return(result.ToString());
            }

            Dev2Logger.Log.Error(errors.MakeDisplayReady());

            return(string.Empty);
        }
Beispiel #12
0
 public static void MyClassInitialize(TestContext testContext)
 {
     Directory.SetCurrentDirectory(testContext.TestDir);
     _testInstance = SimulationRepository.Instance;
     _testResult   = new SimulationResult
     {
         Key   = CreateKey(),
         Value = Dev2BinaryDataListFactory.CreateDataList()
     };
     _testInstance.Save(_testResult);
 }
Beispiel #13
0
        public void Clone_50EntryRS_1kTimes_AtDepth()
        {
            string error;

            IBinaryDataList dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f4"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f5"));

            const int r    = 50;
            const int runs = 1000;

            dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, out error);


            for (int i = 0; i < r; i++)
            {
                dl1.TryCreateRecordsetValue("r1.f1.value r1.f1.value r1.f1.valuer1.f1.valuer1.f1.value", "f1", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.value", "f3", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.value", "f4", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.value r1.f3.value v r1.f3.value r1.f3.value", "f5", "recset", (i + 1), out error);
            }

            DateTime             start1 = DateTime.Now;
            string               er;
            IBinaryDataListEntry val;
            bool tryGetEntry = dl1.TryGetEntry("recset", out val, out er);

            for (int q = 0; q < runs; q++)
            {
                if (tryGetEntry)
                {
                    val.Clone(enTranslationDepth.Data, dl1.UID, out er);
                }
            }


            DateTime end1 = DateTime.Now;

            long   ticks   = (end1.Ticks - start1.Ticks);
            double result1 = (ticks / _ticksPerSec);

            Console.WriteLine(result1 + @" seconds for " + runs + @" to clone ");

            Assert.IsTrue(result1 <= 10.5); // Given .01 buffer ;) WAS : 0.065
        }
        /// <summary>
        /// Gets the wizard data list for a workflow.
        /// </summary>
        /// <param name="dataList"></param>
        /// <returns>
        /// The string for the data list
        /// </returns>
        /// <exception cref="System.Exception">
        /// </exception>
        public string GetWizardDataListForWorkflow(string dataList)
        {
            IBinaryDataList newDl = Dev2BinaryDataListFactory.CreateDataList();
            ErrorResultTO   errors;
            var             dataListStringBuilder = new StringBuilder(dataList);
            Guid            dlID = ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), dataListStringBuilder, dataListStringBuilder, out errors);

            if (!errors.HasErrors())
            {
                IBinaryDataList dl = FetchBinaryDataList(dlID, out errors);
                if (!errors.HasErrors())
                {
                    IList <IBinaryDataListEntry> entries = dl.FetchAllEntries();
                    foreach (IBinaryDataListEntry entry in entries)
                    {
                        if (entry.IsRecordset)
                        {
                            if (entry.ColumnIODirection != enDev2ColumnArgumentDirection.None)
                            {
                                string tmpError;
                                newDl.TryCreateRecordsetTemplate(entry.Namespace, entry.Description, entry.Columns, true, out tmpError);
                            }
                        }
                        else
                        {
                            if (entry.ColumnIODirection != enDev2ColumnArgumentDirection.None)
                            {
                                string tmpError;
                                IBinaryDataListItem scalar = entry.FetchScalar();
                                newDl.TryCreateScalarTemplate(string.Empty, scalar.FieldName, entry.Description, true, out tmpError);
                            }
                        }
                    }
                    Guid newDlId = PushBinaryDataList(newDl.UID, newDl, out errors);
                    dataList = ConvertFrom(newDlId, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Shape, out errors).ToString();
                }
                else
                {
                    throw new Exception(errors.MakeUserReady());
                }
            }
            else
            {
                throw new Exception(errors.MakeUserReady());
            }
            return(dataList);
        }
Beispiel #15
0
        public void DeserializeToXMLFromBinaryDataListWhereDataListContainsInvalidXMLCharactersExpectedInvalidCharactersAreEscaped()
        {
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat);
            IBinaryDataList     dl1          = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            string error;

            dl1.TryCreateScalarTemplate(string.Empty, "cake", "", false, true, enDev2ColumnArgumentDirection.Both, out error);
            dl1.TryCreateScalarValue("Travis Is \"Cool\"&>'nstuff'<", "cake", out error);

            ErrorResultTO errors;
            var           payload = xmlConverter.ConvertFrom(dl1, out errors);

            string       actual   = payload.FetchAsString().ToString();
            const string expected = "Travis Is \"Cool\"&amp;>'nstuff'<";

            StringAssert.Contains(actual, expected, "Not all XML special characters are escaped i.e \"'><&");
        }
        public void UpsertWhereListStringExpectUpsertCorrectlyMultipleRecordset()
        {
            //------------Setup for test--------------------------
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder();

            toUpsert.Add("[[rec().f1]]", new List <string> {
                "test11", "test12"
            });
            toUpsert.Add("[[rec().f2]]", new List <string> {
                "test21", "test22"
            });
            IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList();
            string          creationError;

            dataList.TryCreateRecordsetTemplate("rec", "recset", new List <Dev2Column> {
                DataListFactory.CreateDev2Column("f1", "f1"), DataListFactory.CreateDev2Column("f2", "f2")
            }, true, out creationError);
            ErrorResultTO localErrors;

            compiler.PushBinaryDataList(dataList.UID, dataList, out localErrors);
            //------------Execute Test---------------------------
            compiler.Upsert(dataList.UID, toUpsert, out _errors);
            //------------Assert Results-------------------------
            IList <IBinaryDataListEntry> binaryDataListEntries = dataList.FetchRecordsetEntries();
            IBinaryDataListEntry         binaryDataListEntry   = binaryDataListEntries[0];
            string errString;
            IList <IBinaryDataListItem> binaryDataListItems = binaryDataListEntry.FetchRecordAt(1, out errString);
            IBinaryDataListItem         binaryDataListItem  = binaryDataListItems[0];
            IBinaryDataListItem         binaryDataListItem2 = binaryDataListItems[1];
            string theValue = binaryDataListItem.TheValue;

            Assert.AreEqual("test11", theValue);
            theValue = binaryDataListItem2.TheValue;
            Assert.AreEqual("test21", theValue);
            binaryDataListItems = binaryDataListEntry.FetchRecordAt(2, out errString);
            binaryDataListItem  = binaryDataListItems[0];
            binaryDataListItem2 = binaryDataListItems[1];
            theValue            = binaryDataListItem.TheValue;
            Assert.AreEqual("test12", theValue);
            theValue = binaryDataListItem2.TheValue;

            Assert.AreEqual("test22", theValue);
        }
Beispiel #17
0
        /// <summary>
        /// Gets the outputs.
        /// </summary>
        /// <param name="obj">The obj to get outputs for.</param>
        /// <returns></returns>
        public static IBinaryDataList GetSimpleOutputs(object obj)
        {
            IBinaryDataList binaryDL   = Dev2BinaryDataListFactory.CreateDataList();
            Type            sourceType = obj.GetType();

            foreach (PropertyInfo pi in sourceType.GetProperties())
            {
                List <Outputs> listOfInputs = pi.GetCustomAttributes(typeof(Outputs), true).OfType <Outputs>().ToList();
                if (listOfInputs.Count > 0)
                {
                    string error;
                    if (binaryDL.TryCreateScalarTemplate(string.Empty, listOfInputs[0].UserVisibleName, "", true, out error))
                    {
                        binaryDL.TryCreateScalarValue(pi.GetValue(obj, null).ToString(), listOfInputs[0].UserVisibleName, out error);
                    }
                }
            }
            return(binaryDL);
        }
Beispiel #18
0
        public void XmlTranslator_ConvertAndFilter_WhenXMLSpecialCharsPresent_ExpectEscapedChars()
        {
            //------------Setup for test--------------------------
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormatWithoutSystemTags);
            IBinaryDataList     dl1          = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            string error;

            dl1.TryCreateScalarTemplate(string.Empty, "cake", "", false, true, enDev2ColumnArgumentDirection.Both, out error);
            dl1.TryCreateScalarValue("Travis Is \"Cool\"&>'nstuff'<", "cake", out error);

            //------------Execute Test---------------------------
            ErrorResultTO errors;
            var           actual = xmlConverter.ConvertAndFilter(dl1, "<root><cake/></root>".ToStringBuilder(), out errors);

            //------------Assert Results-------------------------
            const string expected = "Travis Is &quot;Cool&quot;&amp;&gt;&apos;nstuff&apos;&lt;";

            StringAssert.Contains(actual.ToString(), expected, "Not all XML special characters are escaped i.e \"'><&");
        }
Beispiel #19
0
        public void LargeBDL_Create_1Mil_5Cols_Recordset_Entries()
        {
            string error;

            IBinaryDataList dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f4"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f5"));

            const int runs = 10000;

            dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, out error);

            using (dl1)
            {
                DateTime start1 = DateTime.Now;
                for (int i = 0; i < runs; i++)
                {
                    dl1.TryCreateRecordsetValue("r1.f1.value r1.f1.value r1.f1.valuer1.f1.valuer1.f1.value", "f1", "recset", (i + 1), out error);
                    dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", (i + 1), out error);
                    dl1.TryCreateRecordsetValue("r1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.value", "f3", "recset", (i + 1), out error);
                    dl1.TryCreateRecordsetValue("r1.f3.value", "f4", "recset", (i + 1), out error);
                    dl1.TryCreateRecordsetValue("r1.f3.value r1.f3.value v r1.f3.value r1.f3.value", "f5", "recset", (i + 1), out error);
                }

                DateTime end1 = DateTime.Now;

                long   ticks   = (end1.Ticks - start1.Ticks);
                double result1 = (ticks / _ticksPerSec);

                Console.WriteLine(result1 + @" seconds for " + runs + @" with 5 cols");

                Assert.IsTrue(result1 <= 1500, "Expected 500 seconds but got " + result1 + " seconds"); // Given 0.75 WAS : 0.75
                // Since Windblow really sucks at resource allocation, I need to adjust these for when it is forced into a multi-user enviroment!!!!
            }
        }
Beispiel #20
0
        public void CloneWhereHasComplexExpressionAuditorExpectIsOnClonedObject()
        {
            //------------Setup for test--------------------------
            string             error;
            IBinaryDataList    dl1  = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);
            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, out error);
            dl1.TryCreateRecordsetValue("r1.f1.value r1.f1.value r1.f1.valuer1.f1.valuer1.f1.value", "f1", "recset", 1, out error);
            string er;
            IBinaryDataListEntry val;

            dl1.TryGetEntry("recset", out val, out er);
            val.ComplexExpressionAuditor = new ComplexExpressionAuditor();
            //------------Execute Test---------------------------
            IBinaryDataListEntry res = val.Clone(enTranslationDepth.Data, dl1.UID, out er);

            //------------Assert Results-------------------------
            Assert.IsNotNull(res.ComplexExpressionAuditor);
        }
        private Guid CreateDataList(enDev2ColumnArgumentDirection dir)
        {
            DataListFactory.CreateDataListCompiler();
            string        error;
            ErrorResultTO errors;

            IBinaryDataList dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1", dir));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2", dir));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3", dir));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f4", dir));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f5", dir));

            dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, true, dir, out error);

            dl1.TryCreateScalarTemplate(string.Empty, "myScalar", string.Empty, true, true, dir, out error);
            // dl1.Dispose();
            return(_compiler.PushBinaryDataList(dl1.UID, dl1, out errors));
        }
Beispiel #22
0
        public void LargeBDL_Persist_1M_5Cols_Recordset_Entries()
        {
            string error;

            IBinaryDataList dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f4"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f5"));

            const int runs = 10000; //1000000;

            dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, out error);


            DateTime start1 = DateTime.Now;

            for (int i = 0; i < runs; i++)
            {
                dl1.TryCreateRecordsetValue("r1.f1.value r1.f1.value r1.f1.valuer1.f1.valuer1.f1.value", "f1", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.value", "f3", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.value", "f4", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.value r1.f3.value v r1.f3.value r1.f3.value", "f5", "recset", (i + 1), out error);
            }

            DateTime end1 = DateTime.Now;

            long   ticks   = (end1.Ticks - start1.Ticks);
            double result1 = (ticks / _ticksPerSec);

            Console.WriteLine(result1 + @" seconds for " + runs + @" with 5 cols");

            Assert.IsTrue(result1 <= 2600, "Expected 600 seconds but got " + result1 + " seconds"); // create speed
        }
        /// <summary>
        /// Pushes the system model to data list.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dlID">The dl ID.</param>
        /// <param name="model">The model.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public Guid PushSystemModelToDataList <T>(Guid dlID, T model, out ErrorResultTO errors)
        {
            // Serialize the model first ;)
            var           jsonModel = ConvertModelToJson(model);
            ErrorResultTO allErrors = new ErrorResultTO();

            // Create a new DL if need be
            Guid pushID = dlID;

            if (pushID == GlobalConstants.NullDataListID)
            {
                IBinaryDataList bdl = Dev2BinaryDataListFactory.CreateDataList();
                pushID = PushBinaryDataList(bdl.UID, bdl, out errors);
                allErrors.MergeErrors(errors);
                errors.ClearErrors();
            }

            UpsertSystemTag(pushID, enSystemTag.SystemModel, jsonModel.ToString(), out errors);
            allErrors.MergeErrors(errors);

            errors = allErrors;

            return(pushID);
        }
        public void WorkflowExecuted_Where_ExecutionStatusCallBackRegisteredAndDataListMergeRequested_Expected_DataMergedInAndOutOfWorkflow()
        {
            //
            // Create a reset event which is used to wait for callbacks form the server
            //
            ManualResetEventSlim resetEvent = new ManualResetEventSlim(false);

            //
            // Setup MEF context
            //
            ImportService.CurrentContext = CompositionInitializer.DefaultInitialize();

            //
            // Setup test data
            //
            ErrorResultTO errors      = new ErrorResultTO();
            Guid          callBackID  = Guid.NewGuid();
            string        serviceName = "wizardtest";

            IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList();

            string error;

            dataList.TryCreateScalarTemplate("", "testvalue", "", true, out error);
            dataList.TryCreateScalarValue("321", "testvalue", out error);

            DataListMergeOpsTO dataListMergeOpsTO = new DataListMergeOpsTO(dataList.UID);

            ServiceLocator serviceLocator = new ServiceLocator();

            ImportService.SatisfyImports(serviceLocator);

            //
            // Connect to the server
            //
            IEnvironmentConnection conn = new EnvironmentConnection();

            conn.Address = new Uri(ServerSettings.DsfAddress);
            conn.Connect();

            IEventAggregator          eventAggregator       = ImportService.GetExportValue <IEventAggregator>();
            IFrameworkSecurityContext securityContext       = ImportService.GetExportValue <IFrameworkSecurityContext>();
            IEnvironmentConnection    environmentConnection = ImportService.GetExportValue <IEnvironmentConnection>();

            IEnvironmentModel environment = new EnvironmentModel(eventAggregator, securityContext, environmentConnection);

            environment.EnvironmentConnection = conn;

            //
            // Write the datalist to the server over the datalist channel
            //
            conn.DataListChannel.WriteDataList(dataList.UID, dataList, errors);

            //
            // Add an execution callback, the action of this call back will set the reset event allowing the test to continue
            //
            conn.ExecutionChannel.AddExecutionStatusCallback(callBackID, new Action <ExecutionStatusCallbackMessage>(m =>
            {
                if (m.MessageType == ExecutionStatusCallbackMessageType.CompletedCallback)
                {
                    resetEvent.Set();
                }
            }));

            //
            // Get endpoint to query and make request to server
            //
            Uri enpoint = serviceLocator.GetEndpoint(WizardEndpointGenerationStrategyProvider.ServiceWithDataListMergeAndExecutionCallBackKey, new Tuple <string, IEnvironmentModel, DataListMergeOpsTO, Guid>(serviceName, environment, dataListMergeOpsTO, callBackID));

            WebRequest   wr      = WebRequest.Create(enpoint);
            WebResponse  wrsp    = wr.GetResponse();
            Stream       s       = wrsp.GetResponseStream();
            StreamReader sr      = new StreamReader(s);
            string       payload = sr.ReadToEnd();

            //
            // Wait for completed callback
            //
            resetEvent.Wait(10000);

            //
            // Get datalist from the server
            //
            IBinaryDataList resultDataList = conn.DataListChannel.ReadDatalist(dataList.UID, errors);

            //
            // Clean up
            //
            conn.Disconnect();

            IBinaryDataListEntry testValueEntry;

            resultDataList.TryGetEntry("testvalue", out testValueEntry, out error);

            IBinaryDataListEntry inValueEntry;

            resultDataList.TryGetEntry("invalue", out inValueEntry, out error);

            string expected = "123|321";
            string actual   = testValueEntry.FetchScalar().TheValue + "|" + inValueEntry.FetchScalar().TheValue;

            Assert.AreEqual(expected, actual);
        }
Beispiel #25
0
        /// <summary>
        /// Build the template based upon the sent shape
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="error"></param>
        private IBinaryDataList BuildTargetShape(StringBuilder shape, out string error)
        {
            IBinaryDataList result = null;

            error = null;
            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(shape.ToString());
                if (xDoc.DocumentElement != null)
                {
                    var children = xDoc.DocumentElement.ChildNodes;
                    error = string.Empty;

                    HashSet <string> procssesNamespaces = new HashSet <string>();

                    result = Dev2BinaryDataListFactory.CreateDataList();

                    foreach (XmlNode c in children)
                    {
                        if (!DataListUtil.IsSystemTag(c.Name))
                        {
                            if (c.HasChildNodes)
                            {
                                IList <Dev2Column> cols = new List <Dev2Column>();
                                // build template for Recordset
                                if (!procssesNamespaces.Contains(c.Name))
                                {
                                    // build columns
                                    foreach (XmlNode subc in c.ChildNodes)
                                    {
                                        // It is possible for the .Attributes property to be null, a check should be added
                                        if (subc.Attributes != null)
                                        {
                                            cols.Add(DataListFactory.CreateDev2Column(subc.Name,
                                                                                      ParseDescription(subc.Attributes[Description]),
                                                                                      ParseIsEditable(subc.Attributes[IsEditable]),
                                                                                      ParseColumnIODirection(subc.Attributes[GlobalConstants.DataListIoColDirection])));
                                        }
                                        else
                                        {
                                            cols.Add(DataListFactory.CreateDev2Column(subc.Name,
                                                                                      ParseDescription(null),
                                                                                      ParseIsEditable(null),
                                                                                      ParseColumnIODirection(null)));
                                        }
                                    }

                                    string myError;

                                    if (c.Attributes != null)
                                    {
                                        if (!result.TryCreateRecordsetTemplate(c.Name,
                                                                               ParseDescription(c.Attributes[Description]),
                                                                               cols,
                                                                               true,
                                                                               ParseIsEditable(c.Attributes[IsEditable]),
                                                                               ParseColumnIODirection(c.Attributes[GlobalConstants.DataListIoColDirection]),
                                                                               out myError))
                                        {
                                            error = myError;
                                        }
                                    }
                                    else
                                    {
                                        if (!result.TryCreateRecordsetTemplate(c.Name,
                                                                               ParseDescription(null),
                                                                               cols,
                                                                               true,
                                                                               ParseIsEditable(null),
                                                                               ParseColumnIODirection(null),
                                                                               out myError))
                                        {
                                            error = myError;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //scalar
                                if (c.Attributes != null)
                                {
                                    result.TryCreateScalarTemplate(string.Empty,
                                                                   c.Name,
                                                                   ParseDescription(c.Attributes[Description]),
                                                                   true,
                                                                   ParseIsEditable(c.Attributes[IsEditable]),
                                                                   ParseColumnIODirection(c.Attributes[GlobalConstants.DataListIoColDirection]),
                                                                   out error);
                                }
                                else
                                {
                                    result.TryCreateScalarTemplate(string.Empty,
                                                                   c.Name,
                                                                   ParseDescription(null),
                                                                   true,
                                                                   ParseIsEditable(null),
                                                                   ParseColumnIODirection(null),
                                                                   out error);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(result);
        }
Beispiel #26
0
        public void Clone_50EntryRS_10kTimes_AtDepth()
        {
            IBinaryDataList dl1;

            double    result1;
            const int r    = 50;
            const int runs = 10000;

            using (dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID))
            {
                IList <Dev2Column> cols = new List <Dev2Column>();
                cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
                cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
                cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));
                cols.Add(Dev2BinaryDataListFactory.CreateColumn("f4"));
                cols.Add(Dev2BinaryDataListFactory.CreateColumn("f5"));

                string error;
                dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, out error);

                for (int i = 0; i < r; i++)
                {
                    dl1.TryCreateRecordsetValue("r1.f1.value r1.f1.value r1.f1.valuer1.f1.valuer1.f1.value", "f1", "recset", (i + 1), out error);
                    dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", (i + 1), out error);
                    dl1.TryCreateRecordsetValue("r1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.value", "f3", "recset", (i + 1), out error);
                    dl1.TryCreateRecordsetValue("r1.f3.value", "f4", "recset", (i + 1), out error);
                    dl1.TryCreateRecordsetValue("r1.f3.value r1.f3.value v r1.f3.value r1.f3.value", "f5", "recset", (i + 1), out error);
                }

                DateTime             start1 = DateTime.Now;
                string               er;
                IBinaryDataListEntry val;
                bool tryGetEntry = dl1.TryGetEntry("recset", out val, out er);
                for (int q = 0; q < runs; q++)
                {
                    if (tryGetEntry)
                    {
                        // ReSharper disable RedundantAssignment
                        val.Clone(enTranslationDepth.Data, dl1.UID, out er);
                        // ReSharper restore RedundantAssignment
                    }
                }

                DateTime end1 = DateTime.Now;

                long ticks = (end1.Ticks - start1.Ticks);
                result1 = (ticks / _ticksPerSec);
            }
            Console.WriteLine(result1 + @" seconds for " + runs + @" to clone ");

            // Was 5, now 25 for enviroments ;)

            if (result1 <= 125)
            {
                Assert.IsTrue(result1 <= 125, " It Took " + result1); // Given .1 buffer ;) WAS " 0.65
            }
            else
            {
                Assert.Fail("Time for new hardward buddy!");
            }
        }
        /// <summary>
        /// Translates the shape automatic object.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="includeSysTags">Includes the system tags when building the DataList</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public IBinaryDataList TranslateShapeToObject(StringBuilder shape, bool includeSysTags, out ErrorResultTO errors)
        {
            IBinaryDataList result = null;

            errors = new ErrorResultTO();

            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(shape.ToString());
                string error;
                if (xDoc.DocumentElement != null)
                {
                    XmlNodeList      children           = xDoc.DocumentElement.ChildNodes;
                    HashSet <string> procssesNamespaces = new HashSet <string>();

                    result = Dev2BinaryDataListFactory.CreateDataList();

                    foreach (XmlNode c in children)
                    {
                        XmlAttribute descAttribute = null;
                        XmlAttribute ioDirection   = null;

                        if (!DataListUtil.IsSystemTag(c.Name))
                        {
                            if (c.HasChildNodes)
                            {
                                IList <Dev2Column> cols = new List <Dev2Column>();
                                //recordset
                                // build template
                                if (!procssesNamespaces.Contains(c.Name))
                                {
                                    procssesNamespaces.Add(c.Name);

                                    // build columns
                                    foreach (XmlNode subc in c.ChildNodes)
                                    {
                                        if (subc.Attributes != null)
                                        {
                                            descAttribute = subc.Attributes["Description"];
                                            ioDirection   = subc.Attributes["ColumnIODirection"];
                                        }

                                        // set column io direction
                                        enDev2ColumnArgumentDirection dirCol = enDev2ColumnArgumentDirection.None;
                                        if (ioDirection != null)
                                        {
                                            Enum.TryParse(ioDirection.Value, out dirCol);
                                        }


                                        if (descAttribute != null)
                                        {
                                            cols.Add(DataListFactory.CreateDev2Column(subc.Name, descAttribute.Value, true, dirCol));
                                        }
                                        else
                                        {
                                            cols.Add(DataListFactory.CreateDev2Column(subc.Name, String.Empty, true, dirCol));
                                        }
                                    }
                                    string myError;

                                    if (c.Attributes != null)
                                    {
                                        descAttribute = c.Attributes["Description"];
                                        ioDirection   = c.Attributes["ColumnIODirection"];
                                    }


                                    // set column io direction
                                    enDev2ColumnArgumentDirection dir = enDev2ColumnArgumentDirection.None;
                                    if (ioDirection != null)
                                    {
                                        Enum.TryParse(ioDirection.Value, out dir);
                                    }


                                    if (descAttribute != null)
                                    {
                                        if (!result.TryCreateRecordsetTemplate(c.Name, descAttribute.Value, cols, true, true, dir, out myError))
                                        {
                                            errors.AddError(myError);
                                        }
                                    }
                                    else
                                    {
                                        if (!result.TryCreateRecordsetTemplate(c.Name, String.Empty, cols, true, true, dir, out myError))
                                        {
                                            errors.AddError(myError);
                                        }
                                    }
                                }
                                else
                                {
                                    // it is a duplicate we need to handle this correctly ;)
                                    // build columns

                                    IBinaryDataListEntry amendEntry;
                                    result.TryGetEntry(c.Name, out amendEntry, out error);
                                    errors.AddError(error);

                                    if (amendEntry != null)
                                    {
                                        cols = amendEntry.Columns;

                                        foreach (XmlNode subc in c.ChildNodes)
                                        {
                                            if (subc.Attributes != null)
                                            {
                                                descAttribute = subc.Attributes["Description"];
                                                ioDirection   = subc.Attributes["ColumnIODirection"];
                                            }

                                            // set column io direction
                                            enDev2ColumnArgumentDirection dir = enDev2ColumnArgumentDirection.None;
                                            if (ioDirection != null)
                                            {
                                                Enum.TryParse(ioDirection.Value, out dir);
                                            }


                                            if (descAttribute != null)
                                            {
                                                cols.Add(DataListFactory.CreateDev2Column(subc.Name, descAttribute.Value, true, dir));
                                            }
                                            else
                                            {
                                                cols.Add(DataListFactory.CreateDev2Column(subc.Name, String.Empty, true, dir));
                                            }
                                        }

                                        // now re-insert the entry ;)
                                        if (!result.TryCreateRecordsetTemplate(c.Name, String.Empty, cols, true, out error))
                                        {
                                            errors.AddError(error);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //scalar
                                if (c.Attributes != null)
                                {
                                    descAttribute = c.Attributes["Description"];
                                    ioDirection   = c.Attributes["ColumnIODirection"];
                                }

                                // get column direction
                                enDev2ColumnArgumentDirection dir = enDev2ColumnArgumentDirection.None;
                                if (ioDirection != null)
                                {
                                    Enum.TryParse(ioDirection.Value, out dir);
                                }

                                if (descAttribute != null)
                                {
                                    result.TryCreateScalarTemplate(String.Empty, c.Name, descAttribute.Value, true, true, dir, out error);
                                }
                                else
                                {
                                    result.TryCreateScalarTemplate(String.Empty, c.Name, String.Empty, true, true, dir, out error);
                                }
                            }
                        }
                    }
                }


                if (includeSysTags)
                {
                    // Build System Tag Shape ;)
                    for (int i = 0; i < TranslationConstants.systemTags.Length; i++)
                    {
                        if (result != null)
                        {
                            result.TryCreateScalarTemplate(GlobalConstants.SystemTagNamespace,
                                                           TranslationConstants.systemTags.GetValue(i).ToString(),
                                                           String.Empty,
                                                           true,
                                                           out error);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                errors.AddError(e.Message);
            }

            return(result);
        }
        /*
         * There are plenty of test in the DynamicServicesEndPointTest that appear to test this functionality ;)
         */

        /// <summary>
        /// Build the template based upon the sent shape
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="error"></param>
        public static IBinaryDataList BuildTargetShape(string shape, out string error)
        {
            IBinaryDataList result = null;

            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(shape);
                XmlNodeList children = xDoc.DocumentElement.ChildNodes;
                error = string.Empty;

                HashSet <string> procssesNamespaces = new HashSet <string>();

                if (children != null)
                {
                    result = Dev2BinaryDataListFactory.CreateDataList();

                    foreach (XmlNode c in children)
                    {
                        XmlAttribute descAttribute     = null;
                        XmlAttribute columnIoDirection = null;
                        if (!DataListUtil.IsSystemTag(c.Name))
                        {
                            if (c.HasChildNodes)
                            {
                                IList <Dev2Column> cols = new List <Dev2Column>();
                                //recordset
                                if (c.ChildNodes != null)
                                {
                                    // build template
                                    if (!procssesNamespaces.Contains(c.Name))
                                    {
                                        // build columns
                                        foreach (XmlNode subc in c.ChildNodes)
                                        {
                                            // It is possible for the .Attributes property to be null, a check should be added
                                            if (subc.Attributes != null)
                                            {
                                                descAttribute = subc.Attributes["Description"];
                                            }
                                            if (descAttribute != null)
                                            {
                                                cols.Add(DataListFactory.CreateDev2Column(subc.Name, descAttribute.Value));
                                            }
                                            else
                                            {
                                                cols.Add(DataListFactory.CreateDev2Column(subc.Name, string.Empty));
                                            }
                                        }
                                        string myError = string.Empty;
                                        // It is possible for the .Attributes property to be null, a check should be added
                                        if (c.Attributes != null)
                                        {
                                            descAttribute     = c.Attributes["Description"];
                                            columnIoDirection = c.Attributes["ColumnIODirection"];
                                        }
                                        if (descAttribute != null)
                                        {
                                            var columnDirection = enDev2ColumnArgumentDirection.None;
                                            if (columnIoDirection != null)
                                            {
                                                Enum.TryParse(columnIoDirection.Value, true, out columnDirection);
                                            }
                                            if (!result.TryCreateRecordsetTemplate(c.Name, descAttribute.Value, cols, true, false, columnDirection, out myError))
                                            {
                                                error = myError;
                                            }
                                        }
                                        else
                                        {
                                            if (!result.TryCreateRecordsetTemplate(c.Name, string.Empty, cols, true, out myError))
                                            {
                                                error = myError;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //scalar
                                // It is possible for the .Attributes property to be null, a check should be added
                                if (c.Attributes != null)
                                {
                                    descAttribute     = c.Attributes["Description"];
                                    columnIoDirection = c.Attributes["ColumnIODirection"];
                                }
                                if (descAttribute != null)
                                {
                                    var columnDirection = enDev2ColumnArgumentDirection.None;
                                    if (columnIoDirection != null)
                                    {
                                        Enum.TryParse(columnIoDirection.Value, true, out columnDirection);
                                    }
                                    result.TryCreateScalarTemplate(string.Empty, c.Name, descAttribute.Value, true, false, columnDirection, out error);
                                }
                                else
                                {
                                    result.TryCreateScalarTemplate(string.Empty, c.Name, string.Empty, true, out error);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }

            return(result);
        }
        public void MyTestInitialize()
        {
            string error;

            _dl1 = Dev2BinaryDataListFactory.CreateDataList();
            _dl1.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("myValue", "myScalar", out error);

            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));

            _dl1.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl1.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl1.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            // skip 3 ;)

            _dl1.TryCreateRecordsetValue("r4.f1.value", "f1", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f2.value", "f2", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f3.value", "f3", "recset", 4, out error);

            // create 2nd obj
            _dl2 = Dev2BinaryDataListFactory.CreateDataList();
            _dl2.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl2.TryCreateScalarValue("myValue2", "myScalar", out error);

            cols = new List <Dev2Column> {
                Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3")
            };

            _dl2.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl2.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset", 1, out error);

            _dl2.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset", 2, out error);

            _dl2.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset", 3, out error);
            _dl2.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset", 3, out error);
            _dl2.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset", 3, out error);

            // create 3rd obj
            _dl3 = Dev2BinaryDataListFactory.CreateDataList();
            _dl3.TryCreateScalarTemplate(string.Empty, "theScalar", "A scalar", true, out error);
            _dl3.TryCreateScalarValue("theValue", "theScalar", out error);

            cols = new List <Dev2Column> {
                Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3")
            };

            _dl3.TryCreateRecordsetTemplate("recset2", "a recordset", cols, true, out error);

            _dl3.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset2", 1, out error);
            _dl3.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset2", 1, out error);
            _dl3.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset2", 1, out error);

            _dl3.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset2", 2, out error);
            _dl3.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset2", 2, out error);
            _dl3.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset2", 2, out error);

            _dl3.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset2", 3, out error);
            _dl3.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset2", 3, out error);
            _dl3.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset2", 3, out error);

            // create 4th obj
            _dl4 = Dev2BinaryDataListFactory.CreateDataList();
            _dl4.TryCreateScalarTemplate(string.Empty, "theScalar", "A scalar", true, out error);
            _dl4.TryCreateScalarValue("theValue4", "theScalar", out error);
            _dl4.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl4.TryCreateScalarValue("myValue4", "myScalar", out error);

            cols = new List <Dev2Column> {
                Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3")
            };

            _dl4.TryCreateRecordsetTemplate("recset2", "a recordset", cols, true, out error);

            _dl4.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset2", 1, out error);
            _dl4.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset2", 1, out error);
            _dl4.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset2", 1, out error);

            _dl4.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset2", 2, out error);
            _dl4.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset2", 2, out error);
            _dl4.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset2", 2, out error);

            _dl4.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset2", 3, out error);
            _dl4.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset2", 3, out error);
            _dl4.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset2", 3, out error);



            // create 5th obj
            _dlWithBankScalar = Dev2BinaryDataListFactory.CreateDataList();
            _dlWithBankScalar.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dlWithBankScalar.TryCreateScalarValue("", "myScalar", out error);

            _dlWithPopulatedScalar = Dev2BinaryDataListFactory.CreateDataList();
            _dlWithPopulatedScalar.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dlWithPopulatedScalar.TryCreateScalarValue("CAKE!", "myScalar", out error);
        }