/// <summary> /// Verifies that source and destination SCR fields both reference the same process /// </summary> /// <param name="sourceField">The source field</param> /// <param name="destinationField">The destination field</param> /// <returns><c>True</c> if the source field references the same process as the destination field, otherwise <c>False</c></returns> private ConnectivityState CrossRefFieldsAreCompatible(SourceField sourceField, DestinationField destinationField) { var sourceFieldRefProcess = sourceField.AdditionalInfo != null ? ((CrossReferenceFieldInfo)sourceField.AdditionalInfo).ReferencedProcessName : string.Empty; var destinationFieldRefProcess = destinationField.AdditionalInfo != null ? ((CrossReferenceFieldInfo)destinationField.AdditionalInfo).ReferencedProcessName : string.Empty; if (!string.IsNullOrWhiteSpace(sourceFieldRefProcess) && !string.IsNullOrWhiteSpace(destinationFieldRefProcess) && sourceFieldRefProcess != destinationFieldRefProcess) { return ConnectivityState.Refuse( Regex.Unescape(LanguageService.Translate("Warn_ExpressionBuilder_IncompatibleCrossRefFields"))); } return ConnectivityState.Allow(); }
/// <summary> /// The add last modified date field. /// </summary> /// <param name="process"> The process. </param> /// <param name="source"> The source. </param> /// <param name="objectName"> The object name. </param> /// <param name="sourceFieldsSetName"> The source fields set name. </param> /// <exception cref="ArgumentNullException"> </exception> protected void AddLastModifiedOnField(IProcessEdit process, SourceFieldList source, string objectName, string sourceFieldsSetName) { const string LastModifiedOnDisplayName = "Last Modified On"; if (process == null) throw new ArgumentNullException("process"); if (source == null) throw new ArgumentNullException("source"); var dataType = SourceNodeFactory.GetDataType(typeof(DateTime)); var sf = new SourceField(source) { DataType = dataType, Name = LastModifiedOnDisplayName, ConnectorOut = { DataType = dataType, Name = LastModifiedOnDisplayName }, SetName = sourceFieldsSetName, InnerName = LastModifiedOnDisplayName, SystemName = LastModifiedOnDisplayName, ObjectName = objectName }; source.Fields.Add(sf); }
/// <summary> /// Converts to source. /// </summary> /// <param name="name">The name.</param> /// <param name="fieldList">The field list.</param> /// <param name="setName">Name of the set.</param> /// <returns>SourceFieldList.</returns> public static SourceFieldList ConvertToSource(string name, IEnumerable<Expressions.FieldInfo> fieldList, string setName) { var result = new SourceFieldList {ExpressionName = name}; foreach (var field in fieldList) { var sf = new SourceField(result) { DataType = GetDataType(field.DataType), Name = field.Name, InnerName = field.InnerName, ConnectorOut = {DataType = GetDataType(field.DataType), Name = field.Name}, SetName = setName, SystemName = field.SystemName }; sf.Id = sf.ConnectorOut.Id; result.Fields.Add(sf); } return result; }
/// <summary> /// Deserializes the specified XML reader. /// </summary> /// <param name="xmlReader">The XML reader.</param> public override void Deserialize(XmlReader xmlReader) { base.Deserialize(xmlReader); do { if (xmlReader.NodeType == XmlNodeType.EndElement && !"SourceField".Equals(xmlReader.Name) || xmlReader.IsEmptyElement) { return; } if (xmlReader.NodeType == XmlNodeType.Element && "SourceField".Equals(xmlReader.Name)) { var field = new SourceField(this); field.Deserialize(xmlReader); Fields.Add(field); } } while (xmlReader.Read()); }
private static SourceField CreateFileSourceField(IProcessField field, ExpressionObjectBase owner) { var result = new SourceField(owner) { DataType = NodeDataType.File, Name = field.Name, ConnectorOut = { DataType = NodeDataType.File, Name = field.Name }, SetName = SourceFieldSetNames.Item, InnerName = field.SystemName, SystemName = field.SystemName, SubfieldsRetriever = new FileSubfieldsRetriever(SourceFieldSetNames.Item) }; return result; }
/// <summary> /// Creates the reverse cross reference source field. /// </summary> /// <param name="field">The field.</param> /// <param name="owner">The owner.</param> /// <returns>SourceField.</returns> /// <exception cref="System.InvalidOperationException">Invalid field type.</exception> private static SourceField CreateReverseCrossReferenceSourceField(IProcessField field, ExpressionObjectBase owner) { if (field.ColumnType == ColumnTypes.ReverseReference) { return new SourceField(owner) { DataType = NodeDataType.ReverseCrossReference, Name = field.Name, ConnectorOut = { DataType = NodeDataType.ReverseCrossReference, Name = field.Name }, SetName = SourceFieldSetNames.Item, InnerName = field.SystemName, SystemName = string.Format("{0}Member", field.SystemName), SubfieldsRetriever = new ReverseCrossReferenceSubfieldsRetriever(field.Id) }; } if (field.ColumnType == ColumnTypes.ReverseMultiReference) { var result = new SourceField(owner) { DataType = NodeDataType.List, Name = field.Name, ConnectorOut = { DataType = NodeDataType.List, Name = field.Name }, SetName = SourceFieldSetNames.Item, InnerName = string.Format("{0}List", field.SystemName), SystemName = string.Format("{0}List", field.SystemName), SubfieldsRetriever = new ReverseCrossReferenceSubfieldsRetriever(field.Id) }; return result; } throw new InvalidOperationException("Invalid field type."); }
/// <summary> /// Creates the generic source field. /// </summary> /// <param name="field">The field.</param> /// <param name="owner">The owner.</param> /// <returns>SourceField.</returns> private static SourceField CreateGenericSourceField(IProcessField field, ExpressionObjectBase owner) { var dataType = SourceNodeFactory.GetDataType(GetType(field.ColumnType)); var result = new SourceField(owner) { DataType = dataType, Name = field.Name, ConnectorOut = { DataType = dataType, Name = field.Name }, SetName = SourceFieldSetNames.Item, InnerName = field.SystemName, SystemName = field.SystemName }; return result; }
public void CrSubfieldsRetrieverBaseAddSystemSourceFieldsShouldCallAddIdFieldByProcessInfo() { var vm = new ExpressionDesignerWindowViewModelBase.CrSubfieldsRetrieverBase(1); var sourceFields = new SourceField(new SourceFieldList()); var fields = new FieldList(); Mock.Arrange(() => fields.IsReadOnly).Returns(false); Mock.Arrange(() => FieldList.BeginGetFieldList(1, Arg.IsAny<EventHandler<DataPortalResult<FieldList>>>())).DoInstead<int, EventHandler<DataPortalResult<FieldList>>>((pid, evt) => evt(null, new DataPortalResult<FieldList>(fields, null, null))); IEnumerable<IExpressionField> expressionFields = null; var processInfo = new PublishedProcessInfo(); Mock.Arrange(() => processInfo.ProcessId).Returns(1); vm.BeginLoadWorker(sourceFields, (f, fl) => { expressionFields = fl; }, processInfo); Assert.IsNotNull(expressionFields.First(x => x.Name == "Id")); }
/// <summary> /// Determines whether [is valid mapping] [the specified expression]. /// </summary> /// <param name="expression">The expression.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if [is valid mapping] [the specified expression]; otherwise, <c>false</c>.</returns> private bool IsValidMapping(TwoInOneOutExpression expression, SourceField sourceContext) { if (expression.Type == ExpressionNodeType.Max || expression.Type == ExpressionNodeType.Min || expression.Type == ExpressionNodeType.Average || expression.Type == ExpressionNodeType.Sum) { SourceField newSourceContext = null; if (expression.Connector1In != null && expression.Connector1In.Connection != null) newSourceContext = GetSourceContext(expression.Connector1In.Connection.Source); return expression.Connector1In != null && IsValidMapping(expression.Connector1In, sourceContext) && expression.Connector2In != null && IsValidMapping(expression.Connector2In, newSourceContext); } return expression.Connector1In != null && IsValidMapping(expression.Connector1In, sourceContext) && expression.Connector2In != null && IsValidMapping(expression.Connector2In, sourceContext); }
/// <summary> /// Determines whether [is valid mapping] [the specified expression]. /// </summary> /// <param name="expression">The expression.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if [is valid mapping] [the specified expression]; otherwise, <c>false</c>.</returns> private bool IsValidMapping(OneInOneOutExpression expression, SourceField sourceContext) { return expression.ConnectorIn != null && IsValidMapping(expression.ConnectorIn, sourceContext); }
/// <summary> /// Determines whether [is valid mapping] [the specified connector]. /// </summary> /// <param name="connector">The connector.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if [is valid mapping] [the specified connector]; otherwise, <c>false</c>.</returns> private bool IsValidMapping(IConnectorIn connector, SourceField sourceContext) { return connector.Connection != null && connector.Connection.Source != null && IsValidMapping(connector.Connection.Source, sourceContext); }
/// <summary> /// Determines whether [is valid mapping] [the specified connector]. /// </summary> /// <param name="connector">The connector.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if [is valid mapping] [the specified connector]; otherwise, <c>false</c>.</returns> private bool IsValidMapping(IConnectorOut connector, SourceField sourceContext) { if (connector.Owner is ConstantExpression) return true; var oneInOneOutExpression = connector.Owner as OneInOneOutExpression; if (oneInOneOutExpression != null) return IsValidMapping(oneInOneOutExpression, sourceContext); var twoInOneOutExpression = connector.Owner as TwoInOneOutExpression; if (twoInOneOutExpression != null) return IsValidMapping(twoInOneOutExpression, sourceContext); var threeInOneOutExpression = connector.Owner as ThreeInOneOutExpression; if (threeInOneOutExpression != null) return IsValidMapping(threeInOneOutExpression, sourceContext); var fourInOneOutExpression = connector.Owner as FourInOneOutExpression; if (fourInOneOutExpression != null) return IsValidMapping(fourInOneOutExpression, sourceContext); var fiveInOneOutExpression = connector.Owner as FiveInOneOutExpression; if (fiveInOneOutExpression != null) return IsValidMapping(fiveInOneOutExpression, sourceContext); var sixInOneOutExpression = connector.Owner as SixInOneOutExpression; if (sixInOneOutExpression != null) return IsValidMapping(sixInOneOutExpression, sourceContext); var sourceFieldList = connector.Owner as SourceFieldList; if (sourceFieldList != null) return IsValidMapping(sourceFieldList, connector, sourceContext); var functionExpression = connector.Owner as FunctionExpression; if (functionExpression != null) return true; return false; }
public void GetSourceExpressionNodeMethodTest() { var obj = new ExpressionNodeFactory(); var privateAccessor = new PrivateAccessor(obj); var sourceField = new SourceField(new Connection(), true) { DataType = NodeDataType.GageRR, Name = "FieldName", SetName = SourceFieldSetNames.Item, InnerName = "FieldName", SystemName = "FieldSystemName", ObjectName = "FieldName", ParentField = null }; var result = privateAccessor.CallMethod("GetSourceExpressionNode", sourceField, null) as SourceFieldNode; Assert.IsNotNull(result); Assert.AreEqual(NodeDataType.GageRR, result.DataType); Assert.AreEqual("FieldName", result.InitialFieldName); Assert.AreEqual("FieldSystemName", result.FieldName); Assert.IsNull(result.Value); Assert.AreEqual("FieldName", result.PropertyPath); Assert.AreEqual(SourceFieldSetNames.Item, result.SetName); Assert.IsNull(result.ParentNode); Assert.AreEqual("FieldName", result.ObjectName); Assert.IsTrue(result.IsGroupingField); }
/// <summary> /// De-serializes the specified XML reader. /// </summary> /// <param name="xmlReader">The XML reader.</param> public void Deserialize(XmlReader xmlReader) { Id = Guid.Parse(xmlReader.GetAttribute("id")); Name = xmlReader.GetAttribute("name"); DataType = (NodeDataType)Enum.Parse(typeof(NodeDataType), xmlReader.GetAttribute("dataType"), false); InnerName = xmlReader.GetAttribute("innerName"); SetName = xmlReader.GetAttribute("setName"); SystemName = xmlReader.GetAttribute("systemName"); ObjectName = xmlReader.GetAttribute("objectName"); UniqueName = xmlReader.GetAttribute("uniqueName"); //for backward compatibility with previously saved xml var param = xmlReader.GetAttribute("keepSubfieldsAlive"); KeepSubfieldsAlive = param != null && Convert.ToBoolean(param); param = xmlReader.GetAttribute("hideConnector"); HideConnector = param != null && Convert.ToBoolean(param); param = xmlReader.GetAttribute("isGroupingField"); IsGroupingField = param != null && Convert.ToBoolean(param); param = xmlReader.GetAttribute("isGroupCollapsed"); IsGroupCollapsed = param != null && Convert.ToBoolean(param); if (!"ConnectorOut".Equals(xmlReader.Name)) { xmlReader.ReadToFollowing("ConnectorOut"); } ConnectorOut.Deserialize(xmlReader); while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element && "AdditionalInfo".Equals(xmlReader.Name)) { try { if (AdditionalInfo == null) AdditionalInfo = Activator.CreateInstance(Type.GetType(xmlReader.GetAttribute("Type"))) as IExpressionFieldInfo; AdditionalInfo.Deserialize(xmlReader); } catch (Exception) { } } else if (xmlReader.NodeType == XmlNodeType.EndElement && "SourceField".Equals(xmlReader.Name) || xmlReader.IsEmptyElement) { return; } else if (xmlReader.NodeType == XmlNodeType.Element && "Subfields".Equals(xmlReader.Name)) { do { if (xmlReader.NodeType == XmlNodeType.EndElement && !"Subfields".Equals(xmlReader.Name)) { return; } if (xmlReader.NodeType == XmlNodeType.Element && "SourceField".Equals(xmlReader.Name)) { var field = new SourceField(ConnectorOut.Owner); field.Deserialize(xmlReader); field.ParentField = this; _subfields.Add(field); } } while (xmlReader.Read()); } } }
public void CrSubfieldsRetrieverBaseBeginLoadWorkerShouldCallCanUseFieldType() { // Arrange. var vm = new ExpressionDesignerWindowViewModelBase.CrSubfieldsRetrieverBase(1); var sourceFields = new SourceField(new SourceFieldList()) { SystemName = "Ref" }; var fields = new FieldList(); Mock.Arrange(() => fields.IsReadOnly).Returns(false); fields.Add(new FieldInfo(1, "F", "F", new FieldTypeInfo("String", "String", false), string.Empty, ColumnTypes.String, Guid.Empty, false, false, false)); Mock.Arrange(() => FieldList.BeginGetFieldList(1, Arg.IsAny<EventHandler<DataPortalResult<FieldList>>>())).DoInstead<int, EventHandler<DataPortalResult<FieldList>>>((pid, evt) => evt(null, new DataPortalResult<FieldList>(fields, null, null))); IEnumerable<IExpressionField> expressionFields = null; Mock.Arrange(() => ExpressionDesignerWindowViewModelBase.CrSubfieldsRetrieverBase.CanUseFieldType(Arg.IsAny<FieldTypeInfo>())).Returns(true); var processInfo = new PublishedProcessInfo(); Mock.Arrange(() => processInfo.ProcessId).Returns(1); vm.BeginLoadWorker(sourceFields, (f, fl) => { expressionFields = fl; }, processInfo); Assert.AreEqual(2, expressionFields.Count()); Mock.Arrange(() => ExpressionDesignerWindowViewModelBase.CrSubfieldsRetrieverBase.CanUseFieldType(Arg.IsAny<FieldTypeInfo>())).Returns(false); var processInfo2 = new PublishedProcessInfo(); Mock.Arrange(() => processInfo2.ProcessId).Returns(1); vm.BeginLoadWorker(sourceFields, (f, fl) => { expressionFields = fl; }, processInfo2); Assert.AreEqual(1, expressionFields.Count()); }
/// <summary> /// Determines whether [is valid mapping] [the specified expression]. /// </summary> /// <param name="expression">The expression.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if [is valid mapping] [the specified expression]; otherwise, <c>false</c>.</returns> private bool IsValidMapping(ThreeInOneOutExpression expression, SourceField sourceContext) { if (expression.Type == ExpressionNodeType.FindFirst) { SourceField newSourceContext = null; if (expression.Connector1In != null && expression.Connector1In.Connection != null) newSourceContext = GetSourceContext(expression.Connector1In.Connection.Source); return expression.Connector1In != null && IsValidMapping(expression.Connector1In, sourceContext) && expression.Connector2In != null && IsValidMapping(expression.Connector2In, newSourceContext) && expression.Connector3In != null && IsValidMapping(expression.Connector3In, newSourceContext); } return expression.Connector1In != null && IsValidMapping(expression.Connector1In, sourceContext) && expression.Connector2In != null && IsValidMapping(expression.Connector2In, sourceContext) && expression.Connector3In != null && IsValidMapping(expression.Connector3In, sourceContext); }
public void CrSubfieldsRetrieverBaseBeginLoadWorkerShouldCallAddSystemSourceFields() { var vm = new ExpressionDesignerWindowViewModelBase.CrSubfieldsRetrieverBase(1); var sourceFields = new SourceField(new SourceFieldList()); var fields = new FieldList(); Mock.Arrange(() => fields.IsReadOnly).Returns(false); Mock.Arrange(() => FieldList.BeginGetFieldList(1, Arg.IsAny<EventHandler<DataPortalResult<FieldList>>>())).DoInstead<int, EventHandler<DataPortalResult<FieldList>>>((pid, evt) => evt(null, new DataPortalResult<FieldList>(fields, null, null))); IEnumerable<IExpressionField> expressionFields = null; var processInfo = new PublishedProcessInfo(); Mock.Arrange(() => processInfo.ProcessId).Returns(1); var isCalled = false; Mock.NonPublic.Arrange(vm, "AddSystemSourceFields", ArgExpr.IsAny<PublishedProcessInfo>(), ArgExpr.IsAny<List<IExpressionField>>()).DoInstead(() => { isCalled = true; }); vm.BeginLoadWorker(sourceFields, (f, fl) => { expressionFields = fl; }, processInfo); Assert.IsTrue(isCalled); }
/// <summary> /// Determines whether [is valid mapping] [the specified expression]. /// </summary> /// <param name="expression">The expression.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if [is valid mapping] [the specified expression]; otherwise, <c>false</c>.</returns> private bool IsValidMapping(SixInOneOutExpression expression, SourceField sourceContext) { return expression.Connector1In != null && IsValidMapping(expression.Connector1In, sourceContext) && expression.Connector2In != null && IsValidMapping(expression.Connector2In, sourceContext) && expression.Connector3In != null && IsValidMapping(expression.Connector3In, sourceContext) && expression.Connector4In != null && IsValidMapping(expression.Connector4In, sourceContext) && expression.Connector5In != null && IsValidMapping(expression.Connector5In, sourceContext) && expression.Connector6In != null && IsValidMapping(expression.Connector6In, sourceContext); }
public void CrSubfieldsRetrieverBaseAddSystemSourceFieldsShouldCallAddVersionFieldsByPublishedProcessInfo() { var vm = new ExpressionDesignerWindowViewModelBase.CrSubfieldsRetrieverBase(1); var sourceFields = new SourceField(new SourceFieldList()); var fields = new FieldList(); Mock.Arrange(() => fields.IsReadOnly).Returns(false); Mock.Arrange(() => FieldList.BeginGetFieldList(1, Arg.IsAny<EventHandler<DataPortalResult<FieldList>>>())).DoInstead<int, EventHandler<DataPortalResult<FieldList>>>((pid, evt) => evt(null, new DataPortalResult<FieldList>(fields, null, null))); IEnumerable<IExpressionField> expressionFields = null; var processInfo = new PublishedProcessInfo(); Mock.Arrange(() => processInfo.ProcessId).Returns(1); Mock.Arrange(() => processInfo.ProcessOption).Returns(ProcessOption.VersionEnabled); vm.BeginLoadWorker(sourceFields, (f, fl) => { expressionFields = fl; }, processInfo); Assert.IsTrue(expressionFields.Any(x => x.Name == "Version Date")); Assert.IsTrue(expressionFields.Any(x => x.Name == Constants.VersionNumberName)); Assert.IsTrue(expressionFields.Any(x => x.Name == "Version Master Id")); expressionFields = null; var processInfo2 = new PublishedProcessInfo(); Mock.Arrange(() => processInfo2.ProcessId).Returns(1); Mock.Arrange(() => processInfo2.ProcessOption).Returns(ProcessOption.None); vm.BeginLoadWorker(sourceFields, (f, fl) => { expressionFields = fl; }, processInfo2); Assert.IsFalse(expressionFields.Any(x => x.Name == "Version Date")); Assert.IsFalse(expressionFields.Any(x => x.Name == Constants.VersionNumberName)); Assert.IsFalse(expressionFields.Any(x => x.Name == "Version Master Id")); }
/// <summary> /// Determines whether [is valid mapping] [the specified field list]. /// </summary> /// <param name="fieldList">The field list.</param> /// <param name="connector">The connector.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if [is valid mapping] [the specified field list]; otherwise, <c>false</c>.</returns> private bool IsValidMapping(SourceFieldList fieldList, IConnectorOut connector, SourceField sourceContext) { var sourceField = FindSourceField(fieldList.Fields, connector); if (sourceField == null) return false; return CanAccess(sourceField, sourceContext); }
/// <summary> /// Creates the result source field. /// </summary> /// <param name="field">The field.</param> /// <param name="owner">The owner.</param> /// <returns>SourceField.</returns> private static SourceField CreateResultSourceField(IProcessField field, ExpressionObjectBase owner) { var result = new SourceField(owner) { DataType = NodeDataType.Result, Name = field.Name, ConnectorOut = { DataType = NodeDataType.Result, Name = field.Name }, SetName = SourceFieldSetNames.Item, InnerName = field.SystemName, SystemName = field.SystemName }; return result; }
/// <summary> /// Determines whether this instance can access the specified field. /// </summary> /// <param name="field">The field.</param> /// <param name="sourceContext">The source context.</param> /// <returns><c>true</c> if this instance can access the specified field; otherwise, <c>false</c>.</returns> private bool CanAccess(SourceField field, SourceField sourceContext) { var ancestor = FindCommonAncestor((SourceField)field.ParentField, sourceContext); var current = (SourceField)field.ParentField; while (current != ancestor && current != null) { if (current.DataType != NodeDataType.Entity && current.DataType != NodeDataType.CrossReference && current.DataType != NodeDataType.ReverseCrossReference) return false; current = (SourceField)current.ParentField; } return true; }
private static SourceField CreateSampleSourceField(IProcessField field, ExpressionObjectBase owner) { var result = new SourceField(owner) { DataType = NodeDataType.List, Name = field.Name, ConnectorOut = { DataType = NodeDataType.List, Name = field.Name }, SetName = SourceFieldSetNames.Item, InnerName = string.Format("{0}List", field.SystemName), SystemName = string.Format("{0}List", field.SystemName), SubfieldsRetriever = new SampleSubfieldsRetriever(SourceFieldSetNames.Item) }; return result; }
/// <summary> /// Finds the common ancestor. /// </summary> /// <param name="field1">The field1.</param> /// <param name="field2">The field2.</param> /// <returns>SourceField.</returns> private SourceField FindCommonAncestor(SourceField field1, SourceField field2) { var ancestors = GetFieldAncestors(field1); var current = field2; while (current != null) { if (ancestors.Contains(current)) return current; current = (SourceField)current.ParentField; } return null; }
/// <summary> /// Collects all fields. /// </summary> /// <param name="result">The result.</param> /// <param name="parentField">The parent field.</param> private void CollectAllFields(IList<SourceField> result, SourceField parentField) { if (parentField == null) { foreach (var field in Fields) { result.Add(field); CollectAllFields(result, field); } } else { foreach (SourceField field in parentField.Subfields) { result.Add(field); CollectAllFields(result, field); } } }
/// <summary> /// Gets the field ancestors. /// </summary> /// <param name="field">The field.</param> /// <returns>ICollection{SourceField}.</returns> private ICollection<SourceField> GetFieldAncestors(SourceField field) { var result = new HashSet<SourceField>(); var current = field; while (current != null) { result.Add(current); current = (SourceField)current.ParentField; } return result; }
/// <summary> /// Converts to source. /// </summary> /// <param name="name">The name.</param> /// <param name="fieldList">The field list.</param> /// <param name="setName">Name of the set.</param> /// <returns>SourceFieldList.</returns> public static SourceFieldList ConvertToSource(string name, IDictionary<string, object> fieldList, string setName) { var result = new SourceFieldList {ExpressionName = name}; foreach (var field in fieldList) { var sf = new SourceField(result) { DataType = GetDataType(field.Value.GetType()), Name = field.Key, ConnectorOut = {DataType = GetDataType(field.Value.GetType()), Name = field.Key}, SetName = setName, }; sf.Id = sf.ConnectorOut.Id; result.Fields.Add(sf); } return result; }
public void CrSubfieldsRetrieverBaseBeginLoadWorkerShouldCreateStringForMultiCrossRef() { // Arrange. var vm = new ExpressionDesignerWindowViewModelBase.CrSubfieldsRetrieverBase(1); var sourceFields = new SourceField(new SourceFieldList()) { SystemName = "Ref" }; var fields = new FieldList(); Mock.Arrange(() => fields.IsReadOnly).Returns(false); fields.Add(new FieldInfo(1, "Ref", "Ref", new FieldTypeInfo("MultiReference", "MultiReference", false), string.Empty, ColumnTypes.MultiReference, Guid.Empty, false, false, false)); Mock.Arrange(() => FieldList.BeginGetFieldList(1, Arg.IsAny<EventHandler<DataPortalResult<FieldList>>>())).DoInstead<int, EventHandler<DataPortalResult<FieldList>>>((pid, evt) => evt(null, new DataPortalResult<FieldList>(fields, null, null))); IEnumerable<IExpressionField> expressionFields = null; var processInfo = new PublishedProcessInfo(); Mock.Arrange(() => processInfo.ProcessId).Returns(1); vm.BeginLoadWorker(sourceFields, (f, fl) => { expressionFields = fl; }, processInfo); Assert.AreEqual(2, expressionFields.Count()); var firstField = expressionFields.First(x => x.Name == "Ref") as SourceField; Assert.AreEqual(NodeDataType.String, firstField.DataType); Assert.AreEqual(NodeDataType.String, firstField.Connector.DataType); Assert.AreEqual("Ref.Ref", firstField.SystemName); Assert.IsNull(firstField.SubfieldsRetriever); }
/// <summary> /// Converts to source. /// </summary> /// <param name="name">The name.</param> /// <param name="sourceType">Type of the source.</param> /// <param name="propertyFilter">The property filter.</param> /// <param name="setName">Name of the set.</param> /// <returns>SourceFieldList.</returns> public static SourceFieldList ConvertToSource(string name, Type sourceType, Func<PropertyInfo, bool> propertyFilter, string setName) { var result = new SourceFieldList {ExpressionName = name}; var properties = sourceType.GetProperties(); foreach (var property in properties.Where(propertyFilter)) { var sf = new SourceField(result) { Name = property.Name, ConnectorOut = {DataType = GetDataType(property.PropertyType), Name = property.Name}, SetName = setName, InnerName = property.Name }; sf.Id = sf.ConnectorOut.Id; result.Fields.Add(sf); } return result; }
/// <summary> /// Adds version-related system fields. /// </summary> /// <param name="process">The process.</param> /// <param name="source">The source field list.</param> /// <param name="objectName">The source object name.</param> /// <param name="sourceFieldsSetName">The source fields set name.</param> /// <exception cref="System.ArgumentNullException"> /// process /// or /// source /// </exception> /// <exception cref="ArgumentNullException">The <paramref name="process" /> parameter is null.</exception> /// <exception cref="ArgumentNullException">The <paramref name="source" /> parameter is null.</exception> protected void AddVersionFields(IProcessEdit process, SourceFieldList source, string objectName, string sourceFieldsSetName) { if (process == null) throw new ArgumentNullException("process"); if (source == null) throw new ArgumentNullException("source"); if (process.ProcessOptionChoose != ProcessOption.VersionEnabled) return; var dataType = SourceNodeFactory.GetDataType(typeof(string)); var sf = new SourceField(source) { DataType = dataType, Name = Constants.VersionNumberName, ConnectorOut = { DataType = dataType, Name = Constants.VersionNumberName }, ObjectName = objectName, SetName = sourceFieldsSetName, InnerName = Constants.VersionNumber, SystemName = Constants.VersionNumber }; source.Fields.Add(sf); dataType = SourceNodeFactory.GetDataType(typeof(DateTime)); sf = new SourceField(source) { DataType = dataType, Name = VersionDateDisplayName, ConnectorOut = { DataType = dataType, Name = VersionDateDisplayName }, ObjectName = objectName, SetName = sourceFieldsSetName, InnerName = Constants.VersionDate, SystemName = Constants.VersionDate }; source.Fields.Add(sf); dataType = SourceNodeFactory.GetDataType(typeof(int)); sf = new SourceField(source) { DataType = dataType, Name = VersionMasterIdDisplayName, ConnectorOut = { DataType = dataType, Name = VersionMasterIdDisplayName }, ObjectName = objectName, SetName = sourceFieldsSetName, InnerName = Constants.VersionMasterId, SystemName = Constants.VersionMasterId }; source.Fields.Add(sf); }