/// <summary> /// Initializes the mapping document. /// </summary> /// <param name="context">The context.</param> protected override void InitializeMappingDocument(BusinessContext context) { InitializeMappingDocumentRequest request = ((InitializeMappingDocumentRequest)context.Request); MetaClass metaClass = DataContext.Current.GetMetaClass(context.GetTargetMetaClassName()); List<PrimaryKeyId> primaryKeyIds = new List<PrimaryKeyId>(); // Create Default Mapping MappingDocument retVal = new MappingDocument(); DataTable dataTable = request.Data.Tables[request.TableIndex]; MappingElement mapping = new MappingElement(dataTable.TableName, metaClass.Name); retVal.Add(mapping); MappingElementBuilder builder = new MappingElementBuilder(retVal); //Call creation mapping document by saved patterns DefaultMappingHelper.CreateMapingByPatternComparision(dataTable, metaClass, builder); // Write Response InitializeMappingDocumentResponse response = new InitializeMappingDocumentResponse(); response.MappingDocument = retVal; context.SetResponse(response); }
/// <summary> /// Create a configuration with exactly one work item that has ID, Rev and a given field. /// </summary> /// <param name="workItemType">Configuration work item type</param> /// <param name="direction">Field of the custom field of the single work item.</param> /// <param name="linkType">Type of the link of the single work item.</param> /// <param name="autoLinkType">Work item type of the work item to which to automatically link while publishing.</param> /// <param name="autoLinkSubtypeField">Field reference name of the field containing subtype of the automatically linked work item.</param> /// <param name="autoLinkSubtypeValue">Required subtype of of the work item to which to automatically link while publishing.</param> /// <param name="overwrite">Sets or gets whether the link overwrites existing links while publishing.</param> /// <returns>Configuration containing exactly one work item configuration.</returns> public static IConfiguration GetSimpleLinkConfiguration(string workItemType, Direction direction, string linkType, string autoLinkType, string autoLinkSubtypeField, string autoLinkSubtypeValue, bool overwrite) { var configuration = new Configuration(); var item = new MappingElement { RelatedTemplate = "Generic10x1Table.xml", ImageFile = "standard.png", AssignRegularExpression = workItemType, Converters = new MappingConverter[0], WorkItemType = workItemType, MappingWorkItemType = workItemType, AssignCellCol = 1, AssignCellRow = 1, Fields = new[] { new MappingField { Direction = Direction.TfsToOther, Name = "System.ID", TableRow = 2, TableCol = 1 }, new MappingField { Direction = Direction.TfsToOther, Name = "System.Rev", TableRow = 3, TableCol = 1 } }, Links = new[] { new MappingLink { LinkValueType = linkType, AutomaticLinkWorkItemSubtypeField = autoLinkSubtypeField, AutomaticLinkWorkItemSubtypeValue = autoLinkSubtypeValue, AutomaticLinkWorkItemType = autoLinkType, Direction = direction, TableCol = 1, TableRow = 4, Overwrite = overwrite } } }; configuration.GetConfigurationItems().Add(new ConfigurationItem(configuration, item, Path.Combine(Environment.CurrentDirectory, "Configuration"))); return(configuration); }
private void AddRole(BugzillaProfile result, MappingElement role) { if (role != null) { result.RolesMapping.Add(role); } }
/// <summary> /// Removes the rule by column. /// </summary> /// <param name="columnName">Name of the column.</param> public void RemoveRuleByColumn(string columnName) { if (columnName == null) { throw new ArgumentNullException("columnName"); } if (this.MappingDocument.Count == 0) { return; } MappingElement mapping = this.MappingDocument[0]; foreach (MappingRule map in mapping) { if (map.ColumnName == columnName) { mapping.Remove(map); return; } } return; }
/// <summary> /// Initializes the mapping document. /// </summary> /// <param name="context">The context.</param> protected override void InitializeMappingDocument(BusinessContext context) { InitializeMappingDocumentRequest request = ((InitializeMappingDocumentRequest)context.Request); MetaClass metaClass = DataContext.Current.GetMetaClass(context.GetTargetMetaClassName()); List <PrimaryKeyId> primaryKeyIds = new List <PrimaryKeyId>(); // Create Default Mapping MappingDocument retVal = new MappingDocument(); DataTable dataTable = request.Data.Tables[request.TableIndex]; MappingElement mapping = new MappingElement(dataTable.TableName, metaClass.Name); retVal.Add(mapping); MappingElementBuilder builder = new MappingElementBuilder(retVal); //Call creation mapping document by saved patterns DefaultMappingHelper.CreateMapingByPatternComparision(dataTable, metaClass, builder); // Write Response InitializeMappingDocumentResponse response = new InitializeMappingDocumentResponse(); response.MappingDocument = retVal; context.SetResponse(response); }
/// <summary> /// Removes the rule by meta field. /// </summary> /// <param name="metaFieldName">Name of the meta field.</param> public void RemoveRuleByMetaField(string metaFieldName) { if (metaFieldName == null) { throw new ArgumentNullException("metaFieldName"); } if (this.MappingDocument.Count == 0) { return; } MappingElement mapping = this.MappingDocument[0]; foreach (MappingRule map in mapping) { if (map.FieldName == metaFieldName) { mapping.Remove(map); return; } } return; }
/// <summary> /// Create a configuration with exactly one work item that has ID, Rev and a given field. /// </summary> /// <param name="workItemType">Configuration work item type</param> /// <param name="direction">Field of the custom field of the single work item.</param> /// <param name="fieldValueType">Value type of the custom field of the single work item.</param> /// <param name="fieldName">Field reference name of the field of the single work item.</param> /// <returns>Configuration containing exactly one work item configuration.</returns> public static IConfiguration GetSimpleFieldConfiguration(string workItemType, Direction direction, FieldValueType fieldValueType, string fieldName) { var configuration = new Configuration(); var item = new MappingElement { RelatedTemplate = "Generic10x1Table.xml", ImageFile = "standard.png", AssignRegularExpression = workItemType, Converters = new MappingConverter[0], WorkItemType = workItemType, MappingWorkItemType = workItemType, AssignCellCol = 1, AssignCellRow = 1, Fields = new[] { new MappingField { Direction = Direction.TfsToOther, Name = "System.ID", TableRow = 2, TableCol = 1 }, new MappingField { Direction = Direction.TfsToOther, Name = "System.Rev", TableRow = 3, TableCol = 1 }, new MappingField { Direction = direction, FieldValueType = fieldValueType, Name = fieldName, TableRow = 4, TableCol = 1 } }, Links = new MappingLink[0] }; configuration.GetConfigurationItems().Add(new ConfigurationItem(configuration, item, Path.Combine(Environment.CurrentDirectory, "Configuration"))); return(configuration); }
/// <summary> /// Assigns the default value rule. /// </summary> /// <param name="metaFieldName">Name of the meta field.</param> /// <param name="defaultValue">The default value.</param> /// <returns></returns> public MappingRule AssignDefaultValueRule(string metaFieldName, string defaultValue) { if (metaFieldName == null) { throw new ArgumentNullException("metaFieldName"); } if (defaultValue == null) { throw new ArgumentNullException("defaultValue"); } if (this.MappingDocument.Count == 0) { throw new ArgumentException("MappingDocument is empty, create MappingElement or call CreateDefaultMapping."); } //RemoveRuleByColumn(srcColumnName); RemoveRuleByMetaField(metaFieldName); MappingRule retVal = MappingRule.CreateDefaultValue(metaFieldName, defaultValue); MappingElement mapping = this.MappingDocument[0]; mapping.Add(retVal); return(retVal); }
/// <summary> /// Creates the new list default mapping. /// </summary> protected virtual void CreateNewListDefaultMapping() { MappingElement mapping = new MappingElement(this.SourceTableName, this.DestinationMetaClassName); this.MappingDocument.Add(mapping); if (this.ExternalData == null || this.ExternalData.Tables.Count == 0) { return; } foreach (DataColumn column in this.GetSourceColumns()) { // TODO: Exclude PrimaryKey if (column.ColumnName == "Created" || column.ColumnName == "CreatorId" || column.ColumnName == "Modified" || column.ColumnName == "ModifierId") { continue; } MetaField field = CreateNewMetaField(column); this.NewMetaFields.Add(field); AssignCopyValueRule(column.ColumnName, field.Name); } }
/// <summary> /// Creates the list default mapping. /// </summary> protected virtual void CreateListDefaultMapping() { MappingElement mapping = new MappingElement(this.SourceTableName, this.DestinationMetaClassName); this.MappingDocument.Add(mapping); if (this.ExternalData == null || this.ExternalData.Tables.Count == 0) { return; } foreach (DataColumn column in this.GetSourceColumns()) { if (column.ColumnName == "Created" || column.ColumnName == "CreatorId" || column.ColumnName == "Modified" || column.ColumnName == "ModifierId") { continue; } foreach (MetaField field in this.GetDestinationMetaFields()) { if (field.Name.StartsWith(column.ColumnName, StringComparison.OrdinalIgnoreCase) || field.FriendlyName.StartsWith(column.ColumnName, StringComparison.OrdinalIgnoreCase)) { AssignCopyValueRule(column.ColumnName, field.Name); break; } } } }
public void MappingDocSeriliazationTest() { MappingDocument mapDoc = new MappingDocument(); MappingElement mapeElColl = new MappingElement(); mapeElColl.ClassName = "Class1"; mapeElColl.TableName = "Table1"; mapeElColl.PrimaryKeyName = "Id"; MappingRule mapEl = new MappingRule(); mapEl.ColumnName = "column1"; mapEl.FieldName = "field1"; mapEl.DefaultValue = "somevalue"; mapeElColl.Add(mapEl); mapDoc.Add(mapeElColl); string xml = MappingDocument.GetXml(mapDoc); MappingDocument loadedDoc = MappingDocument.LoadFromXml(xml); string xml2 = MappingDocument.GetXml(loadedDoc); if (xml != xml2) { throw new AssertFailedException(); } }
/// <summary> /// Create a configuration with a subtype field /// </summary> /// <param name="templateName"></param> /// <param name="workItemType"></param> /// <param name="direction"></param> /// <param name="fieldValueType"></param> /// <param name="fieldName"></param> /// <param name="workItemSubtypeField"></param> /// <param name="workItemSubtypeValue"></param> /// <returns></returns> public static IConfiguration GetWorkItemSubtypeConfiguration(string templateName, string workItemType, Direction direction, FieldValueType fieldValueType, string fieldName, string workItemSubtypeField, string workItemSubtypeValue) { var configuration = new Configuration(); var item = new MappingElement { RelatedTemplate = templateName, ImageFile = "standard.png", AssignRegularExpression = workItemType, Converters = new MappingConverter[0], WorkItemType = workItemType, MappingWorkItemType = workItemType, WorkItemSubtypeField = workItemSubtypeField, WorkItemSubtypeValue = workItemSubtypeValue, AssignCellCol = 1, AssignCellRow = 1, Fields = new[] { new MappingField { Direction = Direction.TfsToOther, Name = "System.Id", TableRow = 2, TableCol = 3 }, new MappingField { Direction = Direction.TfsToOther, Name = "System.Rev", TableRow = 2, TableCol = 4 }, new MappingField { Direction = Direction.OtherToTfs, Name = "System.Title", TableRow = 2, TableCol = 1 } }, Links = new MappingLink[0] }; configuration.GetConfigurationItems().Add(new ConfigurationItem(configuration, item, Path.Combine(Environment.CurrentDirectory, "Configuration"))); return(configuration); }
public void AddMatch(IParameterSymbol parameter, MappingElement mappingSrc = null) { Matches.Add(new MatchedParameter() { Parameter = parameter, Source = mappingSrc }); if (mappingSrc?.Expression != null) { MatchedCount++; } }
/// <summary> /// Requirement work item type configuration modeled on CMMI (2015) template /// </summary> public static IConfiguration GetCMMIRequirement() { var configuration = new Configuration(); var item = new MappingElement { RelatedTemplate = "Configuration\\Requirement.xml", ImageFile = "standard.png", AssignRegularExpression = "Requirement", Converters = new MappingConverter[0], WorkItemType = "Requirement", MappingWorkItemType = "Requirement", AssignCellCol = 1, AssignCellRow = 1, Fields = new[] { new MappingField { Direction = Direction.OtherToTfs, Name = "System.Title", TableRow = 1, TableCol = 2 }, new MappingField { Direction = Direction.TfsToOther, Name = "System.Id", TableRow = 1, TableCol = 3 }, new MappingField { Direction = Direction.TfsToOther, Name = "System.Rev", TableRow = 1, TableCol = 4 }, new MappingField { Direction = Direction.OtherToTfs, Name = "Microsoft.VSTS.Scheduling.Size", TableRow = 2, TableCol = 1 }, new MappingField { Direction = Direction.OtherToTfs, Name = "Microsoft.VSTS.CMMI.RequirementType", TableRow = 2, TableCol = 2, FieldValueType = FieldValueType.DropDownList }, new MappingField { Direction = Direction.OtherToTfs, Name = "System.AssignedTo", FieldValueType = FieldValueType.DropDownList, TableRow = 2, TableCol = 3 }, new MappingField { Direction = Direction.OtherToTfs, Name = "System.State", FieldValueType = FieldValueType.DropDownList, TableRow = 2, TableCol = 4 }, new MappingField { Direction = Direction.OtherToTfs, Name = "System.Description", TableRow = 3, TableCol = 1, HandleAsDocument = true, HandleAsDocumentMode = HandleAsDocumentType.OleOnDemand, OLEMarkerField = null, OLEMarkerValue = string.Empty, ShapeOnlyWorkaroundMode = ShapeOnlyWorkaroundMode.AddSpace } } }; configuration.GetConfigurationItems().Add(new ConfigurationItem(configuration, item, Path.Combine(Environment.CurrentDirectory, "Configuration"))); return(configuration); }
public MappingElement ToNormalize() { var result = new MappingElement { Column = string.IsNullOrWhiteSpace(Name) ? Column : Name, DataType = DataType, Properties = new MappingProperties { Ordinal = string.IsNullOrWhiteSpace(Ordinal) ? Properties.Ordinal : Ordinal, ConstValue = string.IsNullOrWhiteSpace(ConstValue) ? Properties.ConstValue : ConstValue, Path = string.IsNullOrWhiteSpace(ConstValue) ? Properties.ConstValue : ConstValue, Transform = string.IsNullOrWhiteSpace(Transform) ? Properties.Transform : Transform, Field = string.IsNullOrWhiteSpace(Field) ? Properties.ConstValue : Field } }; return(result); }
/// <summary> /// Create a configuration with exactly one work item that has ID, Rev and a given field. /// </summary> /// <param name="workItemType">Configuration work item type</param> /// <param name="direction">Field of the custom field of the single work item.</param> /// <param name="fieldValueType">Value type of the custom field of the single work item.</param> /// <param name="fieldName">Field reference name of the field of the single work item.</param> /// <returns>Configuration containing exactly one work item configuration.</returns> public static IConfiguration GetSimpleFieldConfigurationWithVariable(string workItemType, Direction direction, FieldValueType fieldValueType, string fieldName) { var configuration = new Configuration(); //Add the variable to the configuartion var variable = new Variable(); variable.Name = TestVariableName; variable.Value = TestVariableText; configuration.Variables.Add(variable); var item = new MappingElement { RelatedTemplate = "Generic10x1Table.xml", ImageFile = "standard.png", AssignRegularExpression = workItemType, Converters = new MappingConverter[0], WorkItemType = workItemType, MappingWorkItemType = workItemType, AssignCellCol = 1, AssignCellRow = 1, Fields = new[] { new MappingField { Direction = Direction.TfsToOther, Name = "System.ID", TableRow = 2, TableCol = 1 }, new MappingField { Direction = Direction.TfsToOther, Name = "System.Rev", TableRow = 3, TableCol = 1 }, new MappingField { Direction = direction, FieldValueType = fieldValueType, Name = fieldName, TableRow = 4, TableCol = 1 }, new MappingField { Direction = Direction.OtherToTfs, Name = "VariableTest", VariableName = TestVariableName, TableRow = 5, TableCol = 1, FieldValueType = FieldValueType.BasedOnVariable, WordBookmark = StaticValueTextBookMarkName } }, Links = new MappingLink[0] }; configuration.GetConfigurationItems().Add(new ConfigurationItem(configuration, item, Path.Combine(Environment.CurrentDirectory, "Configuration"))); return(configuration); }
private static bool FieldDestinationIsMatch(MetaFieldCollection metaFields, MappingElement mapEl) { bool retVal = false; foreach (MappingRule mapRule in mapEl) { foreach (MetaField field in metaFields) { if (mapRule.FieldName == field.Name) { retVal = true; break; } } if (retVal == false) { break; } } return(retVal); }
private static bool DataColumnSourceIsMatch(DataColumnCollection dataColl, MappingElement mapEl) { bool retVal = false; foreach (MappingRule mapRule in mapEl) { foreach (DataColumn column in dataColl) { retVal = mapRule.ColumnName == column.ColumnName; if (retVal) { break; } } if (!retVal) { break; } } return(retVal); }
/// <summary> /// Gets the name of the mapping element by column. /// </summary> /// <param name="sourceColumnName">Name of the source column.</param> /// <returns></returns> public MappingRule GetRuleByColumn(string sourceColumnName) { if (sourceColumnName == null) { throw new ArgumentNullException("sourceColumnName"); } if (this.MappingDocument.Count == 0) { return(null); } MappingElement mapping = this.MappingDocument[0]; foreach (MappingRule map in mapping) { if (map.ColumnName == sourceColumnName) { return(map); } } return(null); }
/// <summary> /// Prepares the mapping set. /// </summary> /// <param name="mapElColl">The map el coll.</param> /// <param name="dataSet">The data set.</param> /// <param name="mappedObjectList">The mapped object list.</param> /// <returns></returns> private MappedObject PrepareMappingSet(MappingElement mapElColl, DataSet dataSet, List<MappedObject> mappedObjectList) { DataTable dataTable = null; dataTable = dataSet.Tables[mapElColl.TableName]; //Not found dataTable specified in MappingElement Table attribute if (dataTable == null) throw new ObjectNotFoundException("Not found data table described in mapping declaration"); return PrepareMappingSet(mapElColl, dataTable, mappedObjectList); }
/// <summary> /// Prepares the mapping set. /// </summary> /// <param name="mapElColl">The map el coll.</param> /// <param name="dataSet">The data set.</param> /// <returns></returns> private MappedObject PrepareMappingSet(MappingElement mapElColl, DataTable dataTable, List<MappedObject> mappedObjectList) { DataColumn dataCol = null; MetaClass metaType = DataContext.Current.GetMetaClass(mapElColl.ClassName); MappedObject retVal = new MappedObject(mapElColl.ClassName, mapElColl); //Process each row foreach (DataRow dataRow in dataTable.Rows) { MetaObjectData moData = new MetaObjectData(); //Always add primary key in MappingData if (!String.IsNullOrEmpty(mapElColl.PrimaryKeyName)) { moData.MapColumnData.Add(mapElColl.PrimaryKeyName, dataRow[mapElColl.PrimaryKeyName]); } //Prepare mapping values foreach (MappingRule mapEl in mapElColl) { object value = null; try { if (String.IsNullOrEmpty(mapEl.ColumnName)) continue; dataCol = dataTable.Columns[mapEl.ColumnName]; //try find record in mapping definition document BaseSourceValue valueGenerator = BaseSourceValue.CreateValueSourceInstance(mapEl); value = valueGenerator.GetValue(dataRow, dataCol, mappedObjectList); value = Value2MetaPropertyType(value, metaType.Fields[mapEl.FieldName]); } catch (Exception e) { MappingError errorInfo = new MappingError(MappingErrorType.SourceValueError, e.Message); errorInfo.Row = dataRow; errorInfo.Column = dataCol; errorInfo.Table = dataTable; errorInfo.Exception = e; MappingEngineErrorEventArgs args = new MappingEngineErrorEventArgs(errorInfo); args.MappingRule = mapEl; args.MappingElement = mapElColl; RaiseErrorEvent(args); if ((args.ResolveError) && (_errResolveAtteptNum < _errResolveAtteptMax)) { _errResolveAtteptNum++; //Try resolve error return PrepareMappingSet(args.MappingElement, args.Error.Table, mappedObjectList); } else { _errorInfoList.Add(errorInfo); continue; } } if (!moData.MapMetaFieldData.ContainsKey(mapEl.FieldName)) { //Save mapped value moData.MapMetaFieldData.Add(mapEl.FieldName, value); } if (!moData.MapColumnData.ContainsKey(dataCol.ColumnName)) { //save previous row column value moData.MapColumnData.Add(dataCol.ColumnName, dataRow[dataCol]); } //reset error resolve attempt _errResolveAtteptNum = 0; } retVal.MetaObjets.Add(moData); } return retVal; }
/// <summary> /// Creates the default by mapping element. /// </summary> public static void CreateMapingByPatternComparision(DataTable srcData, MetaClass dstMetaClass, MappingElementBuilder builder) { if (srcData == null) { throw new ArgumentNullException("srcData"); } if (dstMetaClass == null) { throw new ArgumentNullException("dstMetaClass"); } if (builder == null) { throw new ArgumentNullException("builder"); } //MappingDocument enDefaultMappingDoc = MappingDocument.LoadFromXml(VCardType.LocRM.GetString("DefaultMapping", // CultureInfo.GetCultureInfo("en-US"))); MappingDocument enDefaultMappingDoc = MappingDocument.LoadFromXml(GetWebResourceString("{IbnFramework.OutlookMappingPattern:Outlook2007}", CultureInfo.GetCultureInfo("en-US"))); //MappingDocument ruDefaultMappingDoc = MappingDocument.LoadFromXml(VCardType.LocRM.GetString("DefaultMapping", // CultureInfo.GetCultureInfo("ru-RU"))); MappingDocument ruDefaultMappingDoc = MappingDocument.LoadFromXml(GetWebResourceString("{IbnFramework.OutlookMappingPattern:Outlook2007}", CultureInfo.GetCultureInfo("ru-RU"))); MappingElement srcEl = null; MappingElement dstEl = null; //Recognize source lang and type DataColumnCollection dataColl = srcData.Columns; //Recognize language pattern if (enDefaultMappingDoc != null && enDefaultMappingDoc.Count != 0) { if (DataColumnSourceIsMatch(dataColl, enDefaultMappingDoc[0])) { srcEl = enDefaultMappingDoc[0]; if (FieldDestinationIsMatch(dstMetaClass.Fields, enDefaultMappingDoc[0])) { dstEl = enDefaultMappingDoc[0]; } } } if (ruDefaultMappingDoc != null && ruDefaultMappingDoc.Count != 0) { if (DataColumnSourceIsMatch(dataColl, ruDefaultMappingDoc[0])) { srcEl = ruDefaultMappingDoc[0]; if (FieldDestinationIsMatch(dstMetaClass.Fields, ruDefaultMappingDoc[0])) { dstEl = ruDefaultMappingDoc[0]; } } } //Pattern found, build mapping by pattern if (srcEl != null && dstEl != null) { for (int i = 0; i < srcEl.Count; i++) { builder.AssignCopyValueRule(srcEl[i].ColumnName, dstEl[i].FieldName); } } else { //Pattern not found, build mapping by field friendly names comparison foreach (DataColumn dataCol in srcData.Columns) { CreateMapingByFriendlyNameComparison(dataCol, dstMetaClass, builder); } } }
private Uri CreateRemoteUri(MappingElement mapping, IDictionary<string, string> tokens) { Uri remoteUri; string uri = ReplaceTokens(mapping.TargetURI, tokens); remoteUri = new Uri(uri); return remoteUri; }
/// <summary> /// Creates the new list default mapping. /// </summary> protected virtual void CreateNewListDefaultMapping() { MappingElement mapping = new MappingElement(this.SourceTableName, this.DestinationMetaClassName); this.MappingDocument.Add(mapping); if (this.ExternalData == null || this.ExternalData.Tables.Count == 0) return; foreach (DataColumn column in this.GetSourceColumns()) { // TODO: Exclude PrimaryKey if (column.ColumnName == "Created" || column.ColumnName == "CreatorId" || column.ColumnName == "Modified" || column.ColumnName == "ModifierId") continue; MetaField field = CreateNewMetaField(column); this.NewMetaFields.Add(field); AssignCopyValueRule(column.ColumnName, field.Name); } }
/// <summary> /// Creates the list default mapping. /// </summary> protected virtual void CreateListDefaultMapping() { MappingElement mapping = new MappingElement(this.SourceTableName, this.DestinationMetaClassName); this.MappingDocument.Add(mapping); if (this.ExternalData == null || this.ExternalData.Tables.Count == 0) return; foreach (DataColumn column in this.GetSourceColumns()) { if (column.ColumnName == "Created" || column.ColumnName == "CreatorId" || column.ColumnName == "Modified" || column.ColumnName == "ModifierId") continue; foreach (MetaField field in this.GetDestinationMetaFields()) { if (field.Name.StartsWith(column.ColumnName, StringComparison.OrdinalIgnoreCase) || field.FriendlyName.StartsWith(column.ColumnName, StringComparison.OrdinalIgnoreCase)) { AssignCopyValueRule(column.ColumnName, field.Name); break; } } } }
private static bool FieldDestinationIsMatch(MetaFieldCollection metaFields, MappingElement mapEl) { bool retVal = false; foreach (MappingRule mapRule in mapEl) { foreach (MetaField field in metaFields) { if (mapRule.FieldName == field.Name) { retVal = true; break; } } if (retVal == false) break; } return retVal; }
private static bool DataColumnSourceIsMatch(DataColumnCollection dataColl, MappingElement mapEl) { bool retVal = false; foreach (MappingRule mapRule in mapEl) { foreach (DataColumn column in dataColl) { retVal = mapRule.ColumnName == column.ColumnName; if (retVal) { break; } } if (!retVal) break; } return retVal; }
public MappedObject(String className, MappingElement mapElColl) { _className = className; _mapElColl = mapElColl; _metaObjects = new List<MetaObjectData>(); }
public bool IsEquals(MappingElement mapping) { return(Key == mapping.Key && Value.Equals(mapping.Value)); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationItem"/> class. /// </summary> /// <param name="configuration">Configuration, use to get access the the absolute path.</param> /// <param name="mapping">Mapping used to retrieve values.</param> /// <param name="templateSubFolder">Folder in which to search for referenced files like work item templates and icons</param> public ConfigurationItem(IConfiguration configuration, MappingElement mapping, string templateSubFolder) { SyncServiceTrace.I(Properties.Resources.LogService_LoadWorkItem, mapping.WorkItemType); // Set the simple properties WorkItemType = mapping.WorkItemType; WorkItemSubtypeField = mapping.WorkItemSubtypeField; WorkItemSubtypeValue = mapping.WorkItemSubtypeValue; WorkItemTypeMapping = mapping.MappingWorkItemType; ReqTableIdentifierExpression = mapping.AssignRegularExpression; ReqTableCellRow = mapping.AssignCellRow; ReqTableCellCol = mapping.AssignCellCol; RelatedTemplate = mapping.RelatedTemplate; _configuration = configuration; RelatedTemplateFile = Path.Combine(templateSubFolder, RelatedTemplate); HideElementInWord = mapping.HideElementInWord; PreOperations = null; PostOperations = null; _imageFilename = Path.Combine(templateSubFolder, mapping.ImageFile); FieldConfigurations = new List <IConfigurationFieldItem>(); if (mapping.PreOperations != null && mapping.PreOperations.Count > 0) { PreOperations = new List <IConfigurationTestOperation>(); foreach (var operation in mapping.PreOperations) { PreOperations.Add(new ConfigurationTestOperation(operation)); } } if (mapping.PostOperations != null && mapping.PostOperations.Count > 0) { PostOperations = new List <IConfigurationTestOperation>(); foreach (var operation in mapping.PostOperations) { PostOperations.Add(new ConfigurationTestOperation(operation)); } } // Insert a field for the invisible stack rank if (_configuration.UseStackRank) { var stackRankConfig = FieldConfigurations.FirstOrDefault(x => x.ReferenceFieldName.Equals("Microsoft.VSTS.Common.StackRank", StringComparison.OrdinalIgnoreCase)); if (stackRankConfig != null) { SyncServiceTrace.W("Mapping the stack rank field is not supported in combination with UseStackRank=true"); FieldConfigurations.Remove(stackRankConfig); } FieldConfigurations.Add( new ConfigurationFieldItem("Microsoft.VSTS.Common.StackRank", null, FieldValueType.PlainText, Direction.OtherToTfs, 0, 0, null, false, HandleAsDocumentType.All, null, string.Empty, null, ShapeOnlyWorkaroundMode.AddSpace, false, null, null, String.Empty)); } // Read the configured state transitions if some are defined if (mapping.StateTransitions != null) { _stateTransitionField = mapping.StateTransitions.FieldName; _stateTransitions = new Dictionary <string, string>(); foreach (var transition in mapping.StateTransitions.Items) { _stateTransitions.Add(transition.From, transition.To); } } foreach (MappingField field in mapping.Fields) { // This fixes some items having their ids configured as html. if (field.Name.Equals(FieldReferenceNames.SystemId)) { field.FieldValueType = FieldValueType.PlainText; } ConfigurationFieldItemDefaultValue cfidv = null; if (field.DefaultValue != null) { cfidv = new ConfigurationFieldItemDefaultValue(field.DefaultValue.ShowName, field.DefaultValue.DefaultValue); } FieldConfigurations.Add(new ConfigurationFieldItem(field.Name, field.MappingName, field.FieldValueType, field.Direction, field.TableRow, field.TableCol, field.TestCaseStepDelimiter, field.HandleAsDocument, field.HandleAsDocumentMode, field.OLEMarkerField, field.OLEMarkerValue, cfidv, field.ShapeOnlyWorkaroundMode, field.TableCol != 0 && field.TableRow != 0, field.WordBookmark, field.VariableName, field.DateTimeFormat )); } // If the state transition field is not mapped, add it as unmapped field (so it gets queried anyways) var stateTransition = FieldConfigurations.FirstOrDefault(x => x.ReferenceFieldName.Equals(_stateTransitionField)); if (stateTransition == null && _stateTransitionField != null) { FieldConfigurations.Add(new ConfigurationFieldItem(_stateTransitionField, string.Empty, FieldValueType.PlainText, Direction.OtherToTfs, 0, 0, string.Empty, false, HandleAsDocumentType.OleOnDemand, null, string.Empty, null, ShapeOnlyWorkaroundMode.AddSpace, false, null, null, null)); } // Set the converters _converters = new Dictionary <string, IConverter>(); SyncServiceTrace.I(Properties.Resources.LogService_LoadWorkItem_Converters, mapping.Converters.Length, mapping.WorkItemType); foreach (MappingConverter converter in mapping.Converters) { var valueMapper = new SimpleValueMapper(converter.FieldName); foreach (MappingConverterValue value in converter.Values) { valueMapper.AddMapping(value.Text, value.MappingText); } _converters.Add(valueMapper.FieldName.ToUpperInvariant(), valueMapper); } Links = new List <IConfigurationLinkItem>(); if (mapping.Links != null) { foreach (MappingLink link in mapping.Links) { var cli = new ConfigurationLinkItem(link.LinkValueType, link.LinkedWorkItemTypes, link.Direction, link.TableRow, link.TableCol, link.Overwrite, link.LinkSeparator, link.LinkFormat, link.AutomaticLinkWorkItemType, link.AutomaticLinkWorkItemSubtypeField, link.AutomaticLinkWorkItemSubtypeValue, link.AutomaticLinkSuppressWarnings); Links.Add(cli); } } // Read the 'field to linked work item' configuration. FieldToLinkedItemConfiguration = new List <IConfigurationFieldToLinkedItem>(); if (mapping.FieldsToLinkedItems != null) { foreach (var fieldToLinkedItem in mapping.FieldsToLinkedItems) { FieldToLinkedItemConfiguration.Add(new ConfigurationFieldToLinkedItem(fieldToLinkedItem)); } } }