How to skip the import of a cutom field?

Petya Tsvetanova Petrova January 26, 2013

Hello,

Is it possible to give to the users the opportunity to choose whether to import a custom field or not?

Thanks,

Petya

3 answers

1 accepted

0 votes
Answer accepted
Pawel Niewiadomski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2013

Of course you can but you'll have to implement the whole logic by yourself. It's not that hard.

What you actually want is following:

  • you probably already have your own page for displaying custom fields so add a checkbox there (or other widget to mark what custom fields should be imported) - you can base your implementation on ImporterCustomFieldsPage
  • on this page store the data about selected fields in your ConfigurationBean object
  • when import is run getIssuesIterator will be called
  • if you use our IssueTransformer approach you'll need to add logic in your IssueTransformer class that will not set custom fields for given custom fields that were selected by the user to be ignored
  • the engine (DefaultJiraDataImporter) will import issues

The idea is simple what's in ExternalIssue object gets imported, if you don't put there custom fields data it will not get imported. So you need to control what gets put into your ExternalIssue in your IssueTransformer and you'll be fine.

Petya Tsvetanova Petrova January 31, 2013

Hi Pawel,

thank you for your suggestions. Here is what I did:

  • I added check boxes in the ImporterCustomFieldsPage velocity file;
  • I stored the selected fields in the ConfigBean;
  • Then, in order to have only selected fields for the mapping of the fields' values, I tried to take only the selected fields, but I failed because the SavannahValueMappingDefinitionsFactory is called very early. The reason was that piece of code in the AbstractProjectTransformer:
final ValueMappingHelper helper = configBean.getValueMappingHelper();
		if (helper.isWorkflowSchemeDefined()) {
			project.setWorkflowSchemeName(helper.getWorkflowSchemeName());
		}
    • So I commented that and now it is perfectly working.

However, if we want to use the workflows, I must add some changes in that code which I don't want, because then the merging with the new version would be complicated.

Pawel Niewiadomski
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2013

Have you noticed that AbstractConfigBean2 has initializeValueMappingHelper that you can override and put your own mapping helpers there. So while building your ValueMappingHelper you could already ignore fields that were not selected for import.

In ImporterFieldsMappingPage the valueMappingHelper is reinitialized so you don't need to worry it was used before. At least that's my impression from reading the code.

0 votes
Petya Tsvetanova Petrova January 26, 2013

I develop a Savannah importer plugin as part of your JIM plugin. The thing I want to achieve is to add an opsion "Skip" to the drop-down menu on the "Set up custom fields" step. Choosing that the user could decide not to import values from that particular field. Can I do that?

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2013

What do you mean by "import" a custom field?

Are you importing from another system using the system importers? Drawing data in via a remote link? Something else?

Also, which system? I guessed Jira, but I've just noticed I could be absolutely wrong.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events