Skip to content

Commit 1d1bb08

Browse files
Merge pull request #699 from solidify/revert-693-feature/composite-field-mapper
Revert "Composite field mapper"
2 parents 69e2eb0 + 2b6556e commit 1d1bb08

File tree

5 files changed

+16
-147
lines changed

5 files changed

+16
-147
lines changed

docs/config.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ Currently the tool has a rather naive implementation for mapping certain constru
100100
|MapArray|Maps an array by replacing comma with semi-colon|
101101
|MapRemainingWork|Maps and converts a Jira time to hours|
102102
|MapRendered|Maps field to rendered html format value|
103-
|MapFieldsComposite|Maps multiple fields and concatenates the field values based on a user-defined pattern. In the `source` field, you must specify a pattern where any `${...}` tokens will indicate a field substitution. For example, use `${state}` to include the issue state in the mapped value.|
104103
|(default)|Simply copies soure to target|
105104

106105
## Example configuration
@@ -186,7 +185,7 @@ Currently the tool has a rather naive implementation for mapping certain constru
186185
{
187186
"source": "description",
188187
"target": "System.Description",
189-
"mapper":"MapRendered"
188+
"mapper":"MapRendered"
190189
},
191190
{
192191
"source": "priority",
@@ -250,12 +249,7 @@ Currently the tool has a rather naive implementation for mapping certain constru
250249
{
251250
"source": "comment",
252251
"target": "System.History",
253-
"mapper":"MapRendered"
254-
},
255-
{
256-
"source": "${customfield_a}-${customfield_b}",
257-
"target": "Custom.ConcatenatedAB",
258-
"mapper": "MapFieldsComposite"
252+
"mapper":"MapRendered"
259253
},
260254
{
261255
"source": "status",

docs/faq.md

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
## FAQ - Frequently Asked Questions
2-
3-
### 1. Convert Jira formatted descriptions and comments on migration
4-
5-
- With our latest release (2.3.1) we have introduced a new mapper called "MapRendered" that should be used when mapping fields to get the Html rendered value from Jira.
2+
1. Convert Jira formatted descriptions and comments on migration
3+
- With our latest release (2.3.1) we have introduced a new mapper called "MapRendered" that should be used when mapping fields to get the Html rendered value from Jira.
64

75
Example:
86
`{`
@@ -11,28 +9,25 @@ Example:
119
`"mapper":"MapRendered"`
1210
`}`
1311

14-
### 2. Why I am getting Unauthorized exception when running export?
15-
16-
- It might be that you are using your email as a username, try to use your username instead of an email address.
12+
2. Why I am getting Unauthorized exception when running export?
13+
- It might be that you are using your email as a username, try to use your username instead of an email address.
1714
- using Jira Cloud - it might be that you need to to use the API token as a password.
1815

19-
### 3. How to map custom field by name?
16+
3. How to map custom field by name?
17+
- To map a custom field by name we have to add a mapping in the configuration file.
2018

21-
- To map a custom field by name we have to add a mapping in the configuration file.
22-
23-
Example:
19+
Example:
2420
`{
2521
"source": "CustomFieldName",
2622
"source-type": "name",
2723
"target": "Microsoft.VSTS.TCM.ReproSteps"
2824
}`
2925

30-
### 4. How to migrate custom fields having dropdown lists?
31-
26+
4. How to migrate custom fields having dropdownlists?
3227
- To map a custom field which is an dropdown list you can use MapArray mapper to get in a better way.
3328
Also take a look at the other possible [Mappers](config.md#mappers) to use.
3429

35-
Example:
30+
Example:
3631
` {
3732
"source": "UserPicker",
3833
"source-type": "name",
@@ -42,11 +37,11 @@ Example:
4237
}
4338
`
4439

45-
### 5. How to migrate correct user from Jira to Azure DevOps and assign to the new work items?
40+
5. How to migrate correct user from Jira to Azure DevOps and assign to the new work items ?
41+
- User mapping differes between Jira Cloud and Jira Server. To migrate users and assign the new work items in Azure DevOps to the same user as the original task had in Jira, we need to add a text file in the root that would look something like this:
4642

47-
- User mapping differs between Jira Cloud and Jira Server. To migrate users and assign the new work items in Azure DevOps to the same user as the original task had in Jira, we need to add a text file in the root that would look something like this:
48-
49-
- When using Jira Cloud then firstly make sure in the config the '"using-jira-cloud": true' is set. The mapping file the should have accountId/email value pairs. To use email value pairs the users email should be set to public in the user profile in Jira Cloud. Otherwise the tool cannot get the email and will use accountId instead for mapping.
43+
- When using Jira Cloud then firstly make sure in the config the '"using-jira-cloud": true' is set. The mapping file the should have accountId/email value pairs. To use email value pairs the users email should be set to public in the user profile in Jira Cloud
44+
otherwise the tool cant get the email and will use accountId instead for mapping.
5045

5146
Jira.User1@some.domain=AzureDevOps.User1@some.domain
5247
Jira.User2@some.domain=AzureDevOps.User2@some.domain
@@ -58,30 +53,9 @@ Example:
5853
JiraAccountId2=AzureDevOps.User2@some.domain
5954
JiraAccountId3=AzureDevOps.User3@some.domain
6055

61-
- When using Jira Server then firstly make sure in the config the ' "using-jira-cloud": false' is set. The mapping should look like the example below:
56+
- When using Jira Server then firstly make sure in the config the ' "using-jira-cloud": false' is set. The mapping should look like the example below:
6257

6358
Jira.User1@some.domain=AzureDevOps.User1@some.domain
6459
Jira.User2@some.domain=AzureDevOps.User2@some.domain
6560
Jira.User3@some.domain=AzureDevOps.User3@some.domain
6661

67-
### 6. How to concatenate/combine fields?
68-
69-
It is possible to concatenate fields and specify a custom pattern with the **FieldsComposite** mapper. You will need to include the following mapper in your config file:
70-
71-
```
72-
{
73-
"source": "${field1}-${field2}",
74-
"target": "Custom.TargetField",
75-
"mapper": "MapFieldsComposite"
76-
}
77-
```
78-
79-
Here is another example for adding the issue title to the description:
80-
81-
```
82-
{
83-
"source": "${summary}<br/>${description}",
84-
"target": "System.Description",
85-
"mapper": "MapFieldsComposite"
86-
}
87-
```

src/WorkItemMigrator/JiraExport/JiraMapper.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ internal Dictionary<string, FieldMapping<JiraRevision>> InitializeFieldMappings(
110110
case "MapRendered":
111111
value = r => FieldMapperUtils.MapRenderedValue(r, item.Source, isCustomField, _jiraProvider.GetCustomId(item.Source), _config);
112112
break;
113-
case "MapFieldsComposite":
114-
value = r => FieldMapperUtils.MapFieldsComposite(r, item.Source, isCustomField, _config);
115-
break;
116113
default:
117114
value = IfChanged<string>(item.Source, isCustomField);
118115
break;

src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.IO;
99
using System.Linq;
1010
using System.Reflection;
11-
using System.Text.RegularExpressions;
1211

1312
namespace JiraExport
1413
{
@@ -114,33 +113,7 @@ public static (bool, object) MapRenderedValue(JiraRevision r, string sourceField
114113
return (true, value);
115114
}
116115

117-
public static (bool, object) MapFieldsComposite(JiraRevision r, string sourceField, bool isCustomField, ConfigJson config)
118-
{
119-
if (r == null)
120-
throw new ArgumentNullException(nameof(r));
121-
122-
if (config == null)
123-
throw new ArgumentNullException(nameof(config));
124-
125-
string mapped = sourceField;
126116

127-
// Match source fields, pattern: "${...}"
128-
var matches = Regex.Matches(sourceField, "\\$\\{.+?\\}", RegexOptions.None, TimeSpan.FromMilliseconds(100));
129-
foreach (var match in matches)
130-
{
131-
string matchStripped = match.ToString().Replace("${", "").Replace("}", "");
132-
if (r.Fields.TryGetValue(matchStripped, out object fieldValue))
133-
{
134-
mapped = mapped.Replace("${" + matchStripped + "}", fieldValue.ToString());
135-
}
136-
else
137-
{
138-
// Stop evaluating if we encounter any field in the pattern that does not exist on the revision
139-
return (false, null);
140-
}
141-
}
142-
return (true, mapped);
143-
}
144117

145118
public static object MapTags(string labels)
146119
{

src/WorkItemMigrator/tests/Migration.Jira-Export.Tests/RevisionUtils/FieldMapperUtilsTests.cs

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -412,75 +412,6 @@ public void When_calling_map_rendered_value_with_null_arguments_Then_and_excepti
412412
Assert.Throws<ArgumentNullException>(() => { FieldMapperUtils.MapRenderedValue(null, null, false, null, null); });
413413
}
414414

415-
[Test]
416-
public void When_calling_map_fields_composite_with_valid_input_Then_expected_output_is_returned()
417-
{
418-
var sourceField = "${summary}---${description}";
419-
var configJson = _fixture.Create<ConfigJson>();
420-
var summary = "My Summary";
421-
var description = "My Description";
422-
423-
var expectedOutput = summary + "---" + description;
424-
425-
configJson.TypeMap.Types = new List<Common.Config.Type>() { new Common.Config.Type() { Source = "Story", Target = "Story" } };
426-
configJson.FieldMap.Fields = new List<Common.Config.Field>()
427-
{
428-
new Common.Config.Field()
429-
{
430-
Source = sourceField,
431-
Target = "System.Description",
432-
Mapper = "MapFieldsComposite"
433-
}
434-
};
435415

436-
var jiraRevision = MockRevisionWithParentItem("issue_key", summary);
437-
jiraRevision.Fields.Add("description", description);
438-
439-
var actualOutput = FieldMapperUtils.MapFieldsComposite(jiraRevision, sourceField, false, configJson);
440-
441-
Assert.Multiple(() =>
442-
{
443-
Assert.That(actualOutput.Item1, Is.True);
444-
Assert.That(actualOutput.Item2, Is.EqualTo(expectedOutput));
445-
});
446-
}
447-
448-
[Test]
449-
public void When_calling_map_fields_composite_with_invalid_input_Then_expected_false_and_null_is_returned()
450-
{
451-
var sourceField = "${summary}---${description}";
452-
var configJson = _fixture.Create<ConfigJson>();
453-
var summary = "My Summary";
454-
var description = "My Description";
455-
456-
var expectedOutput = summary + "---" + description;
457-
458-
configJson.TypeMap.Types = new List<Common.Config.Type>() { new Common.Config.Type() { Source = "Story", Target = "Story" } };
459-
configJson.FieldMap.Fields = new List<Common.Config.Field>()
460-
{
461-
new Common.Config.Field()
462-
{
463-
Source = sourceField,
464-
Target = "System.Description",
465-
Mapper = "MapFieldsComposite"
466-
}
467-
};
468-
469-
var jiraRevision = MockRevisionWithParentItem("issue_key", summary);
470-
471-
var actualOutput = FieldMapperUtils.MapFieldsComposite(jiraRevision, sourceField, false, configJson);
472-
473-
Assert.Multiple(() =>
474-
{
475-
Assert.That(actualOutput.Item1, Is.False);
476-
Assert.That(actualOutput.Item2, Is.EqualTo(null));
477-
});
478-
}
479-
480-
[Test]
481-
public void When_calling_map_fields_composite_with_null_arguments_Then_and_exception_is_thrown()
482-
{
483-
Assert.Throws<ArgumentNullException>(() => { FieldMapperUtils.MapFieldsComposite(null, null, false, null); });
484-
}
485416
}
486417
}

0 commit comments

Comments
 (0)