Commit 54d3d903 by Kunj Gupta

UOFLMA-68: Added one more field "Order" in Variable Form, for sorting all items.

parent 8d8bd9c3
...@@ -93,7 +93,6 @@ public class CatalogueVariableApiManager { ...@@ -93,7 +93,6 @@ public class CatalogueVariableApiManager {
JSONObject variableJsonObject = catalogueVariableJsonArray.getJSONObject(i); JSONObject variableJsonObject = catalogueVariableJsonArray.getJSONObject(i);
CatalogueVariable catalogueVariable = gson.fromJson(variableJsonObject.toString(), CatalogueVariable.class); CatalogueVariable catalogueVariable = gson.fromJson(variableJsonObject.toString(), CatalogueVariable.class);
catalogueVariable.parseJson(variableJsonObject); catalogueVariable.parseJson(variableJsonObject);
// if(catalogueVariable.getName()!=null)
catalogueVariableList.add(catalogueVariable); catalogueVariableList.add(catalogueVariable);
} }
listener.onDoneApiCall(catalogueVariableList); listener.onDoneApiCall(catalogueVariableList);
......
...@@ -17,7 +17,6 @@ import java.util.List; ...@@ -17,7 +17,6 @@ import java.util.List;
* Created by Kunj on 12/8/16. * Created by Kunj on 12/8/16.
*/ */
public class CatalogueVariable { public class CatalogueVariable {
private long catalogue_item_id = -1;
@SerializedName("name") @SerializedName("name")
@Expose @Expose
...@@ -37,6 +36,9 @@ public class CatalogueVariable { ...@@ -37,6 +36,9 @@ public class CatalogueVariable {
@SerializedName("reference_table") @SerializedName("reference_table")
@Expose @Expose
private String referenceTable; private String referenceTable;
@SerializedName("order")
@Expose
private int order;
// @SerializedName("type") // @SerializedName("type")
// @Expose // @Expose
...@@ -44,14 +46,6 @@ public class CatalogueVariable { ...@@ -44,14 +46,6 @@ public class CatalogueVariable {
private List<VariableChoice> mVariableChoiceList; private List<VariableChoice> mVariableChoiceList;
public long getCatalogueItemId() {
return catalogue_item_id;
}
public void setCatalogueItemId(long catalogue_item_id) {
this.catalogue_item_id = catalogue_item_id;
}
/** /**
* *
* @return * @return
...@@ -148,6 +142,14 @@ public class CatalogueVariable { ...@@ -148,6 +142,14 @@ public class CatalogueVariable {
this.referenceTable = referenceTable; this.referenceTable = referenceTable;
} }
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public List<VariableChoice> getVariableChoiceList() { public List<VariableChoice> getVariableChoiceList() {
return mVariableChoiceList; return mVariableChoiceList;
} }
...@@ -202,18 +204,19 @@ public class CatalogueVariable { ...@@ -202,18 +204,19 @@ public class CatalogueVariable {
public static class Json { public static class Json {
public static final String SYS_ID = "sys_id"; public static final String SYS_ID = "sys_id";
public static final String TYPE = "type"; public static final String TYPE = "type";
public static final String ORDER = "order";
} }
@Override @Override
public String toString() { public String toString() {
return "CatalogueVariable{" + return "CatalogueVariable{" +
", catalogue_item_id=" + catalogue_item_id + "name='" + name + '\'' +
", name='" + name + '\'' +
", questionText='" + questionText + '\'' + ", questionText='" + questionText + '\'' +
", sysId='" + sysId + '\'' + ", sysId='" + sysId + '\'' +
", mandatory=" + mandatory + ", mandatory=" + mandatory +
", isNoneRequired=" + isNoneRequired + ", isNoneRequired=" + isNoneRequired +
", referenceTable='" + referenceTable + '\'' + ", referenceTable='" + referenceTable + '\'' +
", order=" + order +
", type=" + type + ", type=" + type +
", mVariableChoiceList=" + mVariableChoiceList + ", mVariableChoiceList=" + mVariableChoiceList +
'}'; '}';
......
...@@ -49,6 +49,8 @@ import org.json.JSONException; ...@@ -49,6 +49,8 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import butterknife.BindView; import butterknife.BindView;
...@@ -133,6 +135,14 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -133,6 +135,14 @@ public class CatalogueVariableScreen extends AppCompatActivity {
@Override @Override
public void onDoneApiCall(List<CatalogueVariable> catalogueVariableList) { public void onDoneApiCall(List<CatalogueVariable> catalogueVariableList) {
CatalogueLog.e("Data: catalogueVariableList: " + catalogueVariableList); CatalogueLog.e("Data: catalogueVariableList: " + catalogueVariableList);
Collections.sort(catalogueVariableList, new Comparator<CatalogueVariable>() {
@Override
public int compare(CatalogueVariable lhs, CatalogueVariable rhs) {
return (lhs.getOrder() - rhs.getOrder());
}
});
mCatalogueVariableList = catalogueVariableList; mCatalogueVariableList = catalogueVariableList;
if(!catalogueVariableList.isEmpty()) { if(!catalogueVariableList.isEmpty()) {
...@@ -211,7 +221,7 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -211,7 +221,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
for (int i = 0; i < mCatalogueVariableList.size(); i++) { for (int i = 0; i < mCatalogueVariableList.size(); i++) {
CatalogueVariable catalogueVariable = mCatalogueVariableList.get(i); CatalogueVariable catalogueVariable = mCatalogueVariableList.get(i);
ViewType viewType = catalogueVariable.getType(); ViewType viewType = catalogueVariable.getType();
CatalogueLog.e("viewType: " + viewType); CatalogueLog.e("viewType: " + viewType + ", Order: "+catalogueVariable.getOrder());
if (catalogueVariable.getName() == null) { if (catalogueVariable.getName() == null) {
TextView nameNullView = new TextView(CatalogueVariableScreen.this); TextView nameNullView = new TextView(CatalogueVariableScreen.this);
nameNullView.setText(R.string.name_null_view_string); nameNullView.setText(R.string.name_null_view_string);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment