mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Fix p18 issue For an item with P18 item, do not add another one (#3527)
* Add p18value variable to contrib * set place.pic to candidate contribution * Add p18 value to contrib * Passes p18 value to wikidata upload service * Checks if pic parameter of the wikidata item is empty or not. If not, it does not overrides the existing image, it is just a regular commons upload. * Make public var private * Make current tests pass * Add test case for p18 value is not empty * Fix wrong log message * Add nonnul annotation and fix method javadoc
This commit is contained in:
parent
bdb61dfda6
commit
e5d5a7af92
5 changed files with 40 additions and 10 deletions
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.wikidata;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -45,10 +46,11 @@ public class WikidataEditService {
|
|||
|
||||
/**
|
||||
* Create a P18 claim and log the edit with custom tag
|
||||
* @param wikidataEntityId
|
||||
* @param fileName
|
||||
* @param wikidataEntityId a unique id of each Wikidata items
|
||||
* @param fileName name of the file we will upload
|
||||
* @param p18Value pic attribute of Wikidata item
|
||||
*/
|
||||
public void createClaimWithLogging(String wikidataEntityId, String fileName) {
|
||||
public void createClaimWithLogging(String wikidataEntityId, String fileName, @NonNull String p18Value) {
|
||||
if (wikidataEntityId == null) {
|
||||
Timber.d("Skipping creation of claim as Wikidata entity ID is null");
|
||||
return;
|
||||
|
|
@ -64,6 +66,11 @@ public class WikidataEditService {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!p18Value.trim().isEmpty()) {
|
||||
Timber.d("Skipping creation of claim as p18Value is not empty, we won't override existing image");
|
||||
return;
|
||||
}
|
||||
|
||||
editWikidataProperty(wikidataEntityId, fileName);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue