-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch edit for relationships #6283
base: issue-2331
Are you sure you want to change the base?
Conversation
Triggered by 350ee9c on branch refs/heads/issue-6126
TODO: Change upload plan construction for remote to ones |
- This was caused because we treat remote to-ones as to-many in the upload plan (affects COGs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upload plan construction for COGs work but COJO records do not get cloned + updated. Any pointers on where I can look?
Okay nevermind, I was testing it incorrectly
TODO:
BUG:
|
NOTE:
|
Fixes #6126
Fixes #6248
Warning
Use a db used for testing other batch edit PRs or create a new one
Adding docs from #4929:
Batch-editing
Implementation and design
Batch edit behaviors
Make a query with columns in the base table, and select relationships to edit. There are 4 different types of relationships, in general. Some example relationships for Collection Object as base table:
Fields
The following fields are readonly. All other simple fields when changed will be updated
To-one dependent (for ex. collectionobjectattribute)
These relationships get directly updated, and are not matched. If the to-one is not in the db, it'll create one.
This also includes collectingevent when embedded.
Test cases to consider:
To-many dependent (for ex. determinations)
Same as to-one dependent. These relationships get directly updated. If the corresponding record is not present, a new one gets created.
Test cases to consider:
To-one independent (for ex. cataloger)
These relationships get matched, and uploaded (if match is not found). During upload, it performs a clone of the record (cloning all the non-unique fields, and dependents). The clone takes into account relationships also mapped. That is, if agent needs to be cloned, and you have mapped agentspecialty, it'll take the agentspecialty mapped (rather than cloning previous's agentspecialty).
Test cases to consider:
To-many independent
Same as to-many dependent. The only difference is that we always perform an update (we don't delete these). If a mapped record is not present, it'll create one, without any matching.
Test cases to consider:
Trees
There are two different routes to perform tree updates.
Workbench method:
If you want to modify a specific rank, or say reassign species for determination, you'd want to add a specific rank in the query. In this case, it always matches and uploads (and possibly clone), so we don't have updates.
In the query builder, it'll enforce that you select complete branch of the tree. That is, if your query contains rank "species", and "genus", it'll demand you to add ranks all the way down from "genus" to "species". If used part of a relationship, it'll demand going the way down from "genus" to the lowest rank in the tree.
Update method:
If in the query builder, there is no visible tree rank field, it allows direct modifications (and, thus, updates) to the tree table. This will be useful if you want to, say, update remarks for ones that match name "ploia"
In both of the above methods, fullname, nodenumber, highestchildnodenumber is completely readonly.
Results
There are 4 new different type of results;
NoChange
Reported when the record was meant to updated, but no change occurred. That is, all the values from the db were the same. This is not visible to the user.
Updated
Reported when the record's fields were changed. This does not consider relationships (they are reported with different result)
Deleted
Reported when a record is deleted. Happens when a dependent relationship's cells are all empty.
MatchedAndChanged
Reported when a to-one independent was matched to another record, different than the current one.
Preferences
There are three different preference options.
Remote Preferenences (2)
Defer For Match
Set by
sp7.batchEdit.deferForMatch
.This preference controls whether database fields are included for matching or not. Defaults to false.Defer For Null
Set by
sp7.batchEdit.deferForNull
.This preference controls whether database fields are included for determining if the record is null or not. For dependents, null records are deleted, so this preference is used to control the caution batch-edit followsThe preferences can also be accessed from going to Data Mapper > Batch Edit Preferences

User Preferenences (1)
Number of query rows
Determines how many number of query results are used for batch-edit. Defaults to 5000.
Can enable/disable rollback
Rollbacks
Rollbacks are complicated to perform. In the current design, whenever user creates a batch-edit dataset, via the query builder, it makes two datasets. User can only see one of them. The second is a "backer" of the first, and contains a FK to the first (so we can find backer of a dataset later). When rollback is requested, for every row in the main one, we find the original row in the backer, and perform the regular batch-edit update on it. Essentially, it applies original snapshot.
This is highly experimental, so it is recommended to always take a backup of the db, but this should work in a good amount of cases.
Misc
Checklist
self-explanatory (or properly documented)
Testing instructions
Regression tests