Conversation
|
@Tristaan thanks for this, I will take a look. |
|
When you say "it does not overwrite existing values, it just adds new values", are you wanting to overwrite all existing values in for example the "Identifier" field even if they are not persistent identifiers? For example, if I have in my Identifier field some local identifiers (e.g. "etdid3876"), if this node was part of a batch, that value would be wiped out and replaced with "ark:/4653/fooo499q"? If that's the case, we can do that in the persister, but we'll need to provide an option to either overwrite or append values, since not all sites will want to do that. Let me know if I have misunderstood what you're looking for. |
|
Well why can't we have the best of both worlds? Overwrite (or don't write
for that matter) if the same value exists in field_identifiers. Else append
to the array.
…On Fri, 17 Sep 2021, 16:08 Mark Jordan, ***@***.***> wrote:
When you say "it does not overwrite existing values, it just adds new
values", are you wanting to overwrite all existing values in for example
the "Identifier" field even if they are not persistent identifiers? For
example, if I have in my Identifier field some local identifiers (e.g.
"etdid3876"), if this node was part of a batch, that value would be wiped
out and replaced with "ark:/4653/fooo499q"? If that's the case, we can do
that in the persister, but we'll need to provide an option to either
overwrite or append values, since not all sites will want to do that. Let
me know if I have misunderstood what you're looking for.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#23 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABEPGMDKQKDLHCB5IZGDZY3UCNDVFANCNFSM5ECL3AGQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
|
Gotcha. I'll comment on one way of doing that over in the code review. |
src/Persister/Generic.php
Outdated
| public function persist(&$entity, $pid, $save = TRUE) { | ||
| $target_field = trim($this->config->get('persistent_identifiers_target_field')); | ||
| if (method_exists($entity, 'hasField') && $entity->hasField($target_field)) { | ||
| // TODO: Don't add same values |
There was a problem hiding this comment.
Something like this maybe?
$existing_values = $entity->get($target_field)->getValue()
foreach ($existing_values as $value) {
if ($pid != $value) {
$entity->{$target_field}[] = $pid;
}
}There was a problem hiding this comment.
Or maybe better to use a !in_array($pid, $existing_values)?
There was a problem hiding this comment.
an !in_array is better, because looping through the field, if they have multiple values causes additional appends to the array.
Hello,
As said in the issue #22, here is the batch processing. I solved it using an controller and a link in the form. It is working, but it needs some work done in the generic persister, because it does not overwrite existing values, it just adds new values. This is really impractical if doing batch processes multiple times. I did not know how to solve this.
Hope to hear from someone soon.