Commit 67ff5765 by Kunj Gupta

UOFLMA-118: implemented API to modify Dynamic Form according to UI Policies.

parent 44225f97
Showing with 502 additions and 108 deletions
...@@ -30,7 +30,7 @@ public class HomeScreenAdapter extends BaseAdapter { ...@@ -30,7 +30,7 @@ public class HomeScreenAdapter extends BaseAdapter {
@Override @Override
public int getCount() { public int getCount() {
// Number of times getView method call depends upon mGridValues.length // Number of times getVariableViewContainer method call depends upon mGridValues.length
return mGridValues.length; return mGridValues.length;
} }
...@@ -44,7 +44,7 @@ public class HomeScreenAdapter extends BaseAdapter { ...@@ -44,7 +44,7 @@ public class HomeScreenAdapter extends BaseAdapter {
return position; return position;
} }
// Number of times getView method call depends upon mGridValues.length // Number of times getVariableViewContainer method call depends upon mGridValues.length
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder; ViewHolder holder;
......
package com.vsoft.uoflservicenow.api; package com.vsoft.uoflservicenow.api;
import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
...@@ -18,53 +21,16 @@ import retrofit2.converter.gson.GsonConverterFactory; ...@@ -18,53 +21,16 @@ import retrofit2.converter.gson.GsonConverterFactory;
*/ */
public class RestClient { public class RestClient {
public static Retrofit getInitializedRestAdapter(final String accessToken) {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
Interceptor interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder();
if(!TextUtils.isEmpty(accessToken)) {
final String bearer = "Bearer " + accessToken;
requestBuilder.header(Constants.API_HEADER_PARAM_AUTHORIZATION, bearer);
}
requestBuilder.header("Accept", "application/json");
requestBuilder.header("Content-Type", "application/json");
requestBuilder.method(original.method(), original.body());
Request request = requestBuilder.build();
try {
return chain.proceed(request);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
};
httpClient.interceptors().add(interceptor);
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.interceptors().add(logging);
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(Constants.DOMAIN)
.client(httpClient.build())
.addConverterFactory(new GsonStringConverterFactory())
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
public static Retrofit getInitializedRestAdapter(String username, String password) { public static Retrofit getInitializedRestAdapter(String username, String password) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level // set your desired log level
logging.setLevel(HttpLoggingInterceptor.Level.BODY); logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); OkHttpClient.Builder httpClient = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS);
String credentials = username + ":" + password; String credentials = username + ":" + password;
final String basic = final String basic =
"Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
...@@ -101,51 +67,15 @@ public class RestClient { ...@@ -101,51 +67,15 @@ public class RestClient {
return builder.build(); return builder.build();
} }
public static Retrofit getInitializedRestAdapterWithOutHeader(String username, String password) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
String credentials = username + ":" + password;
final String basic =
"Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
// add your other interceptors
Interceptor interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder()
.header(Constants.API_HEADER_PARAM_AUTHORIZATION, basic);
requestBuilder.method(original.method(), original.body());
Request request = requestBuilder.build();
try {
return chain.proceed(request);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
};
httpClient.interceptors().add(interceptor);
// add logging as last interceptor
httpClient.interceptors().add(logging); // <-- this is the important line!
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(Constants.DOMAIN)
.client(httpClient.build())
.addConverterFactory(new GsonStringConverterFactory())
.addConverterFactory(GsonConverterFactory.create());
return builder.build();
}
public static Retrofit getInitializedRestAdapterWithOutAuthorizationHeader() { public static Retrofit getInitializedRestAdapterWithOutAuthorizationHeader() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level // set your desired log level
logging.setLevel(HttpLoggingInterceptor.Level.BODY); logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); OkHttpClient.Builder httpClient = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS);
// add your other interceptors // add your other interceptors
Interceptor interceptor = new Interceptor() { Interceptor interceptor = new Interceptor() {
@Override @Override
......
...@@ -49,6 +49,10 @@ public interface CatalogueVariableApi { ...@@ -49,6 +49,10 @@ public interface CatalogueVariableApi {
@Query(Constants.URL_PARAM_TABLE_NAME) String tableName, @Query(Constants.URL_PARAM_TABLE_NAME) String tableName,
@Query(Constants.URL_PARAM_FILE_NAME) String fileName, @Query(Constants.URL_PARAM_FILE_NAME) String fileName,
@Body RequestBody attachmentRequestBody); @Body RequestBody attachmentRequestBody);
// Get Variable API
@GET(Constants.URL_GET_UI_POLICY)
Call<ResponseBody> getUiPolicy(@Query(CatalogueVariable.Json.SYS_ID) String sysId);
} }
package com.vsoft.uoflservicenow.api.listeners.get;
import com.vsoft.uoflservicenow.db.models.UiPolicyItem;
import java.util.List;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface GetUiPolicyApiListener {
void onDoneApiCall(List<UiPolicyItem> uiPolicyItemList);
}
...@@ -101,8 +101,8 @@ public class CatalogueApiManager { ...@@ -101,8 +101,8 @@ public class CatalogueApiManager {
final List<Catalogue> catalogueList = new ArrayList<>(catalogueJsonArray.length()); final List<Catalogue> catalogueList = new ArrayList<>(catalogueJsonArray.length());
final List<Catalogue> finalCatalogueList = new ArrayList<>(catalogueJsonArray.length()); final List<Catalogue> finalCatalogueList = new ArrayList<>(catalogueJsonArray.length());
for (int i = 0; i < catalogueJsonArray.length(); i++) { for (int i = 0; i < catalogueJsonArray.length(); i++) {
JSONObject expenseJsonObject = catalogueJsonArray.getJSONObject(i); JSONObject catalogueJsonObject = catalogueJsonArray.getJSONObject(i);
Catalogue catalogue = gson.fromJson(expenseJsonObject.toString(), Catalogue.class); Catalogue catalogue = gson.fromJson(catalogueJsonObject.toString(), Catalogue.class);
catalogueList.add(catalogue); catalogueList.add(catalogue);
} }
if(!catalogueList.isEmpty()) { if(!catalogueList.isEmpty()) {
...@@ -208,8 +208,8 @@ public class CatalogueApiManager { ...@@ -208,8 +208,8 @@ public class CatalogueApiManager {
List<CatalogueOrder> catalogueOrderList = new ArrayList<>(catalogueOrderJsonArray.length()); List<CatalogueOrder> catalogueOrderList = new ArrayList<>(catalogueOrderJsonArray.length());
for (int i = 0; i < catalogueOrderJsonArray.length(); i++) { for (int i = 0; i < catalogueOrderJsonArray.length(); i++) {
JSONObject expenseJsonObject = catalogueOrderJsonArray.getJSONObject(i); JSONObject orderJsonObject = catalogueOrderJsonArray.getJSONObject(i);
CatalogueOrder catalogueOrder = gson.fromJson(expenseJsonObject.toString(), CatalogueOrder.class); CatalogueOrder catalogueOrder = gson.fromJson(orderJsonObject.toString(), CatalogueOrder.class);
catalogueOrderList.add(catalogueOrder); catalogueOrderList.add(catalogueOrder);
} }
......
...@@ -97,8 +97,8 @@ public class CatalogueItemApiManager { ...@@ -97,8 +97,8 @@ public class CatalogueItemApiManager {
List<CatalogueItem> catalogueItemList = new ArrayList<>(catalogueItemJsonArray.length()); List<CatalogueItem> catalogueItemList = new ArrayList<>(catalogueItemJsonArray.length());
for (int i = 0; i < catalogueItemJsonArray.length(); i++) { for (int i = 0; i < catalogueItemJsonArray.length(); i++) {
JSONObject expenseJsonObject = catalogueItemJsonArray.getJSONObject(i); JSONObject catalogueItemJsonObject = catalogueItemJsonArray.getJSONObject(i);
CatalogueItem catalogueItem = gson.fromJson(expenseJsonObject.toString(), CatalogueItem.class); CatalogueItem catalogueItem = gson.fromJson(catalogueItemJsonObject.toString(), CatalogueItem.class);
catalogueItemList.add(catalogueItem); catalogueItemList.add(catalogueItem);
} }
listener.onDoneApiCall(catalogueItemList); listener.onDoneApiCall(catalogueItemList);
......
...@@ -9,9 +9,12 @@ import com.google.gson.JsonParseException; ...@@ -9,9 +9,12 @@ import com.google.gson.JsonParseException;
import com.vsoft.uoflservicenow.api.RestClient; import com.vsoft.uoflservicenow.api.RestClient;
import com.vsoft.uoflservicenow.api.interfaces.CatalogueVariableApi; import com.vsoft.uoflservicenow.api.interfaces.CatalogueVariableApi;
import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueVariableApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueVariableApiListener;
import com.vsoft.uoflservicenow.api.listeners.get.GetUiPolicyApiListener;
import com.vsoft.uoflservicenow.api.listeners.post.PostVariableFormApiListener; import com.vsoft.uoflservicenow.api.listeners.post.PostVariableFormApiListener;
import com.vsoft.uoflservicenow.db.models.CatalogueVariable; import com.vsoft.uoflservicenow.db.models.CatalogueVariable;
import com.vsoft.uoflservicenow.db.models.CatalogueVariableSet; import com.vsoft.uoflservicenow.db.models.CatalogueVariableSet;
import com.vsoft.uoflservicenow.db.models.UiPolicyAction;
import com.vsoft.uoflservicenow.db.models.UiPolicyItem;
import com.vsoft.uoflservicenow.enums.SyncStatus; import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog; import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
...@@ -168,11 +171,106 @@ public class CatalogueVariableApiManager { ...@@ -168,11 +171,106 @@ public class CatalogueVariableApiManager {
} }
} }
public static SyncStatus submitVariableForm(String catalogueItemSysId, JSONArray catalogueJsonArray, PostVariableFormApiListener listener) { public static SyncStatus getUiPolicy(String catalogueItemSysId, GetUiPolicyApiListener listener) {
CatalogueLog.d("submitVariableForm: " + catalogueJsonArray); CatalogueLog.d("CatalogueVariableApiManager: getUiPolicy: ");
String expenseJsonString = catalogueJsonArray.toString();
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).postCatalogueItem(catalogueItemSysId, expenseJsonString); Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).getUiPolicy(catalogueItemSysId);
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if (response.isSuccessful()) {
try {
JSONObject jsonObject = new JSONObject(response.body().string());
JSONObject error = jsonObject.optJSONObject(Constants.RESPONSE_ERROR_OBJECT_NAME);
if (error == null) {
JSONArray resultJsonArray = jsonObject.getJSONArray(Constants.RESPONSE_RESULT_OBJECT_NAME);
if(resultJsonArray.length() > 0) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(long.class, new JsonDeserializer<Long>() {
@Override
public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
long value = 0;
try {
value = json.getAsLong();
} catch (NumberFormatException e) {
CatalogueLog.d("CatalogueVariableApiManager: getUiPolicy: deserialize: long.class: NumberFormatException: ");
}
return value;
}
})
.registerTypeAdapter(int.class, new JsonDeserializer<Integer>() {
@Override
public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
int value = 0;
try {
value = json.getAsInt();
} catch (NumberFormatException e) {
CatalogueLog.d("CatalogueVariableApiManager: getUiPolicy: deserialize: int.class: NumberFormatException: ");
}
return value;
}
})
.registerTypeAdapter(float.class, new JsonDeserializer<Float>() {
@Override
public Float deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
float value = 0;
try {
value = json.getAsFloat();
} catch (NumberFormatException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: deserialize: float.class: NumberFormatException: ", e);
}
return value;
}
})
.create();
JSONArray uiPolicyJsonArray = resultJsonArray.getJSONArray(0);
List<UiPolicyItem> uiPolicyItemList = new ArrayList<>(uiPolicyJsonArray.length());
for (int i = 0; i < uiPolicyJsonArray.length(); i++) {
JSONObject UiPolicyResponseJsonObject = uiPolicyJsonArray.getJSONObject(i);
UiPolicyItem uiPolicyItem = gson.fromJson(UiPolicyResponseJsonObject.toString(), UiPolicyItem.class);
JSONArray UiPolicyActionJsonArray = UiPolicyResponseJsonObject.getJSONArray(Constants.RESPONSE_VARIABLES_UI_POLICY_ACTIONS);
List<UiPolicyAction> uiPolicyActionList = new ArrayList<>(UiPolicyActionJsonArray.length());
for (int j = 0; j < UiPolicyActionJsonArray.length(); j++) {
JSONObject UiPolicyActionJsonObject = UiPolicyActionJsonArray.getJSONObject(j);
UiPolicyAction uiPolicyAction = gson.fromJson(UiPolicyActionJsonObject.toString(), UiPolicyAction.class);
uiPolicyActionList.add(uiPolicyAction);
}
uiPolicyItem.setUiPolicyActions(uiPolicyActionList);
uiPolicyItemList.add(uiPolicyItem);
}
listener.onDoneApiCall(uiPolicyItemList);
} else {
listener.onDoneApiCall(new ArrayList<UiPolicyItem>(0));
}
return SyncStatus.SUCCESS;
} else
return SyncStatus.FAIL;
} catch (JSONException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: onResponse: ", e);
return SyncStatus.FAIL;
} catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: onResponse: ", e);
return SyncStatus.FAIL;
}
} else {
return SyncStatus.FAIL;
}
} catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: IOException: ", e);
return SyncStatus.FAIL;
} catch (NullPointerException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: NullPointerException: ", e);
return SyncStatus.FAIL;
}
}
public static SyncStatus submitVariableForm(String catalogueItemSysId, String catalogueJsonString, PostVariableFormApiListener listener) {
CatalogueLog.d("submitVariableForm: " + catalogueJsonString);
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).postCatalogueItem(catalogueItemSysId, catalogueJsonString);
try { try {
//Retrofit synchronous call //Retrofit synchronous call
Response<ResponseBody> response = call.execute(); Response<ResponseBody> response = call.execute();
...@@ -194,7 +292,7 @@ public class CatalogueVariableApiManager { ...@@ -194,7 +292,7 @@ public class CatalogueVariableApiManager {
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: submitVariableForm: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: submitVariableForm: IOException: ", e);
return SyncStatus.FAIL; return SyncStatus.FAIL;
} catch (NullPointerException e){ } catch (NullPointerException e) {
CatalogueLog.e("CatalogueVariableApiManager: submitVariableForm: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: submitVariableForm: IOException: ", e);
return SyncStatus.FAIL; return SyncStatus.FAIL;
} }
...@@ -215,7 +313,7 @@ public class CatalogueVariableApiManager { ...@@ -215,7 +313,7 @@ public class CatalogueVariableApiManager {
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: postAttachment: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: postAttachment: IOException: ", e);
return SyncStatus.FAIL; return SyncStatus.FAIL;
} catch (NullPointerException e){ } catch (NullPointerException e) {
CatalogueLog.e("CatalogueVariableApiManager: postAttachment: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: postAttachment: IOException: ", e);
return SyncStatus.FAIL; return SyncStatus.FAIL;
} }
......
...@@ -95,9 +95,9 @@ public class IncidentApiManager { ...@@ -95,9 +95,9 @@ public class IncidentApiManager {
List<Incident> incidentList = new ArrayList<>(incidentJsonArray.length()); List<Incident> incidentList = new ArrayList<>(incidentJsonArray.length());
for (int i = 0; i < incidentJsonArray.length(); i++) { for (int i = 0; i < incidentJsonArray.length(); i++) {
JSONObject expenseJsonObject = incidentJsonArray.getJSONObject(i); JSONObject incidentJsonObject = incidentJsonArray.getJSONObject(i);
Incident incident = gson.fromJson(expenseJsonObject.toString(), Incident.class); Incident incident = gson.fromJson(incidentJsonObject.toString(), Incident.class);
incident.parseJson(expenseJsonObject); incident.parseJson(incidentJsonObject);
incidentList.add(incident); incidentList.add(incident);
} }
listener.onDoneApiCall(incidentList); listener.onDoneApiCall(incidentList);
......
...@@ -88,8 +88,8 @@ public class UserApiManager { ...@@ -88,8 +88,8 @@ public class UserApiManager {
List<UserApiValues> userList = new ArrayList<>(catalogueJsonArray.length()); List<UserApiValues> userList = new ArrayList<>(catalogueJsonArray.length());
for (int i = 0; i < catalogueJsonArray.length(); i++) { for (int i = 0; i < catalogueJsonArray.length(); i++) {
JSONObject expenseJsonObject = catalogueJsonArray.getJSONObject(i); JSONObject catalogueJsonObject = catalogueJsonArray.getJSONObject(i);
UserApiValues catalogue = gson.fromJson(expenseJsonObject.toString(), UserApiValues.class); UserApiValues catalogue = gson.fromJson(catalogueJsonObject.toString(), UserApiValues.class);
userList.add(catalogue); userList.add(catalogue);
} }
listener.onDoneApiCall(userList); listener.onDoneApiCall(userList);
......
...@@ -46,11 +46,11 @@ public class CatalogueVariable { ...@@ -46,11 +46,11 @@ public class CatalogueVariable {
@Expose @Expose
private boolean active; private boolean active;
// @SerializedName("type") // @SerializedName("type")
// @Expose // @Expose
private ViewType type; private ViewType type;
private List<VariableChoice> mVariableChoiceList; private List<VariableChoice> mVariableChoiceList;
/** /**
...@@ -213,6 +213,16 @@ public class CatalogueVariable { ...@@ -213,6 +213,16 @@ public class CatalogueVariable {
return choiceText; return choiceText;
} }
public String getDisplayChoiceText(String text) {
for (int i = 0; i < mVariableChoiceList.size(); i++) {
VariableChoice variableChoice = mVariableChoiceList.get(i);
if(variableChoice.getText().equals(text)) {
return variableChoice.getValue();
}
}
return null;
}
public void parseJson(JSONObject jsonObject) { public void parseJson(JSONObject jsonObject) {
String viewType = null; String viewType = null;
try { try {
......
package com.vsoft.uoflservicenow.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class UiPolicyAction {
@SerializedName("visible")
@Expose
private String visible;
@SerializedName("mandatory")
@Expose
private String mandatory;
@SerializedName("variable")
@Expose
private String variableName;
@SerializedName("disabled")
@Expose
private String disabled;
/**
*
* @return
* The visible
*/
public String getVisible() {
return visible;
}
/**
*
* @param visible
* The visible
*/
public void setVisible(String visible) {
this.visible = visible;
}
/**
*
* @return
* The mandatory
*/
public String getMandatory() {
return mandatory;
}
/**
*
* @param mandatory
* The mandatory
*/
public void setMandatory(String mandatory) {
this.mandatory = mandatory;
}
/**
*
* @return
* The variableName
*/
public String getVariableName() {
return variableName;
}
/**
*
* @param variableName
* The variableName
*/
public void setVariableName(String variableName) {
this.variableName = variableName;
}
/**
*
* @return
* The disabled
*/
public String getDisabled() {
return disabled;
}
/**
*
* @param disabled
* The disabled
*/
public void setDisabled(String disabled) {
this.disabled = disabled;
}
}
package com.vsoft.uoflservicenow.db.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.vsoft.uoflservicenow.utils.PartialCondition;
import java.util.List;
/**
* Created by chaukadev on 6/10/16.
*/
public class UiPolicyItem {
private List<UiPolicyAction> uiPolicyActions;
private List<PartialCondition> partialConditions;
@SerializedName("condition")
@Expose
private String condition;
@SerializedName("sys_id")
public List<UiPolicyAction> getUiPolicyActions() {
return uiPolicyActions;
}
public void setUiPolicyActions(List<UiPolicyAction> uiPolicyActions) {
this.uiPolicyActions = uiPolicyActions;
}
public List<PartialCondition> getPartialConditions() {
return partialConditions;
}
public void setPartialConditions(List<PartialCondition> partialConditions) {
this.partialConditions = partialConditions;
}
/**
*
* @return
* The condition
*/
public String getCondition() {
return condition;
}
/**
*
* @param condition
* The condition
*/
public void setCondition(String condition) {
this.condition = condition;
}
}
package com.vsoft.uoflservicenow.db.models;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by chaukadev on 7/10/16.
*/
public class VariableViewContainer {
private CatalogueVariable variable;
private View labelView;
private View inputView;
private View errorView;
private ViewGroup containerView;
public View getLabelView() {
return labelView;
}
public void setLabelView(View labelView) {
this.labelView = labelView;
}
public View getInputView() {
return inputView;
}
public void setInputView(View inputView) {
this.inputView = inputView;
}
public View getErrorView() {
return errorView;
}
public void setErrorView(View errorView) {
this.errorView = errorView;
}
public ViewGroup getContainerView() {
return containerView;
}
public void setContainerView(ViewGroup containerView) {
this.containerView = containerView;
}
}
package com.vsoft.uoflservicenow.enums;
/**
* @since 1.0
* @author Kunj on 06/10/16.
*
*/
public enum Operator {
UNKNOWN (-1, ""),
EQUAL (1, "="),
IS_NOT_EMPTY (2, "ISNOTEMPTY");
private int id;
private String operatorString;
Operator(int id, String operatorString) {
this.id = id;
this.operatorString = operatorString;
}
public String getOperatorString() {
return operatorString;
}
public void setOperatorString(String operatorString) {
this.operatorString = operatorString;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public static Operator from(int id) {
for(int i = 0; i < Operator.values().length; i++) {
Operator operator = Operator.values()[i];
if(operator.id == id)
return Operator.values()[i];
}
return UNKNOWN;
}
public static Operator from(String operatorString) {
for(int i = 0; i < Operator.values().length; i++) {
Operator operator = Operator.values()[i];
if(operator.operatorString.equals(operatorString))
return Operator.values()[i];
}
return UNKNOWN;
}
}
package com.vsoft.uoflservicenow.utils;
import com.vsoft.uoflservicenow.db.models.UiPolicyAction;
/**
* Created by kunj on 6/10/16.
*/
public class ActionCondition {
private int[] childViewTagIndex;
private UiPolicyAction uiPolicyAction;
private String operatorValue;
public int[] getChildViewTagIndex() {
return childViewTagIndex;
}
public void setChildViewTagIndex(int[] childViewTagIndex) {
this.childViewTagIndex = childViewTagIndex;
}
public UiPolicyAction getUiPolicyAction() {
return uiPolicyAction;
}
public void setUiPolicyAction(UiPolicyAction uiPolicyAction) {
this.uiPolicyAction = uiPolicyAction;
}
public String getOperatorValue() {
return operatorValue;
}
public void setOperatorValue(String operatorValue) {
this.operatorValue = operatorValue;
}
}
...@@ -117,6 +117,7 @@ public class Constants { ...@@ -117,6 +117,7 @@ public class Constants {
public static final String RESPONSE_VARIABLE_SET_OBJECT_NAME = "variablesets"; public static final String RESPONSE_VARIABLE_SET_OBJECT_NAME = "variablesets";
public static final String RESPONSE_VARIABLES_OBJECT_NAME = "variables"; public static final String RESPONSE_VARIABLES_OBJECT_NAME = "variables";
public static final String RESPONSE_CATEGORY_OBJECT_NAME = "Category"; public static final String RESPONSE_CATEGORY_OBJECT_NAME = "Category";
public static final String RESPONSE_VARIABLES_UI_POLICY_ACTIONS = "ui_policy_actions";
/** /**
* Catalogue web services urls * Catalogue web services urls
...@@ -133,6 +134,7 @@ public class Constants { ...@@ -133,6 +134,7 @@ public class Constants {
/*Variable form API */ /*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/variables";
public static final String URL_GET_UI_POLICY = "/api/uno33/uofl_mobile/uipolicy";
public static final String URL_GET_VARIABLE_CHOICE = API_PATH + "question_choice"; public static final String URL_GET_VARIABLE_CHOICE = API_PATH + "question_choice";
public static final String URL_POST_CATALOGUE_ITEM = "api/uno33/uofl_mobile"; public static final String URL_POST_CATALOGUE_ITEM = "api/uno33/uofl_mobile";
public static final String URL_GET_REFERENCE = API_PATH; public static final String URL_GET_REFERENCE = API_PATH;
......
package com.vsoft.uoflservicenow.utils;
import com.vsoft.uoflservicenow.enums.Operator;
/**
* Created by kunj on 6/10/16.
*/
public class PartialCondition {
private String viewSysId;
private Operator operator;
private String operatorValue;
public String getOperatorValue() {
return operatorValue;
}
public void setOperatorValue(String operatorValue) {
this.operatorValue = operatorValue;
}
public String getViewSysId() {
return viewSysId;
}
public void setViewSysId(String viewSysId) {
this.viewSysId = viewSysId;
}
public Operator getOperator() {
return operator;
}
public void setOperator(Operator operator) {
this.operator = operator;
}
@Override
public String toString() {
return "PartialCondition{" +
"viewSysId='" + viewSysId + '\'' +
", operator=" + operator +
", operatorValue='" + operatorValue + '\'' +
'}';
}
}
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<string name="password_string">Password</string> <string name="password_string">Password</string>
<!--Variable Screen--> <!--Variable Screen-->
<string name="variable_form_misc_info_string">%1$s [add %2$s]</string> <string name="variable_form_misc_info_string">%1$s [add %2$.2f]</string>
<string name="variable_form_header_string">Submit Order</string> <string name="variable_form_header_string">Submit Order</string>
<string name="variable_form_view_mandatory_sign_string">&lt;font color="#FF0000"&gt;*&lt;/font&gt;</string> <string name="variable_form_view_mandatory_sign_string">&lt;font color="#FF0000"&gt;*&lt;/font&gt;</string>
<string name="variable_form_reference_dialog_title_string">Search \'%s\'</string> <string name="variable_form_reference_dialog_title_string">Search \'%s\'</string>
......
...@@ -73,14 +73,14 @@ if [ -n "$JAVA_HOME" ] ; then ...@@ -73,14 +73,14 @@ if [ -n "$JAVA_HOME" ] ; then
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variableName in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else else
JAVACMD="java" JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variableName in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
......
...@@ -26,7 +26,7 @@ if "%ERRORLEVEL%" == "0" goto init ...@@ -26,7 +26,7 @@ if "%ERRORLEVEL%" == "0" goto init
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variableName in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
...@@ -40,7 +40,7 @@ if exist "%JAVA_EXE%" goto init ...@@ -40,7 +40,7 @@ if exist "%JAVA_EXE%" goto init
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variableName in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
...@@ -79,7 +79,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar ...@@ -79,7 +79,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
if "%ERRORLEVEL%"=="0" goto mainEnd if "%ERRORLEVEL%"=="0" goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variableName GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1 exit /b 1
......
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