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(); }
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 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); }
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); }
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 OperationFieldExecuter(RequestContext requestContext, OutputObjectScope parentScope, int fieldIndex) { _requestContext = requestContext; _parentScope = parentScope; _fieldIndex = fieldIndex; _operationField = _parentScope.Fields[_fieldIndex]; }
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); }
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(); }
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); }
private void ValidateMappedFieldAndProcessSubset(MappedField mappedField) { var typeDef = mappedField.FieldDef.TypeRef.TypeDef; var selField = mappedField.Field; var selSubset = selField.SelectionSubset; var typeName = typeDef.Name; switch (typeDef) { case ScalarTypeDef _: case EnumTypeDef _: if (selSubset != null) { AddError($"Field '{selField.Key}' of type '{typeName}' may not have a selection subset.", selSubset); } break; default: // ObjectType, Union or Interface if (selSubset == null) { AddError($"Field '{selField.Key}' of type '{typeName}' must have a selection subset.", selField); return; } _pendingSelectionSets.Add(new PendingSelectionSet() { SubSet = selSubset, OverType = typeDef, Directives = selField.Directives }); break; } }
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 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 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); }
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); }
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(); }
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; } }
private void btnAdd_Click(object sender, System.EventArgs e) { string BookmarkCaption = ""; //text that appears in bookmark list //Validate source data //have to select List Item if (listOfficeWorksFields.SelectedItem == null) { MessageBox.Show("Tem que seleccionar um campo da lista!", _msgbox_title); return; } //have to select Bookmark if (txtBookmark.Text.Trim().Length == 0) { MessageBox.Show("O campo Bookmark é obrigatório!", _msgbox_title); return; } //Bookmark already in use if (IsBookMarkInMappGrid(txtBookmark.Text)) { MessageBox.Show("Bookmark já existente!", _msgbox_title); return; } //Insert New Item MappedField oNewMapping = new MappedField(); oNewMapping.BookmarkName = txtBookmark.Text; BookmarkCaption = oNewMapping.BookmarkName; oNewMapping.FieldIdentifier = Convert.ToInt32(((ListViewItem)listOfficeWorksFields.SelectedItem).Tag); oNewMapping.FieldName = ((ListViewItem)listOfficeWorksFields.SelectedItem).Text; oNewMapping.RequiredField = chkRequired.Checked; //if Entity field then set the Entity Type if (groupBox1.Enabled) { oNewMapping.EntityType = (radioButton1.Checked ? enumEntityType.EntityTypeOrigin : enumEntityType.EntityTypeDestiny); BookmarkCaption += " [" + (radioButton1.Checked? "Origem" : "Destino") + "]"; } //Add Row _MappingGrid.AddRow(new string[] { BookmarkCaption, oNewMapping.FieldName }, oNewMapping, true); //set row RequiredField color _MappingGrid.MarkRow((_MappingGrid.ObjectItems.Count - 1), false, oNewMapping.RequiredField); //reset Form ResetForm(); //Hide me this.Hide(); }
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 FieldContext(RequestContext requestContext, IOperationFieldContext rootField, MappedField field, int fieldIndex, IList <OutputObjectScope> allParentScopes = null) { _requestContext = requestContext; RootField = rootField; Field = field; FieldIndex = fieldIndex; AllParentScopes = allParentScopes ?? OutputObjectScope.EmptyList; if (Flags.IsSet(FieldFlags.ReturnsComplexType)) { AllResultScopes = new List <OutputObjectScope>(); } }
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); }
/// <summary> /// Maps a member from the type's definition to its constructed version. /// </summary> public IEntity MapMember(IEntity source) { if (source == null) { return(null); } if (_mappedMembers.ContainsKey(source)) { return(_mappedMembers[source]); } IEntity mapped = null; switch (source.EntityType) { case EntityType.Method: mapped = new MappedMethod(_typeSystemServices, ((ExternalMethod)source).MethodInfo, this); break; case EntityType.Constructor: mapped = new MappedConstructor(_typeSystemServices, ((ExternalConstructor)source).ConstructorInfo, this); break; case EntityType.Field: mapped = new MappedField(_typeSystemServices, ((ExternalField)source).FieldInfo, this); break; case EntityType.Property: mapped = new MappedProperty(_typeSystemServices, ((ExternalProperty)source).PropertyInfo, this); break; case EntityType.Type: mapped = MapType((IType)source); break; case EntityType.Event: mapped = new MappedEvent(_typeSystemServices, ((ExternalEvent)source).EventInfo, this); break; default: throw new ArgumentException( string.Format("Invalid entity type for mapping: {0}.", source.EntityType)); } _mappedMembers[source] = mapped; return(mapped); }
private bool IsSourceFieldMapped(MappedField mappedField, out string collidedField) { collidedField = string.Empty; bool retVal = false; switch (mappedField.MapFromSide) { case SourceSideTypeEnum.Left: retVal = IsSourceFieldMapped(mappedField.MapFromSide, mappedField.LeftName); if (retVal) { collidedField = mappedField.LeftName; } break; case SourceSideTypeEnum.Right: retVal = IsSourceFieldMapped(mappedField.MapFromSide, mappedField.RightName); if (retVal) { collidedField = mappedField.RightName; } break; case SourceSideTypeEnum.Any: bool rNameRslt = IsSourceFieldMapped(mappedField.MapFromSide, mappedField.RightName); if (rNameRslt) { collidedField = mappedField.RightName; } bool lNameRslt = IsSourceFieldMapped(mappedField.MapFromSide, mappedField.LeftName); if (lNameRslt) { collidedField = mappedField.LeftName; } retVal = (lNameRslt || rNameRslt); break; default: throw new InvalidOperationException(); } return(retVal); }
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); }
internal MappedField NewMappedField(string source, string target) { MappedField field = new MappedField(); if (MigrationTestType == MigrationTestType.TwoWayRight) { field.LeftName = target; field.RightName = source; field.MapFromSide = SourceSideTypeEnum.Right; } else { field.LeftName = source; field.RightName = target; field.MapFromSide = SourceSideTypeEnum.Left; } return(field); }
// Might be called for ObjectType or Interface (for intf - just to check fields exist) private List <MappedSelectionItem> MapSelectionItems(IList <SelectionItem> selItems, ObjectTypeDef objectTypeDef, IList <RequestDirective> ownerDirectives = null, bool isForUnion = false) { var mappedItems = new List <MappedSelectionItem>(); foreach (var item in selItems) { switch (item) { case SelectionField selFld: var fldDef = objectTypeDef.Fields.FirstOrDefault(f => f.Name == selFld.Name); if (fldDef == null) { // if field not found, the behavior depends if it is a union; it is error for a union if (!isForUnion) { AddError($"Field '{selFld.Name}' not found on type '{objectTypeDef.Name}'.", selFld); } continue; } var mappedArgs = MapArguments(selFld.Args, fldDef.Args, selFld); var mappedFld = new MappedField(selFld, fldDef, mappedArgs); AddRuntimeModelDirectives(mappedFld); AddRuntimeRequestDirectives(mappedFld); mappedItems.Add(mappedFld); ValidateMappedFieldAndProcessSubset(mappedFld); break; case FragmentSpread fs: var mappedSpread = MapFragmentSpread(fs, objectTypeDef, isForUnion); if (mappedSpread != null)// null is indicator of error { AddRuntimeRequestDirectives(mappedSpread); mappedItems.Add(mappedSpread); } break; }//switch var allDirs = ownerDirectives.MergeLists(item.Directives); } //foreach item return(mappedItems); }
private ICollection <MappedField> GetFields(XPathNavigator parentNode, BaseField[] fieldMappings) { var mappedFields = new List <MappedField>(); if (fieldMappings == null) { return(null); } foreach (BaseField fieldMapping in fieldMappings) { object fieldValue = GetFieldValue(parentNode, fieldMapping); var mappedField = new MappedField(fieldMapping.FieldType, fieldValue); mappedFields.Add(mappedField); } return(mappedFields); }
private void AddRuntimeModelDirectives(MappedField mappedField) { var fldDef = mappedField.FieldDef; if (fldDef.Directives != null) { foreach (var fldDir in fldDef.Directives) { mappedField.AddDirective(new RuntimeModelDirective(fldDir)); } } var typeDefDirs = fldDef.TypeRef.TypeDef.Directives; if (typeDefDirs != null) { foreach (var tdir in typeDefDirs) { mappedField.AddDirective(new RuntimeModelDirective(tdir)); } } }
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); }
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); }