Commit 628c9287 by Kunj Gupta

UOFLMA-78 : Fix - Reference search API changes.

parent e7724bc7
...@@ -2,15 +2,17 @@ package com.vsoft.uoflservicenow.api.interfaces; ...@@ -2,15 +2,17 @@ package com.vsoft.uoflservicenow.api.interfaces;
import com.vsoft.uoflservicenow.db.models.CatalogueItem; import com.vsoft.uoflservicenow.db.models.CatalogueItem;
import com.vsoft.uoflservicenow.db.models.CatalogueVariable; import com.vsoft.uoflservicenow.db.models.CatalogueVariable;
import com.vsoft.uoflservicenow.db.models.Reference;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
import java.util.Map;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.POST; import retrofit2.http.POST;
import retrofit2.http.Query; import retrofit2.http.Query;
import retrofit2.http.QueryMap;
import retrofit2.http.Url; import retrofit2.http.Url;
...@@ -36,7 +38,7 @@ public interface CatalogueVariableApi { ...@@ -36,7 +38,7 @@ public interface CatalogueVariableApi {
// Get Reference API // Get Reference API
@GET @GET
Call<ResponseBody> getReference(@Url String url, @Query(Reference.Json.FIRST_NAME) String firstName); Call<ResponseBody> getReference(@Url String url, @QueryMap Map<String, String> options);
} }
...@@ -24,6 +24,7 @@ import java.io.IOException; ...@@ -24,6 +24,7 @@ import java.io.IOException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
...@@ -128,11 +129,11 @@ public class VariableChoiceApiManager { ...@@ -128,11 +129,11 @@ public class VariableChoiceApiManager {
} }
} }
public static SyncStatus getReference(String tableName, String firstName, GetReferenceApiListener listener) { public static SyncStatus getReference(String tableName, Map<String,String> queryMap, GetReferenceApiListener listener) {
CatalogueLog.d("VariableChoiceApiManager: getReference: tableName: "+tableName); CatalogueLog.d("VariableChoiceApiManager: getReference: tableName: "+tableName);
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).getReference(Constants.URL_GET_REFERENCE + tableName, firstName); Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).getReference(Constants.URL_GET_REFERENCE + tableName, queryMap);
try { try {
//Retrofit synchronous call //Retrofit synchronous call
Response<ResponseBody> response = call.execute(); Response<ResponseBody> response = call.execute();
......
...@@ -39,6 +39,9 @@ public class CatalogueVariable { ...@@ -39,6 +39,9 @@ public class CatalogueVariable {
@SerializedName("order") @SerializedName("order")
@Expose @Expose
private int order; private int order;
@SerializedName("reference_display_column")
@Expose
private String referenceColumnName;
// @SerializedName("type") // @SerializedName("type")
// @Expose // @Expose
...@@ -150,6 +153,14 @@ public class CatalogueVariable { ...@@ -150,6 +153,14 @@ public class CatalogueVariable {
this.order = order; this.order = order;
} }
public String getReferenceColumnName() {
return referenceColumnName;
}
public void setReferenceColumnName(String referenceColumnName) {
this.referenceColumnName = referenceColumnName;
}
public List<VariableChoice> getVariableChoiceList() { public List<VariableChoice> getVariableChoiceList() {
return mVariableChoiceList; return mVariableChoiceList;
} }
......
...@@ -32,7 +32,9 @@ import com.vsoft.uoflservicenow.utils.DialogUtils; ...@@ -32,7 +32,9 @@ import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.Util; import com.vsoft.uoflservicenow.utils.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
...@@ -54,7 +56,7 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -54,7 +56,7 @@ public class SelectReferenceDialog extends DialogFragment {
private ReferenceListener mListener; private ReferenceListener mListener;
private Unbinder mUnbinder; private Unbinder mUnbinder;
private List<Reference> mReferenceList; private List<Reference> mReferenceList;
private String mReferenceTableName, mReferenceTitle; private String mReferenceTableName, mReferenceColumnName, mReferenceTitle;
private CatalogueApplication mApplication; private CatalogueApplication mApplication;
public SelectReferenceDialog() { public SelectReferenceDialog() {
...@@ -65,11 +67,12 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -65,11 +67,12 @@ public class SelectReferenceDialog extends DialogFragment {
mListener = listener; mListener = listener;
} }
public static SelectReferenceDialog newInstance(String tableName, String title) { public static SelectReferenceDialog newInstance(String tableName, String columnName, String title) {
SelectReferenceDialog selectReferenceDialog = new SelectReferenceDialog(); SelectReferenceDialog selectReferenceDialog = new SelectReferenceDialog();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(Constants.DATA_KEY_REFERENCE_TABLE_NAME, tableName); bundle.putString(Constants.DATA_KEY_REFERENCE_TABLE_NAME, tableName);
bundle.putString(Constants.DATA_KEY_REFERENCE_TABLE_COLUMN_NAME, columnName);
bundle.putString(Constants.DATA_KEY_REFERENCE_TITLE, title); bundle.putString(Constants.DATA_KEY_REFERENCE_TITLE, title);
selectReferenceDialog.setArguments(bundle); selectReferenceDialog.setArguments(bundle);
...@@ -83,6 +86,7 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -83,6 +86,7 @@ public class SelectReferenceDialog extends DialogFragment {
mApplication = (CatalogueApplication) getActivity().getApplication(); mApplication = (CatalogueApplication) getActivity().getApplication();
mReferenceTableName = getArguments().getString(Constants.DATA_KEY_REFERENCE_TABLE_NAME); mReferenceTableName = getArguments().getString(Constants.DATA_KEY_REFERENCE_TABLE_NAME);
mReferenceColumnName = getArguments().getString(Constants.DATA_KEY_REFERENCE_TABLE_COLUMN_NAME);
mReferenceTitle = getArguments().getString(Constants.DATA_KEY_REFERENCE_TITLE); mReferenceTitle = getArguments().getString(Constants.DATA_KEY_REFERENCE_TITLE);
} }
...@@ -168,7 +172,9 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -168,7 +172,9 @@ public class SelectReferenceDialog extends DialogFragment {
@Override @Override
protected SyncStatus doInBackground(String... params) { protected SyncStatus doInBackground(String... params) {
return VariableChoiceApiManager.getReference(mReferenceTableName, params[0], new GetReferenceApiListener() { Map<String, String> stringMap = new HashMap<>(1);
stringMap.put(mReferenceColumnName, params[0]);
return VariableChoiceApiManager.getReference(mReferenceTableName, stringMap, new GetReferenceApiListener() {
@Override @Override
public void onDoneApiCall(List<Reference> referenceList) { public void onDoneApiCall(List<Reference> referenceList) {
mReferenceList = referenceList; mReferenceList = referenceList;
......
...@@ -460,8 +460,9 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -460,8 +460,9 @@ public class CatalogueVariableScreen extends AppCompatActivity {
TagObject tagObject = (TagObject)v.getTag(); TagObject tagObject = (TagObject)v.getTag();
CatalogueVariable catalogueVariable = mCatalogueVariableList.get(tagObject.getIndex()); CatalogueVariable catalogueVariable = mCatalogueVariableList.get(tagObject.getIndex());
String tableName = catalogueVariable.getReferenceTable(); String tableName = catalogueVariable.getReferenceTable();
String columnName = catalogueVariable.getReferenceColumnName();
String title = catalogueVariable.getQuestionText(); String title = catalogueVariable.getQuestionText();
SelectReferenceDialog spinnerDialog = SelectReferenceDialog.newInstance(tableName, title); SelectReferenceDialog spinnerDialog = SelectReferenceDialog.newInstance(tableName, columnName, title);
spinnerDialog.setListener(listener); spinnerDialog.setListener(listener);
spinnerDialog.show(fm, ""); spinnerDialog.show(fm, "");
return true; return true;
......
...@@ -27,6 +27,7 @@ public class Constants { ...@@ -27,6 +27,7 @@ public class Constants {
public static final String DATA_KEY_CATALOGUE_ITEM_DESCRIPTION = "catalogue_item_des"; public static final String DATA_KEY_CATALOGUE_ITEM_DESCRIPTION = "catalogue_item_des";
public static final String DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION = "catalogue_item_short_des"; public static final String DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION = "catalogue_item_short_des";
public static final String DATA_KEY_REFERENCE_TABLE_NAME = "table_name"; public static final String DATA_KEY_REFERENCE_TABLE_NAME = "table_name";
public static final String DATA_KEY_REFERENCE_TABLE_COLUMN_NAME = "table_column_name";
public static final String DATA_KEY_REFERENCE_TITLE = "title"; public static final String DATA_KEY_REFERENCE_TITLE = "title";
/** /**
......
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