Closed (fixed)
Project:
farmOS
Version:
2.x-dev
Component:
Import/export
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
22 Aug 2023 at 12:10 UTC
Updated:
20 Oct 2023 at 18:04 UTC
Jump to comment: Most recent
farmOS v1 provided CSV importers for each asset and log type (see https://v1.farmos.org/guide/import/). This functionality has not been ported to farmOS v2
Provide a core farmOS CSV Import module. Use Drupal core's Migrate API as the basis, along with the Migrate Source CSV and Migrate Source UI modules.
Automatically generate importers for each asset and log type, as well as each taxonomy term type (see #2931181: Add CSV importers for taxonomy terms).
Also allow additional migrations to be provided as migrate_plus.migration.* configuration entities (with the support of the Migrate Plus module).
Adds new forms for importing assets, logs, and taxonomy terms via CSV file.
None.
None.
Comments
Comment #3
m.stentaThis effort is supported by OpenTEAM's ACTION initiative (see https://gitlab.com/OpenTEAMAg/feedback/support_requests/-/issues/146), and builds upon the initial work and investigations of @pcambra in #3151244: [META] farmOS 2.x Importers.
Comment #4
m.stentaComment #5
m.stentaI am working on this in my
2.x-csvbranch on my GitHub fork: https://github.com/mstenta/farmOS/tree/2.x-csvI filled in the work that has already been done in the "Remaining tasks" above, but there is more to add. I will organize my notes and update the list as I go.
Comment #7
m.stentaWith the "default" importers we are going to provide on behalf of all asset/log/term types we will need to strike the right balance so that they are useful for general import use cases. But ultimately there are tradeoffs, and we'll need to make some decisions about what to support and what to defer to "custom" importers.
An example of this is log quantities. In my first pass I simply added 4 columns to the generic CSV templates:
quantity measurequantity valuequantity unitsquantity labelSo currently only a single quantity is supported. I discussed this @paul121 in chat:
Comment #8
m.stentaAnother tricky decision is how to handle asset references, including the
parentfield on assets, and theasset,location,equipment,group, etc fields on logs.I added support for taxonomy terms to set their
parentby name. This is easy enough and makes sense for terms because in theory they should be unique.For assets it's trickier. You may have multiple assets with the same name. Or archived assets that had the same name as a current asset (eg: if you use an ID tag as a name, and reuse ID tags after an animal is archived).
We had the same exact quandary in farmOS v1 (see #3086611: Allow CSV imports to reference assets by name), and ultimately decided to support asset IDs and asset names. That led to another issue (#3086844: Issues importing BOTH asset IDs AND asset names), but generally worked OK.
We may just need to take the same approach in v2, unless there's a better idea...
Comment #9
m.stentaAlso, asset references need to support multiple values, so a comma-separated list of IDs/names needs to be supported.
Comment #10
m.stentaWe may also want to support lookup by ID Tag...
This is making me thing we might want to provide a custom
asset_lookupmigration process plugin, which encapsulates all of this custom logic.Comment #11
m.stentaI looked into this briefly, and it wasn't as trivial as I was hoping, so I'm going to punt on it for the time being and focus on more important things. Users can still get to these importers through the menu. These action links are really "nice to haves" - not critical. But if we have time left at the end I might look into this again.
Comment #12
m.stentaI opened a pull request for review: https://github.com/farmOS/farmOS/pull/722
This is a big one, but the commit history should describe the changes in a logical order. There are a lot of potential next-steps, but I think this is a good first step, and it's already better than the v1 importers in a number of ways.
Comment #14
m.stentaMerged!