Commit 00a21c21 by Kunj

In Catalogue Variable - Combined multiple calls in single calls.

parent 9085c295
package com.vsoft.servicenow.api.listeners.get;
import com.vsoft.servicenow.db.models.CatalogueVariable;
import com.vsoft.servicenow.db.models.CatalogueVariableSet;
import java.util.List;
import com.vsoft.servicenow.db.models.CatalogueVariableResponse;
/**
* @since 1.0
......@@ -11,6 +8,6 @@ import java.util.List;
*
*/
public interface GetCatalogueVariableApiListener {
void onDoneApiCall(List<CatalogueVariableSet> variableSetList, List<CatalogueVariable> variableList);
void onDoneApiCall(CatalogueVariableResponse catalogueVariableResponse);
void onFailApiCall();
}
......@@ -48,14 +48,14 @@ public class CatalogueVariable {
@SerializedName("default_value")
@Expose
private String defaultValue;
@SerializedName("question_choice")
@Expose
private List<VariableChoice> questionChoice = null;
// @SerializedName("type")
// @Expose
private ViewType type;
private List<VariableChoice> mVariableChoiceList;
/**
*
* @return
......@@ -185,20 +185,20 @@ public class CatalogueVariable {
}
public List<VariableChoice> getVariableChoiceList() {
return mVariableChoiceList;
return questionChoice;
}
public void setVariableChoiceList(List<VariableChoice> mVariableChoiceList) {
this.mVariableChoiceList = mVariableChoiceList;
this.questionChoice = mVariableChoiceList;
}
public String[] getDisplayChoiceText(Context context) {
String[] choiceText;
if(defaultValue!=null) {
choiceText = new String[mVariableChoiceList.size() + 1];
choiceText = new String[questionChoice.size() + 1];
choiceText[0] = defaultValue;
for (int i = 0; i < mVariableChoiceList.size(); i++) {
VariableChoice variableChoice = mVariableChoiceList.get(i);
for (int i = 0; i < questionChoice.size(); i++) {
VariableChoice variableChoice = questionChoice.get(i);
/*(i+1) for add None text as a first Element*/
if(variableChoice.getMisc() > 0) {
choiceText[i + 1] = String.format(context.getString(R.string.variable_form_misc_info_string),
......@@ -209,10 +209,10 @@ public class CatalogueVariable {
}
}
} else if(isNoneRequired) {
choiceText = new String[mVariableChoiceList.size() + 1];
choiceText = new String[questionChoice.size() + 1];
choiceText[0] = context.getString(R.string.none_string);
for (int i = 0; i < mVariableChoiceList.size(); i++) {
VariableChoice variableChoice = mVariableChoiceList.get(i);
for (int i = 0; i < questionChoice.size(); i++) {
VariableChoice variableChoice = questionChoice.get(i);
/*(i+1) for add None text as a first Element*/
if(variableChoice.getMisc() > 0) {
choiceText[i + 1] = String.format(context.getString(R.string.variable_form_misc_info_string),
......@@ -223,9 +223,9 @@ public class CatalogueVariable {
}
}
} else {
choiceText = new String[mVariableChoiceList.size()];
for (int i = 0; i < mVariableChoiceList.size(); i++) {
VariableChoice variableChoice = mVariableChoiceList.get(i);
choiceText = new String[questionChoice.size()];
for (int i = 0; i < questionChoice.size(); i++) {
VariableChoice variableChoice = questionChoice.get(i);
if(variableChoice.getMisc() > 0) {
choiceText[i] = String.format(context.getString(R.string.variable_form_misc_info_string),
variableChoice.getText(),
......@@ -239,8 +239,8 @@ public class CatalogueVariable {
}
public String getDisplayChoiceText(String text) {
for (int i = 0; i < mVariableChoiceList.size(); i++) {
VariableChoice variableChoice = mVariableChoiceList.get(i);
for (int i = 0; i < questionChoice.size(); i++) {
VariableChoice variableChoice = questionChoice.get(i);
if(variableChoice.getText().equals(text)) {
return variableChoice.getValue();
}
......@@ -280,7 +280,7 @@ public class CatalogueVariable {
", active=" + active +
", defaultValue='" + defaultValue + '\'' +
", type=" + type +
", mVariableChoiceList=" + mVariableChoiceList +
", mVariableChoiceList=" + questionChoice +
'}';
}
}
package com.vsoft.servicenow.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by kunj on 16/02/17.
*/
public class CatalogueVariableResponse {
@SerializedName("variables")
@Expose
private List<CatalogueVariable> variables = null;
@SerializedName("ui_policy")
@Expose
private List<UiPolicyItem> uiPolicy = null;
@SerializedName("variablesets")
@Expose
private List<CatalogueVariableSet> variablesets = null;
public List<CatalogueVariable> getVariables() {
return variables;
}
public void setVariables(List<CatalogueVariable> variables) {
this.variables = variables;
}
public List<UiPolicyItem> getUiPolicy() {
return uiPolicy;
}
public void setUiPolicy(List<UiPolicyItem> uiPolicy) {
this.uiPolicy = uiPolicy;
}
public List<CatalogueVariableSet> getVariablesets() {
return variablesets;
}
public void setVariablesets(List<CatalogueVariableSet> variablesets) {
this.variablesets = variablesets;
}
}
......@@ -12,12 +12,15 @@ import java.util.List;
public class UiPolicyItem {
private List<UiPolicyAction> uiPolicyActions;
private List<PartialCondition> partialConditions;
@SerializedName("condition")
@Expose
private String condition;
@SerializedName("sys_id")
private String sysId;
@SerializedName("ui_policy_actions")
@Expose
private List<UiPolicyAction> uiPolicyActions;
public List<UiPolicyAction> getUiPolicyActions() {
return uiPolicyActions;
......@@ -52,4 +55,22 @@ public class UiPolicyItem {
public void setCondition(String condition) {
this.condition = condition;
}
/**
*
* @return
* The sys_id
*/
public String getSysId() {
return sysId;
}
/**
*
* @param sysId
* The sys_id
*/
public void setSysId(String sysId) {
this.sysId = sysId;
}
}
......@@ -26,7 +26,7 @@ public class AppConfig {
public static final String URL_GET_CATALOGUE_ITEM = "api/uno33/uofl_mobile/catalog_item";
/*Variable form API */
public static final String URL_GET_VARIABLE = "/api/uno33/uofl_mobile/variables";
public static final String URL_GET_VARIABLE = "api/uno33/uofl_mobile/catalogue_variable_screen";
public static final String URL_GET_UI_POLICY = "/api/uno33/uofl_mobile/uipolicy";
public static final String URL_GET_VARIABLE_CHOICE = "/api/uno33/uofl_mobile/question_choice";
public static final String URL_POST_CATALOGUE_ITEM = "api/uno33/uofl_mobile";
......
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