Project

General

Profile

Feature #22701

Updated by Toshi MARUYAMA almost 8 years ago

When importing issues via CSV with parent relations, the parent issues need to be positioned before child issues. Otherwise the relation will be ignored. 

 To work around this limitation, the issue import could be ne extended to use multiple passes: 

 # one to import basic issue properties 
 # one to import relations to other issues 

 This way it becomes easier to create the CSV files for imports, since order is no longer important. 

 This change would also be a prerequisite to import general issue relations. Since those cannot be more complex that parent relations and cannot necessarily be linearized properly. 



 Attached you find a patch series based on trunk r15361. 

 While implemented the changes, I tried to keep the @Import@ free from issue related information. Other existing @Import@ sub classes - within plugins e.g. - should need as little updates as possible. 


 h3. 0001 Extend test data for issue import 

 This change adds two rows to the existing issue import fixture file. These rows contain a parent and a child issue, while the parent is placed after the child. This would not import properly given the current implementation. 

 The patch also updates the existing tests, where the number of imported issues is asserted. 

 h3. 0002 Add test for issue relations to following rows 

 This patch extends the existing parent issue import test to also verify that the newly introduced parent child relation is properly imported. This test fails with the current implementation. 

 h3. 0003 Multi-pass CSV import 

 This patch defines a @required_passes@ method within @Import@ which returns @1@ by default and may be overwritten in sub classes. The @IssueImport@ does so and returns @1@ if no @parent_id@ mapping was set, otherwise it returns @2@. 

 The @run@ method is split into @run@ and @run_pass@. The first one is recursive and called once for each pass. It also handles the @max_*@ options. The second is only responsible for reading the rows, creating or updating the ImportItems and passing everything to @build_object@. 

 Since @build_object@ may now be called multiple times (once for each pass), the argument list was extended to provide more context. If somebody created a custom import in a plugin, this would need to be changed by the plugin's author. 

 In the @IssueImport@, @build_object@ is now split into @build_issue@ and @build_relations@, the first is called in the first pass, the second in pass 2. 

 The patch also contains a migration, which adds a @completed_passes@ field to @ImportItem@. This is needed to properly (re-)store progress for multi-step imports, like the ones via the web UI. 

 Finally the patch adds some test to make sure, that the general behavior of multi-step imports did not change with the introduction of multi-pass imports. 


 *Disclaimer*: I know, this is a rather large change to fix a minor nuisance. But as mentioned earlier, I think, this change is a necessary prerequisite to support importing "Related Issues" properly, which I would like to contribute next, if this patch is accepted.

Back