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
feac4b31
authored
Apr 16, 2018
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Changed the POST API for HRCase Variable form submission.
parent
c3018954
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
111 additions
and
14 deletions
app/src/main/java/com/vsoft/servicenow/api/interfaces/HRCaseVariableApi.java
app/src/main/java/com/vsoft/servicenow/api/listeners/post/PostHRCaseVariableFormApiListener.java
app/src/main/java/com/vsoft/servicenow/api/managers/HRCaseVariableApiManager.java
app/src/main/java/com/vsoft/servicenow/api/pojos/HRCaseVariableSubmitApiResponse.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariable.java
app/src/main/java/com/vsoft/servicenow/service/SyncService.java
app/src/main/java/com/vsoft/servicenow/ui/HRCaseVariableScreen.java
app/src/main/java/com/vsoft/servicenow/utils/Constants.java
app/src/vportal/java/com/vsoft/servicenow/AppConfig.java
app/src/main/java/com/vsoft/servicenow/api/interfaces/HRCaseVariableApi.java
View file @
feac4b31
...
@@ -2,6 +2,7 @@ package com.vsoft.servicenow.api.interfaces;
...
@@ -2,6 +2,7 @@ package com.vsoft.servicenow.api.interfaces;
import
com.vsoft.servicenow.db.models.CatalogueItem
;
import
com.vsoft.servicenow.db.models.CatalogueItem
;
import
com.vsoft.servicenow.db.models.CatalogueVariable
;
import
com.vsoft.servicenow.db.models.CatalogueVariable
;
import
com.vsoft.servicenow.db.models.HRCaseVariable
;
import
com.vsoft.servicenow.utils.Constants
;
import
com.vsoft.servicenow.utils.Constants
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -13,6 +14,7 @@ import retrofit2.http.Body;
...
@@ -13,6 +14,7 @@ import retrofit2.http.Body;
import
retrofit2.http.GET
;
import
retrofit2.http.GET
;
import
retrofit2.http.Header
;
import
retrofit2.http.Header
;
import
retrofit2.http.POST
;
import
retrofit2.http.POST
;
import
retrofit2.http.Path
;
import
retrofit2.http.Query
;
import
retrofit2.http.Query
;
import
retrofit2.http.QueryMap
;
import
retrofit2.http.QueryMap
;
import
retrofit2.http.Url
;
import
retrofit2.http.Url
;
...
@@ -26,7 +28,7 @@ import retrofit2.http.Url;
...
@@ -26,7 +28,7 @@ import retrofit2.http.Url;
public
interface
HRCaseVariableApi
{
public
interface
HRCaseVariableApi
{
// Get HRCase Variable API
// Get HRCase Variable API
@GET
(
Constants
.
URL_GET_HR_CASE_VARIABLE
)
@GET
(
Constants
.
URL_GET_HR_CASE_VARIABLE
)
Call
<
ResponseBody
>
getVariable
(
@Query
(
Catalogu
eVariable
.
Json
.
SYS_ID
)
String
sysId
);
Call
<
ResponseBody
>
getVariable
(
@Query
(
HRCas
eVariable
.
Json
.
SYS_ID
)
String
sysId
);
// Get HRCase Variable Choices API
// Get HRCase Variable Choices API
@GET
(
Constants
.
URL_GET_HR_CASE_VARIABLE_CHOICE
)
@GET
(
Constants
.
URL_GET_HR_CASE_VARIABLE_CHOICE
)
...
@@ -34,7 +36,7 @@ public interface HRCaseVariableApi {
...
@@ -34,7 +36,7 @@ public interface HRCaseVariableApi {
// Post HRCase item API
// Post HRCase item API
@POST
(
Constants
.
URL_POST_HR_CASE_ITEM
)
@POST
(
Constants
.
URL_POST_HR_CASE_ITEM
)
Call
<
ResponseBody
>
postHRCaseItem
(
@
Query
(
CatalogueItem
.
Json
.
SYS_ID
)
String
sysId
,
Call
<
ResponseBody
>
postHRCaseItem
(
@
Path
(
HRCaseVariable
.
Json
.
SYS_ID
)
String
user
,
@Body
String
catalogueItemJson
);
@Body
String
catalogueItemJson
);
// Get HRCase Reference API
// Get HRCase Reference API
...
@@ -51,7 +53,7 @@ public interface HRCaseVariableApi {
...
@@ -51,7 +53,7 @@ public interface HRCaseVariableApi {
// Get HRCase Variable API
// Get HRCase Variable API
@GET
(
Constants
.
URL_GET_HR_CASE_UI_POLICY
)
@GET
(
Constants
.
URL_GET_HR_CASE_UI_POLICY
)
Call
<
ResponseBody
>
getUiPolicy
(
@Query
(
Catalogu
eVariable
.
Json
.
SYS_ID
)
String
sysId
);
Call
<
ResponseBody
>
getUiPolicy
(
@Query
(
HRCas
eVariable
.
Json
.
SYS_ID
)
String
sysId
);
}
}
app/src/main/java/com/vsoft/servicenow/api/listeners/post/PostHRCaseVariableFormApiListener.java
View file @
feac4b31
package
com
.
vsoft
.
servicenow
.
api
.
listeners
.
post
;
package
com
.
vsoft
.
servicenow
.
api
.
listeners
.
post
;
import
com.vsoft.servicenow.api.pojos.HRCaseVariableSubmitApiResponse
;
/**
/**
* @since 1.0
* @since 1.0
* @author Created by Kunj on 13/04/2018.
* @author Created by Kunj on 13/04/2018.
*
*
*/
*/
public
interface
PostHRCaseVariableFormApiListener
{
public
interface
PostHRCaseVariableFormApiListener
{
void
onDoneApiCall
(
String
hrCaseVariableFromSysId
);
void
onDoneApiCall
(
HRCaseVariableSubmitApiResponse
hrCaseVariableSubmitApiResponse
);
void
onFailApiCall
();
void
onFailApiCall
();
}
}
app/src/main/java/com/vsoft/servicenow/api/managers/HRCaseVariableApiManager.java
View file @
feac4b31
...
@@ -14,6 +14,7 @@ import com.vsoft.servicenow.api.interfaces.HRCaseVariableApi;
...
@@ -14,6 +14,7 @@ import com.vsoft.servicenow.api.interfaces.HRCaseVariableApi;
import
com.vsoft.servicenow.api.listeners.get.GetHRCaseVariableApiListener
;
import
com.vsoft.servicenow.api.listeners.get.GetHRCaseVariableApiListener
;
import
com.vsoft.servicenow.api.listeners.post.PostHRCaseAttachmentApiListener
;
import
com.vsoft.servicenow.api.listeners.post.PostHRCaseAttachmentApiListener
;
import
com.vsoft.servicenow.api.listeners.post.PostHRCaseVariableFormApiListener
;
import
com.vsoft.servicenow.api.listeners.post.PostHRCaseVariableFormApiListener
;
import
com.vsoft.servicenow.api.pojos.HRCaseVariableSubmitApiResponse
;
import
com.vsoft.servicenow.db.models.CatalogueVariable
;
import
com.vsoft.servicenow.db.models.CatalogueVariable
;
import
com.vsoft.servicenow.db.models.HRCaseVariable
;
import
com.vsoft.servicenow.db.models.HRCaseVariable
;
import
com.vsoft.servicenow.db.models.HRCaseVariableChoice
;
import
com.vsoft.servicenow.db.models.HRCaseVariableChoice
;
...
@@ -226,8 +227,48 @@ public class HRCaseVariableApiManager {
...
@@ -226,8 +227,48 @@ public class HRCaseVariableApiManager {
JSONObject
jsonObject
=
new
JSONObject
(
response
.
body
().
string
());
JSONObject
jsonObject
=
new
JSONObject
(
response
.
body
().
string
());
JSONObject
error
=
jsonObject
.
optJSONObject
(
Constants
.
RESPONSE_ERROR_OBJECT_NAME
);
JSONObject
error
=
jsonObject
.
optJSONObject
(
Constants
.
RESPONSE_ERROR_OBJECT_NAME
);
if
(
error
==
null
)
{
if
(
error
==
null
)
{
String
resultSysId
=
jsonObject
.
getString
(
Constants
.
RESPONSE_RESULT_OBJECT_NAME
);
Gson
gson
=
new
GsonBuilder
()
listener
.
onDoneApiCall
(
resultSysId
);
.
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
(
"HRCaseVariableApiManager: submitHRCaseVariableForm: 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
(
"HRCaseVariableApiManager: submitHRCaseVariableForm: 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
(
"HRCaseVariableApiManager: submitHRCaseVariableForm: deserialize: float.class: NumberFormatException: "
,
e
);
}
return
value
;
}
})
.
create
();
JSONObject
resultJsonObject
=
jsonObject
.
getJSONObject
(
Constants
.
RESPONSE_RESULT_OBJECT_NAME
);
HRCaseVariableSubmitApiResponse
hrCaseVariableResponse
=
gson
.
fromJson
(
resultJsonObject
.
toString
(),
HRCaseVariableSubmitApiResponse
.
class
);
listener
.
onDoneApiCall
(
hrCaseVariableResponse
);
}
}
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
app/src/main/java/com/vsoft/servicenow/api/pojos/HRCaseVariableSubmitApiResponse.java
0 → 100644
View file @
feac4b31
package
com
.
vsoft
.
servicenow
.
api
.
pojos
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
/**
* Created by chaukadev on 4/16/18.
*/
public
class
HRCaseVariableSubmitApiResponse
{
@SerializedName
(
"record"
)
@Expose
private
String
record
;
@SerializedName
(
"redirect_url"
)
@Expose
private
String
redirectUrl
;
public
String
getRecord
()
{
return
record
;
}
public
void
setRecord
(
String
record
)
{
this
.
record
=
record
;
}
public
String
getRedirectUrl
()
{
return
redirectUrl
;
}
public
void
setRedirectUrl
(
String
redirectUrl
)
{
this
.
redirectUrl
=
redirectUrl
;
}
}
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariable.java
View file @
feac4b31
...
@@ -412,7 +412,11 @@ public class HRCaseVariable {
...
@@ -412,7 +412,11 @@ public class HRCaseVariable {
}
}
public
static
class
Json
{
public
static
class
Json
{
public
static
final
String
SYS_ID
=
"sys_id"
;
public
static
final
String
TYPE
=
"type"
;
public
static
final
String
TYPE
=
"type"
;
/*Variable form attachment*/
public
static
final
String
TABLE_NAME_VALUE
=
"sc_req_item"
;
}
}
@Override
@Override
...
...
app/src/main/java/com/vsoft/servicenow/service/SyncService.java
View file @
feac4b31
...
@@ -13,6 +13,7 @@ import com.vsoft.servicenow.api.managers.CatalogueVariableApiManager;
...
@@ -13,6 +13,7 @@ import com.vsoft.servicenow.api.managers.CatalogueVariableApiManager;
import
com.vsoft.servicenow.api.managers.HRCaseItemApiManager
;
import
com.vsoft.servicenow.api.managers.HRCaseItemApiManager
;
import
com.vsoft.servicenow.api.managers.HRCaseVariableApiManager
;
import
com.vsoft.servicenow.api.managers.HRCaseVariableApiManager
;
import
com.vsoft.servicenow.api.managers.IncidentApiManager
;
import
com.vsoft.servicenow.api.managers.IncidentApiManager
;
import
com.vsoft.servicenow.api.pojos.HRCaseVariableSubmitApiResponse
;
import
com.vsoft.servicenow.db.managers.AttachmentManager
;
import
com.vsoft.servicenow.db.managers.AttachmentManager
;
import
com.vsoft.servicenow.db.managers.CatalogueItemInputManager
;
import
com.vsoft.servicenow.db.managers.CatalogueItemInputManager
;
import
com.vsoft.servicenow.db.managers.CatalogueItemManager
;
import
com.vsoft.servicenow.db.managers.CatalogueItemManager
;
...
@@ -243,10 +244,20 @@ public class SyncService extends IntentService {
...
@@ -243,10 +244,20 @@ public class SyncService extends IntentService {
hrCaseItemInput
.
getData
(),
hrCaseItemInput
.
getData
(),
new
PostHRCaseVariableFormApiListener
()
{
new
PostHRCaseVariableFormApiListener
()
{
@Override
@Override
public
void
onDoneApiCall
(
String
variableFromSysId
)
{
public
void
onDoneApiCall
(
HRCaseVariableSubmitApiResponse
hrCaseVariableSubmitApiResponse
)
{
syncStatus
=
SyncStatus
.
SUCCESS
;
syncStatus
=
SyncStatus
.
SUCCESS
;
CatalogueLog
.
e
(
"syncHRCaseVariableForm: saveHRCaseVariableForm: result is SUCCESS"
);
CatalogueLog
.
e
(
"syncHRCaseVariableForm: saveHRCaseVariableForm: result is SUCCESS"
);
hrCaseItemInput
.
setSysId
(
variableFromSysId
);
//We are getting response without direct sys_id of submitted form.
//Getting "record" variable, it is containing sys_id with url form.
//We need to split the url and get the sys_id, URL like - api/now/table/hr_case/dc5116784f6d93400edad5401210c764
String
record
=
hrCaseVariableSubmitApiResponse
.
getRecord
();
String
[]
recordSpit
=
record
.
split
(
"/"
);
String
submittedFormSysId
=
null
;
if
(
recordSpit
.
length
>
0
)
{
submittedFormSysId
=
recordSpit
[
recordSpit
.
length
-
1
];
}
hrCaseItemInput
.
setSysId
(
submittedFormSysId
);
HRCaseItemInputManager
.
handleSaveServerResponse
(
hrCaseItemInput
,
Collections
.
singletonList
(
CATALOGUE_ITEM_INPUT_SYS_ID
),
SYNC_FLAG_NONE
);
HRCaseItemInputManager
.
handleSaveServerResponse
(
hrCaseItemInput
,
Collections
.
singletonList
(
CATALOGUE_ITEM_INPUT_SYS_ID
),
SYNC_FLAG_NONE
);
}
}
...
...
app/src/main/java/com/vsoft/servicenow/ui/HRCaseVariableScreen.java
View file @
feac4b31
...
@@ -591,7 +591,7 @@ public class HRCaseVariableScreen extends HandleNotificationActivity {
...
@@ -591,7 +591,7 @@ public class HRCaseVariableScreen extends HandleNotificationActivity {
}
}
private
void
saveFormData
()
{
private
void
saveFormData
()
{
JSON
Array
jsonArray
;
JSON
Object
parentJsonObject
;
JSONObject
jsonObject
=
null
;
JSONObject
jsonObject
=
null
;
boolean
hasErrors
=
false
;
boolean
hasErrors
=
false
;
boolean
skipInvisibleItem
=
false
;
boolean
skipInvisibleItem
=
false
;
...
@@ -670,12 +670,16 @@ public class HRCaseVariableScreen extends HandleNotificationActivity {
...
@@ -670,12 +670,16 @@ public class HRCaseVariableScreen extends HandleNotificationActivity {
if
(
hasErrors
)
if
(
hasErrors
)
return
;
return
;
jsonArray
=
new
JSONArray
();
parentJsonObject
=
new
JSONObject
();
jsonArray
.
put
(
jsonObject
);
try
{
parentJsonObject
.
put
(
"variables"
,
jsonObject
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
/*Save data in local DB*/
/*Save data in local DB*/
HRCaseItemInput
.
HRCaseItemInputBuilder
builder
=
HRCaseItemInput
.
HRCaseItemInputBuilder
.
aHRCaseItemInput
();
HRCaseItemInput
.
HRCaseItemInputBuilder
builder
=
HRCaseItemInput
.
HRCaseItemInputBuilder
.
aHRCaseItemInput
();
builder
.
setData
(
jsonArray
.
toString
());
builder
.
setData
(
parentJsonObject
.
toString
());
builder
.
setHRCaseItemId
(
mHRCaseItem
.
getId
());
builder
.
setHRCaseItemId
(
mHRCaseItem
.
getId
());
long
id
=
HRCaseItemInputManager
.
save
(
builder
.
build
(),
DBConstants
.
SYNC_FLAG_CREATE
);
long
id
=
HRCaseItemInputManager
.
save
(
builder
.
build
(),
DBConstants
.
SYNC_FLAG_CREATE
);
...
...
app/src/main/java/com/vsoft/servicenow/utils/Constants.java
View file @
feac4b31
...
@@ -185,7 +185,7 @@ public class Constants {
...
@@ -185,7 +185,7 @@ public class Constants {
public
static
final
String
URL_GET_HR_CASE_VARIABLE
=
AppConfig
.
URL_GET_HR_CASE_VARIABLE
;
public
static
final
String
URL_GET_HR_CASE_VARIABLE
=
AppConfig
.
URL_GET_HR_CASE_VARIABLE
;
public
static
final
String
URL_GET_HR_CASE_UI_POLICY
=
AppConfig
.
URL_GET_HR_CASE_UI_POLICY
;
public
static
final
String
URL_GET_HR_CASE_UI_POLICY
=
AppConfig
.
URL_GET_HR_CASE_UI_POLICY
;
public
static
final
String
URL_GET_HR_CASE_VARIABLE_CHOICE
=
DOMAIN
+
AppConfig
.
URL_GET_HR_CASE_VARIABLE_CHOICE
;
public
static
final
String
URL_GET_HR_CASE_VARIABLE_CHOICE
=
DOMAIN
+
AppConfig
.
URL_GET_HR_CASE_VARIABLE_CHOICE
;
public
static
final
String
URL_POST_HR_CASE_ITEM
=
AppConfig
.
URL_POST_HR_CASE_
CATALOGUE_
ITEM
;
public
static
final
String
URL_POST_HR_CASE_ITEM
=
AppConfig
.
URL_POST_HR_CASE_ITEM
;
public
static
final
String
URL_GET_HR_CASE_REFERENCE
=
API_PATH
;
public
static
final
String
URL_GET_HR_CASE_REFERENCE
=
API_PATH
;
public
static
final
String
URL_POST_HR_CASE_ATTACHMENT
=
DOMAIN
+
"api/now/v1/attachment/file"
;
public
static
final
String
URL_POST_HR_CASE_ATTACHMENT
=
DOMAIN
+
"api/now/v1/attachment/file"
;
...
...
app/src/vportal/java/com/vsoft/servicenow/AppConfig.java
View file @
feac4b31
...
@@ -50,7 +50,7 @@ public class AppConfig {
...
@@ -50,7 +50,7 @@ public class AppConfig {
public
static
final
String
URL_GET_HR_CASE_VARIABLE
=
"api/vsng2/uofl_mobile/catalogue_variable_screen"
;
public
static
final
String
URL_GET_HR_CASE_VARIABLE
=
"api/vsng2/uofl_mobile/catalogue_variable_screen"
;
public
static
final
String
URL_GET_HR_CASE_UI_POLICY
=
"/api/vsng2/uofl_mobile/uipolicy"
;
public
static
final
String
URL_GET_HR_CASE_UI_POLICY
=
"/api/vsng2/uofl_mobile/uipolicy"
;
public
static
final
String
URL_GET_HR_CASE_VARIABLE_CHOICE
=
"/api/vsng2/uofl_mobile/question_choice"
;
public
static
final
String
URL_GET_HR_CASE_VARIABLE_CHOICE
=
"/api/vsng2/uofl_mobile/question_choice"
;
public
static
final
String
URL_POST_HR_CASE_
CATALOGUE_ITEM
=
"api/vsng2/uofl_mobile/createCase
"
;
public
static
final
String
URL_POST_HR_CASE_
ITEM
=
"/api/sn_sc/servicecatalog/items/{sys_id}/submit_producer
"
;
/**
/**
* Socket Chat server URLs - Urls given by Ravi
* Socket Chat server URLs - Urls given by Ravi
...
...
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