Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Krishna Vemulavada
/
vera_2.1_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
67ff5765
authored
Oct 14, 2016
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
UOFLMA-118: implemented API to modify Dynamic Form according to UI Policies.
parent
44225f97
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1128 additions
and
217 deletions
app/src/main/java/com/vsoft/uoflservicenow/adapters/HomeScreenAdapter.java
app/src/main/java/com/vsoft/uoflservicenow/api/RestClient.java
app/src/main/java/com/vsoft/uoflservicenow/api/interfaces/CatalogueVariableApi.java
app/src/main/java/com/vsoft/uoflservicenow/api/listeners/get/GetUiPolicyApiListener.java
app/src/main/java/com/vsoft/uoflservicenow/api/managers/CatalogueApiManager.java
app/src/main/java/com/vsoft/uoflservicenow/api/managers/CatalogueItemApiManager.java
app/src/main/java/com/vsoft/uoflservicenow/api/managers/CatalogueVariableApiManager.java
app/src/main/java/com/vsoft/uoflservicenow/api/managers/IncidentApiManager.java
app/src/main/java/com/vsoft/uoflservicenow/api/managers/UserApiManager.java
app/src/main/java/com/vsoft/uoflservicenow/db/models/CatalogueVariable.java
app/src/main/java/com/vsoft/uoflservicenow/db/models/UiPolicyAction.java
app/src/main/java/com/vsoft/uoflservicenow/db/models/UiPolicyItem.java
app/src/main/java/com/vsoft/uoflservicenow/db/models/VariableViewContainer.java
app/src/main/java/com/vsoft/uoflservicenow/enums/Operator.java
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueVariableScreen.java
app/src/main/java/com/vsoft/uoflservicenow/utils/ActionCondition.java
app/src/main/java/com/vsoft/uoflservicenow/utils/Constants.java
app/src/main/java/com/vsoft/uoflservicenow/utils/PartialCondition.java
app/src/main/java/com/vsoft/uoflservicenow/utils/Util.java
app/src/main/res/values/strings.xml
gradlew
gradlew.bat
app/src/main/java/com/vsoft/uoflservicenow/adapters/HomeScreenAdapter.java
View file @
67ff5765
...
@@ -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 getV
iew
method call depends upon mGridValues.length
// Number of times getV
ariableViewContainer
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 getV
iew
method call depends upon mGridValues.length
// Number of times getV
ariableViewContainer
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
;
...
...
app/src/main/java/com/vsoft/uoflservicenow/api/RestClient.java
View file @
67ff5765
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
...
...
app/src/main/java/com/vsoft/uoflservicenow/api/interfaces/CatalogueVariableApi.java
View file @
67ff5765
...
@@ -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
);
}
}
app/src/main/java/com/vsoft/uoflservicenow/api/listeners/get/GetUiPolicyApiListener.java
0 → 100644
View file @
67ff5765
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
);
}
app/src/main/java/com/vsoft/uoflservicenow/api/managers/CatalogueApiManager.java
View file @
67ff5765
...
@@ -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
expens
eJsonObject
=
catalogueJsonArray
.
getJSONObject
(
i
);
JSONObject
catalogu
eJsonObject
=
catalogueJsonArray
.
getJSONObject
(
i
);
Catalogue
catalogue
=
gson
.
fromJson
(
expens
eJsonObject
.
toString
(),
Catalogue
.
class
);
Catalogue
catalogue
=
gson
.
fromJson
(
catalogu
eJsonObject
.
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
expense
JsonObject
=
catalogueOrderJsonArray
.
getJSONObject
(
i
);
JSONObject
order
JsonObject
=
catalogueOrderJsonArray
.
getJSONObject
(
i
);
CatalogueOrder
catalogueOrder
=
gson
.
fromJson
(
expense
JsonObject
.
toString
(),
CatalogueOrder
.
class
);
CatalogueOrder
catalogueOrder
=
gson
.
fromJson
(
order
JsonObject
.
toString
(),
CatalogueOrder
.
class
);
catalogueOrderList
.
add
(
catalogueOrder
);
catalogueOrderList
.
add
(
catalogueOrder
);
}
}
...
...
app/src/main/java/com/vsoft/uoflservicenow/api/managers/CatalogueItemApiManager.java
View file @
67ff5765
...
@@ -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
expense
JsonObject
=
catalogueItemJsonArray
.
getJSONObject
(
i
);
JSONObject
catalogueItem
JsonObject
=
catalogueItemJsonArray
.
getJSONObject
(
i
);
CatalogueItem
catalogueItem
=
gson
.
fromJson
(
expense
JsonObject
.
toString
(),
CatalogueItem
.
class
);
CatalogueItem
catalogueItem
=
gson
.
fromJson
(
catalogueItem
JsonObject
.
toString
(),
CatalogueItem
.
class
);
catalogueItemList
.
add
(
catalogueItem
);
catalogueItemList
.
add
(
catalogueItem
);
}
}
listener
.
onDoneApiCall
(
catalogueItemList
);
listener
.
onDoneApiCall
(
catalogueItemList
);
...
...
app/src/main/java/com/vsoft/uoflservicenow/api/managers/CatalogueVariableApiManager.java
View file @
67ff5765
...
@@ -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
;
}
}
...
...
app/src/main/java/com/vsoft/uoflservicenow/api/managers/IncidentApiManager.java
View file @
67ff5765
...
@@ -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
expense
JsonObject
=
incidentJsonArray
.
getJSONObject
(
i
);
JSONObject
incident
JsonObject
=
incidentJsonArray
.
getJSONObject
(
i
);
Incident
incident
=
gson
.
fromJson
(
expense
JsonObject
.
toString
(),
Incident
.
class
);
Incident
incident
=
gson
.
fromJson
(
incident
JsonObject
.
toString
(),
Incident
.
class
);
incident
.
parseJson
(
expense
JsonObject
);
incident
.
parseJson
(
incident
JsonObject
);
incidentList
.
add
(
incident
);
incidentList
.
add
(
incident
);
}
}
listener
.
onDoneApiCall
(
incidentList
);
listener
.
onDoneApiCall
(
incidentList
);
...
...
app/src/main/java/com/vsoft/uoflservicenow/api/managers/UserApiManager.java
View file @
67ff5765
...
@@ -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
expens
eJsonObject
=
catalogueJsonArray
.
getJSONObject
(
i
);
JSONObject
catalogu
eJsonObject
=
catalogueJsonArray
.
getJSONObject
(
i
);
UserApiValues
catalogue
=
gson
.
fromJson
(
expens
eJsonObject
.
toString
(),
UserApiValues
.
class
);
UserApiValues
catalogue
=
gson
.
fromJson
(
catalogu
eJsonObject
.
toString
(),
UserApiValues
.
class
);
userList
.
add
(
catalogue
);
userList
.
add
(
catalogue
);
}
}
listener
.
onDoneApiCall
(
userList
);
listener
.
onDoneApiCall
(
userList
);
...
...
app/src/main/java/com/vsoft/uoflservicenow/db/models/CatalogueVariable.java
View file @
67ff5765
...
@@ -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
{
...
...
app/src/main/java/com/vsoft/uoflservicenow/db/models/UiPolicyAction.java
0 → 100644
View file @
67ff5765
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
;
}
}
app/src/main/java/com/vsoft/uoflservicenow/db/models/UiPolicyItem.java
0 → 100644
View file @
67ff5765
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
;
}
}
app/src/main/java/com/vsoft/uoflservicenow/db/models/VariableViewContainer.java
0 → 100644
View file @
67ff5765
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
;
}
}
app/src/main/java/com/vsoft/uoflservicenow/enums/Operator.java
0 → 100644
View file @
67ff5765
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
;
}
}
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueVariableScreen.java
View file @
67ff5765
...
@@ -30,17 +30,21 @@ import android.support.v7.widget.Toolbar;
...
@@ -30,17 +30,21 @@ import android.support.v7.widget.Toolbar;
import
android.text.Html
;
import
android.text.Html
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.text.method.LinkMovementMethod
;
import
android.text.method.LinkMovementMethod
;
import
android.util.StringBuilderPrinter
;
import
android.util.TypedValue
;
import
android.util.TypedValue
;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.webkit.WebView
;
import
android.webkit.WebView
;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.CheckBox
;
import
android.widget.CompoundButton
;
import
android.widget.DatePicker
;
import
android.widget.DatePicker
;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
android.widget.RadioGroup
;
import
android.widget.RelativeLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.TimePicker
;
import
android.widget.TimePicker
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -49,6 +53,7 @@ import com.google.android.gms.analytics.Tracker;
...
@@ -49,6 +53,7 @@ import com.google.android.gms.analytics.Tracker;
import
com.vsoft.uoflservicenow.CatalogueApplication
;
import
com.vsoft.uoflservicenow.CatalogueApplication
;
import
com.vsoft.uoflservicenow.R
;
import
com.vsoft.uoflservicenow.R
;
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.get.GetVariableChoiceApiListener
;
import
com.vsoft.uoflservicenow.api.listeners.get.GetVariableChoiceApiListener
;
import
com.vsoft.uoflservicenow.api.listeners.post.PostVariableFormApiListener
;
import
com.vsoft.uoflservicenow.api.listeners.post.PostVariableFormApiListener
;
import
com.vsoft.uoflservicenow.api.managers.CatalogueVariableApiManager
;
import
com.vsoft.uoflservicenow.api.managers.CatalogueVariableApiManager
;
...
@@ -56,8 +61,12 @@ import com.vsoft.uoflservicenow.api.managers.VariableChoiceApiManager;
...
@@ -56,8 +61,12 @@ import com.vsoft.uoflservicenow.api.managers.VariableChoiceApiManager;
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.Reference
;
import
com.vsoft.uoflservicenow.db.models.Reference
;
import
com.vsoft.uoflservicenow.db.models.UiPolicyAction
;
import
com.vsoft.uoflservicenow.db.models.UiPolicyItem
;
import
com.vsoft.uoflservicenow.db.models.VariableChoice
;
import
com.vsoft.uoflservicenow.db.models.VariableChoice
;
import
com.vsoft.uoflservicenow.db.models.VariableViewContainer
;
import
com.vsoft.uoflservicenow.dialog.SelectReferenceDialog
;
import
com.vsoft.uoflservicenow.dialog.SelectReferenceDialog
;
import
com.vsoft.uoflservicenow.enums.Operator
;
import
com.vsoft.uoflservicenow.enums.SyncStatus
;
import
com.vsoft.uoflservicenow.enums.SyncStatus
;
import
com.vsoft.uoflservicenow.enums.ViewType
;
import
com.vsoft.uoflservicenow.enums.ViewType
;
import
com.vsoft.uoflservicenow.listeners.ReferenceListener
;
import
com.vsoft.uoflservicenow.listeners.ReferenceListener
;
...
@@ -65,7 +74,7 @@ import com.vsoft.uoflservicenow.ui.supportviews.DateAndTimePickerFragment;
...
@@ -65,7 +74,7 @@ import com.vsoft.uoflservicenow.ui.supportviews.DateAndTimePickerFragment;
import
com.vsoft.uoflservicenow.utils.CatalogueLog
;
import
com.vsoft.uoflservicenow.utils.CatalogueLog
;
import
com.vsoft.uoflservicenow.utils.Constants
;
import
com.vsoft.uoflservicenow.utils.Constants
;
import
com.vsoft.uoflservicenow.utils.DialogUtils
;
import
com.vsoft.uoflservicenow.utils.DialogUtils
;
import
com.vsoft.uoflservicenow.utils.
TagObject
;
import
com.vsoft.uoflservicenow.utils.
PartialCondition
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
...
@@ -80,7 +89,9 @@ import java.io.InputStream;
...
@@ -80,7 +89,9 @@ import java.io.InputStream;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Stack
;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
...
@@ -88,6 +99,11 @@ import butterknife.OnClick;
...
@@ -88,6 +99,11 @@ import butterknife.OnClick;
import
okhttp3.MediaType
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
import
okhttp3.RequestBody
;
import
static
com
.
google
.
android
.
gms
.
analytics
.
internal
.
zzy
.
C
;
import
static
com
.
google
.
android
.
gms
.
analytics
.
internal
.
zzy
.
c
;
import
static
com
.
google
.
android
.
gms
.
analytics
.
internal
.
zzy
.
n
;
import
static
com
.
google
.
android
.
gms
.
analytics
.
internal
.
zzy
.
s
;
/**
/**
* Created by Kunj on 11/8/16.
* Created by Kunj on 11/8/16.
*/
*/
...
@@ -100,11 +116,13 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -100,11 +116,13 @@ public class CatalogueVariableScreen extends AppCompatActivity {
@BindView
(
R
.
id
.
variable_screen_bottom_layout
)
RelativeLayout
mBottomLayout
;
@BindView
(
R
.
id
.
variable_screen_bottom_layout
)
RelativeLayout
mBottomLayout
;
private
List
<
CatalogueVariable
>
mCatalogueVariableList
=
new
ArrayList
<>();
private
List
<
CatalogueVariable
>
mCatalogueVariableList
=
new
ArrayList
<>();
private
JSONArray
mJsonArray
;
private
List
<
UiPolicyItem
>
mUiPolicyItemList
;
private
CatalogueApplication
mApplication
;
private
CatalogueApplication
mApplication
;
private
String
mCatalogueItemSysId
,
mCatalogueItemDescription
,
mCatalogueItemShortDescription
,
mCatalogueItemTitle
;
private
String
mCatalogueItemSysId
,
mCatalogueItemDescription
,
mCatalogueItemShortDescription
,
mCatalogueItemTitle
;
private
File
mAttachmentFile
;
private
File
mAttachmentFile
;
private
Uri
mAttachmentUri
;
private
Uri
mAttachmentUri
;
private
HashMap
<
CatalogueVariable
,
VariableViewContainer
>
mVariableViewMap
;
private
HashMap
<
String
,
ArrayList
<
CatalogueVariable
>>
mContainerViewMap
;
private
static
final
int
WRITE_EXTERNAL_STORAGE
=
1
;
private
static
final
int
WRITE_EXTERNAL_STORAGE
=
1
;
private
static
final
int
FILE_SELECT_CODE
=
0
;
private
static
final
int
FILE_SELECT_CODE
=
0
;
...
@@ -166,11 +184,10 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -166,11 +184,10 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
@Override
@Override
protected
SyncStatus
doInBackground
(
String
...
params
)
{
protected
SyncStatus
doInBackground
(
final
String
...
params
)
{
syncStatus
=
CatalogueVariableApiManager
.
getCatalogueVariable
(
mCatalogueItemSysId
,
new
GetCatalogueVariableApiListener
()
{
syncStatus
=
CatalogueVariableApiManager
.
getCatalogueVariable
(
mCatalogueItemSysId
,
new
GetCatalogueVariableApiListener
()
{
@Override
@Override
public
void
onDoneApiCall
(
List
<
CatalogueVariableSet
>
variableSetList
,
List
<
CatalogueVariable
>
variableList
)
{
public
void
onDoneApiCall
(
List
<
CatalogueVariableSet
>
variableSetList
,
List
<
CatalogueVariable
>
variableList
)
{
/*For variableset */
/*For variableset */
for
(
int
i
=
0
;
i
<
variableSetList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
variableSetList
.
size
();
i
++)
{
CatalogueVariableSet
catalogueVariableSet
=
variableSetList
.
get
(
i
);
CatalogueVariableSet
catalogueVariableSet
=
variableSetList
.
get
(
i
);
...
@@ -179,7 +196,43 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -179,7 +196,43 @@ public class CatalogueVariableScreen extends AppCompatActivity {
/*For variable list*/
/*For variable list*/
setVariableChoiceData
(
variableList
);
setVariableChoiceData
(
variableList
);
syncStatus
=
CatalogueVariableApiManager
.
getUiPolicy
(
mCatalogueItemSysId
,
new
GetUiPolicyApiListener
()
{
@Override
public
void
onDoneApiCall
(
List
<
UiPolicyItem
>
uiPolicyItemList
)
{
mUiPolicyItemList
=
uiPolicyItemList
;
for
(
int
i
=
0
;
i
<
mUiPolicyItemList
.
size
();
i
++)
{
UiPolicyItem
uiPolicyItem
=
mUiPolicyItemList
.
get
(
i
);
String
condition
=
uiPolicyItem
.
getCondition
();
if
(
condition
!=
null
)
{
String
[]
splitStrings
=
uiPolicyItem
.
getCondition
().
split
(
"\\^"
);
List
<
PartialCondition
>
partialConditionList
=
new
ArrayList
<>(
splitStrings
.
length
-
1
);
for
(
int
j
=
0
;
j
<
splitStrings
.
length
-
1
;
j
++)
{
PartialCondition
partialCondition
=
new
PartialCondition
();
String
value
=
splitStrings
[
j
].
replace
(
"IO:"
,
""
);
String
sysId
=
value
.
substring
(
0
,
32
);
String
operatorAndValue
=
value
.
substring
(
32
);
partialCondition
.
setViewSysId
(
sysId
);
if
(!
operatorAndValue
.
contains
(
"="
))
{
partialCondition
.
setOperator
(
Operator
.
from
(
operatorAndValue
));
}
else
{
String
[]
strings
=
operatorAndValue
.
split
(
"="
);
partialCondition
.
setOperator
(
Operator
.
EQUAL
);
/*Below condition is use for condition=empty,
*we need to handle empty condition in else statement*/
if
(
strings
.
length
>=
2
)
{
partialCondition
.
setOperatorValue
(
strings
[
1
]);
}
else
{
partialCondition
.
setOperatorValue
(
""
);
}
}
partialConditionList
.
add
(
partialCondition
);
}
uiPolicyItem
.
setPartialConditions
(
partialConditionList
);
}
}
}
});
}
}
});
});
return
syncStatus
;
return
syncStatus
;
...
@@ -194,6 +247,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -194,6 +247,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
if
(
mCatalogueVariableList
!=
null
)
{
if
(
mCatalogueVariableList
!=
null
)
{
createView
();
createView
();
runUIPolicyActions
(
null
);
}
}
}
else
{
}
else
{
showFetchVariableErrorDialog
(
R
.
string
.
failed_to_fetch_catalogue_form_string
);
showFetchVariableErrorDialog
(
R
.
string
.
failed_to_fetch_catalogue_form_string
);
...
@@ -211,7 +265,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -211,7 +265,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
VariableChoiceApiManager
.
getVariableChoice
(
catalogueVariable
.
getSysId
(),
new
GetVariableChoiceApiListener
()
{
VariableChoiceApiManager
.
getVariableChoice
(
catalogueVariable
.
getSysId
(),
new
GetVariableChoiceApiListener
()
{
@Override
@Override
public
void
onDoneApiCall
(
List
<
VariableChoice
>
variableChoiceList
)
{
public
void
onDoneApiCall
(
List
<
VariableChoice
>
variableChoiceList
)
{
CatalogueLog
.
e
(
"Data: variableChoiceList: "
+
variableChoiceList
);
/*Sort List of CatalogueOrder*/
/*Sort List of CatalogueOrder*/
Collections
.
sort
(
variableChoiceList
,
new
Comparator
<
VariableChoice
>()
{
Collections
.
sort
(
variableChoiceList
,
new
Comparator
<
VariableChoice
>()
{
@Override
@Override
...
@@ -239,6 +292,9 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -239,6 +292,9 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
private
void
getCustomLayout
()
{
private
void
getCustomLayout
()
{
mVariableViewMap
=
new
HashMap
<>(
mCatalogueVariableList
.
size
());
Stack
<
LinearLayout
>
stack
=
null
;
/*Child view of scroll view*/
/*Child view of scroll view*/
LinearLayout
.
LayoutParams
childControlViewLayoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
childControlViewLayoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
...
@@ -283,6 +339,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -283,6 +339,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
if
(!
mCatalogueVariableList
.
isEmpty
())
{
if
(!
mCatalogueVariableList
.
isEmpty
())
{
VariableViewContainer
container
;
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
);
/*If API return active false for a variable, there is no need show that variable*/
/*If API return active false for a variable, there is no need show that variable*/
...
@@ -299,35 +356,22 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -299,35 +356,22 @@ public class CatalogueVariableScreen extends AppCompatActivity {
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
small_margin
),
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
small_margin
),
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
small_margin
));
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
small_margin
));
mContainerLayout
.
addView
(
nameNullView
,
childLabelViewLayoutParams
);
mContainerLayout
.
addView
(
nameNullView
,
childLabelViewLayoutParams
);
}
else
if
(
viewType
!=
ViewType
.
MACRO
&&
viewType
!=
ViewType
.
CONTAINER_START
&&
viewType
!=
ViewType
.
CONTAINER_END
&&
viewType
!=
ViewType
.
CONTAINER_SPLIT
)
{
}
else
if
(
viewType
==
ViewType
.
CONTAINER_END
)
{
/*For MACRO, CONTAINER_START, CONTAINER_END and CONTAINER_SPLIT, there is no need to render any view*/
/*In Container End, we need to add view for rendering*/
if
(
viewType
!=
ViewType
.
LABEL
&&
viewType
!=
ViewType
.
CHECK_BOX
&&
viewType
!=
ViewType
.
BREAK
)
{
LinearLayout
containerLinearLayout
;
/*Create label for every type*/
if
(
stack
!=
null
&&
!
stack
.
isEmpty
())
{
if
(!
catalogueVariable
.
isMandatory
())
{
containerLinearLayout
=
stack
.
pop
();
TextView
label
=
new
TextView
(
CatalogueVariableScreen
.
this
);
if
(
containerLinearLayout
!=
null
)
{
label
.
setText
(
catalogueVariable
.
getQuestionText
());
mContainerLayout
.
addView
(
containerLinearLayout
);
childLabelViewLayoutParams
.
topMargin
=
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
small_margin
);
mContainerLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
else
{
/*Create labelWithMandatory with mandatory value*/
StringBuilder
stringBuilder
=
new
StringBuilder
();
stringBuilder
.
append
(
catalogueVariable
.
getQuestionText
());
stringBuilder
.
append
(
getString
(
R
.
string
.
variable_form_view_mandatory_sign_string
));
TextView
labelWithMandatory
=
new
TextView
(
CatalogueVariableScreen
.
this
);
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
N
)
{
labelWithMandatory
.
setText
(
Html
.
fromHtml
(
stringBuilder
.
toString
(),
Html
.
FROM_HTML_MODE_LEGACY
));
}
else
{
labelWithMandatory
.
setText
(
Html
.
fromHtml
(
stringBuilder
.
toString
()));
}
}
mContainerLayout
.
addView
(
labelWithMandatory
,
childLabelViewLayoutParams
);
}
}
}
}
else
if
(
viewType
!=
ViewType
.
MACRO
&&
viewType
!=
ViewType
.
CONTAINER_SPLIT
)
{
container
=
Util
.
getVariableViewContainer
(
CatalogueVariableScreen
.
this
,
View
controlView
=
Util
.
getView
(
CatalogueVariableScreen
.
this
,
viewType
,
catalogueVariable
);
catalogueVariable
,
childLabelViewLayoutParams
);
mVariableViewMap
.
put
(
catalogueVariable
,
container
);
View
controlView
=
container
.
getInputView
();
if
(
controlView
!=
null
)
{
if
(
controlView
!=
null
)
{
controlView
.
setTag
(
new
TagObject
(
i
,
null
));
if
(
viewType
==
ViewType
.
DATE
)
{
if
(
viewType
==
ViewType
.
DATE
)
{
controlView
.
setOnClickListener
(
dateListener
);
controlView
.
setOnClickListener
(
dateListener
);
}
else
if
(
viewType
==
ViewType
.
DATE_AND_TIME
)
{
}
else
if
(
viewType
==
ViewType
.
DATE_AND_TIME
)
{
...
@@ -337,21 +381,45 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -337,21 +381,45 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
else
if
(
viewType
==
ViewType
.
UI_PAGE
)
{
}
else
if
(
viewType
==
ViewType
.
UI_PAGE
)
{
((
LinearLayout
)
controlView
).
getChildAt
(
0
).
setOnClickListener
(
attachmentListener
);
((
LinearLayout
)
controlView
).
getChildAt
(
0
).
setOnClickListener
(
attachmentListener
);
mAttachmentTextView
=
(
TextView
)((
LinearLayout
)
controlView
).
getChildAt
(
1
);
mAttachmentTextView
=
(
TextView
)((
LinearLayout
)
controlView
).
getChildAt
(
1
);
}
}
else
if
(
viewType
==
ViewType
.
CHECK_BOX
)
{
((
CheckBox
)
controlView
).
setOnCheckedChangeListener
(
checkedChangeListener
);
/*Set bottom margin for custom view*/
// if this checkbox is a trigger of UI action, set a listener for change, and send a broadcast event
if
(
viewType
!=
ViewType
.
BREAK
)
{
}
else
if
(
viewType
==
ViewType
.
MULTIPLE_CHOICE
)
{
mContainerLayout
.
addView
(
controlView
,
childControlViewLayoutParams
);
((
RadioGroup
)
controlView
).
setOnCheckedChangeListener
(
radioGroupCheckedChangeListener
);
}
else
// if this checkbox is a trigger of UI action, set a listener for change, and send a broadcast event
mContainerLayout
.
addView
(
controlView
);
}
else
if
(
viewType
==
ViewType
.
SELECT_BOX
)
{
((
Spinner
)
controlView
).
setOnItemSelectedListener
(
spinnerItemSelectedListener
);
/*Mandatory variable contain error view*/
// if this checkbox is a trigger of UI action, set a listener for change, and send a broadcast event
if
(
catalogueVariable
.
isMandatory
())
{
}
/*Add error view for validation*/
View
errorView
=
getErrorView
();
LinearLayout
containerLinearLayout
=
null
;
errorView
.
setTag
(
"error_"
+
i
);
if
(
stack
!=
null
&&
!
stack
.
isEmpty
())
{
mContainerLayout
.
addView
(
errorView
);
containerLinearLayout
=
stack
.
peek
();
}
}
if
(
containerLinearLayout
!=
null
)
{
/*That mean, we need to add only in container view*/
if
(
container
.
getContainerView
()
!=
null
)
containerLinearLayout
.
addView
(
container
.
getContainerView
());
else
containerLinearLayout
.
addView
(
container
.
getInputView
());
}
else
if
(
viewType
!=
ViewType
.
BREAK
)
{
/*Set bottom margin for custom view*/
if
(
container
.
getContainerView
()!=
null
)
mContainerLayout
.
addView
(
container
.
getContainerView
(),
childControlViewLayoutParams
);
else
mContainerLayout
.
addView
(
container
.
getInputView
(),
childControlViewLayoutParams
);
}
else
{
if
(
container
.
getContainerView
()
!=
null
)
mContainerLayout
.
addView
(
container
.
getContainerView
());
else
mContainerLayout
.
addView
(
container
.
getInputView
());
}
}
else
if
(
viewType
==
ViewType
.
CONTAINER_START
)
{
/*For Container start, we need to create a layout, it contain all views until we reach Container End*/
LinearLayout
containerLinearLayout
=
(
LinearLayout
)
container
.
getContainerView
();
if
(
stack
==
null
)
stack
=
new
Stack
();
stack
.
push
(
containerLinearLayout
);
}
else
{
}
else
{
TextView
viewNotImplemented
=
new
TextView
(
CatalogueVariableScreen
.
this
);
TextView
viewNotImplemented
=
new
TextView
(
CatalogueVariableScreen
.
this
);
viewNotImplemented
.
setText
(
String
.
format
(
getString
(
R
.
string
.
view_not_implemented_string
),
viewType
.
getDisplayString
()));
viewNotImplemented
.
setText
(
String
.
format
(
getString
(
R
.
string
.
view_not_implemented_string
),
viewType
.
getDisplayString
()));
...
@@ -362,15 +430,21 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -362,15 +430,21 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
}
}
}
}
/*This condition is use for where u do not have Container End at the end of loop, then we need to render*/
if
(
stack
!=
null
)
{
while
(!
stack
.
isEmpty
())
{
LinearLayout
popLinearLayout
=
stack
.
pop
();
if
(!
stack
.
isEmpty
())
{
LinearLayout
peekLinearLayout
=
stack
.
peek
();
peekLinearLayout
.
addView
(
popLinearLayout
);
}
else
{
if
(
popLinearLayout
!=
null
)
mContainerLayout
.
addView
(
popLinearLayout
);
}
}
}
}
}
}
private
View
getErrorView
()
{
TextView
textView
=
new
TextView
(
CatalogueVariableScreen
.
this
);
textView
.
setTextColor
(
ContextCompat
.
getColor
(
CatalogueVariableScreen
.
this
,
R
.
color
.
error_color
));
textView
.
setText
(
R
.
string
.
error_string
);
textView
.
setVisibility
(
View
.
GONE
);
return
textView
;
}
}
@OnClick
(
R
.
id
.
variable_screen_submit_text_view
)
@OnClick
(
R
.
id
.
variable_screen_submit_text_view
)
...
@@ -385,36 +459,48 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -385,36 +459,48 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
private
void
saveFormData
()
{
private
void
saveFormData
()
{
/*For Local DB column and value*/
JSONArray
jsonArray
;
List
<
String
>
columnList
=
new
ArrayList
<>(
mCatalogueVariableList
.
size
());
JSONObject
jsonObject
=
null
;
List
<
String
>
valueList
=
new
ArrayList
<>(
mCatalogueVariableList
.
size
());
mJsonArray
=
new
JSONArray
();
TagObject
tempTagObj
=
new
TagObject
(
0
,
null
);
boolean
hasErrors
=
false
;
boolean
hasErrors
=
false
;
boolean
skipInvisibleItem
=
false
;
for
(
int
i
=
0
;
i
<
mCatalogueVariableList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
mCatalogueVariableList
.
size
();
i
++)
{
tempTagObj
.
setIndex
(
i
);
CatalogueVariable
catalogueVariable
=
mCatalogueVariableList
.
get
(
i
);
CatalogueVariable
catalogueVariable
=
mCatalogueVariableList
.
get
(
i
);
ViewType
viewType
=
catalogueVariable
.
getType
();
VariableViewContainer
container
=
mVariableViewMap
.
get
(
catalogueVariable
);
if
(
viewType
!=
ViewType
.
LABEL
&&
viewType
!=
ViewType
.
BREAK
)
{
View
view
=
mContainerLayout
.
findViewWithTag
(
tempTagObj
);
if
(
catalogueVariable
.
getType
()
==
ViewType
.
CONTAINER_START
&&
container
!=
null
&&
container
.
getContainerView
()
!=
null
&&
container
.
getContainerView
().
getVisibility
()
==
View
.
GONE
)
{
skipInvisibleItem
=
true
;
}
if
(
skipInvisibleItem
&&
catalogueVariable
.
getType
()
!=
ViewType
.
CONTAINER_END
)
{
continue
;
}
if
(
catalogueVariable
.
getType
()
==
ViewType
.
CONTAINER_END
)
{
skipInvisibleItem
=
false
;
}
if
(
jsonObject
==
null
)
{
jsonObject
=
new
JSONObject
();
}
ViewType
viewType
=
catalogueVariable
.
getType
();
if
(
container
!=
null
&&
viewType
!=
ViewType
.
LABEL
&&
viewType
!=
ViewType
.
BREAK
)
{
View
view
=
container
.
getInputView
();
if
(
view
!=
null
)
{
if
(
view
!=
null
)
{
String
value
=
Util
.
getVariableViewValue
(
view
,
viewType
);
String
value
=
Util
.
getVariableViewValue
(
view
,
viewType
);
View
errorView
=
mContainerLayout
.
findViewWithTag
(
"error_"
+
i
);
View
errorView
=
container
.
getErrorView
(
);
columnList
.
add
(
catalogueVariable
.
getName
());
JSONObject
jsonObject
=
new
JSONObject
();
String
jsonColumnValue
=
value
;
String
jsonColumnValue
=
value
;
/*Convert date and time long value to string for server communication*/
/*Convert date and time long value to string for server communication*/
if
(
viewType
==
ViewType
.
DATE
)
{
if
(
viewType
==
ViewType
.
DATE
)
{
jsonColumnValue
=
Util
.
getDateFromLong
(
Util
.
getDateFromString
(
value
));
jsonColumnValue
=
Util
.
getDateFromLong
(
Util
.
getDateFromString
(
value
));
}
else
if
(
viewType
==
ViewType
.
DATE_AND_TIME
)
{
}
else
if
(
viewType
==
ViewType
.
DATE_AND_TIME
)
{
jsonColumnValue
=
Util
.
getDateTime
(
Util
.
getDateTimeFromString
(
value
));
jsonColumnValue
=
Util
.
getDateTime
(
Util
.
getDateTimeFromString
(
value
));
}
}
if
(
catalogueVariable
.
isMandatory
())
{
if
(
catalogueVariable
.
isMandatory
())
{
if
(
viewType
!=
ViewType
.
SELECT_BOX
&&
viewType
!=
ViewType
.
UI_PAGE
)
{
if
(
viewType
!=
ViewType
.
SELECT_BOX
&&
viewType
!=
ViewType
.
UI_PAGE
)
{
if
(
TextUtils
.
isEmpty
(
jsonColumnValue
))
{
if
(
TextUtils
.
isEmpty
(
jsonColumnValue
))
{
hasErrors
=
true
;
hasErrors
=
true
;
...
@@ -439,14 +525,11 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -439,14 +525,11 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
}
}
}
}
try
{
try
{
jsonObject
.
put
(
catalogueVariable
.
getName
(),
jsonColumnValue
);
jsonObject
.
put
(
catalogueVariable
.
getName
(),
jsonColumnValue
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
mJsonArray
.
put
(
jsonObject
);
valueList
.
add
(
value
);
}
}
}
}
}
}
...
@@ -455,7 +538,9 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -455,7 +538,9 @@ public class CatalogueVariableScreen extends AppCompatActivity {
return
;
return
;
if
(
mApplication
.
isNetConnected
())
{
if
(
mApplication
.
isNetConnected
())
{
new
SubmitForm
().
execute
();
jsonArray
=
new
JSONArray
();
jsonArray
.
put
(
jsonObject
);
new
SubmitForm
().
execute
(
jsonArray
.
toString
());
}
else
{
}
else
{
DialogUtils
.
showNoConnectionDialogWithCloseActivity
(
CatalogueVariableScreen
.
this
);
DialogUtils
.
showNoConnectionDialogWithCloseActivity
(
CatalogueVariableScreen
.
this
);
}
}
...
@@ -520,8 +605,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -520,8 +605,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
@Override
@Override
public
void
positiveButtonClick
(
Reference
reference
)
{
public
void
positiveButtonClick
(
Reference
reference
)
{
editText
.
setText
(
reference
.
getName
());
editText
.
setText
(
reference
.
getName
());
TagObject
tagObject
=
(
TagObject
)
v
.
getTag
();
v
.
setTag
(
reference
);
tagObject
.
setTagObject
(
reference
);
}
}
@Override
@Override
...
@@ -530,8 +614,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -530,8 +614,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
};
};
FragmentManager
fm
=
getSupportFragmentManager
();
FragmentManager
fm
=
getSupportFragmentManager
();
TagObject
tagObject
=
(
TagObject
)
v
.
getTag
();
CatalogueVariable
catalogueVariable
=
getVariableForView
(
v
);
CatalogueVariable
catalogueVariable
=
mCatalogueVariableList
.
get
(
tagObject
.
getIndex
());
String
tableName
=
catalogueVariable
.
getReferenceTable
();
String
tableName
=
catalogueVariable
.
getReferenceTable
();
String
columnName
=
catalogueVariable
.
getReferenceColumnName
();
String
columnName
=
catalogueVariable
.
getReferenceColumnName
();
String
title
=
catalogueVariable
.
getQuestionText
();
String
title
=
catalogueVariable
.
getQuestionText
();
...
@@ -558,6 +641,35 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -558,6 +641,35 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
};
};
CompoundButton
.
OnCheckedChangeListener
checkedChangeListener
=
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
isChecked
)
{
CatalogueVariable
catalogueVariable
=
getVariableForView
(
compoundButton
);
runUIPolicyActions
(
catalogueVariable
.
getSysId
());
}
};
RadioGroup
.
OnCheckedChangeListener
radioGroupCheckedChangeListener
=
new
RadioGroup
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
RadioGroup
radioGroup
,
int
i
)
{
CatalogueVariable
catalogueVariable
=
getVariableForView
(
radioGroup
);
runUIPolicyActions
(
catalogueVariable
.
getSysId
());
}
};
AdapterView
.
OnItemSelectedListener
spinnerItemSelectedListener
=
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
adapterView
,
View
view
,
int
i
,
long
l
)
{
CatalogueVariable
catalogueVariable
=
getVariableForView
(
adapterView
);
runUIPolicyActions
(
catalogueVariable
.
getSysId
());
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
adapterView
)
{
}
};
class
SubmitForm
extends
AsyncTask
<
String
,
Void
,
SyncStatus
>
{
class
SubmitForm
extends
AsyncTask
<
String
,
Void
,
SyncStatus
>
{
private
ProgressDialog
progressDialog
;
private
ProgressDialog
progressDialog
;
...
@@ -572,7 +684,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -572,7 +684,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
@Override
@Override
protected
SyncStatus
doInBackground
(
String
...
params
)
{
protected
SyncStatus
doInBackground
(
String
...
params
)
{
return
CatalogueVariableApiManager
.
submitVariableForm
(
mCatalogueItemSysId
,
mJsonArray
,
new
PostVariableFormApiListener
()
{
return
CatalogueVariableApiManager
.
submitVariableForm
(
mCatalogueItemSysId
,
params
[
0
]
,
new
PostVariableFormApiListener
()
{
@Override
@Override
public
void
onDoneApiCall
(
String
variableFromSysId
)
{
public
void
onDoneApiCall
(
String
variableFromSysId
)
{
if
(
mAttachmentFile
!=
null
)
{
if
(
mAttachmentFile
!=
null
)
{
...
@@ -904,4 +1016,167 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -904,4 +1016,167 @@ public class CatalogueVariableScreen extends AppCompatActivity {
AlertDialog
alert
=
builder
.
create
();
AlertDialog
alert
=
builder
.
create
();
alert
.
show
();
alert
.
show
();
}
}
private
void
runUIPolicyActions
(
String
sysId
)
{
for
(
int
i
=
0
;
i
<
mUiPolicyItemList
.
size
();
i
++)
{
UiPolicyItem
item
=
mUiPolicyItemList
.
get
(
i
);
/*UIPolicy condition is null then skip iterator*/
if
(
item
.
getPartialConditions
()==
null
)
continue
;
boolean
needToExecuteUIPolicy
=
false
;
if
(
sysId
!=
null
)
{
for
(
int
j
=
0
;
j
<
item
.
getPartialConditions
().
size
();
j
++)
{
if
(
item
.
getPartialConditions
().
get
(
j
).
getViewSysId
().
equals
(
sysId
))
{
needToExecuteUIPolicy
=
true
;
break
;
}
}
if
(!
needToExecuteUIPolicy
)
continue
;
}
boolean
conditionsSatisfied
=
true
;
for
(
int
j
=
0
;
j
<
item
.
getPartialConditions
().
size
();
j
++)
{
PartialCondition
condition
=
item
.
getPartialConditions
().
get
(
j
);
CatalogueVariable
variable
=
getVariableForSysId
(
condition
.
getViewSysId
());
VariableViewContainer
variableViewContainer
=
mVariableViewMap
.
get
(
variable
);
if
(
variableViewContainer
==
null
||
variableViewContainer
.
getInputView
()
==
null
)
{
continue
;
}
String
value
=
Util
.
getVariableViewValueForUIPolicy
(
variableViewContainer
.
getInputView
(),
variable
);
switch
(
condition
.
getOperator
())
{
case
EQUAL:
conditionsSatisfied
=
conditionsSatisfied
&&
value
.
equals
(
condition
.
getOperatorValue
());
break
;
case
IS_NOT_EMPTY:
conditionsSatisfied
=
conditionsSatisfied
&&
!
TextUtils
.
isEmpty
(
value
);
break
;
}
}
if
(
conditionsSatisfied
)
{
for
(
int
j
=
0
;
j
<
item
.
getUiPolicyActions
().
size
();
j
++)
{
UiPolicyAction
action
=
item
.
getUiPolicyActions
().
get
(
j
);
CatalogueVariable
variable
=
getVariableForName
(
action
.
getVariableName
());
VariableViewContainer
container
=
mVariableViewMap
.
get
(
variable
);
if
(
container
!=
null
)
{
if
(
action
.
getMandatory
().
equals
(
Boolean
.
toString
(
true
)))
{
variable
.
setMandatory
(
true
);
/*For first time, by default there is no error view
*but after call UIPolicy api we need to create an error view and set it to container.*/
if
(
container
.
getErrorView
()==
null
)
{
TextView
errorView
=
Util
.
getErrorView
(
CatalogueVariableScreen
.
this
);
container
.
setErrorView
(
errorView
);
container
.
getContainerView
().
addView
(
errorView
);
}
setMandatoryView
(
container
,
variable
.
getQuestionText
(),
true
);
}
else
if
(
action
.
getMandatory
().
equals
(
Boolean
.
toString
(
false
)))
{
variable
.
setMandatory
(
false
);
setMandatoryView
(
container
,
variable
.
getQuestionText
(),
false
);
}
if
(
action
.
getVisible
().
equals
(
Boolean
.
toString
(
true
)))
{
container
.
getContainerView
().
setVisibility
(
View
.
VISIBLE
);
runUIPolicyActions
(
variable
.
getSysId
());
}
else
if
(
action
.
getVisible
().
equals
(
Boolean
.
toString
(
false
)))
{
container
.
getContainerView
().
setVisibility
(
View
.
GONE
);
}
if
(
action
.
getDisabled
().
equals
(
Boolean
.
toString
(
true
)))
{
container
.
getContainerView
().
setEnabled
(
true
);
}
else
if
(
action
.
getDisabled
().
equals
(
Boolean
.
toString
(
false
)))
{
container
.
getContainerView
().
setEnabled
(
false
);
}
}
}
}
else
{
for
(
int
j
=
0
;
j
<
item
.
getUiPolicyActions
().
size
();
j
++)
{
UiPolicyAction
action
=
item
.
getUiPolicyActions
().
get
(
j
);
CatalogueVariable
variable
=
getVariableForName
(
action
.
getVariableName
());
VariableViewContainer
container
=
mVariableViewMap
.
get
(
variable
);
if
(
container
!=
null
)
{
if
(
action
.
getMandatory
().
equals
(
Boolean
.
toString
(
true
)))
{
variable
.
setMandatory
(
false
);
setMandatoryView
(
container
,
variable
.
getQuestionText
(),
false
);
}
else
if
(
action
.
getMandatory
().
equals
(
Boolean
.
toString
(
false
)))
{
/*For first time, by default there is no error view
*but after call UIPolicy api we need to create an error view and set it to container.*/
if
(
container
.
getErrorView
()==
null
)
{
TextView
errorView
=
Util
.
getErrorView
(
CatalogueVariableScreen
.
this
);
container
.
setErrorView
(
errorView
);
container
.
getContainerView
().
addView
(
errorView
);
}
variable
.
setMandatory
(
true
);
setMandatoryView
(
container
,
variable
.
getQuestionText
(),
true
);
}
if
(
action
.
getVisible
().
equals
(
Boolean
.
toString
(
true
)))
{
container
.
getContainerView
().
setVisibility
(
View
.
GONE
);
}
else
if
(
action
.
getVisible
().
equals
(
Boolean
.
toString
(
false
)))
{
container
.
getContainerView
().
setVisibility
(
View
.
VISIBLE
);
runUIPolicyActions
(
variable
.
getSysId
());
}
if
(
action
.
getDisabled
().
equals
(
Boolean
.
toString
(
true
)))
{
container
.
getContainerView
().
setEnabled
(
false
);
}
else
if
(
action
.
getDisabled
().
equals
(
Boolean
.
toString
(
false
)))
{
container
.
getContainerView
().
setEnabled
(
true
);
}
}
}
}
}
}
private
CatalogueVariable
getVariableForSysId
(
String
sysId
)
{
for
(
int
i
=
0
;
i
<
mCatalogueVariableList
.
size
();
i
++)
{
if
(
mCatalogueVariableList
.
get
(
i
).
getSysId
().
equals
(
sysId
))
return
mCatalogueVariableList
.
get
(
i
);
}
return
null
;
}
private
CatalogueVariable
getVariableForName
(
String
name
)
{
for
(
int
i
=
0
;
i
<
mCatalogueVariableList
.
size
();
i
++)
{
if
(
mCatalogueVariableList
.
get
(
i
).
getName
().
equals
(
name
))
return
mCatalogueVariableList
.
get
(
i
);
}
return
null
;
}
private
CatalogueVariable
getVariableForView
(
View
view
)
{
for
(
int
i
=
0
;
i
<
mCatalogueVariableList
.
size
();
i
++)
{
VariableViewContainer
container
=
mVariableViewMap
.
get
(
mCatalogueVariableList
.
get
(
i
));
if
(
container
==
null
)
{
continue
;
}
if
(
container
.
getInputView
()
!=
null
)
{
if
(
container
.
getInputView
()
==
view
)
return
mCatalogueVariableList
.
get
(
i
);
}
else
if
(
container
.
getContainerView
()
!=
null
)
{
if
(
container
.
getContainerView
()
==
view
)
return
mCatalogueVariableList
.
get
(
i
);
}
}
return
null
;
}
private
void
setMandatoryView
(
VariableViewContainer
container
,
String
displayString
,
boolean
isMandatory
)
{
TextView
label
=
(
TextView
)
container
.
getLabelView
();
if
(
label
!=
null
)
{
if
(!
isMandatory
)
{
label
.
setText
(
displayString
);
}
else
{
/*Create label with mandatory value*/
StringBuilder
stringBuilder
=
new
StringBuilder
();
stringBuilder
.
append
(
displayString
);
stringBuilder
.
append
(
getString
(
R
.
string
.
variable_form_view_mandatory_sign_string
));
label
=
(
TextView
)
container
.
getLabelView
();
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
N
)
{
label
.
setText
(
Html
.
fromHtml
(
stringBuilder
.
toString
(),
Html
.
FROM_HTML_MODE_LEGACY
));
}
else
{
label
.
setText
(
Html
.
fromHtml
(
stringBuilder
.
toString
()));
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/vsoft/uoflservicenow/utils/ActionCondition.java
0 → 100644
View file @
67ff5765
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
;
}
}
app/src/main/java/com/vsoft/uoflservicenow/utils/Constants.java
View file @
67ff5765
...
@@ -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
;
...
...
app/src/main/java/com/vsoft/uoflservicenow/utils/PartialCondition.java
0 → 100644
View file @
67ff5765
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
+
'\''
+
'}'
;
}
}
app/src/main/java/com/vsoft/uoflservicenow/utils/Util.java
View file @
67ff5765
...
@@ -3,6 +3,7 @@ package com.vsoft.uoflservicenow.utils;
...
@@ -3,6 +3,7 @@ package com.vsoft.uoflservicenow.utils;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Typeface
;
import
android.graphics.Typeface
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.text.Html
;
import
android.text.InputType
;
import
android.text.InputType
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.text.method.PasswordTransformationMethod
;
import
android.text.method.PasswordTransformationMethod
;
...
@@ -26,6 +27,7 @@ import com.vsoft.uoflservicenow.R;
...
@@ -26,6 +27,7 @@ import com.vsoft.uoflservicenow.R;
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.db.models.Reference
;
import
com.vsoft.uoflservicenow.db.models.VariableChoice
;
import
com.vsoft.uoflservicenow.db.models.VariableChoice
;
import
com.vsoft.uoflservicenow.db.models.VariableViewContainer
;
import
com.vsoft.uoflservicenow.enums.ViewType
;
import
com.vsoft.uoflservicenow.enums.ViewType
;
import
java.text.ParseException
;
import
java.text.ParseException
;
...
@@ -33,11 +35,60 @@ import java.text.SimpleDateFormat;
...
@@ -33,11 +35,60 @@ import java.text.SimpleDateFormat;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
static
com
.
vsoft
.
uoflservicenow
.
enums
.
ViewType
.
BREAK
;
import
static
com
.
vsoft
.
uoflservicenow
.
enums
.
ViewType
.
CHECK_BOX
;
/**
/**
* Created by Kunj on 12/8/16.
* Created by Kunj on 12/8/16.
*/
*/
public
class
Util
{
public
class
Util
{
public
static
View
getView
(
Context
context
,
ViewType
viewType
,
CatalogueVariable
catalogueVariable
)
{
private
static
TextView
getLabelView
(
Context
context
,
CatalogueVariable
catalogueVariable
,
LinearLayout
.
LayoutParams
childLabelViewLayoutParams
)
{
ViewType
viewType
=
catalogueVariable
.
getType
();
if
(
catalogueVariable
.
getQuestionText
()
!=
null
&&
viewType
!=
ViewType
.
MACRO
/*&& viewType != ViewType.CONTAINER_START*/
&&
viewType
!=
ViewType
.
CONTAINER_END
&&
viewType
!=
ViewType
.
CONTAINER_SPLIT
&&
viewType
!=
ViewType
.
LABEL
&&
viewType
!=
CHECK_BOX
&&
viewType
!=
BREAK
)
{
/*For MACRO, CONTAINER_START, CONTAINER_END and CONTAINER_SPLIT, there is no need to render any view*/
/*Create label for every type*/
if
(!
catalogueVariable
.
isMandatory
())
{
TextView
label
=
new
TextView
(
context
);
label
.
setText
(
catalogueVariable
.
getQuestionText
());
childLabelViewLayoutParams
.
topMargin
=
(
int
)
context
.
getResources
().
getDimension
(
R
.
dimen
.
small_margin
);
return
label
;
}
else
{
/*Create label with mandatory value*/
StringBuilder
stringBuilder
=
new
StringBuilder
();
stringBuilder
.
append
(
catalogueVariable
.
getQuestionText
());
stringBuilder
.
append
(
context
.
getString
(
R
.
string
.
variable_form_view_mandatory_sign_string
));
TextView
label
=
new
TextView
(
context
);
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
N
)
{
label
.
setText
(
Html
.
fromHtml
(
stringBuilder
.
toString
(),
Html
.
FROM_HTML_MODE_LEGACY
));
}
else
{
label
.
setText
(
Html
.
fromHtml
(
stringBuilder
.
toString
()));
}
return
label
;
}
}
else
{
return
null
;
}
}
public
static
VariableViewContainer
getVariableViewContainer
(
Context
context
,
CatalogueVariable
catalogueVariable
,
LinearLayout
.
LayoutParams
childLabelViewLayoutParams
)
{
VariableViewContainer
container
=
new
VariableViewContainer
();
/*Label View*/
TextView
label
=
getLabelView
(
context
,
catalogueVariable
,
childLabelViewLayoutParams
);
container
.
setLabelView
(
label
);
/*Error View*/
TextView
errorView
=
null
;
if
(
catalogueVariable
.
isMandatory
())
{
errorView
=
getErrorView
(
context
);
}
container
.
setErrorView
(
errorView
);
ViewType
viewType
=
catalogueVariable
.
getType
();
LinearLayout
linearLayout
;
switch
(
viewType
)
{
switch
(
viewType
)
{
case
YES_NO:
case
YES_NO:
Spinner
spinner
=
new
Spinner
(
context
);
Spinner
spinner
=
new
Spinner
(
context
);
...
@@ -48,7 +99,19 @@ public class Util {
...
@@ -48,7 +99,19 @@ public class Util {
context
.
getResources
().
getString
(
R
.
string
.
no_string
)});
context
.
getResources
().
getString
(
R
.
string
.
no_string
)});
spinnerArrayAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
spinnerArrayAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
spinner
.
setAdapter
(
spinnerArrayAdapter
);
spinner
.
setAdapter
(
spinnerArrayAdapter
);
return
spinner
;
container
.
setInputView
(
spinner
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
spinner
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
MULTI_LINE_TEXT:
case
MULTI_LINE_TEXT:
EditText
multiLineEditText
=
new
EditText
(
context
);
EditText
multiLineEditText
=
new
EditText
(
context
);
multiLineEditText
.
setSingleLine
(
false
);
multiLineEditText
.
setSingleLine
(
false
);
...
@@ -57,7 +120,19 @@ public class Util {
...
@@ -57,7 +120,19 @@ public class Util {
multiLineEditText
.
setLines
(
3
);
multiLineEditText
.
setLines
(
3
);
multiLineEditText
.
setVerticalScrollBarEnabled
(
true
);
multiLineEditText
.
setVerticalScrollBarEnabled
(
true
);
multiLineEditText
.
setGravity
(
Gravity
.
START
);
multiLineEditText
.
setGravity
(
Gravity
.
START
);
return
multiLineEditText
;
container
.
setInputView
(
multiLineEditText
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
multiLineEditText
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
HTML:
case
HTML:
EditText
htmlEditText
=
new
EditText
(
context
);
EditText
htmlEditText
=
new
EditText
(
context
);
htmlEditText
.
setSingleLine
(
false
);
htmlEditText
.
setSingleLine
(
false
);
...
@@ -66,45 +141,119 @@ public class Util {
...
@@ -66,45 +141,119 @@ public class Util {
htmlEditText
.
setLines
(
3
);
htmlEditText
.
setLines
(
3
);
htmlEditText
.
setVerticalScrollBarEnabled
(
true
);
htmlEditText
.
setVerticalScrollBarEnabled
(
true
);
htmlEditText
.
setGravity
(
Gravity
.
START
);
htmlEditText
.
setGravity
(
Gravity
.
START
);
return
htmlEditText
;
container
.
setInputView
(
htmlEditText
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
htmlEditText
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
NUMERIC_SCALE:
case
NUMERIC_SCALE:
LinearLayout
linearLayout
=
new
LinearLayout
(
context
);
LinearLayout
numericScaleLayout
=
new
LinearLayout
(
context
);
numericScaleLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
RadioButton
[]
radioButtons
=
new
RadioButton
[
5
];
RadioButton
[]
radioButtons
=
new
RadioButton
[
5
];
RadioGroup
rg
=
new
RadioGroup
(
context
);
//create the RadioGroup
RadioGroup
rg
=
new
RadioGroup
(
context
);
//create the RadioGroup
rg
.
setOrientation
(
RadioGroup
.
HORIZONTAL
);
//or RadioGroup.VERTICAL
rg
.
setOrientation
(
RadioGroup
.
HORIZONTAL
);
//or RadioGroup.VERTICAL
for
(
int
i
=
0
;
i
<
5
;
i
++){
for
(
int
i
=
0
;
i
<
5
;
i
++){
radioButtons
[
i
]
=
new
RadioButton
(
context
);
radioButtons
[
i
]
=
new
RadioButton
(
context
);
radioButtons
[
i
].
setText
(
String
.
format
(
context
.
getString
(
R
.
string
.
variable_form_radio_text_string
),
(
i
+
1
)));
radioButtons
[
i
].
setText
(
String
.
format
(
context
.
getString
(
R
.
string
.
variable_form_radio_text_string
),
(
i
+
1
)));
rg
.
addView
(
radioButtons
[
i
]);
rg
.
addView
(
radioButtons
[
i
]);
}
}
linearLayout
.
addView
(
rg
);
container
.
setInputView
(
rg
);
return
linearLayout
;
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
numericScaleLayout
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
CHECK_BOX:
case
CHECK_BOX:
CheckBox
checkBox
=
new
CheckBox
(
context
);
CheckBox
checkBox
=
new
CheckBox
(
context
);
checkBox
.
setText
(
catalogueVariable
.
getQuestionText
());
checkBox
.
setText
(
catalogueVariable
.
getQuestionText
());
return
checkBox
;
container
.
setInputView
(
checkBox
);
break
;
case
SINGLE_LINE_TEXT:
case
SINGLE_LINE_TEXT:
EditText
singleLineEditText
=
new
EditText
(
context
);
EditText
singleLineEditText
=
new
EditText
(
context
);
singleLineEditText
.
setSingleLine
(
true
);
singleLineEditText
.
setSingleLine
(
true
);
singleLineEditText
.
setLines
(
1
);
singleLineEditText
.
setLines
(
1
);
singleLineEditText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_CAP_SENTENCES
);
singleLineEditText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_CAP_SENTENCES
);
return
singleLineEditText
;
container
.
setInputView
(
singleLineEditText
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
singleLineEditText
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
WIDE_SINGLE_LINE_TEXT:
case
WIDE_SINGLE_LINE_TEXT:
EditText
wideSingleLineEditText
=
new
EditText
(
context
);
EditText
wideSingleLineEditText
=
new
EditText
(
context
);
wideSingleLineEditText
.
setSingleLine
(
true
);
wideSingleLineEditText
.
setSingleLine
(
true
);
wideSingleLineEditText
.
setLines
(
1
);
wideSingleLineEditText
.
setLines
(
1
);
wideSingleLineEditText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_CAP_SENTENCES
);
wideSingleLineEditText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_CAP_SENTENCES
);
return
wideSingleLineEditText
;
container
.
setInputView
(
wideSingleLineEditText
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
wideSingleLineEditText
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
DATE:
case
DATE:
Button
dateTextButton
=
new
Button
(
context
);
Button
dateTextButton
=
new
Button
(
context
);
dateTextButton
.
setText
(
getDefaultDate
());
dateTextButton
.
setText
(
getDefaultDate
());
dateTextButton
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
dateTextButton
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
return
dateTextButton
;
container
.
setInputView
(
dateTextButton
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
dateTextButton
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
DATE_AND_TIME:
case
DATE_AND_TIME:
Button
dateTimeButton
=
new
Button
(
context
);
Button
dateTimeButton
=
new
Button
(
context
);
dateTimeButton
.
setText
(
getDefaultDateTime
()
/* + " " + getDefaultTime()*/
);
dateTimeButton
.
setText
(
getDefaultDateTime
()
/* + " " + getDefaultTime()*/
);
dateTimeButton
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
dateTimeButton
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
return
dateTimeButton
;
container
.
setInputView
(
dateTimeButton
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
dateTimeButton
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
REFERENCE:
case
REFERENCE:
EditText
referenceEditText
=
new
EditText
(
context
);
EditText
referenceEditText
=
new
EditText
(
context
);
referenceEditText
.
setLines
(
1
);
referenceEditText
.
setLines
(
1
);
...
@@ -114,7 +263,19 @@ public class Util {
...
@@ -114,7 +263,19 @@ public class Util {
referenceEditText
.
setFocusableInTouchMode
(
false
);
referenceEditText
.
setFocusableInTouchMode
(
false
);
referenceEditText
.
setClickable
(
false
);
referenceEditText
.
setClickable
(
false
);
referenceEditText
.
setCompoundDrawablesWithIntrinsicBounds
(
0
,
0
,
android
.
R
.
drawable
.
ic_menu_search
,
0
);
referenceEditText
.
setCompoundDrawablesWithIntrinsicBounds
(
0
,
0
,
android
.
R
.
drawable
.
ic_menu_search
,
0
);
return
referenceEditText
;
container
.
setInputView
(
referenceEditText
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
referenceEditText
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
LABEL:
case
LABEL:
LinearLayout
labelLayout
=
new
LinearLayout
(
context
);
LinearLayout
labelLayout
=
new
LinearLayout
(
context
);
labelLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
labelLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
...
@@ -123,6 +284,7 @@ public class Util {
...
@@ -123,6 +284,7 @@ public class Util {
labelTextView
.
setText
(
catalogueVariable
.
getQuestionText
());
labelTextView
.
setText
(
catalogueVariable
.
getQuestionText
());
labelTextView
.
setTypeface
(
null
,
Typeface
.
BOLD
);
labelTextView
.
setTypeface
(
null
,
Typeface
.
BOLD
);
labelLayout
.
addView
(
labelTextView
);
labelLayout
.
addView
(
labelTextView
);
container
.
setInputView
(
labelTextView
);
View
view
=
new
View
(
context
);
View
view
=
new
View
(
context
);
view
.
setLayoutParams
(
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
1
));
view
.
setLayoutParams
(
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
1
));
...
@@ -130,7 +292,8 @@ public class Util {
...
@@ -130,7 +292,8 @@ public class Util {
labelLayout
.
addView
(
view
);
labelLayout
.
addView
(
view
);
labelLayout
.
setPadding
(
0
,
0
,
0
,
(
int
)
context
.
getResources
().
getDimension
(
R
.
dimen
.
small_margin
));
labelLayout
.
setPadding
(
0
,
0
,
0
,
(
int
)
context
.
getResources
().
getDimension
(
R
.
dimen
.
small_margin
));
return
labelLayout
;
container
.
setContainerView
(
labelLayout
);
break
;
case
MASKED:
case
MASKED:
EditText
maskedEditText
=
new
EditText
(
context
);
EditText
maskedEditText
=
new
EditText
(
context
);
maskedEditText
.
setInputType
(
InputType
.
TYPE_TEXT_VARIATION_PASSWORD
);
maskedEditText
.
setInputType
(
InputType
.
TYPE_TEXT_VARIATION_PASSWORD
);
...
@@ -138,7 +301,19 @@ public class Util {
...
@@ -138,7 +301,19 @@ public class Util {
maskedEditText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_CAP_SENTENCES
);
maskedEditText
.
setInputType
(
InputType
.
TYPE_TEXT_FLAG_CAP_SENTENCES
);
maskedEditText
.
setSingleLine
(
true
);
maskedEditText
.
setSingleLine
(
true
);
maskedEditText
.
setTransformationMethod
(
PasswordTransformationMethod
.
getInstance
());
maskedEditText
.
setTransformationMethod
(
PasswordTransformationMethod
.
getInstance
());
return
maskedEditText
;
container
.
setInputView
(
maskedEditText
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
maskedEditText
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
MULTIPLE_CHOICE:
case
MULTIPLE_CHOICE:
LinearLayout
multiChoiceLinearLayout
=
new
LinearLayout
(
context
);
LinearLayout
multiChoiceLinearLayout
=
new
LinearLayout
(
context
);
multiChoiceLinearLayout
.
setOrientation
(
LinearLayout
.
HORIZONTAL
);
multiChoiceLinearLayout
.
setOrientation
(
LinearLayout
.
HORIZONTAL
);
...
@@ -161,7 +336,19 @@ public class Util {
...
@@ -161,7 +336,19 @@ public class Util {
radioGroup
.
addView
(
multiChoiceRadioButtons
[
i
]);
radioGroup
.
addView
(
multiChoiceRadioButtons
[
i
]);
}
}
multiChoiceLinearLayout
.
addView
(
radioGroup
);
multiChoiceLinearLayout
.
addView
(
radioGroup
);
return
multiChoiceLinearLayout
;
container
.
setInputView
(
radioGroup
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
multiChoiceLinearLayout
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
SELECT_BOX:
case
SELECT_BOX:
Spinner
selectBoxSpinner
=
new
Spinner
(
context
);
Spinner
selectBoxSpinner
=
new
Spinner
(
context
);
selectBoxSpinner
.
setPadding
(
0
,
(
int
)
context
.
getResources
().
getDimension
(
R
.
dimen
.
normal_margin
),
selectBoxSpinner
.
setPadding
(
0
,
(
int
)
context
.
getResources
().
getDimension
(
R
.
dimen
.
normal_margin
),
...
@@ -170,12 +357,25 @@ public class Util {
...
@@ -170,12 +357,25 @@ public class Util {
new
ArrayAdapter
<>(
context
,
android
.
R
.
layout
.
simple_spinner_item
,
catalogueVariable
.
getDisplayChoiceText
(
context
,
catalogueVariable
.
isNoneRequired
()));
new
ArrayAdapter
<>(
context
,
android
.
R
.
layout
.
simple_spinner_item
,
catalogueVariable
.
getDisplayChoiceText
(
context
,
catalogueVariable
.
isNoneRequired
()));
selectBoxSpinnerArrayAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
selectBoxSpinnerArrayAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
selectBoxSpinner
.
setAdapter
(
selectBoxSpinnerArrayAdapter
);
selectBoxSpinner
.
setAdapter
(
selectBoxSpinnerArrayAdapter
);
return
selectBoxSpinner
;
container
.
setInputView
(
selectBoxSpinner
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
selectBoxSpinner
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
BREAK:
case
BREAK:
View
breakView
=
new
View
(
context
);
View
breakView
=
new
View
(
context
);
breakView
.
setLayoutParams
(
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
1
));
breakView
.
setLayoutParams
(
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
1
));
breakView
.
setBackgroundColor
(
ContextCompat
.
getColor
(
context
,
android
.
R
.
color
.
black
));
breakView
.
setBackgroundColor
(
ContextCompat
.
getColor
(
context
,
android
.
R
.
color
.
black
));
return
breakView
;
container
.
setInputView
(
breakView
);
break
;
case
UI_PAGE:
case
UI_PAGE:
LinearLayout
uiPageLayout
=
new
LinearLayout
(
context
);
LinearLayout
uiPageLayout
=
new
LinearLayout
(
context
);
uiPageLayout
.
setOrientation
(
LinearLayout
.
HORIZONTAL
);
uiPageLayout
.
setOrientation
(
LinearLayout
.
HORIZONTAL
);
...
@@ -195,10 +395,36 @@ public class Util {
...
@@ -195,10 +395,36 @@ public class Util {
attachmentTextView
.
setEllipsize
(
TextUtils
.
TruncateAt
.
MIDDLE
);
attachmentTextView
.
setEllipsize
(
TextUtils
.
TruncateAt
.
MIDDLE
);
attachmentTextView
.
setText
(
R
.
string
.
variable_form_ui_page_no_selected_attachment_string
);
attachmentTextView
.
setText
(
R
.
string
.
variable_form_ui_page_no_selected_attachment_string
);
uiPageLayout
.
addView
(
attachmentTextView
,
layoutParams
);
uiPageLayout
.
addView
(
attachmentTextView
,
layoutParams
);
container
.
setInputView
(
uiPageLayout
);
return
uiPageLayout
;
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
}
return
null
;
linearLayout
.
addView
(
uiPageLayout
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
case
CONTAINER_START:
LinearLayout
containerLinearLayout
=
new
LinearLayout
(
context
);
containerLinearLayout
.
setOrientation
(
LinearLayout
.
HORIZONTAL
);
linearLayout
=
new
LinearLayout
(
context
);
linearLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
if
(
label
!=
null
)
{
linearLayout
.
addView
(
label
,
childLabelViewLayoutParams
);
}
linearLayout
.
addView
(
containerLinearLayout
);
if
(
errorView
!=
null
)
{
linearLayout
.
addView
(
errorView
);
}
container
.
setContainerView
(
linearLayout
);
break
;
}
return
container
;
}
}
public
static
String
getVariableViewValue
(
View
view
,
ViewType
viewType
)
{
public
static
String
getVariableViewValue
(
View
view
,
ViewType
viewType
)
{
...
@@ -224,7 +450,7 @@ public class Util {
...
@@ -224,7 +450,7 @@ public class Util {
}
}
case
CHECK_BOX:
case
CHECK_BOX:
CheckBox
checkBox
=
(
CheckBox
)
view
;
CheckBox
checkBox
=
(
CheckBox
)
view
;
return
checkBox
.
isChecked
()
?
"
1"
:
"0
"
;
return
checkBox
.
isChecked
()
?
"
true"
:
"false
"
;
case
SINGLE_LINE_TEXT:
case
SINGLE_LINE_TEXT:
EditText
singleLineEditText
=
(
EditText
)
view
;
EditText
singleLineEditText
=
(
EditText
)
view
;
return
singleLineEditText
.
getText
().
toString
();
return
singleLineEditText
.
getText
().
toString
();
...
@@ -238,8 +464,7 @@ public class Util {
...
@@ -238,8 +464,7 @@ public class Util {
Button
dateTimeButton
=
(
Button
)
view
;
Button
dateTimeButton
=
(
Button
)
view
;
return
dateTimeButton
.
getText
().
toString
();
return
dateTimeButton
.
getText
().
toString
();
case
REFERENCE:
case
REFERENCE:
TagObject
tagObject
=
(
TagObject
)
view
.
getTag
();
Reference
reference
=
(
Reference
)
view
.
getTag
();
Reference
reference
=
(
Reference
)
tagObject
.
getTagObject
();
if
(
reference
!=
null
)
{
if
(
reference
!=
null
)
{
return
reference
.
getSysId
();
return
reference
.
getSysId
();
}
else
{
}
else
{
...
@@ -249,15 +474,12 @@ public class Util {
...
@@ -249,15 +474,12 @@ public class Util {
EditText
maskedEditText
=
(
EditText
)
view
;
EditText
maskedEditText
=
(
EditText
)
view
;
return
maskedEditText
.
getText
().
toString
();
return
maskedEditText
.
getText
().
toString
();
case
MULTIPLE_CHOICE:
case
MULTIPLE_CHOICE:
LinearLayout
multipleChoiceLinearLayout
=
(
LinearLayout
)
view
;
RadioGroup
multipleChoiceRadioGroup
=
(
RadioGroup
)
view
;
for
(
int
i
=
0
;
i
<
multipleChoiceLinearLayout
.
getChildCount
();
i
++)
{
int
radioButtonID
=
multipleChoiceRadioGroup
.
getCheckedRadioButtonId
();
RadioGroup
radioGroup
=
(
RadioGroup
)
multipleChoiceLinearLayout
.
getChildAt
(
i
);
RadioButton
radioButton
=
(
RadioButton
)
multipleChoiceRadioGroup
.
findViewById
(
radioButtonID
);
int
radioButtonID
=
radioGroup
.
getCheckedRadioButtonId
();
RadioButton
radioButton
=
(
RadioButton
)
radioGroup
.
findViewById
(
radioButtonID
);
if
(
radioButton
!=
null
)
{
if
(
radioButton
!=
null
)
{
return
radioButton
.
getTag
().
toString
();
return
radioButton
.
getTag
().
toString
();
}
}
}
return
""
;
return
""
;
case
SELECT_BOX:
case
SELECT_BOX:
Spinner
selectBoxSpinner
=
(
Spinner
)
view
;
Spinner
selectBoxSpinner
=
(
Spinner
)
view
;
...
@@ -267,6 +489,25 @@ public class Util {
...
@@ -267,6 +489,25 @@ public class Util {
}
}
}
}
public
static
String
getVariableViewValueForUIPolicy
(
View
view
,
CatalogueVariable
catalogueVariable
)
{
switch
(
catalogueVariable
.
getType
())
{
case
SELECT_BOX:
Spinner
selectBoxSpinner
=
(
Spinner
)
view
;
String
value
=
catalogueVariable
.
getDisplayChoiceText
(
selectBoxSpinner
.
getSelectedItem
().
toString
());
return
value
;
default
:
return
getVariableViewValue
(
view
,
catalogueVariable
.
getType
());
}
}
public
static
TextView
getErrorView
(
Context
context
)
{
TextView
textView
=
new
TextView
(
context
);
textView
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
error_color
));
textView
.
setText
(
R
.
string
.
error_string
);
textView
.
setVisibility
(
View
.
GONE
);
return
textView
;
}
public
static
String
getDefaultDate
()
{
public
static
String
getDefaultDate
()
{
Calendar
c
=
Calendar
.
getInstance
();
Calendar
c
=
Calendar
.
getInstance
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"dd MMM, yyyy"
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"dd MMM, yyyy"
);
...
...
app/src/main/res/values/strings.xml
View file @
67ff5765
...
@@ -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"
>
<
font color="#FF0000"
>
*
<
/font
>
</string>
<string
name=
"variable_form_view_mandatory_sign_string"
>
<
font color="#FF0000"
>
*
<
/font
>
</string>
<string
name=
"variable_form_reference_dialog_title_string"
>
Search \'%s\'
</string>
<string
name=
"variable_form_reference_dialog_title_string"
>
Search \'%s\'
</string>
...
...
gradlew
View file @
67ff5765
...
@@ -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 variable
Name
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 variable
Name
in your environment to match the
location of your Java installation."
location of your Java installation."
fi
fi
...
...
gradlew.bat
View file @
67ff5765
...
@@ -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 variable
Name
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 variable
Name
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 variable
Name
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment