Closed Jheald closed 4 years ago
For this kind of elaborated edit, I would recommend using wd edit-item
and a JSON file:
Q4115189_edit.json
:
{
"id": "Q4115189",
"claims": {
"P767": [
{
"snaktype": "somevalue",
"references": [
{
"P1932": "UBL, E.",
"P248": "Q53556514",
"P5199": "000011361",
"P813": "2019-03-06"
}
]
}
]
}
}
NB: the references
value is an array of objects, with each objects counting as one reference entry that can have several properties
wd edit-item ./Q4115189_edit.json`
I feel that this functionality is basic enough that it should be more accessible. Most claims are best referenced with multiple reference fields, especially retrieved (P813) in combination with imported from (P143) or reference URL (P854).
The edit-entity method doesn't seem usable to me, as it carries too great a risk of removing existing qualifiers. The only way I see to avoid that is to first query for an existing claim, and then perform some complex logic to combine the existing claim with your new reference. I'm not thrilled about doing that myself; isn't that what libraries are for?
I was hoping to wrap wd's interface to make it easy to add a claim with a reference URL like this:
# wikidata add claim with reference
wdacwr(){
claim_guid=$(wd add-claim "$1" "$2" "$3" | jq -r .claim.id)
wd add-reference "$claim_guid" P854 "$4"
wd add-reference "$claim_guid" P813 `date --rfc-3339=date`
}
Of course, that creates two references, not one reference with two fields.
The lack of this feature makes wikibase-cli almost unusable for me.
@daniel-barrows your PR is welcome ;)
actually, given the latest developments in wikibase-edit
, that wasn't that hard to implementation: 5635ba6, published in v15.1.0
: add a reference with multiple snaks
The following works, but creates three separate references:
claim_guid=$(wd add-claim Q63313825 P767 '{"snaktype":"somevalue"}' | jd claim.id) wd add-qualifier $claim_guid P1932 'UBL, E.' wd add-reference $claim_guid P248 'Q53556514' wd add-reference $claim_guid P5199 '000011361' wd add-reference $claim_guid P813 '2019-03-06'
Is it possible to get wd ar to add just one reference, with the three parts of it grouped together?