public void SetExcludePriorityFieldMap(Configuration config) { FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; MappedField mField1 = new MappedField(); mField1.LeftName = FIELD_TITLE; mField1.RightName = FIELD_TITLE; mField1.MapFromSide = SourceSideTypeEnum.Left; MappedField mField2 = new MappedField(); mField2.LeftName = FIELD_DESCRIPTION; mField2.RightName = string.Empty; mField2.MapFromSide = SourceSideTypeEnum.Left; fieldMap.MappedFields.MappedField.Add(mField1); fieldMap.MappedFields.MappedField.Add(mField2); WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
public void SetMissingStateReasonFieldMap(Configuration config) { FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; MappedField mField1 = new MappedField(); mField1.LeftName = CoreFieldReferenceNames.State; mField1.RightName = CoreFieldReferenceNames.Title; mField1.MapFromSide = SourceSideTypeEnum.Left; MappedField mField2 = new MappedField(); mField2.LeftName = CoreFieldReferenceNames.Reason; mField2.RightName = CoreFieldReferenceNames.Description; mField2.MapFromSide = SourceSideTypeEnum.Left; fieldMap.MappedFields.MappedField.Add(mField1); fieldMap.MappedFields.MappedField.Add(mField2); WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
public void SetMissingStateReasonFieldMap(MigrationTestEnvironment env, Configuration config) { FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; MappedField mField1 = env.NewMappedField(CoreFieldReferenceNames.State, CoreFieldReferenceNames.Title); MappedField mField2 = env.NewMappedField(CoreFieldReferenceNames.Reason, CoreFieldReferenceNames.Description); fieldMap.MappedFields.MappedField.Add(mField1); fieldMap.MappedFields.MappedField.Add(mField2); WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
public virtual void DropField() { UndoXmlChanges(); WITSessionCustomSetting customSettings = m_session.WITCustomSetting; if (m_mappedField == null) { m_mappedField = new MappedField(); m_fieldMap.MappedFields.MappedField.Add(m_mappedField); } m_mappedField.valueMap = string.Empty; if (IsLeftSidedConflict) { m_mappedField.RightName = SourceField; m_mappedField.LeftName = string.Empty; m_mappedField.MapFromSide = SourceSideTypeEnum.Right; } else { m_mappedField.LeftName = SourceField; m_mappedField.RightName = string.Empty; m_mappedField.MapFromSide = SourceSideTypeEnum.Left; } // save config m_session.UpdateCustomSetting(customSettings); int configId = SaveConfiguration(); // set conflictRuleViewModel options ObservableDataField updatedConfigIdDataField = m_conflictRuleViewModel.ObservableDataFields.First(x => string.Equals(x.FieldName, Constants.DATAKEY_UPDATED_CONFIGURATION_ID)); updatedConfigIdDataField.FieldValue = configId.ToString(); }
private void TestEnvironment_FieldMapToEmpty(MigrationTestEnvironment env, Configuration config) { // Map field MappedField mField1 = env.NewMappedField(FIELD_PRIORITY, String.Empty); mField1.valueMap = string.Empty; // set value map name to be empty string // Map the rest of the fields using wild card MappedField defaultField = env.NewMappedField("*", "*"); FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
internal void SetNewValue() { UndoXmlChanges(); WITSessionCustomSetting customSetting = m_session.WITCustomSetting; if (m_fieldsAggregationGroup != null) { m_fieldsAggregationGroup.TargetFieldName = NewTargetField; } else if (IsLeftSidedConflict) { if (m_mappedField == null) { m_mappedField = m_fieldMap.MappedFields.MappedField.FirstOrDefault(x => string.Equals(x.RightName, SourceField)); if (m_mappedField == null) { m_mappedField = new MappedField(); m_mappedField.MapFromSide = SourceSideTypeEnum.Right; m_fieldMap.MappedFields.MappedField.Add(m_mappedField); } } m_mappedField.RightName = SourceField; m_mappedField.LeftName = NewTargetField; } else { if (m_mappedField == null) { m_mappedField = m_fieldMap.MappedFields.MappedField.FirstOrDefault(x => string.Equals(x.LeftName, SourceField)); if (m_mappedField == null) { m_mappedField = new MappedField(); m_mappedField.MapFromSide = SourceSideTypeEnum.Left; m_fieldMap.MappedFields.MappedField.Add(m_mappedField); } } m_mappedField.LeftName = SourceField; m_mappedField.RightName = NewTargetField; } // save config m_session.UpdateCustomSetting(customSetting); int configId = SaveConfiguration(); // set conflictRuleViewModel options m_conflictRuleViewModel.SelectedResolutionAction = m_conflictRuleViewModel.ResolutionActions.First(x => x.ReferenceName.Equals(new InvalidFieldConflictUseFieldMapAction().ReferenceName)); ObservableDataField mapFromDataField = m_conflictRuleViewModel.ObservableDataFields.First(x => string.Equals(x.FieldName, InvalidFieldConflictUseFieldMapAction.DATAKEY_MAP_FROM)); mapFromDataField.FieldValue = TargetField; ObservableDataField mapToDataField = m_conflictRuleViewModel.ObservableDataFields.First(x => string.Equals(x.FieldName, InvalidFieldConflictUseFieldMapAction.DATAKEY_MAP_TO)); mapToDataField.FieldValue = NewTargetField; ObservableDataField updatedConfigIdDataField = m_conflictRuleViewModel.ObservableDataFields.First(x => string.Equals(x.FieldName, Constants.DATAKEY_UPDATED_CONFIGURATION_ID)); updatedConfigIdDataField.FieldValue = configId.ToString(); }
void TestEnvironment_InsertTwoFieldMapToSameTargetInMappedField(MigrationTestEnvironment env, Configuration config) { // Map field MappedField mField1 = env.NewMappedField(FIELD_PRIORITY, FIELD_PRIORITY); mField1.valueMap = string.Empty; // set value map name to be empty string // Map to SAME field again MappedField defaultField = env.NewMappedField(FIELD_AREA_PATH, FIELD_PRIORITY); FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
public WorkItemTypeViewModel(WorkItemTypeMappingElement workItemType, WITSessionCustomSetting customSettings) { m_workItemType = workItemType; FieldMap fieldMap = customSettings.FieldMaps.FieldMap.FirstOrDefault(x => string.Equals(x.name, m_workItemType.fieldMap)); if (fieldMap != null) { foreach (FieldsAggregationGroup aggregatedField in fieldMap.AggregatedFields.FieldsAggregationGroup) { FieldMapViewModelBase fieldMapViewModel = FieldMapViewModelFactory.CreateInstance(aggregatedField, customSettings); if (fieldMapViewModel != null) { m_fieldMaps.Add(fieldMapViewModel); } } foreach (MappedField mappedField in fieldMap.MappedFields.MappedField) { FieldMapViewModelBase fieldMapViewModel = FieldMapViewModelFactory.CreateInstance(mappedField, customSettings); if (fieldMapViewModel != null) { m_fieldMaps.Add(fieldMapViewModel); } } } }
private void SetFieldMap_NoWildCardMap(MigrationTestEnvironment env, Configuration config) { // Map Description to an invalide field MappedField mField1 = env.NewMappedField(FIELD_DESCRIPTION, FIELD_DESCRIPTION); // The field map does not have a wild card mapping like below: // Map the rest of the fields using wild card //MappedField defaultField = env.NewMappedField("*","*"); FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; //fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
public void SetExcludePriorityFieldMap(MigrationTestEnvironment env, Configuration config) { FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; MappedField mField1 = env.NewMappedField(FIELD_TITLE, FIELD_TITLE); mField1.MapFromSide = env.GetSourceSideTypeEnum(); MappedField mField2 = env.NewMappedField(FIELD_DESCRIPTION, String.Empty); mField2.MapFromSide = env.GetSourceSideTypeEnum(); fieldMap.MappedFields.MappedField.Add(mField1); fieldMap.MappedFields.MappedField.Add(mField2); WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
private void SetFieldMap_NoWildCardMap(Configuration config) { // Map Description to an invalide field MappedField mField1 = new MappedField(); mField1.LeftName = FIELD_DESCRIPTION; mField1.RightName = FIELD_DESCRIPTION; mField1.MapFromSide = SourceSideTypeEnum.Left; // The field map does not have a wild card mapping like below: // Map the rest of the fields using wild card //MappedField defaultField = new MappedField(); //defaultField.LeftName = "*"; //defaultField.RightName = "*"; //defaultField.MapFromSide = SourceSideTypeEnum.Left; FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; //fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
public void SetAggregatedFieldMap(MigrationTestEnvironment env, Configuration config) { // Aggregated fields AggregatedFields aggregatedFields = new AggregatedFields(); FieldsAggregationGroup group = new FieldsAggregationGroup(); group.MapFromSide = env.GetSourceSideTypeEnum(); group.TargetFieldName = FIELD_DESCRIPTION; group.Format = AggregationFormat; SourceField f0 = new SourceField(); f0.Index = 0; f0.SourceFieldName = FIELD_TITLE; SourceField f1 = new SourceField(); f1.Index = 1; f1.SourceFieldName = "System.Rev"; group.SourceField.Add(f0); group.SourceField.Add(f1); aggregatedFields.FieldsAggregationGroup.Add(group); // construct FieldMap // Map all fields explictly using wildcard MappedField defaultField = env.NewMappedField("*", "*"); FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); // TODO: Create another test case for aggreated fields feature // Construct configurations with conflicting field maps //MappedField mField1 = env.NewMappedField(FIELD_TITLE,FIELD_DESCRIPTION); //MappedField mField2 = env.NewMappedField(FIELD_DESCRIPTION,FIELD_TITLE); //fieldMap.MappedFields.MappedField.Add(mField1); //fieldMap.MappedFields.MappedField.Add(mField2); fieldMap.AggregatedFields = aggregatedFields; WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
internal void DropField() { UndoXmlChanges(); WITSessionCustomSetting customSetting = m_session.WITCustomSetting; if (m_fieldsAggregationGroup != null) { m_fieldMap.AggregatedFields.FieldsAggregationGroup.Remove(m_fieldsAggregationGroup); } else if (m_mappedField == null) { m_mappedField = new MappedField(); if (IsLeftSidedConflict) { m_mappedField.RightName = SourceField; m_mappedField.LeftName = string.Empty; m_mappedField.MapFromSide = SourceSideTypeEnum.Right; } else { m_mappedField.LeftName = SourceField; m_mappedField.RightName = string.Empty; m_mappedField.MapFromSide = SourceSideTypeEnum.Left; } m_fieldMap.MappedFields.MappedField.Add(m_mappedField); } else { m_fieldMap.MappedFields.MappedField.Remove(m_mappedField); /* * if (m_fieldMap.MappedFields.MappedField.Remove(m_mappedField)) * { * ValueMap valueMap = customSetting.ValueMaps.ValueMap.FirstOrDefault(x => string.Equals(x.name, m_mappedField.valueMap)); * if (valueMap != null) * { * customSetting.ValueMaps.ValueMap.Remove(valueMap); * } * } */ } // save config m_session.UpdateCustomSetting(customSetting); int configId = SaveConfiguration(); // set conflictRuleViewModel options m_conflictRuleViewModel.SelectedResolutionAction = m_conflictRuleViewModel.ResolutionActions.First(x => x.ReferenceName.Equals(new InvalidFieldConflictDropFieldAction().ReferenceName)); ObservableDataField invalidFieldDataField = m_conflictRuleViewModel.ObservableDataFields.First(x => string.Equals(x.FieldName, InvalidFieldConflictDropFieldAction.DATAKEY_INVALID_FIELD)); invalidFieldDataField.FieldValue = TargetField; ObservableDataField updatedConfigIdDataField = m_conflictRuleViewModel.ObservableDataFields.First(x => string.Equals(x.FieldName, Constants.DATAKEY_UPDATED_CONFIGURATION_ID)); updatedConfigIdDataField.FieldValue = configId.ToString(); }
public void SetConditionalWildcardPriorityValueMap(Configuration config) { // Map P2 to P1 Value v1 = new Value(); v1.LeftValue = "2"; v1.RightValue = "1"; ValueMap vMap = new ValueMap(); vMap.name = "PriorityValueMap"; vMap.Value.Add(v1); Value v2 = new Value(); v2.LeftValue = "*"; v2.RightValue = "3"; v2.When.ConditionalSrcFieldName = "System.Description"; v2.When.ConditionalSrcFieldValue = ConditionalValueMapDescription; vMap.Value.Add(v2); // Map field MappedField mField1 = new MappedField(); mField1.LeftName = FIELD_PRIORITY; mField1.RightName = FIELD_PRIORITY; mField1.MapFromSide = SourceSideTypeEnum.Left; mField1.valueMap = vMap.name; // Map the rest of the fields using wild card MappedField defaultField = new MappedField(); defaultField.LeftName = "*"; defaultField.RightName = "*"; defaultField.MapFromSide = SourceSideTypeEnum.Left; FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); customSetting.ValueMaps.ValueMap.Add(vMap); SetWitSessionCustomSetting(config, customSetting); }
public WITCustomSettingViewModel(WITSessionCustomSetting setting) { m_setting = setting; WorkItemTypes = new List <WorkItemTypeViewModel>(); foreach (WorkItemTypeMappingElement type in m_setting.WorkItemTypes.WorkItemType) { WorkItemTypes.Add(new WorkItemTypeViewModel(type, setting)); } }
/// <summary> /// Compares WIT session custom settings - raise session-level impact when there is mismatch /// </summary> /// <param name="newWITSessionCustomSetting"></param> /// <param name="currWITSessionCustomSetting"></param> private void CompareWITSessionSetting( Guid sessionUniqueId, WITSessionCustomSetting newWITSessionCustomSetting, WITSessionCustomSetting currWITSessionCustomSetting) { CompareWITMappings(sessionUniqueId, newWITSessionCustomSetting.WorkItemTypes, currWITSessionCustomSetting.WorkItemTypes); CompareFieldMappings(sessionUniqueId, newWITSessionCustomSetting.FieldMaps, currWITSessionCustomSetting.FieldMaps); CompareValueMappings(sessionUniqueId, newWITSessionCustomSetting.ValueMaps, currWITSessionCustomSetting.ValueMaps); }
void TestEnvironment_InsertWronglyIndexedAggrSrcField(Configuration config) { // Aggregated fields AggregatedFields aggregatedFields = new AggregatedFields(); FieldsAggregationGroup group = new FieldsAggregationGroup(); group.MapFromSide = SourceSideTypeEnum.Left; group.TargetFieldName = FIELD_DESCRIPTION; group.Format = AggregationFormat; // NOTE: both source fields are assigned with indice 10 SourceField f0 = new SourceField(); f0.Index = 10; f0.SourceFieldName = FIELD_TITLE; SourceField f1 = new SourceField(); f1.Index = 10; f1.SourceFieldName = FIELD_DESCRIPTION; group.SourceField.Add(f0); group.SourceField.Add(f1); aggregatedFields.FieldsAggregationGroup.Add(group); // construct FieldMap // Map all fields explictly using wildcard MappedField defaultField = new MappedField(); defaultField.LeftName = "*"; defaultField.RightName = "*"; defaultField.MapFromSide = SourceSideTypeEnum.Left; FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.AggregatedFields = aggregatedFields; WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
public BasicFieldMapViewModel(MappedField field, WITSessionCustomSetting customSettings) { m_field = field; if (!string.IsNullOrEmpty(m_field.valueMap)) { Values = customSettings.ValueMaps.ValueMap.FirstOrDefault(x => string.Equals(x.name, m_field.valueMap)); } else { Values = null; } }
public void SetConditionalHybridPriorityValueMap(MigrationTestEnvironment env, Configuration config) { // Map P2 to P1 Value v1 = env.NewValue("2", "1"); Value v2 = env.NewValue("*", "1"); v2.When.ConditionalSrcFieldName = "System.Description"; v2.When.ConditionalSrcFieldValue = ConditionalValueMapDescription; Value v3 = env.NewValue("2", "3"); v3.When.ConditionalSrcFieldName = "System.Description"; v3.When.ConditionalSrcFieldValue = ConditionalValueMapDescription; ValueMap vMap = new ValueMap(); vMap.name = "PriorityValueMap"; vMap.Value.Add(v1); vMap.Value.Add(v2); vMap.Value.Add(v3); // Map field MappedField mField1 = env.NewMappedField(FIELD_PRIORITY, FIELD_PRIORITY); mField1.valueMap = vMap.name; // Map the rest of the fields using wild card MappedField defaultField = env.NewMappedField("*", "*"); FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); customSetting.ValueMaps.ValueMap.Add(vMap); SetWitSessionCustomSetting(config, customSetting); }
public void SetUserValueMap(Configuration config) { // User Map Value v1 = new Value(); v1.LeftValue = SourceUser; v1.RightValue = TargetUser; ValueMap vMap = new ValueMap(); vMap.name = "UserMap"; vMap.Value.Add(v1); // Map field MappedField mField1 = new MappedField(); mField1.LeftName = FIELD_ASSIGNEDTO; mField1.RightName = FIELD_ASSIGNEDTO; mField1.MapFromSide = SourceSideTypeEnum.Left; mField1.valueMap = vMap.name; // Map the rest of the fields using wild card MappedField defaultField = new MappedField(); defaultField.LeftName = "*"; defaultField.RightName = "*"; defaultField.MapFromSide = SourceSideTypeEnum.Left; FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); customSetting.ValueMaps.ValueMap.Add(vMap); SetWitSessionCustomSetting(config, customSetting); }
public static FieldMapViewModelBase CreateInstance(object obj, WITSessionCustomSetting customSettings) { if (obj is FieldsAggregationGroup) { return(new AggregatedFieldMapViewModel(obj as FieldsAggregationGroup, customSettings)); } else if (obj is MappedField) { return(new BasicFieldMapViewModel(obj as MappedField, customSettings)); } else { return(null); } }
private void SetInvalidFieldValueMap(Configuration config) { ValueMap vMap = new ValueMap(); vMap.name = "PriorityValues"; var value = new Value(); value.LeftValue = "*"; value.RightValue = "10000"; vMap.Value.Add(value); MappedField mField1 = new MappedField(); mField1.LeftName = FIELD_PRIORITY; mField1.RightName = FIELD_PRIORITY; mField1.MapFromSide = SourceSideTypeEnum.Left; mField1.valueMap = "PriorityValues"; // Map the rest of the fields using wild card MappedField defaultField = new MappedField(); defaultField.LeftName = "*"; defaultField.RightName = "*"; defaultField.MapFromSide = SourceSideTypeEnum.Left; FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); customSetting.ValueMaps.ValueMap.Add(vMap); SetWitSessionCustomSetting(config, customSetting); }
public void SetUserValueMap(MigrationTestEnvironment env, Configuration config) { // User Map Value v1 = env.NewValue(SourceUser, TargetUser); ValueMap vMap = new ValueMap(); vMap.name = "UserMap"; vMap.Value.Add(v1); // Map field MappedField mField1 = env.NewMappedField(FIELD_ASSIGNEDTO, FIELD_ASSIGNEDTO); mField1.valueMap = vMap.name; // Map the rest of the fields using wild card MappedField defaultField = env.NewMappedField("*", "*"); FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); customSetting.ValueMaps.ValueMap.Add(vMap); SetWitSessionCustomSetting(config, customSetting); }
void TestEnvironment_InsertTwoFieldMapFromSameSourceInMappedField(Configuration config) { // Map field MappedField mField1 = new MappedField(); mField1.LeftName = FIELD_PRIORITY; mField1.RightName = FIELD_PRIORITY; mField1.MapFromSide = SourceSideTypeEnum.Left; mField1.valueMap = string.Empty; // set value map name to be empty string // Map to SAME field again MappedField defaultField = new MappedField(); defaultField.LeftName = FIELD_PRIORITY; defaultField.RightName = FIELD_AREA_PATH; defaultField.MapFromSide = SourceSideTypeEnum.Left; FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
private void SetEmptyValueMapNameInFieldMap(Configuration config) { // Map field MappedField mField1 = new MappedField(); mField1.LeftName = FIELD_PRIORITY; mField1.RightName = FIELD_PRIORITY; mField1.MapFromSide = SourceSideTypeEnum.Left; mField1.valueMap = string.Empty; // set value map name to be empty string // Map the rest of the fields using wild card MappedField defaultField = new MappedField(); defaultField.LeftName = "*"; defaultField.RightName = "*"; defaultField.MapFromSide = SourceSideTypeEnum.Left; FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); SetWitSessionCustomSetting(config, customSetting); }
private void SetInvalidFieldValueMap(MigrationTestEnvironment env, Configuration config) { ValueMap vMap = new ValueMap(); vMap.name = "PriorityValues"; var value = env.NewValue("*", "10000"); vMap.Value.Add(value); MappedField mField1 = env.NewMappedField(FIELD_PRIORITY, FIELD_PRIORITY); mField1.valueMap = "PriorityValues"; // Map the rest of the fields using wild card MappedField defaultField = env.NewMappedField("*", "*"); FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.FieldMaps.FieldMap.Add(fieldMap); customSetting.ValueMaps.ValueMap.Add(vMap); SetWitSessionCustomSetting(config, customSetting); }
protected void SetWitSessionCustomSetting(Configuration config, WITSessionCustomSetting customSetting) { customSetting.SessionConfig = config.SessionGroup.Sessions.Session[0]; customSetting.Update(); }
public AggregatedFieldMapViewModel(FieldsAggregationGroup field, WITSessionCustomSetting customSettings) { m_field = field; }
void TestEnvironment_InsertTwoFieldMapFromSameSourceInMappedFieldRight(MigrationTestEnvironment env, Configuration config) { // Map field MappedField mField1 = env.NewMappedField(FIELD_PRIORITY, FIELD_PRIORITY); mField1.MapFromSide = env.GetTargetSideTypeEnum(); mField1.valueMap = string.Empty; // set value map name to be empty string // Map to SAME field again MappedField defaultField = env.NewMappedField(FIELD_PRIORITY, FIELD_AREA_PATH); defaultField.MapFromSide = env.GetTargetSideTypeEnum(); FieldMap fieldMap = new FieldMap(); fieldMap.name = "BugToBugFieldMap"; fieldMap.MappedFields.MappedField.Add(defaultField); fieldMap.MappedFields.MappedField.Add(mField1); // Map work item type WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement(); typeMapping.LeftWorkItemTypeName = "Bug"; typeMapping.RightWorkItemTypeName = "Bug"; typeMapping.fieldMap = fieldMap.name; //=================== another work item type mapping MappedField mField1_1 = env.NewMappedField(FIELD_PRIORITY, FIELD_PRIORITY); mField1_1.MapFromSide = SourceSideTypeEnum.Right; mField1_1.valueMap = string.Empty; // set value map name to be empty string // Map to SAME field again MappedField defaultField_1 = env.NewMappedField(FIELD_PRIORITY, FIELD_AREA_PATH); defaultField_1.MapFromSide = SourceSideTypeEnum.Right; FieldMap fieldMap_1 = new FieldMap(); fieldMap_1.name = "BugToBugFieldMap_1"; fieldMap_1.MappedFields.MappedField.Add(defaultField_1); fieldMap_1.MappedFields.MappedField.Add(mField1_1); // Map work item type WorkItemTypeMappingElement typeMapping_1 = new WorkItemTypeMappingElement(); typeMapping_1.LeftWorkItemTypeName = "Bug_1"; typeMapping_1.RightWorkItemTypeName = "Bug_1"; typeMapping_1.fieldMap = fieldMap_1.name; // Build WIT Session custom setting WITSessionCustomSetting customSetting = new WITSessionCustomSetting(); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping); customSetting.WorkItemTypes.WorkItemType.Add(typeMapping_1); customSetting.FieldMaps.FieldMap.Add(fieldMap); customSetting.FieldMaps.FieldMap.Add(fieldMap_1); SetWitSessionCustomSetting(config, customSetting); }
public virtual void SetNewValue() { UndoXmlChanges(); WITSessionCustomSetting customSettings = m_session.WITCustomSetting; if (m_mappedField == null) // no field mapping exists { // add new field mapping m_mappedField = new MappedField(); if (IsLeftSidedConflict) { m_mappedField.MapFromSide = SourceSideTypeEnum.Right; m_mappedField.RightName = SourceField; m_mappedField.LeftName = TargetField; } else { m_mappedField.MapFromSide = SourceSideTypeEnum.Left; m_mappedField.LeftName = SourceField; m_mappedField.RightName = TargetField; } m_fieldMap.MappedFields.MappedField.Add(m_mappedField); } // add/get valueMap ValueMap valueMap; if (!string.IsNullOrEmpty(m_mappedField.valueMap)) { valueMap = customSettings.ValueMaps.ValueMap.FirstOrDefault(x => string.Equals(x.name, m_mappedField.valueMap)); Debug.Assert(valueMap != null, string.Format("valueMap {0} not found", m_mappedField.valueMap)); } else { valueMap = new ValueMap(); valueMap.name = GenerateValueMapName(customSettings.ValueMaps.ValueMap, TargetFieldDispName); m_mappedField.valueMap = valueMap.name; customSettings.ValueMaps.ValueMap.Add(valueMap); } // add/set value string sourceValue = AlwaysMapToValue ? WitMappingConfigVocab.Any : TargetFieldCurrentValue; if (IsLeftSidedConflict) { UpdateValueMap(TargetFieldCurrentValue, sourceValue, NewValue, sourceValue, valueMap.Value); } else { UpdateValueMap(sourceValue, TargetFieldCurrentValue, sourceValue, NewValue, valueMap.Value); } // save config m_session.UpdateCustomSetting(customSettings); int configId = SaveConfiguration(); // set conflictRuleViewModel options ObservableDataField updatedConfigIdDataField = m_conflictRuleViewModel.ObservableDataFields.First(x => string.Equals(x.FieldName, Constants.DATAKEY_UPDATED_CONFIGURATION_ID)); updatedConfigIdDataField.FieldValue = configId.ToString(); }