Fix issue 3526 Unlike "Items" tab, "child classes" tab does not display description nor image thumbnail (#3619)

* fix thumbnail issue 3526

* Fix Description issue 3526

* revert changes on this file, not finished with it yet

* Fix Description for Child and Parent classes - issue 3526

* Remove conflict text in file

* Remove retrofit.HEAD import

* Incorporated review comments
This commit is contained in:
vvijayalakshmi21 2020-04-10 15:26:14 +05:30 committed by GitHub
parent 628a6056e0
commit 62f176443b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 98 additions and 6 deletions

View file

@ -13,7 +13,9 @@ public class Binding {
@SerializedName("subclassLabel")
@Expose
private SubclassLabel subclassLabel;
@SerializedName("subclassDescription")
@Expose
private SubclassDescription subclassDescription;
/**
* No args constructor for use in serialization
*
@ -26,10 +28,11 @@ public class Binding {
* @param subclassLabel
* @param subclass
*/
public Binding(Subclass subclass, SubclassLabel subclassLabel) {
public Binding(Subclass subclass, SubclassLabel subclassLabel, SubclassDescription subclassDescription) {
super();
this.subclass = subclass;
this.subclassLabel = subclassLabel;
this.subclassDescription = subclassDescription;
}
public Subclass getSubclass() {
@ -44,8 +47,16 @@ public class Binding {
return subclassLabel;
}
public SubclassDescription getSubclassDescription(){
return subclassDescription;
}
public void setSubclassLabel(SubclassLabel subclassLabel) {
this.subclassLabel = subclassLabel;
}
public void setSubclassDescription(SubclassDescription subclassDescription) {
this.subclassDescription = subclassDescription;
}
}

View file

@ -0,0 +1,68 @@
package fr.free.nrw.commons.depictions.SubClass.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Model class for parsing SparqlQueryResponse
*/
public class SubclassDescription {
@SerializedName("type")
@Expose
private String type;
@SerializedName("value")
@Expose
private String value;
@SerializedName("xml:lang")
@Expose
private String xmlLang;
/**
* No args constructor for use in serialization
*
*/
public SubclassDescription() {
}
/**
*
* @param value
* @param xmlLang
* @param type
*/
public SubclassDescription(String type, String value, String xmlLang) {
super();
this.type = type;
this.value = value;
this.xmlLang = xmlLang;
}
public String getType() {
return type;
}
/**
* returns type
*/
public void setType(String type) {
this.type = type;
}
/**
* gets value of the depiction
*/
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
/**
* get language in which the depiction was requested
*/
public String getXmlLang() {
return xmlLang;
}
}

View file

@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
import com.google.gson.Gson;
import fr.free.nrw.commons.depictions.SubClass.models.SubclassDescription;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -242,7 +243,13 @@ public class OkHttpJsonApiClient {
String label = binding.getSubclassLabel().getValue();
String entityId = binding.getSubclass().getValue();
entityId = entityId.substring(entityId.lastIndexOf("/") + 1);
subItems.add(new DepictedItem(label, "", "", false,entityId ));
String description = "";
SubclassDescription subclassDescription = binding.getSubclassDescription();
if (subclassDescription != null
&& subclassDescription.getXmlLang() != null) {
description = subclassDescription.getValue();
}
subItems.add(new DepictedItem(label, description, "", false, entityId));
Timber.e(label);
}
}
@ -288,7 +295,13 @@ public class OkHttpJsonApiClient {
if (parentClass.get("value") != null) {
String entityId = parentClass.getString("value");
entityId = entityId.substring(entityId.lastIndexOf("/") + 1);
subItems.add(new DepictedItem(labelString, "", "", false, entityId));
String description = "";
if (!object.isNull("parentClassDescription")) {
JSONObject parentClassDescription = (JSONObject) object
.get("parentClassDescription");
description = parentClassDescription.getString("value");
}
subItems.add(new DepictedItem(labelString, description, "", false, entityId));
}
}
}

View file

@ -1,4 +1,4 @@
SELECT ?parentClass ?parentClassLabel WHERE {
SELECT ?parentClass ?parentClassLabel ?parentClassDescription WHERE {
wd:${QID} wdt:P279 ?parentClass.
SERVICE wikibase:label { bd:serviceParam wikibase:language ${LANG}. }
}

View file

@ -1,4 +1,4 @@
SELECT ?subclass ?subclassLabel WHERE {
SELECT ?subclass ?subclassLabel ?subclassDescription WHERE {
?subclass wdt:P279 wd:${QID}.
SERVICE wikibase:label { bd:serviceParam wikibase:language ${LANG}. }
}