Wikidata / Wikidata-Toolkit

Java library to interact with Wikibase
https://www.mediawiki.org/wiki/Wikidata_Toolkit
Apache License 2.0
375 stars 99 forks source link

Port to Android #356

Open nicolas-raoul opened 6 years ago

nicolas-raoul commented 6 years ago

As a developer of the Commons Android app, I would like to use a Java library to add P18 (image) statements from the app (the app directs the user to nearby points of interest missing a P18 to take pictures of them).

It would be great if there were an Android-compatible small library that allowed that. If there is already one that I have missed, please let me know, thanks :-)

Tpt commented 6 years ago

It would be great indeed to make WikidataToolkit work with Android. I am not much familiar with it. It would be amazing if you could do a pull request for this.

Tpt commented 6 years ago

The new 0.9.0 release should work with Android. @nicolas-raoul If you have some time may you test?

maskaravivek commented 6 years ago

@Tpt Is there any documentation to easily get started on it :)

Tpt commented 6 years ago

@maskaravivek The documentation is here with links to example: https://www.mediawiki.org/wiki/Wikidata_Toolkit

Feel free to ask anything you need :-)

Tpt commented 6 years ago

About the WikidataToolkit dependencies: we could definitely consider to move from one JSON deserialization library or HTTP client to an other if it makes the Android use case much more appealing.

mikeklein commented 4 years ago

A little late to the party here...but I am seeing failure on Android whereas toolkit works fine under Spring.

Am receiving null for a well known QID (any qid actually) with following code:

    WikibaseDataFetcher wbdf = getWikibaseDataFetcher("en");
    EntityDocument edoc = wbdf.getEntityDocument(qid);

The QID is 26303...Thales a pre-socratic philosopher. Any ideas of why it is failing?

Tpt commented 4 years ago

@mikeklein Hi! Sorry for the problem. It's strange. If the API call where failing (no network, invalid host...), the code would have returned an exception instead. Are you sure that your qid is valid and you are reaching Wikidata (and not test Wikidata, Commons...)? It's hard to get a good understanding of what your code is doing from just two lines of code.

wetneb commented 4 years ago

Just to be sure we are on the same page, the qid should be a string containing "Q36303", not "36303".

mikeklein commented 4 years ago

Hello and thanks for quick response. I just found that the problem "magickally" went away an hour ago.

I did debug earlier and it was throwing following error btw:

Error when reading JSON for entity Q80612: com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of org.wikidata.wdtk.datamodel.implementation.TermImpl, problem: Exception from call site #30 bootstrap method at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: org.wikidata.wdtk.datamodel.implementation.ItemDocumentImpl["labels"]→java.util.LinkedHashMap["en"])

And yes the Q was part of string param value...thanks.