IRecordSetItemModel CreateRecordSet(XmlNode xmlNode) { IRecordSetItemModel recset; if (xmlNode.Attributes != null) { recset = DataListItemModelFactory.CreateRecordSetItemModel(xmlNode.Name, Common.ParseDescription(xmlNode.Attributes[Common.Description]), Common.ParseColumnIODirection(xmlNode.Attributes[GlobalConstants.DataListIoColDirection])); if (recset != null) { recset.IsEditable = Common.ParseIsEditable(xmlNode.Attributes[Common.IsEditable]); recset.OnDeleted += (item) => _vm.RemoveDataListItem(item); _vm.Add(recset); } } else { recset = DataListItemModelFactory.CreateRecordSetItemModel(xmlNode.Name, Common.ParseDescription(null)); if (recset != null) { recset.IsEditable = Common.ParseIsEditable(null); recset.OnDeleted += (item) => _vm.RemoveDataListItem(item); _vm.Add(recset); } } return(recset); }
public void DataListViewModel_DifferentVariablesCollection_Object_Is_NOT_Equal() { //---------------Set up test pack------------------- var mockResourceModel = Dev2MockFactory.SetupResourceModelMock(); var dataListViewModel = new DataListViewModel(new Mock <IEventAggregator>().Object); var dataListViewModel1 = new DataListViewModel(new Mock <IEventAggregator>().Object); dataListViewModel.InitializeDataListViewModel(mockResourceModel.Object); dataListViewModel1.InitializeDataListViewModel(mockResourceModel.Object); dataListViewModel.RecsetCollection.Clear(); dataListViewModel.ScalarCollection.Clear(); dataListViewModel1.RecsetCollection.Clear(); dataListViewModel1.ScalarCollection.Clear(); dataListViewModel1.ComplexObjectCollection.Clear(); dataListViewModel.ComplexObjectCollection.Clear(); var carRecordset = DataListItemModelFactory.CreateRecordSetItemModel("Car", "A recordset of information about a car"); carRecordset.Children.Add(DataListItemModelFactory.CreateRecordSetFieldItemModel("Make", "Make of vehicle", carRecordset)); carRecordset.Children.Add(DataListItemModelFactory.CreateRecordSetFieldItemModel("Model", "Model of vehicle", carRecordset)); carRecordset.Input = true; carRecordset.Output = true; dataListViewModel.Add(carRecordset); dataListViewModel1.Add(carRecordset); dataListViewModel.Add(DataListItemModelFactory.CreateScalarItemModel("Country", "name of Country", enDev2ColumnArgumentDirection.Both)); //---------------Assert Precondition---------------- Assert.IsNotNull(dataListViewModel); Assert.IsNotNull(dataListViewModel1); //---------------Execute Test ---------------------- var equals = dataListViewModel.Equals(dataListViewModel1); //---------------Test Result ----------------------- Assert.IsFalse(equals); }
/// <summary> /// Converts a binary data list to list a data list item view models. /// </summary> /// <param name="dataListToConvert">The data list to convert.</param> /// <param name="errorString">The error string.</param> /// <returns></returns> private void ConvertBinaryDataListToListOfIDataListItemModels(IBinaryDataList dataListToConvert, out string errorString) { errorString = string.Empty; RecsetCollection = new OptomizedObservableCollection <IDataListItemModel>(); ScalarCollection = new OptomizedObservableCollection <IDataListItemModel>(); IList <IBinaryDataListEntry> listOfEntries = dataListToConvert.FetchAllEntries(); foreach (IBinaryDataListEntry entry in listOfEntries) { if (entry.IsRecordset) { IDataListItemModel recset = DataListItemModelFactory.CreateDataListModel(entry.Namespace, entry.Description, entry.ColumnIODirection); recset.IsEditable = entry.IsEditable; Validator.Add(recset); foreach (Dev2Column col in entry.Columns) { IDataListItemModel child = DataListItemModelFactory.CreateDataListModel(col.ColumnName, col.ColumnDescription, col.ColumnIODirection); child.Parent = recset; child.IsEditable = col.IsEditable; recset.Children.Add(child); recset.Validator.Add(child); } RecsetCollection.Add(recset); } else { IDataListItemModel scalar = DataListItemModelFactory.CreateDataListModel(entry.Namespace, entry.Description, entry.ColumnIODirection); scalar.IsEditable = entry.IsEditable; ScalarCollection.Add(scalar); Validator.Add(scalar); } } }
private IRecordSetItemModel CreateRecordSet(XmlNode xmlNode) { IRecordSetItemModel recset; if (xmlNode.Attributes != null) { recset = DataListItemModelFactory.CreateRecordSetItemModel(xmlNode.Name, Common.ParseDescription(xmlNode.Attributes[Common.Description]), null, null, false, "", true, true, false, Common.ParseColumnIODirection(xmlNode.Attributes[GlobalConstants.DataListIoColDirection])); if (recset != null) { recset.IsEditable = Common.ParseIsEditable(xmlNode.Attributes[Common.IsEditable]); _vm.RecsetCollection.Add(recset); } } else { recset = DataListItemModelFactory.CreateRecordSetItemModel(xmlNode.Name, Common.ParseDescription(null)); if (recset != null) { recset.IsEditable = Common.ParseIsEditable(null); _vm.RecsetCollection.Add(recset); } } return(recset); }
/// <summary> /// Creates the list of data list item view model to bind to. /// </summary> /// <param name="errorString">The error string.</param> /// <returns></returns> public void CreateListsOfIDataListItemModelToBindTo(out string errorString) { errorString = string.Empty; if (!string.IsNullOrEmpty(Resource.DataList)) { ErrorResultTO errors = new ErrorResultTO(); try { if (!string.IsNullOrEmpty(Resource.DataList)) { ConvertDataListStringToCollections(Resource.DataList); } } catch (Exception) { errors.AddError(ErrorResource.InvalidVariableList); } } else { RecsetCollection.Clear(); ScalarCollection.Clear(); ComplexObjectCollection.Clear(); _recordsetHandler.AddRecordSet(); } BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>(); DataListHeaderItemModel variableNode = DataListItemModelFactory.CreateDataListHeaderItem("Variable"); if (ScalarCollection.Count == 0) { IScalarItemModel dataListItemModel = DataListItemModelFactory.CreateScalarItemModel(string.Empty); dataListItemModel.IsComplexObject = false; dataListItemModel.AllowNotes = false; ScalarCollection.Add(dataListItemModel); } BaseCollection.Add(variableNode); DataListHeaderItemModel recordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordset"); if (RecsetCollection.Count == 0) { _recordsetHandler.AddRecordSet(); } BaseCollection.Add(recordsetsNode); DataListHeaderItemModel complexObjectNode = DataListItemModelFactory.CreateDataListHeaderItem("Object"); BaseCollection.Add(complexObjectNode); AddBlankRow(null); BaseCollection[0].Children = ScalarCollection; BaseCollection[1].Children = RecsetCollection; BaseCollection[2].Children = ComplexObjectCollection; WriteToResourceModel(); }
/// <summary> /// Creates the list of data list item view model to bind to. /// </summary> /// <param name="errorString">The error string.</param> /// <returns></returns> public void CreateListsOfIDataListItemModelToBindTo(out string errorString) { errorString = string.Empty; IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); if (!string.IsNullOrEmpty(Resource.DataList)) { ErrorResultTO errors = new ErrorResultTO(); try { IBinaryDataList binarnyDl = CreateBinaryDataListFromXmlData(Resource.DataList, out errors); if (!errors.HasErrors()) { ConvertBinaryDataListToListOfIDataListItemModels(binarnyDl, out errorString); } else { string errorMessage = errors.FetchErrors().Aggregate(string.Empty, (current, error) => current + error); throw new Exception(errorMessage); } if (binarnyDl != null) { compiler.ForceDeleteDataListByID(binarnyDl.UID); } } catch (Exception) { errors.AddError("Invalid variable list. Please insure that your variable list has valid entries"); } } else { RecsetCollection.Clear(); AddRecordSet(); ScalarCollection.Clear(); } BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>(); DataListHeaderItemModel varNode = DataListItemModelFactory.CreateDataListHeaderItem("Variable"); if (ScalarCollection.Count == 0) { var dataListItemModel = DataListItemModelFactory.CreateDataListModel(string.Empty); ScalarCollection.Add(dataListItemModel); } varNode.Children = ScalarCollection; BaseCollection.Add(varNode); //AddRecordsetNamesIfMissing(); DataListHeaderItemModel recordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordset"); if (RecsetCollection.Count == 0) { AddRecordSet(); } recordsetsNode.Children = RecsetCollection; BaseCollection.Add(recordsetsNode); }
public void AddRowToRecordsets() { var blankList = _vm.RecsetCollection.Where(c => c.IsBlank && c.Children.Count == 1 && c.Children[0].IsBlank).ToList(); if (blankList.Count == 0) { AddRecordSet(); } foreach (var recset in _vm.RecsetCollection) { var blankChildList = recset.Children.Where(c => c.IsBlank).ToList(); if (blankChildList.Count != 0) { continue; } var newChild = DataListItemModelFactory.CreateRecordSetFieldItemModel(string.Empty); if (newChild != null) { newChild.Parent = recset; recset.Children.Add(newChild); newChild.OnDeleted += (item) => _vm.RemoveDataListItem(item); } } }
public void AddScalars(XmlNode xmlNode) { if (xmlNode.Attributes != null) { IScalarItemModel scalar = DataListItemModelFactory.CreateScalarItemModel(xmlNode.Name, Common.ParseDescription(xmlNode.Attributes[Common.Description]), Common.ParseColumnIODirection(xmlNode.Attributes[GlobalConstants.DataListIoColDirection])); if (scalar != null) { scalar.IsEditable = Common.ParseIsEditable(xmlNode.Attributes[Common.IsEditable]); if (string.IsNullOrEmpty(_vm.SearchText)) { _vm.ScalarCollection.Add(scalar); } else if (scalar.DisplayName.ToUpper().StartsWith(_vm.SearchText.ToUpper())) { _vm.ScalarCollection.Add(scalar); } } } else { IScalarItemModel scalar = DataListItemModelFactory.CreateScalarItemModel(xmlNode.Name, Common.ParseDescription(null), Common.ParseColumnIODirection(null)); if (scalar != null) { scalar.IsEditable = Common.ParseIsEditable(null); if (string.IsNullOrEmpty(_vm.SearchText)) { _vm.ScalarCollection.Add(scalar); } else if (scalar.DisplayName.ToUpper().StartsWith(_vm.SearchText.ToUpper())) { _vm.ScalarCollection.Add(scalar); } } } }
public void AddMissingScalarParts(IDataListVerifyPart part) { if (_vm.ScalarCollection.FirstOrDefault(c => c.DisplayName == part.Field) == null) { var scalar = DataListItemModelFactory.CreateScalarItemModel(part.Field, part.Description); UpdateScalar(scalar); } }
/// <summary> /// Adds a record set. /// </summary> private void AddRecordSet() { IDataListItemModel recset = DataListItemModelFactory.CreateDataListModel(string.Empty); IDataListItemModel childItem = DataListItemModelFactory.CreateDataListModel(string.Empty); recset.IsExpanded = false; childItem.Parent = recset; recset.Children.Add(childItem); RecsetCollection.Add(recset); }
public void AddMissingTempRecordSet(IDataListVerifyPart part, IRecordSetItemModel tmpRecset) { var child = DataListItemModelFactory.CreateRecordSetFieldItemModel(part.Field, part.Description, tmpRecset); if (child != null) { child.DisplayName = part.Recordset + "()." + part.Field; tmpRecset.Children.Add(child); } }
public void CreateDataListModelWithParentAndDisplayNameShouldCorrectlySetName() { //-------------------------Setup--------------------------------------- IDataListItemModel parentItem = DataListItemModelFactory.CreateDataListModel("testRec"); //-------------------------Execute----------------------------------- IDataListItemModel childItem = DataListItemModelFactory.CreateDataListModel("field1", "this is a field", parentItem); //-------------------------Assert------------------------------------- Assert.AreEqual("field1", childItem.Name); Assert.AreEqual("testRec", childItem.Parent.Name); }
private void AddRowToScalars() { IList <IDataListItemModel> blankList = ScalarCollection.Where(c => c.IsBlank).ToList(); if (blankList.Count == 0) { IDataListItemModel scalar = DataListItemModelFactory.CreateDataListModel(string.Empty); ScalarCollection.Add(scalar); Validator.Add(scalar); } }
/// <summary> /// Sorts the scalars. /// </summary> private void SortScalars() { IList <IDataListItemModel> newScalarCollection = ScalarCollection.OrderBy(c => c.DisplayName).Where(c => !c.IsBlank).ToList(); ScalarCollection.Clear(); foreach (IDataListItemModel item in newScalarCollection) { ScalarCollection.Add(item); } ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty)); }
public void AddMissingDataListItems(IList <IDataListVerifyPart> parts) { var tmpRecsetList = new List <IRecordSetItemModel>(); foreach (var part in parts) { if (part.IsJson) { _complexObjectHandler.AddComplexObject(part); } else { if (part.IsScalar) { _scalarHandler.AddMissingScalarParts(part); } else { var recsetToAddTo = RecsetCollection.FirstOrDefault(c => c.DisplayName == part.Recordset); var tmpRecset = tmpRecsetList.FirstOrDefault(c => c.DisplayName == part.Recordset); if (recsetToAddTo != null) { _recordsetHandler.AddMissingRecordSetPart(recsetToAddTo, part); } else if (tmpRecset != null) { _recordsetHandler.AddMissingTempRecordSet(part, tmpRecset); } else { var recset = DataListItemModelFactory.CreateRecordSetItemModel(part.Recordset, part.Description); tmpRecsetList.Add(recset); } } } } _recordsetHandler.AddMissingTempRecordSetList(tmpRecsetList); _scalarHandler.RemoveBlankScalars(); _recordsetHandler.RemoveBlankRecordsets(); _recordsetHandler.RemoveBlankRecordsetFields(); _complexObjectHandler.RemoveBlankComplexObjects(); if (parts.Count > 0) { AddBlankRow(null); } UpdateIntellisenseList(); WriteToResourceModel(); }
public void AddRowToScalars() { var blankList = _vm.ScalarCollection.Where(c => c.IsBlank).ToList(); if (blankList.Count != 0) { return; } var scalar = DataListItemModelFactory.CreateScalarItemModel(string.Empty); _vm.Add(scalar); }
void AddRowToScalars() { List <IDataListItemModel> blankList = ScalarCollection.Where(c => c.IsBlank).ToList(); if (blankList.Count != 0) { return; } IDataListItemModel scalar = DataListItemModelFactory.CreateDataListModel(string.Empty); ScalarCollection.Add(scalar); }
public void AddMissingRecordSetPart(IRecordSetItemModel recsetToAddTo, IDataListVerifyPart part) { if (recsetToAddTo.Children.FirstOrDefault(c => c.DisplayName == part.Field) == null) { var child = DataListItemModelFactory.CreateRecordSetFieldItemModel(part.Field, part.Description, recsetToAddTo); if (recsetToAddTo.Children.Count > 0) { recsetToAddTo.Children.Insert(recsetToAddTo.Children.Count - 1, child); } else { recsetToAddTo.Children.Add(child); } } }
/// <summary> /// Creates the list of data list item view model to bind to. /// </summary> /// <param name="_resource">The resource model.</param> /// <param name="errorString">The error string.</param> /// <returns></returns> private void CreateListsOfIDataListItemModelToBindTo(out string errorString) { ErrorResultTO errors = new ErrorResultTO(); errorString = string.Empty; if (!string.IsNullOrEmpty(_resource.DataList)) { IBinaryDataList binarnyDL = CreateBinaryDataListFromXmlData(_resource.DataList, out errors); if (!errors.HasErrors()) { ConvertBinaryDataListToListOfIDataListItemModels(binarnyDL, out errorString); } else { string errorMessage = string.Empty; foreach (string error in errors.FetchErrors()) { errorMessage += error; } throw new Exception(errorMessage); } _compiler.ForceDeleteDataListByID(binarnyDL.UID); } else { RecsetCollection = new OptomizedObservableCollection <IDataListItemModel>(); AddRecordSet(); ScalarCollection = new OptomizedObservableCollection <IDataListItemModel>(); ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty)); } BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>(); DataListHeaderItemModel VarNode = DataListItemModelFactory.CreateDataListHeaderItem("Variables"); if (ScalarCollection.Count == 0) { ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty)); } VarNode.Children = ScalarCollection; BaseCollection.Add(VarNode); DataListHeaderItemModel RecordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordsets"); if (RecsetCollection.Count == 0) { AddRecordSet(); } RecordsetsNode.Children = RecsetCollection; BaseCollection.Add(RecordsetsNode); }
public void AddMissingTempRecordSetList(IEnumerable <IRecordSetItemModel> tmpRecsetList) { foreach (var item in tmpRecsetList) { if (item.Children.Count == 0) { item.Children.Add(DataListItemModelFactory.CreateRecordSetFieldItemModel(string.Empty, string.Empty, item)); } if (_vm.RecsetCollection.Count > 0) { _vm.RecsetCollection.Insert(_vm.RecsetCollection.Count - 1, item); } else { _vm.RecsetCollection.Add(item); } } }
public void AddRecordSet() { IRecordSetItemModel recset = DataListItemModelFactory.CreateRecordSetItemModel(string.Empty); IRecordSetFieldItemModel childItem = DataListItemModelFactory.CreateRecordSetFieldItemModel(string.Empty); if (recset != null) { recset.IsComplexObject = false; recset.AllowNotes = false; recset.IsExpanded = false; if (childItem != null) { childItem.IsComplexObject = false; childItem.AllowNotes = false; childItem.Parent = recset; recset.Children.Add(childItem); } _vm.RecsetCollection.Add(recset); } }
/// <summary> /// Sorts the scalars. /// </summary> private void SortScalars(bool ascending) { IList <IDataListItemModel> newScalarCollection; if (ascending) { newScalarCollection = ScalarCollection.OrderBy(c => c.DisplayName) .Where(c => !c.IsBlank).ToList(); } else { newScalarCollection = ScalarCollection.OrderByDescending(c => c.DisplayName) .Where(c => !c.IsBlank).ToList(); } ScalarCollection.Clear(); foreach (var item in newScalarCollection) { ScalarCollection.Add(item); } ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty)); }
private void AddRowToRecordsets() { IList <IDataListItemModel> blankList = RecsetCollection.Where(c => c.IsBlank && c.Children.Count == 1 && c.Children[0].IsBlank).ToList(); if (blankList.Count == 0) { AddRecordSet(); } foreach (IDataListItemModel recset in RecsetCollection) { IList <IDataListItemModel> blankChildList = recset.Children.Where(c => c.IsBlank).ToList(); if (blankChildList.Count == 0) { IDataListItemModel newChild = DataListItemModelFactory.CreateDataListModel(string.Empty); newChild.Parent = recset; recset.Children.Add(newChild); recset.Validator.Add(newChild); } } }