Ok, here is my suggestion for wbsetclaim:
* we introduce a new optional parameter "id"
* if a guid is set inside the claim serialization, change that claim if it
exists and return an error if that claim is unknown.
* if no guid is set in the claim serialization, create a new claim for the
entity identified by the new parameter "id". if "id" is not set,
return an
error.
This would be a breaking change for all users that are creating claims
through wbsetclaim at the moment. This would not break for any other user.
comments?
cheers, tobi
On Wed, Feb 26, 2014 at 8:19 PM, addshorewiki <addshorewiki(a)gmail.com>wrote;wrote:
I realise I should probably have included the example
that is in the API
doc so here it goes:
Creates a new claim on the item for the property P56 and a value of
"ExampleString":action=wbeditentity&id=Q42&data={"claims":[{"mainsnak":{"snaktype":"value","property":"P56","datavalue":{"value":"ExampleString","type":"string"}},"type":"statement","rank":"normal"}]}
<http://www.wikidata.org/w/api.php?action=wbeditentity&id=Q42&data=%7B%22claims%22:[%7B%22mainsnak%22:%7B%22snaktype%22:%22value%22,%22property%22:%22P56%22,%22datavalue%22:%7B%22value%22:%22ExampleString%22,%22type%22:%22string%22%7D%7D,%22type%22:%22statement%22,%22rank%22:%22normal%22%7D]%7D>
Removes the claims from the item with the guids q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F
and
q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X:action=wbeditentity&id=Q42&data={"claims":[{"id":"Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F","remove":""},{"id":"Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X","remove":""}]}
<http://www.wikidata.org/w/api.php?action=wbeditentity&id=Q42&data=%7B%22claims%22:[%7B%22id%22:%22Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F%22,%22remove%22:%22%22%7D,%7B%22id%22:%22Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X%22,%22remove%22:%22%22%7D]%7D>
Sets the claim with the GUID to the value of the
claim:action=wbeditentity&id=Q42&data={"claims":[{"id":"Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X","mainsnak":{"snaktype":"value","property":"P56","datavalue":{"value":"ChangedString","type":"string"}},"type":"statement","rank":"normal"}]}
<http://www.wikidata.org/w/api.php?action=wbeditentity&id=Q42&data=%7B%22claims%22:[%7B%22id%22:%22Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X%22,%22mainsnak%22:%7B%22snaktype%22:%22value%22,%22property%22:%22P56%22,%22datavalue%22:%7B%22value%22:%22ChangedString%22,%22type%22:%22string%22%7D%7D,%22type%22:%22statement%22,%22rank%22:%22normal%22%7D]%7D>
Addshore
On 26 February 2014 19:01, Markus Krötzsch <markus(a)semantic-mediawiki.org>wrote;wrote:
On 26/02/14 18:41, Jeroen De Dauw wrote:
Hey,
> you can create claims with wbsetclaim. But
you would need to create
a valid
> GUID [1] yourself. The claim-GUID you send
with your request needs
to be
> <entityId>$<GUID> (e.g.
Q2$5627445f-43cb-ed6d-3adb-760e66bd17ee).
Uh, didn't we fix this a long time ago?
Client-Supplied GUIDs are
evil :(
This has come up at some point, and as far as I recall, we dropped the
requirement to provide the GUID. So I suspect one can provide a claim
without a GUID, else something went wrong somewhere.
Requests with GUIDs that are not associated with
any Statement should
be rejected
Not allowing specifying GUIDs is another topic altogether. Disallowing
them is not the intention of the current system, and needs discussion
before that is changed. This seems to be both out of scope of this
thread and be way to low on the priority list (after all, where is the
problem, its been working just fine) to spend time on.
As Daniel said: "Client-Supplied GUIDs are evil :(". My only point was
that one should never use such GUIDs for new statements. Returning an error
seems better than just creating a new GUID, but both would work. Mainly, we
should not use externally provided GUIDs. For example, if somebody is
mistaken to believe that any string of the proper format can be used, then
we might get bot code where the "GUID" is based on a constant. Wikibase
should better make sure that it uses quality GUIDs, which are as random as
a GUID is supposed to be.
Markus
_______________________________________________
Wikidata-tech mailing list
Wikidata-tech(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
_______________________________________________
Wikidata-tech mailing list
Wikidata-tech(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
--
Tobi Gritschacher
Software Developer - Wikidata -
http://www.wikidata.org
Imagine a world, in which every single human being can freely
share in the sum of all knowledge. That's our commitment.
Wikimedia Deutschland e.V. | Tempelhofer Ufer 23-24 | 10963 Berlin
Phone +49 (0)30 219 158 260
http://wikimedia.de <http://www.wikimedia.de/>
Wikimedia Deutschland - Gesellschaft zur Förderung Freien Wissens e.V.
Eingetragen im Vereinsregister des Amtsgerichts Berlin-Charlottenburg unter
der Nummer 23855 B. Als gemeinnützig anerkannt durch das Finanzamt für
Körperschaften I Berlin, Steuernummer 27/681/51985.