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
fcec8066
authored
Apr 13, 2018
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added View HR Case functionality with screen design, local DB and offline syncing.
parent
4c7d9383
Show whitespace changes
Inline
Side-by-side
Showing
41 changed files
with
1303 additions
and
47 deletions
app/src/main/java/com/vsoft/servicenow/adapters/MyHRCaseAdapter.java
app/src/main/java/com/vsoft/servicenow/api/interfaces/HRCaseVariableApi.java
app/src/main/java/com/vsoft/servicenow/api/interfaces/MyHRCaseApi.java
app/src/main/java/com/vsoft/servicenow/api/listeners/get/GetHRCaseVariableApiListener.java
app/src/main/java/com/vsoft/servicenow/api/listeners/get/GetHRCaseVariableChoiceApiListener.java
app/src/main/java/com/vsoft/servicenow/api/listeners/get/GetMyHRCaseApiListener.java
app/src/main/java/com/vsoft/servicenow/api/listeners/post/PostHRCaseAttachmentApiListener.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/managers/HRCaseVariableChoiceApiManager.java
app/src/main/java/com/vsoft/servicenow/api/managers/MyHRCaseApiManager.java
app/src/main/java/com/vsoft/servicenow/db/DBConstants.java
app/src/main/java/com/vsoft/servicenow/db/DBManager.java
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseAttachmentManager.java
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseItemInputManager.java
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseUiPolicyActionManager.java
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseUiPolicyItemManager.java
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseVariableChoiceManager.java
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseVariableManager.java
app/src/main/java/com/vsoft/servicenow/db/managers/MyHRCaseManager.java
app/src/main/java/com/vsoft/servicenow/db/managers/MyHRCaseRequestOpenedByDisplayValueManager.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseAttachment.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseItemInput.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseRequest.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseRequestDisplayValue.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseUiPolicyAction.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseUiPolicyItem.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariable.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariableChoice.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariableResponse.java
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariableSet.java
app/src/main/java/com/vsoft/servicenow/menu/ViewHRCaseMenuItemData.java
app/src/main/java/com/vsoft/servicenow/ui/HRCaseVariableScreen.java
app/src/main/java/com/vsoft/servicenow/ui/MyHRCaseActivity.java
app/src/main/java/com/vsoft/servicenow/ui/ViewHRCaseScreen.java
app/src/main/java/com/vsoft/servicenow/utils/Constants.java
app/src/main/res/layout/my_hr_case_list_item.xml
app/src/main/res/layout/my_hr_case_list_screen.xml
app/src/main/res/values/strings.xml
app/src/vportal/AndroidManifest.xml
app/src/vportal/java/com/vsoft/servicenow/AppConfig.java
app/src/main/java/com/vsoft/servicenow/adapters/MyHRCaseAdapter.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
adapters
;
import
android.content.Context
;
import
android.graphics.Color
;
import
android.graphics.drawable.GradientDrawable
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.BaseAdapter
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.vsoft.servicenow.R
;
import
com.vsoft.servicenow.db.models.HRCaseRequest
;
import
com.vsoft.servicenow.db.models.MyRequest
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Created by Kunj on 13/04/2018.
*/
public
class
MyHRCaseAdapter
extends
BaseAdapter
{
private
final
List
<
HRCaseRequest
>
mReqList
=
new
ArrayList
<>(
0
);
private
LayoutInflater
mInflater
;
private
Context
mContext
;
public
MyHRCaseAdapter
(
Context
context
)
{
mInflater
=
(
LayoutInflater
)
context
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
mContext
=
context
;
}
public
void
setRequestList
(
List
<
HRCaseRequest
>
myreqList
)
{
mReqList
.
clear
();
if
(
myreqList
!=
null
)
mReqList
.
addAll
(
myreqList
);
notifyDataSetChanged
();
}
@Override
public
int
getCount
()
{
// TODO Auto-generated method stub
return
mReqList
.
size
();
}
@Override
public
HRCaseRequest
getItem
(
int
position
)
{
// TODO Auto-generated method stub
return
mReqList
.
get
(
position
);
}
@Override
public
long
getItemId
(
int
position
)
{
// TODO Auto-generated method stub
return
position
;
}
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
// TODO Auto-generated method stub
ViewHolder
holder
;
if
(
convertView
==
null
)
{
convertView
=
mInflater
.
inflate
(
R
.
layout
.
my_hr_case_list_item
,
parent
,
false
);
holder
=
new
ViewHolder
();
holder
.
number
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
number
);
// holder.shortDescription = (TextView) convertView.findViewById(R.id.shotrDescription);
holder
.
approval
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
approval
);
holder
.
statusIndicator
=
(
ImageView
)
convertView
.
findViewById
(
R
.
id
.
approval_image
);
convertView
.
setTag
(
holder
);
}
else
{
holder
=
(
ViewHolder
)
convertView
.
getTag
();
}
HRCaseRequest
req
=
mReqList
.
get
(
position
);
holder
.
number
.
setText
(
req
.
getNumber
());
if
(!
req
.
getApproval
().
isEmpty
())
{
if
(
req
.
getApproval
().
equalsIgnoreCase
(
"requested"
))
{
holder
.
approval
.
setText
(
mContext
.
getResources
().
getString
(
R
.
string
.
requested
));
((
GradientDrawable
)
holder
.
statusIndicator
.
getBackground
()).
setColor
(
Color
.
parseColor
(
"#FFB400"
));
}
else
if
(
req
.
getApproval
().
equalsIgnoreCase
(
"not requested"
))
{
holder
.
approval
.
setText
(
mContext
.
getResources
().
getString
(
R
.
string
.
notrequest
));
((
GradientDrawable
)
holder
.
statusIndicator
.
getBackground
()).
setColor
(
Color
.
parseColor
(
"#5CE1ED"
));
}
else
if
(
req
.
getApproval
().
equalsIgnoreCase
(
"approved"
))
{
holder
.
approval
.
setText
(
mContext
.
getResources
().
getString
(
R
.
string
.
approved
));
((
GradientDrawable
)
holder
.
statusIndicator
.
getBackground
()).
setColor
(
Color
.
parseColor
(
"#06D323"
));
}
else
if
(
req
.
getApproval
().
equalsIgnoreCase
(
"rejected"
))
{
holder
.
approval
.
setText
(
mContext
.
getResources
().
getString
(
R
.
string
.
rejected
));
((
GradientDrawable
)
holder
.
statusIndicator
.
getBackground
()).
setColor
(
Color
.
parseColor
(
"#FF0000"
));
}
else
if
(
req
.
getApproval
().
equalsIgnoreCase
(
"not yet requested"
))
{
holder
.
approval
.
setText
(
mContext
.
getResources
().
getString
(
R
.
string
.
notrequest
));
((
GradientDrawable
)
holder
.
statusIndicator
.
getBackground
()).
setColor
(
Color
.
parseColor
(
"#5CE1ED"
));
}
}
return
convertView
;
}
static
class
ViewHolder
{
private
TextView
number
;
// private TextView shortDescription;
private
TextView
approval
;
private
ImageView
statusIndicator
;
}
}
\ No newline at end of file
app/src/main/java/com/vsoft/servicenow/api/interfaces/HRCaseVariableApi.java
View file @
fcec8066
...
@@ -20,7 +20,7 @@ import retrofit2.http.Url;
...
@@ -20,7 +20,7 @@ import retrofit2.http.Url;
/**
/**
* @since 1.0
* @since 1.0
* @author
Kunj on 11/8/16
.
* @author
Created by Kunj on 13/04/2018
.
*
*
*/
*/
public
interface
HRCaseVariableApi
{
public
interface
HRCaseVariableApi
{
...
...
app/src/main/java/com/vsoft/servicenow/api/interfaces/MyHRCaseApi.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
api
.
interfaces
;
import
com.vsoft.servicenow.utils.Constants
;
import
okhttp3.ResponseBody
;
import
retrofit2.Call
;
import
retrofit2.http.GET
;
import
retrofit2.http.Query
;
/**
* @since 1.0
* @author Created by Kunj on 13/04/2018.
*
*/
public
interface
MyHRCaseApi
{
// Get My HRCase API
@GET
(
Constants
.
URL_GET_MY_HR_CASE
)
Call
<
ResponseBody
>
getMyHRCase
(
@Query
(
Constants
.
URL_PARAM_OPENED_BY
)
String
userSysId
,
@Query
(
Constants
.
URL_PARAM_SYSPRM_DISPLAY_VALUE
)
String
sysparmDisplayValue
);
}
app/src/main/java/com/vsoft/servicenow/api/listeners/get/GetHRCaseVariableApiListener.java
View file @
fcec8066
...
@@ -4,7 +4,7 @@ import com.vsoft.servicenow.db.models.HRCaseVariableResponse;
...
@@ -4,7 +4,7 @@ import com.vsoft.servicenow.db.models.HRCaseVariableResponse;
/**
/**
* @since 1.0
* @since 1.0
* @author
Kunj on 11/8/16
* @author
Created by Kunj on 13/04/2018.
*
*
*/
*/
public
interface
GetHRCaseVariableApiListener
{
public
interface
GetHRCaseVariableApiListener
{
...
...
app/src/main/java/com/vsoft/servicenow/api/listeners/get/GetHRCaseVariableChoiceApiListener.java
View file @
fcec8066
...
@@ -7,7 +7,7 @@ import java.util.List;
...
@@ -7,7 +7,7 @@ import java.util.List;
/**
/**
* @since 1.0
* @since 1.0
* @author
Kunj on 11/8/16
* @author
Created by Kunj on 13/04/2018.
*
*
*/
*/
public
interface
GetHRCaseVariableChoiceApiListener
{
public
interface
GetHRCaseVariableChoiceApiListener
{
...
...
app/src/main/java/com/vsoft/servicenow/api/listeners/get/GetMyHRCaseApiListener.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
api
.
listeners
.
get
;
import
com.vsoft.servicenow.db.models.HRCase
;
import
com.vsoft.servicenow.db.models.HRCaseRequest
;
import
com.vsoft.servicenow.db.models.MyRequest
;
import
java.util.List
;
/**
* @since 1.0
* @author Created by Kunj on 13/04/2018.
*
*/
public
interface
GetMyHRCaseApiListener
{
void
onDoneApiCall
(
List
<
HRCaseRequest
>
catalogueList
);
void
onFailApiCall
();
}
app/src/main/java/com/vsoft/servicenow/api/listeners/post/PostHRCaseAttachmentApiListener.java
View file @
fcec8066
...
@@ -2,7 +2,7 @@ package com.vsoft.servicenow.api.listeners.post;
...
@@ -2,7 +2,7 @@ package com.vsoft.servicenow.api.listeners.post;
/**
/**
* @since 1.0
* @since 1.0
* @author
Kunj on 11/8/16
* @author
Created by Kunj on 13/04/2018.
*
*
*/
*/
public
interface
PostHRCaseAttachmentApiListener
{
public
interface
PostHRCaseAttachmentApiListener
{
...
...
app/src/main/java/com/vsoft/servicenow/api/listeners/post/PostHRCaseVariableFormApiListener.java
View file @
fcec8066
...
@@ -2,7 +2,7 @@ package com.vsoft.servicenow.api.listeners.post;
...
@@ -2,7 +2,7 @@ package com.vsoft.servicenow.api.listeners.post;
/**
/**
* @since 1.0
* @since 1.0
* @author
Kunj on 11/8/16
* @author
Created by Kunj on 13/04/2018.
*
*
*/
*/
public
interface
PostHRCaseVariableFormApiListener
{
public
interface
PostHRCaseVariableFormApiListener
{
...
...
app/src/main/java/com/vsoft/servicenow/api/managers/HRCaseVariableApiManager.java
View file @
fcec8066
...
@@ -40,7 +40,7 @@ import retrofit2.Response;
...
@@ -40,7 +40,7 @@ import retrofit2.Response;
import
retrofit2.Retrofit
;
import
retrofit2.Retrofit
;
/**
/**
* @author
Kunj on 11/8/16
.
* @author
Created by Kunj on 13/04/2018
.
*
*
*/
*/
public
class
HRCaseVariableApiManager
{
public
class
HRCaseVariableApiManager
{
...
...
app/src/main/java/com/vsoft/servicenow/api/managers/HRCaseVariableChoiceApiManager.java
View file @
fcec8066
...
@@ -36,9 +36,8 @@ import retrofit2.Response;
...
@@ -36,9 +36,8 @@ import retrofit2.Response;
import
retrofit2.Retrofit
;
import
retrofit2.Retrofit
;
/**
/**
* @author Kunj on 11/8/16.
* @author Created by Kunj on 13/04/2018.
*bkunj@vscbkunj@vsc
**/
*/
public
class
HRCaseVariableChoiceApiManager
{
public
class
HRCaseVariableChoiceApiManager
{
public
static
void
getHRCaseVariableChoice
(
Context
context
,
String
hrCaseVariableSysId
,
GetHRCaseVariableChoiceApiListener
listener
)
{
public
static
void
getHRCaseVariableChoice
(
Context
context
,
String
hrCaseVariableSysId
,
GetHRCaseVariableChoiceApiListener
listener
)
{
...
...
app/src/main/java/com/vsoft/servicenow/api/managers/MyHRCaseApiManager.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
api
.
managers
;
import
android.content.Context
;
import
android.util.Log
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
com.google.gson.JsonDeserializationContext
;
import
com.google.gson.JsonDeserializer
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonParseException
;
import
com.vsoft.servicenow.api.RestClient
;
import
com.vsoft.servicenow.api.interfaces.MyHRCaseApi
;
import
com.vsoft.servicenow.api.interfaces.MyRequestApi
;
import
com.vsoft.servicenow.api.listeners.get.GetMyHRCaseApiListener
;
import
com.vsoft.servicenow.api.listeners.get.GetMyRequestApiListener
;
import
com.vsoft.servicenow.db.models.HRCaseRequest
;
import
com.vsoft.servicenow.db.models.MyRequest
;
import
com.vsoft.servicenow.enums.SyncStatus
;
import
com.vsoft.servicenow.utils.CatalogueLog
;
import
com.vsoft.servicenow.utils.Constants
;
import
com.vsoft.servicenow.utils.PrefManager
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.lang.reflect.Type
;
import
java.util.ArrayList
;
import
java.util.List
;
import
okhttp3.ResponseBody
;
import
retrofit2.Call
;
import
retrofit2.Response
;
import
retrofit2.Retrofit
;
/**
* Created by Kunj on 13/04/2018.
*/
public
class
MyHRCaseApiManager
{
public
static
SyncStatus
getMyHRCase
(
Context
context
,
GetMyHRCaseApiListener
listener
)
{
String
accessToken
=
PrefManager
.
getSharedPref
(
context
,
PrefManager
.
PREFERENCE_ACCESS_TOKEN
);
String
userSysId
=
PrefManager
.
getSharedPref
(
context
,
PrefManager
.
PREFERENCE_USER_SYS_ID
);
if
(
accessToken
.
isEmpty
())
{
listener
.
onFailApiCall
();
return
SyncStatus
.
FAIL
;
}
final
Retrofit
retrofit
=
RestClient
.
getInitializedRestAdapter
(
accessToken
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
MyHRCaseApi
.
class
).
getMyHRCase
(
userSysId
,
"true"
);
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
hrCaseJsonArray
=
jsonObject
.
getJSONArray
(
Constants
.
RESPONSE_RESULT_OBJECT_NAME
);
if
(
hrCaseJsonArray
.
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
(
"MyHRCaseApiManager: getMyHRCase: 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
(
"MyHRCaseApiManager: getMyHRCase: 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
(
"MyHRCaseApiManager: getMyHRCase: deserialize: float.class: NumberFormatException: "
,
e
);
}
return
value
;
}
})
.
create
();
List
<
HRCaseRequest
>
hrCaseList
=
new
ArrayList
<>(
hrCaseJsonArray
.
length
());
for
(
int
i
=
0
;
i
<
hrCaseJsonArray
.
length
();
i
++)
{
JSONObject
hrCaseJsonObject
=
hrCaseJsonArray
.
getJSONObject
(
i
);
HRCaseRequest
hrCaseRequest
=
gson
.
fromJson
(
hrCaseJsonObject
.
toString
(),
HRCaseRequest
.
class
);
hrCaseRequest
.
parseJson
(
hrCaseJsonObject
);
hrCaseList
.
add
(
hrCaseRequest
);
}
listener
.
onDoneApiCall
(
hrCaseList
);
}
else
{
listener
.
onDoneApiCall
(
new
ArrayList
<
HRCaseRequest
>(
0
));
}
return
SyncStatus
.
SUCCESS
;
}
else
return
SyncStatus
.
FAIL
;
}
catch
(
JSONException
e
)
{
CatalogueLog
.
e
(
"MyHRCaseApiManager: getMyHRCase: onResponse: "
,
e
);
return
SyncStatus
.
FAIL
;
}
catch
(
IOException
e
)
{
CatalogueLog
.
e
(
"MyHRCaseApiManager: getMyHRCase: onResponse: "
,
e
);
return
SyncStatus
.
FAIL
;
}
}
else
{
CatalogueLog
.
d
(
"MyRequestApiManager: getMyRequest: response is not success"
);
if
(
response
.
code
()
==
401
)
{
Log
.
d
(
Constants
.
TAG
,
"-- is 401, try refresh token..."
);
SyncStatus
status
=
LoginApiManager
.
refreshLogin
(
context
,
PrefManager
.
getSharedPref
(
context
,
PrefManager
.
PREFERENCE_REFRESH_TOKEN
));
if
(
status
==
SyncStatus
.
SUCCESS
)
{
CatalogueLog
.
d
(
"refresh token success, retry same..."
);
return
getMyHRCase
(
context
,
listener
);
}
else
{
CatalogueLog
.
d
(
"refresh token failed, return FAIL"
);
listener
.
onFailApiCall
();
return
SyncStatus
.
FAIL
;
}
}
else
{
listener
.
onFailApiCall
();
return
SyncStatus
.
FAIL
;
}
}
}
catch
(
IOException
e
)
{
CatalogueLog
.
e
(
"MyHRCaseApiManager: getMyHRCase: IOException: "
,
e
);
return
SyncStatus
.
FAIL
;
}
catch
(
NullPointerException
e
)
{
CatalogueLog
.
e
(
"MyHRCaseApiManager: getMyHRCase: NullPointerException: "
,
e
);
return
SyncStatus
.
FAIL
;
}
}
}
app/src/main/java/com/vsoft/servicenow/db/DBConstants.java
View file @
fcec8066
...
@@ -27,6 +27,8 @@ public interface DBConstants {
...
@@ -27,6 +27,8 @@ public interface DBConstants {
String
TABLE_HR_CASE_UI_POLICY_ACTION
=
"hr_case_ui_policy_action"
;
String
TABLE_HR_CASE_UI_POLICY_ACTION
=
"hr_case_ui_policy_action"
;
String
TABLE_HR_CASE_UI_POLICY_ITEM
=
"hr_case_ui_policy_item"
;
String
TABLE_HR_CASE_UI_POLICY_ITEM
=
"hr_case_ui_policy_item"
;
String
TABLE_HR_CASE_VARIABLE_CHOICES
=
"hr_case_variable_choices"
;
String
TABLE_HR_CASE_VARIABLE_CHOICES
=
"hr_case_variable_choices"
;
String
TABLE_MY_HR_CASE_REQUEST
=
"hr_case_requests"
;
String
TABLE_MY_HR_CASE_REQUEST_OPENED_BY
=
"hr_case_request_opened_by"
;
String
ID
=
"_id"
;
String
ID
=
"_id"
;
String
SYS_ID
=
"sys_id"
;
String
SYS_ID
=
"sys_id"
;
...
@@ -608,4 +610,44 @@ public interface DBConstants {
...
@@ -608,4 +610,44 @@ public interface DBConstants {
int
INDEX_HR_CASE_VARIABLE_CHOICE_MISC
=
5
;
int
INDEX_HR_CASE_VARIABLE_CHOICE_MISC
=
5
;
int
HR_CASE_VARIABLE_CHOICE_COLUMN_COUNT
=
6
;
int
HR_CASE_VARIABLE_CHOICE_COLUMN_COUNT
=
6
;
/**
* HRCaseRequest table
*/
String
HR_CASE_REQUEST_ID
=
ID
;
String
HR_CASE_REQUEST_NUMBER
=
"number"
;
String
HR_CASE_REQUEST_SYS_UPDATED_ON
=
"sys_updated_on"
;
String
HR_CASE_REQUEST_APPROVAL
=
"approval"
;
String
HR_CASE_REQUEST_OPENED_BY_VALUE
=
"opened_by_value"
;
String
HR_CASE_REQUEST_SYNC_DIRTY
=
SYNC_DIRTY
;
/**
* Request for HRCaseRequest table. *Use these only if you fetch all columns*
*/
int
INDEX_HR_CASE_REQUEST_ID
=
0
;
int
INDEX_HR_CASE_REQUEST_NUMBER
=
1
;
int
INDEX_HR_CASE_REQUEST_SYS_UPDATED_ON
=
2
;
int
INDEX_HR_CASE_REQUEST_APPROVAL
=
3
;
int
INDEX_HR_CASE_REQUEST_OPENED_BY_VALUE
=
4
;
int
INDEX_HR_CASE_REQUEST_SYNC_DIRTY
=
5
;
int
HR_CASE_REQUEST_COLUMN_COUNT
=
6
;
/**
* TABLE_MY_HR_CASE_REQUEST_OPENED_BY table
*/
String
MY_HR_CASE_REQUEST_OPENED_BY_ID
=
ID
;
String
MY_HR_CASE_REQUEST_OPENED_BY_DISPLAY_VALUE
=
"display_value"
;
String
MY_HR_CASE_REQUEST_OPENED_BY_LINK
=
"link"
;
String
MY_HR_CASE_REQUEST_OPENED_BY_SYNC_DIRTY
=
SYNC_DIRTY
;
/**
* TABLE_MY_HR_CASE_REQUEST_OPENED_BY table. *Use these only if you fetch all columns*
*/
int
INDEX_MY_HR_CASE_REQUEST_OPENED_BY_ID
=
0
;
int
INDEX_MY_HR_CASE_REQUEST_OPENED_BY_DISPLAY_VALUE
=
1
;
int
INDEX_MY_HR_CASE_REQUEST_OPENED_BY_LINK
=
2
;
int
INDEX_MY_HR_CASE_REQUEST_OPENED_BY_SYNC_DIRTY
=
3
;
int
MY_HR_CASE_REQUEST_OPENED_BY_COLUMN_COUNT
=
4
;
}
}
\ No newline at end of file
app/src/main/java/com/vsoft/servicenow/db/DBManager.java
View file @
fcec8066
...
@@ -59,6 +59,8 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
...
@@ -59,6 +59,8 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
createHRCaseUiPolicyActionTable
(
db
);
createHRCaseUiPolicyActionTable
(
db
);
createHRCaseUiPolicyItemTable
(
db
);
createHRCaseUiPolicyItemTable
(
db
);
createHRCaseVariableChoiceTable
(
db
);
createHRCaseVariableChoiceTable
(
db
);
createMyHRCaseRequestTable
(
db
);
createMyHRCaseRequestOpenedByTable
(
db
);
}
}
}
}
...
@@ -339,4 +341,22 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
...
@@ -339,4 +341,22 @@ public class DBManager extends SQLiteOpenHelper implements DBConstants {
+
HR_CASE_VARIABLE_CHOICE_MISC
+
" real);"
);
+
HR_CASE_VARIABLE_CHOICE_MISC
+
" real);"
);
}
}
private
void
createMyHRCaseRequestTable
(
SQLiteDatabase
db
)
{
db
.
execSQL
(
"create table "
+
TABLE_MY_HR_CASE_REQUEST
+
"("
+
HR_CASE_REQUEST_ID
+
" integer primary key autoincrement, "
+
HR_CASE_REQUEST_NUMBER
+
" text, "
+
HR_CASE_REQUEST_SYS_UPDATED_ON
+
" real, "
+
HR_CASE_REQUEST_APPROVAL
+
" text, "
+
HR_CASE_REQUEST_OPENED_BY_VALUE
+
" real, "
+
HR_CASE_REQUEST_SYNC_DIRTY
+
" integer default "
+
SYNC_FLAG_NONE
+
");"
);
}
private
void
createMyHRCaseRequestOpenedByTable
(
SQLiteDatabase
db
)
{
db
.
execSQL
(
"create table "
+
TABLE_MY_HR_CASE_REQUEST_OPENED_BY
+
"("
+
MY_HR_CASE_REQUEST_OPENED_BY_ID
+
" integer primary key autoincrement, "
+
MY_HR_CASE_REQUEST_OPENED_BY_DISPLAY_VALUE
+
" text, "
+
MY_HR_CASE_REQUEST_OPENED_BY_LINK
+
" real, "
+
MY_HR_CASE_REQUEST_OPENED_BY_SYNC_DIRTY
+
" integer default "
+
SYNC_FLAG_NONE
+
");"
);
}
}
}
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseAttachmentManager.java
View file @
fcec8066
...
@@ -14,7 +14,7 @@ import java.util.List;
...
@@ -14,7 +14,7 @@ import java.util.List;
/**
/**
*
*
* @author
Kunj on 11-08-2016
.
* @author
Created by Kunj on 13/04/2018
.
*/
*/
public
class
HRCaseAttachmentManager
implements
DBConstants
{
public
class
HRCaseAttachmentManager
implements
DBConstants
{
...
...
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseItemInputManager.java
View file @
fcec8066
...
@@ -14,7 +14,7 @@ import java.util.List;
...
@@ -14,7 +14,7 @@ import java.util.List;
/**
/**
*
*
* @author
Kunj on 11-08-2016
.
* @author
Created by Kunj on 13/04/2018
.
*/
*/
public
class
HRCaseItemInputManager
implements
DBConstants
{
public
class
HRCaseItemInputManager
implements
DBConstants
{
...
...
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseUiPolicyActionManager.java
View file @
fcec8066
...
@@ -14,7 +14,7 @@ import java.util.List;
...
@@ -14,7 +14,7 @@ import java.util.List;
/**
/**
*
*
* @author
Kunj on 18-11-2016
.
* @author
Created by Kunj on 13/04/2018
.
*/
*/
public
class
HRCaseUiPolicyActionManager
implements
DBConstants
{
public
class
HRCaseUiPolicyActionManager
implements
DBConstants
{
...
...
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseUiPolicyItemManager.java
View file @
fcec8066
...
@@ -15,7 +15,7 @@ import java.util.List;
...
@@ -15,7 +15,7 @@ import java.util.List;
/**
/**
*
*
* @author
Kunj on 18-11-2016
.
* @author
Created by Kunj on 13/04/2018
.
*/
*/
public
class
HRCaseUiPolicyItemManager
implements
DBConstants
{
public
class
HRCaseUiPolicyItemManager
implements
DBConstants
{
...
...
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseVariableChoiceManager.java
View file @
fcec8066
...
@@ -13,8 +13,8 @@ import java.util.ArrayList;
...
@@ -13,8 +13,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
/**
/**
* Created by
kunj on 21/02/17
.
* Created by
Kunj on 13/04/2018
.
*/
*
*
/
public
class
HRCaseVariableChoiceManager
implements
DBConstants
{
public
class
HRCaseVariableChoiceManager
implements
DBConstants
{
...
...
app/src/main/java/com/vsoft/servicenow/db/managers/HRCaseVariableManager.java
View file @
fcec8066
...
@@ -15,7 +15,7 @@ import java.util.List;
...
@@ -15,7 +15,7 @@ import java.util.List;
/**
/**
*
*
* @author
Kunj on 11-08-2016
.
* @author
Created by Kunj on 13/04/2018
.
*/
*/
public
class
HRCaseVariableManager
implements
DBConstants
{
public
class
HRCaseVariableManager
implements
DBConstants
{
...
...
app/src/main/java/com/vsoft/servicenow/db/managers/MyHRCaseManager.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
db
.
managers
;
import
android.content.ContentValues
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
com.vsoft.servicenow.CatalogueApplication
;
import
com.vsoft.servicenow.db.DBConstants
;
import
com.vsoft.servicenow.db.models.HRCaseRequest
;
import
com.vsoft.servicenow.db.models.HRCaseRequestDisplayValue
;
import
com.vsoft.servicenow.db.models.MyRequest
;
import
com.vsoft.servicenow.db.models.MyRequestDisplayValue
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
/**
*
* @author Created by Kunj on 13/04/2018.
*/
public
class
MyHRCaseManager
implements
DBConstants
{
public
static
long
save
(
HRCaseRequest
hrCaseRequest
,
int
syncDirty
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
if
(
db
!=
null
)
{
hrCaseRequest
.
setSyncDirty
(
syncDirty
);
long
id
=
db
.
insert
(
TABLE_MY_HR_CASE_REQUEST
,
null
,
getContentValues
(
hrCaseRequest
));
hrCaseRequest
.
setId
(
id
);
return
id
;
}
else
{
return
-
1
;
}
}
public
static
int
delete
(
HRCaseRequest
hrCaseRequest
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
if
(
db
!=
null
)
{
if
(
hrCaseRequest
.
getNumber
()
==
null
||
hrCaseRequest
.
getNumber
().
isEmpty
())
{
return
db
.
delete
(
TABLE_MY_HR_CASE_REQUEST
,
HR_CASE_REQUEST_ID
+
"="
+
hrCaseRequest
.
getId
(),
null
);
}
else
{
return
update
(
hrCaseRequest
,
SYNC_FLAG_DELETE
);
}
}
return
-
1
;
}
public
static
int
update
(
HRCaseRequest
hrCaseRequest
,
int
syncDirty
)
{
return
update
(
hrCaseRequest
,
null
,
syncDirty
);
}
public
static
int
update
(
HRCaseRequest
hrCaseRequest
,
List
<
String
>
column
,
int
syncDirty
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
if
(
db
!=
null
)
{
hrCaseRequest
.
setSyncDirty
(
syncDirty
);
if
(
column
==
null
||
column
.
size
()
==
0
)
{
return
db
.
update
(
TABLE_MY_HR_CASE_REQUEST
,
getContentValues
(
hrCaseRequest
),
HR_CASE_REQUEST_ID
+
"="
+
hrCaseRequest
.
getId
(),
null
);
}
else
{
ContentValues
contentValues
=
new
ContentValues
(
column
.
size
());
contentValues
.
put
(
HR_CASE_REQUEST_SYNC_DIRTY
,
hrCaseRequest
.
getSyncDirty
());
for
(
int
i
=
0
;
i
<
column
.
size
();
i
++)
{
String
columnName
=
column
.
get
(
i
);
if
(
HR_CASE_REQUEST_NUMBER
.
equals
(
columnName
))
{
contentValues
.
put
(
HR_CASE_REQUEST_NUMBER
,
hrCaseRequest
.
getNumber
());
}
else
if
(
HR_CASE_REQUEST_SYS_UPDATED_ON
.
equals
(
columnName
))
{
contentValues
.
put
(
HR_CASE_REQUEST_SYS_UPDATED_ON
,
hrCaseRequest
.
getUpdateOn
());
}
else
if
(
HR_CASE_REQUEST_APPROVAL
.
equals
(
columnName
))
{
contentValues
.
put
(
HR_CASE_REQUEST_APPROVAL
,
hrCaseRequest
.
getApproval
());
}
else
if
(
HR_CASE_REQUEST_OPENED_BY_VALUE
.
equals
(
columnName
))
{
contentValues
.
put
(
HR_CASE_REQUEST_OPENED_BY_VALUE
,
hrCaseRequest
.
getOpenedBy
().
getDisplayValue
());
}
}
return
db
.
update
(
TABLE_MY_HR_CASE_REQUEST
,
contentValues
,
HR_CASE_REQUEST_ID
+
"="
+
hrCaseRequest
.
getId
(),
null
);
}
}
else
{
return
-
1
;
}
}
public
static
void
handleGetRequest
(
List
<
HRCaseRequest
>
serverHrCaseRequestList
)
{
if
(
serverHrCaseRequestList
!=
null
&&
!
serverHrCaseRequestList
.
isEmpty
())
{
/*requestSysIdMap contain all server response request Sys Id*/
HashMap
<
String
,
Integer
>
requestSysIdMap
=
new
HashMap
<>(
0
);
Integer
intObj
=
Integer
.
valueOf
(
1
);
for
(
int
i
=
0
;
i
<
serverHrCaseRequestList
.
size
();
i
++)
{
String
sysId
=
serverHrCaseRequestList
.
get
(
i
).
getNumber
();
requestSysIdMap
.
put
(
sysId
,
intObj
);
}
/*localHrCaseRequestList is contain all local Incidents */
List
<
HRCaseRequest
>
localHrCaseRequestList
=
getAllRequests
();
if
(
localHrCaseRequestList
!=
null
&&
!
localHrCaseRequestList
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
localHrCaseRequestList
.
size
();
i
++)
{
HRCaseRequest
localHrCaseRequest
=
localHrCaseRequestList
.
get
(
i
);
String
localRequestNumber
=
localHrCaseRequest
.
getNumber
();
if
(
localRequestNumber
!=
null
&&
!
localRequestNumber
.
isEmpty
()
&&
!
requestSysIdMap
.
containsKey
(
localRequestNumber
))
{
//Update sys_id with empty string because required to delete locally
localHrCaseRequest
.
setNumber
(
""
);
MyHRCaseRequestOpenedByDisplayValueManager
.
delete
(
localHrCaseRequest
.
getOpenedBy
());
delete
(
localHrCaseRequest
);
}
}
}
/*Check this HRCaseRequest is exist in local DB or not
* If doesn't exist in local, save it
* If exist in local, update the local item with data from server item.
* */
for
(
int
i
=
0
;
i
<
serverHrCaseRequestList
.
size
();
i
++)
{
HRCaseRequest
hrCaseRequest
=
serverHrCaseRequestList
.
get
(
i
);
HRCaseRequest
localRequest
=
getRequestFromNumber
(
hrCaseRequest
.
getNumber
());
if
(
localRequest
==
null
)
{
MyHRCaseRequestOpenedByDisplayValueManager
.
save
(
hrCaseRequest
.
getOpenedBy
(),
DBConstants
.
SYNC_FLAG_NONE
);
save
(
hrCaseRequest
,
DBConstants
.
SYNC_FLAG_NONE
);
}
else
{
/*Update complete local MyRequest object with response MyRequest object*/
hrCaseRequest
.
setId
(
localRequest
.
getId
());
hrCaseRequest
.
setOpenedBy
(
localRequest
.
getOpenedBy
());
update
(
hrCaseRequest
,
DBConstants
.
SYNC_FLAG_NONE
);
}
}
}
else
{
/*That means there is no HR_CASE_REQUEST in server response, then all local items should be deleted those are contain sys_id*/
/*localRequestList is contain all local MyRequest */
List
<
HRCaseRequest
>
localRequestList
=
getAllRequests
();
if
(
localRequestList
!=
null
&&
!
localRequestList
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
localRequestList
.
size
();
i
++)
{
HRCaseRequest
localMyRequest
=
localRequestList
.
get
(
i
);
String
localIncidentNumber
=
localMyRequest
.
getNumber
();
if
(
localIncidentNumber
!=
null
&&
!
localIncidentNumber
.
isEmpty
())
{
//Update number with empty string because required to delete locally
localMyRequest
.
setNumber
(
""
);
MyHRCaseRequestOpenedByDisplayValueManager
.
delete
(
localMyRequest
.
getOpenedBy
());
delete
(
localMyRequest
);
}
}
}
}
}
public
static
List
<
HRCaseRequest
>
getAllRequests
()
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
if
(
db
!=
null
)
{
Cursor
c
=
db
.
rawQuery
(
"select * from "
+
TABLE_MY_HR_CASE_REQUEST
+
" where "
+
INCIDENT_SYNC_DIRTY
+
"!="
+
DBConstants
.
SYNC_FLAG_DELETE
,
null
);
ArrayList
<
HRCaseRequest
>
requestList
;
if
(
c
.
getCount
()
>
0
)
{
requestList
=
new
ArrayList
<>(
c
.
getCount
());
while
(
c
.
moveToNext
())
{
HRCaseRequest
.
HRCaseRequestBuilder
builder
=
HRCaseRequest
.
HRCaseRequestBuilder
.
aMyRequest
();
fillAllRequestDetails
(
c
,
builder
);
requestList
.
add
(
builder
.
build
());
}
}
else
{
requestList
=
new
ArrayList
<>(
0
);
}
c
.
close
();
return
requestList
;
}
else
{
return
new
ArrayList
<>(
0
);
}
}
public
static
HRCaseRequest
get
(
long
requestId
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
HRCaseRequest
myRequest
=
null
;
if
(
db
!=
null
)
{
Cursor
c
=
db
.
rawQuery
(
"select * from "
+
TABLE_MY_HR_CASE_REQUEST
+
" where "
+
HR_CASE_REQUEST_ID
+
"="
+
requestId
,
null
);
if
(
c
.
moveToFirst
())
{
HRCaseRequest
.
HRCaseRequestBuilder
builder
=
HRCaseRequest
.
HRCaseRequestBuilder
.
aMyRequest
();
fillAllRequestDetails
(
c
,
builder
);
myRequest
=
builder
.
build
();
}
c
.
close
();
}
return
myRequest
;
}
public
static
HRCaseRequest
getRequestFromNumber
(
String
number
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
HRCaseRequest
myRequest
=
null
;
if
(
db
!=
null
)
{
Cursor
c
=
db
.
rawQuery
(
"select * from "
+
TABLE_MY_HR_CASE_REQUEST
+
" where "
+
INCIDENT_NUMBER
+
"='"
+
number
+
"'"
,
null
);
if
(
c
.
moveToFirst
())
{
HRCaseRequest
.
HRCaseRequestBuilder
builder
=
HRCaseRequest
.
HRCaseRequestBuilder
.
aMyRequest
();
fillAllRequestDetails
(
c
,
builder
);
myRequest
=
builder
.
build
();
}
c
.
close
();
}
return
myRequest
;
}
private
static
void
fillAllRequestDetails
(
Cursor
c
,
HRCaseRequest
.
HRCaseRequestBuilder
builder
)
{
builder
.
setId
(
c
.
getLong
(
INDEX_HR_CASE_REQUEST_ID
));
builder
.
setNumber
(
c
.
getString
(
INDEX_HR_CASE_REQUEST_NUMBER
));
long
rowId
=
c
.
getLong
(
INDEX_HR_CASE_REQUEST_OPENED_BY_VALUE
);
HRCaseRequestDisplayValue
myRequestDisplayValue
;
if
(
rowId
==
-
1
)
{
myRequestDisplayValue
=
new
HRCaseRequestDisplayValue
();
}
else
{
myRequestDisplayValue
=
MyHRCaseRequestOpenedByDisplayValueManager
.
get
(
rowId
);
}
builder
.
setOpenedBy
(
myRequestDisplayValue
);
builder
.
setUpdateOn
(
c
.
getLong
(
INDEX_HR_CASE_REQUEST_SYS_UPDATED_ON
));
builder
.
setApproval
(
c
.
getString
(
INDEX_HR_CASE_REQUEST_APPROVAL
));
builder
.
setSyncDirty
(
c
.
getInt
(
INDEX_HR_CASE_REQUEST_SYNC_DIRTY
));
}
private
static
ContentValues
getContentValues
(
HRCaseRequest
hrCaseRequest
)
{
ContentValues
cv
=
new
ContentValues
(
HR_CASE_REQUEST_COLUMN_COUNT
-
1
);
cv
.
put
(
HR_CASE_REQUEST_NUMBER
,
hrCaseRequest
.
getNumber
());
cv
.
put
(
HR_CASE_REQUEST_SYS_UPDATED_ON
,
hrCaseRequest
.
getUpdateOn
());
cv
.
put
(
HR_CASE_REQUEST_APPROVAL
,
hrCaseRequest
.
getApproval
());
cv
.
put
(
HR_CASE_REQUEST_OPENED_BY_VALUE
,
hrCaseRequest
.
getOpenedBy
().
getId
());
cv
.
put
(
HR_CASE_REQUEST_SYNC_DIRTY
,
hrCaseRequest
.
getSyncDirty
());
return
cv
;
}
}
\ No newline at end of file
app/src/main/java/com/vsoft/servicenow/db/managers/MyHRCaseRequestOpenedByDisplayValueManager.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
db
.
managers
;
import
android.content.ContentValues
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
com.vsoft.servicenow.CatalogueApplication
;
import
com.vsoft.servicenow.db.DBConstants
;
import
com.vsoft.servicenow.db.models.HRCaseRequestDisplayValue
;
import
com.vsoft.servicenow.db.models.MyRequestDisplayValue
;
import
java.util.List
;
/**
*
* @author Created by Kunj on 13/04/2018.
*/
public
class
MyHRCaseRequestOpenedByDisplayValueManager
implements
DBConstants
{
public
static
long
save
(
HRCaseRequestDisplayValue
hrCaseRequestDisplayValue
,
int
syncDirty
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
if
(
db
!=
null
)
{
hrCaseRequestDisplayValue
.
setSyncDirty
(
syncDirty
);
long
id
=
db
.
insert
(
TABLE_MY_HR_CASE_REQUEST_OPENED_BY
,
null
,
getContentValues
(
hrCaseRequestDisplayValue
));
hrCaseRequestDisplayValue
.
setId
(
id
);
return
id
;
}
else
{
return
-
1
;
}
}
public
static
int
delete
(
HRCaseRequestDisplayValue
hrCaseRequestDisplayValue
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
if
(
db
!=
null
)
{
return
db
.
delete
(
TABLE_MY_HR_CASE_REQUEST_OPENED_BY
,
MY_HR_CASE_REQUEST_OPENED_BY_ID
+
"="
+
hrCaseRequestDisplayValue
.
getId
(),
null
);
}
return
-
1
;
}
public
static
int
update
(
HRCaseRequestDisplayValue
hrCaseRequestDisplayValue
,
int
syncDirty
)
{
return
update
(
hrCaseRequestDisplayValue
,
null
,
syncDirty
);
}
public
static
int
update
(
HRCaseRequestDisplayValue
hrCaseRequestDisplayValue
,
List
<
String
>
column
,
int
syncDirty
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
if
(
db
!=
null
)
{
hrCaseRequestDisplayValue
.
setSyncDirty
(
syncDirty
);
if
(
column
==
null
||
column
.
size
()
==
0
)
{
return
db
.
update
(
TABLE_MY_HR_CASE_REQUEST_OPENED_BY
,
getContentValues
(
hrCaseRequestDisplayValue
),
MY_HR_CASE_REQUEST_OPENED_BY_ID
+
"="
+
hrCaseRequestDisplayValue
.
getId
(),
null
);
}
else
{
ContentValues
contentValues
=
new
ContentValues
(
column
.
size
());
contentValues
.
put
(
MY_HR_CASE_REQUEST_OPENED_BY_SYNC_DIRTY
,
hrCaseRequestDisplayValue
.
getSyncDirty
());
for
(
int
i
=
0
;
i
<
column
.
size
();
i
++)
{
String
columnName
=
column
.
get
(
i
);
if
(
MY_HR_CASE_REQUEST_OPENED_BY_LINK
.
equals
(
columnName
))
{
contentValues
.
put
(
MY_HR_CASE_REQUEST_OPENED_BY_LINK
,
hrCaseRequestDisplayValue
.
getLink
());
}
else
if
(
MY_HR_CASE_REQUEST_OPENED_BY_DISPLAY_VALUE
.
equals
(
columnName
))
{
contentValues
.
put
(
MY_HR_CASE_REQUEST_OPENED_BY_DISPLAY_VALUE
,
hrCaseRequestDisplayValue
.
getDisplayValue
());
}
}
return
db
.
update
(
TABLE_MY_HR_CASE_REQUEST_OPENED_BY
,
contentValues
,
MY_HR_CASE_REQUEST_OPENED_BY_ID
+
"="
+
hrCaseRequestDisplayValue
.
getId
(),
null
);
}
}
else
{
return
-
1
;
}
}
public
static
void
handleGetRequestItem
(
HRCaseRequestDisplayValue
hrCaseRequestDisplayValue
,
long
requestId
)
{
HRCaseRequestDisplayValue
localMyRequestDisplayValue
=
get
(
requestId
);
if
(
localMyRequestDisplayValue
!=
null
)
{
delete
(
localMyRequestDisplayValue
);
}
else
{
save
(
hrCaseRequestDisplayValue
,
SYNC_FLAG_NONE
);
}
}
public
static
HRCaseRequestDisplayValue
get
(
long
uiPolicyActionId
)
{
SQLiteDatabase
db
=
CatalogueApplication
.
getDatabase
();
HRCaseRequestDisplayValue
myRequestDisplayValue
=
null
;
if
(
db
!=
null
)
{
Cursor
c
=
db
.
rawQuery
(
"select * from "
+
TABLE_MY_HR_CASE_REQUEST_OPENED_BY
+
" where "
+
MY_HR_CASE_REQUEST_OPENED_BY_ID
+
"="
+
uiPolicyActionId
,
null
);
if
(
c
.
moveToFirst
())
{
HRCaseRequestDisplayValue
.
HRCaseDisplayValueBuilder
builder
=
HRCaseRequestDisplayValue
.
HRCaseDisplayValueBuilder
.
aMyRequest
();
fillAllRequestItemDetails
(
c
,
builder
);
myRequestDisplayValue
=
builder
.
build
();
}
c
.
close
();
}
return
myRequestDisplayValue
;
}
private
static
void
fillAllRequestItemDetails
(
Cursor
c
,
HRCaseRequestDisplayValue
.
HRCaseDisplayValueBuilder
builder
)
{
builder
.
setId
(
c
.
getLong
(
INDEX_MY_HR_CASE_REQUEST_OPENED_BY_ID
));
builder
.
setDisplayValue
(
c
.
getString
(
INDEX_MY_HR_CASE_REQUEST_OPENED_BY_DISPLAY_VALUE
));
builder
.
setLink
(
c
.
getString
(
INDEX_MY_HR_CASE_REQUEST_OPENED_BY_LINK
));
builder
.
setSyncDirty
(
c
.
getInt
(
INDEX_MY_HR_CASE_REQUEST_OPENED_BY_SYNC_DIRTY
));
}
private
static
ContentValues
getContentValues
(
HRCaseRequestDisplayValue
myRequestDisplayValue
)
{
ContentValues
cv
=
new
ContentValues
(
MY_HR_CASE_REQUEST_OPENED_BY_COLUMN_COUNT
-
1
);
cv
.
put
(
MY_HR_CASE_REQUEST_OPENED_BY_DISPLAY_VALUE
,
myRequestDisplayValue
.
getDisplayValue
());
cv
.
put
(
MY_HR_CASE_REQUEST_OPENED_BY_LINK
,
myRequestDisplayValue
.
getLink
());
cv
.
put
(
MY_HR_CASE_REQUEST_OPENED_BY_SYNC_DIRTY
,
myRequestDisplayValue
.
getSyncDirty
());
return
cv
;
}
}
\ No newline at end of file
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseAttachment.java
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
db
.
models
;
package
com
.
vsoft
.
servicenow
.
db
.
models
;
/**
/**
* Created by Kunj on 1
1/8/16
.
* Created by Kunj on 1
3/04/2018
.
*/
*
*
/
public
class
HRCaseAttachment
{
public
class
HRCaseAttachment
{
private
long
id
=
-
1
;
private
long
id
=
-
1
;
...
...
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseItemInput.java
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
db
.
models
;
package
com
.
vsoft
.
servicenow
.
db
.
models
;
/**
/**
* Created by Kunj on 1
1/8/16
.
* Created by Kunj on 1
3/04/2018
.
*/
*
*
/
public
class
HRCaseItemInput
{
public
class
HRCaseItemInput
{
private
long
id
=
-
1
;
private
long
id
=
-
1
;
...
...
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseRequest.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
db
.
models
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
com.vsoft.servicenow.utils.Util
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
/**
* Created by Kunj on 13/04/2018.
*/
public
class
HRCaseRequest
{
private
long
id
=
-
1
;
@SerializedName
(
"number"
)
@Expose
private
String
number
;
@SerializedName
(
"sys_updated_on"
)
// @Expose
private
long
updateOn
;
@SerializedName
(
"approval"
)
@Expose
String
approval
;
@SerializedName
(
"opened_by"
)
@Expose
HRCaseRequestDisplayValue
openedBy
;
private
int
syncDirty
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getNumber
()
{
return
number
;
}
public
void
setNumber
(
String
number
)
{
this
.
number
=
number
;
}
public
long
getUpdateOn
()
{
return
updateOn
;
}
public
void
setUpdateOn
(
long
updateOn
)
{
this
.
updateOn
=
updateOn
;
}
public
String
getApproval
()
{
return
approval
;
}
public
void
setApproval
(
String
approval
)
{
this
.
approval
=
approval
;
}
public
HRCaseRequestDisplayValue
getOpenedBy
()
{
return
openedBy
;
}
public
void
setOpenedBy
(
HRCaseRequestDisplayValue
openedBy
)
{
this
.
openedBy
=
openedBy
;
}
public
int
getSyncDirty
()
{
return
syncDirty
;
}
public
void
setSyncDirty
(
int
syncDirty
)
{
this
.
syncDirty
=
syncDirty
;
}
public
void
parseJson
(
JSONObject
jsonObject
)
{
String
dueDate
=
null
;
try
{
dueDate
=
jsonObject
.
getString
(
Json
.
DUE_DATE
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
this
.
setUpdateOn
(
Util
.
getDateTimeForMyIncidentFromString
(
dueDate
));
}
public
static
final
class
HRCaseRequestBuilder
{
private
long
id
=
-
1
;
private
String
number
;
private
long
updateOn
;
private
String
approval
;
private
HRCaseRequestDisplayValue
requestOpenedBy
;
private
int
syncDirty
;
private
HRCaseRequestBuilder
()
{
}
public
static
HRCaseRequestBuilder
aMyRequest
()
{
return
new
HRCaseRequestBuilder
();
}
public
HRCaseRequestBuilder
setId
(
long
id
)
{
this
.
id
=
id
;
return
this
;
}
public
HRCaseRequestBuilder
setNumber
(
String
number
)
{
this
.
number
=
number
;
return
this
;
}
public
HRCaseRequestBuilder
setUpdateOn
(
long
updateOn
)
{
this
.
updateOn
=
updateOn
;
return
this
;
}
public
HRCaseRequestBuilder
setApproval
(
String
approval
)
{
this
.
approval
=
approval
;
return
this
;
}
public
HRCaseRequestBuilder
setOpenedBy
(
HRCaseRequestDisplayValue
requestOpenedBy
)
{
this
.
requestOpenedBy
=
requestOpenedBy
;
return
this
;
}
public
HRCaseRequestBuilder
setSyncDirty
(
int
syncDirty
)
{
this
.
syncDirty
=
syncDirty
;
return
this
;
}
public
HRCaseRequestBuilder
but
()
{
return
aMyRequest
().
setId
(
id
).
setNumber
(
number
).
setUpdateOn
(
updateOn
)
.
setApproval
(
approval
)
.
setOpenedBy
(
requestOpenedBy
).
setSyncDirty
(
syncDirty
);
}
public
HRCaseRequest
build
()
{
HRCaseRequest
myRequest
=
new
HRCaseRequest
();
myRequest
.
setId
(
id
);
myRequest
.
setNumber
(
number
);
myRequest
.
setUpdateOn
(
updateOn
);
myRequest
.
setApproval
(
approval
);
myRequest
.
setOpenedBy
(
requestOpenedBy
);
myRequest
.
setSyncDirty
(
syncDirty
);
return
myRequest
;
}
}
public
static
class
Json
{
public
static
final
String
URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE
=
"request.requested_for=javascript:gs.getUserID()"
;
public
static
final
String
DUE_DATE
=
"sys_updated_on"
;
}
}
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseRequestDisplayValue.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
db
.
models
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
/**
* Created by Kunj on 13/04/2018.
*/
public
class
HRCaseRequestDisplayValue
{
private
long
id
=
-
1
;
@SerializedName
(
"display_value"
)
@Expose
private
String
displayValue
;
@SerializedName
(
"link"
)
@Expose
private
String
link
;
private
int
syncDirty
;
public
int
getSyncDirty
()
{
return
syncDirty
;
}
public
void
setSyncDirty
(
int
syncDirty
)
{
this
.
syncDirty
=
syncDirty
;
}
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getDisplayValue
()
{
return
displayValue
;
}
public
void
setDisplayValue
(
String
displayValue
)
{
this
.
displayValue
=
displayValue
;
}
public
String
getLink
()
{
return
link
;
}
public
void
setLink
(
String
link
)
{
this
.
link
=
link
;
}
public
static
final
class
HRCaseDisplayValueBuilder
{
private
long
id
=
-
1
;
private
String
link
;
private
String
displayValue
;
private
int
syncDirty
;
private
HRCaseDisplayValueBuilder
()
{
}
public
static
HRCaseDisplayValueBuilder
aMyRequest
()
{
return
new
HRCaseDisplayValueBuilder
();
}
public
HRCaseDisplayValueBuilder
setId
(
long
id
)
{
this
.
id
=
id
;
return
this
;
}
public
HRCaseDisplayValueBuilder
setDisplayValue
(
String
displayValue
)
{
this
.
displayValue
=
displayValue
;
return
this
;
}
public
HRCaseDisplayValueBuilder
setLink
(
String
link
)
{
this
.
link
=
link
;
return
this
;
}
public
HRCaseDisplayValueBuilder
setSyncDirty
(
int
syncDirty
)
{
this
.
syncDirty
=
syncDirty
;
return
this
;
}
public
HRCaseDisplayValueBuilder
but
()
{
return
aMyRequest
().
setId
(
id
).
setDisplayValue
(
displayValue
)
.
setLink
(
link
).
setSyncDirty
(
syncDirty
);
}
public
HRCaseRequestDisplayValue
build
()
{
HRCaseRequestDisplayValue
myRequestDisplayValue
=
new
HRCaseRequestDisplayValue
();
myRequestDisplayValue
.
setId
(
id
);
myRequestDisplayValue
.
setLink
(
link
);
myRequestDisplayValue
.
setDisplayValue
(
displayValue
);
myRequestDisplayValue
.
setSyncDirty
(
syncDirty
);
return
myRequestDisplayValue
;
}
}
}
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseUiPolicyAction.java
View file @
fcec8066
...
@@ -4,6 +4,9 @@ package com.vsoft.servicenow.db.models;
...
@@ -4,6 +4,9 @@ package com.vsoft.servicenow.db.models;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
/**
* Created by Kunj on 13/04/2018.
* */
public
class
HRCaseUiPolicyAction
{
public
class
HRCaseUiPolicyAction
{
private
long
id
=
-
1
;
private
long
id
=
-
1
;
...
...
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseUiPolicyItem.java
View file @
fcec8066
...
@@ -7,9 +7,8 @@ import com.vsoft.servicenow.utils.PartialCondition;
...
@@ -7,9 +7,8 @@ import com.vsoft.servicenow.utils.PartialCondition;
import
java.util.List
;
import
java.util.List
;
/**
/**
* Created by chaukadev on 6/10/16.
* Created by Kunj on 13/04/2018.
*/
* */
public
class
HRCaseUiPolicyItem
{
public
class
HRCaseUiPolicyItem
{
private
long
id
=
-
1
;
private
long
id
=
-
1
;
...
...
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariable.java
View file @
fcec8066
...
@@ -14,8 +14,8 @@ import java.util.List;
...
@@ -14,8 +14,8 @@ import java.util.List;
/**
/**
* Created by Kunj on 1
2/8/16
.
* Created by Kunj on 1
3/04/2018
.
*/
*
*
/
public
class
HRCaseVariable
{
public
class
HRCaseVariable
{
private
long
id
=
-
1
;
private
long
id
=
-
1
;
...
...
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariableChoice.java
View file @
fcec8066
...
@@ -4,6 +4,9 @@ package com.vsoft.servicenow.db.models;
...
@@ -4,6 +4,9 @@ package com.vsoft.servicenow.db.models;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
/**
* Created by Kunj on 13/04/2018.
* */
public
class
HRCaseVariableChoice
{
public
class
HRCaseVariableChoice
{
private
long
id
;
private
long
id
;
...
...
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariableResponse.java
View file @
fcec8066
...
@@ -6,9 +6,8 @@ import com.google.gson.annotations.SerializedName;
...
@@ -6,9 +6,8 @@ import com.google.gson.annotations.SerializedName;
import
java.util.List
;
import
java.util.List
;
/**
/**
* Created by kunj on 16/02/17.
* Created by Kunj on 13/04/2018.
*/
* */
public
class
HRCaseVariableResponse
{
public
class
HRCaseVariableResponse
{
@SerializedName
(
"variables"
)
@SerializedName
(
"variables"
)
@Expose
@Expose
...
...
app/src/main/java/com/vsoft/servicenow/db/models/HRCaseVariableSet.java
View file @
fcec8066
...
@@ -8,8 +8,8 @@ import java.util.List;
...
@@ -8,8 +8,8 @@ import java.util.List;
/**
/**
* Created by Kunj on 1
2/8/16
.
* Created by Kunj on 1
3/04/2018
.
*/
*
*
/
public
class
HRCaseVariableSet
{
public
class
HRCaseVariableSet
{
@SerializedName
(
"order"
)
@SerializedName
(
"order"
)
...
...
app/src/main/java/com/vsoft/servicenow/menu/ViewHRCaseMenuItemData.java
View file @
fcec8066
...
@@ -3,8 +3,7 @@ package com.vsoft.servicenow.menu;
...
@@ -3,8 +3,7 @@ package com.vsoft.servicenow.menu;
import
android.os.Parcel
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
android.os.Parcelable
;
import
com.vsoft.servicenow.ui.ReportIncidentScreen
;
import
com.vsoft.servicenow.ui.MyHRCaseActivity
;
import
com.vsoft.servicenow.ui.ViewHRCaseScreen
;
/**
/**
* Created by Kunj on 23/03/18.
* Created by Kunj on 23/03/18.
...
@@ -46,7 +45,7 @@ public class ViewHRCaseMenuItemData extends HomeScreenMenuItemData implements Pa
...
@@ -46,7 +45,7 @@ public class ViewHRCaseMenuItemData extends HomeScreenMenuItemData implements Pa
public
Builder
()
{
public
Builder
()
{
item
=
new
ViewHRCaseMenuItemData
();
item
=
new
ViewHRCaseMenuItemData
();
setActivity
(
ViewHRCaseScreen
.
class
);
setActivity
(
MyHRCaseActivity
.
class
);
}
}
}
}
}
}
app/src/main/java/com/vsoft/servicenow/ui/HRCaseVariableScreen.java
View file @
fcec8066
...
@@ -106,8 +106,8 @@ import butterknife.ButterKnife;
...
@@ -106,8 +106,8 @@ import butterknife.ButterKnife;
import
butterknife.OnClick
;
import
butterknife.OnClick
;
/**
/**
* Created by Kunj on 1
1/8/16
.
* Created by Kunj on 1
3/04/2018
.
*/
*
*
/
public
class
HRCaseVariableScreen
extends
HandleNotificationActivity
{
public
class
HRCaseVariableScreen
extends
HandleNotificationActivity
{
@BindView
(
R
.
id
.
tool_bar_view
)
Toolbar
mToolbar
;
@BindView
(
R
.
id
.
tool_bar_view
)
Toolbar
mToolbar
;
...
...
app/src/main/java/com/vsoft/servicenow/ui/MyHRCaseActivity.java
0 → 100644
View file @
fcec8066
package
com
.
vsoft
.
servicenow
.
ui
;
import
android.app.ProgressDialog
;
import
android.content.DialogInterface
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.support.v7.app.ActionBar
;
import
android.support.v7.app.AlertDialog
;
import
android.support.v7.widget.Toolbar
;
import
android.text.Html
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ListView
;
import
android.widget.ProgressBar
;
import
com.google.android.gms.analytics.Tracker
;
import
com.vsoft.servicenow.CatalogueApplication
;
import
com.vsoft.servicenow.R
;
import
com.vsoft.servicenow.adapters.MyHRCaseAdapter
;
import
com.vsoft.servicenow.adapters.MyRequestAdapter
;
import
com.vsoft.servicenow.api.listeners.get.GetMyHRCaseApiListener
;
import
com.vsoft.servicenow.api.listeners.get.GetMyRequestApiListener
;
import
com.vsoft.servicenow.api.managers.MyHRCaseApiManager
;
import
com.vsoft.servicenow.db.managers.MyHRCaseManager
;
import
com.vsoft.servicenow.db.models.HRCaseRequest
;
import
com.vsoft.servicenow.enums.SyncStatus
;
import
com.vsoft.servicenow.utils.DialogUtils
;
import
com.vsoft.servicenow.utils.Util
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.OnClick
;
import
butterknife.OnItemClick
;
/**
* Created by Kunj on 13/04/2018.
* */
public
class
MyHRCaseActivity
extends
HandleNotificationActivity
{
@BindView
(
R
.
id
.
tool_bar_view
)
Toolbar
mToolbar
;
@BindView
(
R
.
id
.
my_hr_case_screen_list_view
)
ListView
mListView
;
@BindView
(
R
.
id
.
toolbar_refresh_icon
)
ImageView
mRefreshIcon
;
@BindView
(
R
.
id
.
toolbar_progress_icon
)
ProgressBar
mProgressBar
;
private
List
<
HRCaseRequest
>
mHrCaseRequestList
;
private
MyHRCaseAdapter
mAdapter
;
private
boolean
isProgressRequire
;
private
CatalogueApplication
mApplication
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
// TODO Auto-generated method stub
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
my_hr_case_list_screen
);
ButterKnife
.
bind
(
this
);
mApplication
=
(
CatalogueApplication
)
getApplication
();
setSupportActionBar
(
mToolbar
);
ActionBar
actionBar
=
getSupportActionBar
();
if
(
actionBar
!=
null
)
{
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
actionBar
.
setElevation
(
0
);
actionBar
.
setTitle
(
R
.
string
.
my_hr_case_text_string
);
actionBar
.
setDisplayShowHomeEnabled
(
false
);
actionBar
.
setDisplayShowTitleEnabled
(
true
);
}
Tracker
tracker
=
mApplication
.
getDefaultTracker
();
// Send initial screen view hit.
Util
.
sendScreenName
(
tracker
,
actionBar
.
getTitle
().
toString
());
mAdapter
=
new
MyHRCaseAdapter
(
MyHRCaseActivity
.
this
);
mListView
.
setAdapter
(
mAdapter
);
mHrCaseRequestList
=
MyHRCaseManager
.
getAllRequests
();
if
(!
mHrCaseRequestList
.
isEmpty
())
{
setData
(
mHrCaseRequestList
);
}
if
(
mApplication
.
isNetConnected
())
{
isProgressRequire
=
mHrCaseRequestList
.
isEmpty
();
new
FetchMyRequestData
().
execute
();
}
else
{
if
(
mHrCaseRequestList
.
isEmpty
())
{
DialogUtils
.
showNoConnectionDialogWithCloseActivity
(
MyHRCaseActivity
.
this
);
}
else
{
setData
(
mHrCaseRequestList
);
}
}
}
class
FetchMyRequestData
extends
AsyncTask
<
String
,
Void
,
SyncStatus
>
{
private
ProgressDialog
progressDialog
;
private
SyncStatus
syncStatus
=
SyncStatus
.
FAIL
;
@Override
protected
void
onPreExecute
()
{
super
.
onPreExecute
();
if
(
isProgressRequire
)
{
progressDialog
=
new
ProgressDialog
(
MyHRCaseActivity
.
this
);
progressDialog
.
setMessage
(
getString
(
R
.
string
.
loading_string
));
progressDialog
.
show
();
progressDialog
.
setCancelable
(
false
);
}
else
{
mRefreshIcon
.
setVisibility
(
View
.
GONE
);
mProgressBar
.
setVisibility
(
View
.
VISIBLE
);
}
}
@Override
protected
SyncStatus
doInBackground
(
String
...
params
)
{
MyHRCaseApiManager
.
getMyHRCase
(
MyHRCaseActivity
.
this
,
new
GetMyHRCaseApiListener
()
{
@Override
public
void
onDoneApiCall
(
List
<
HRCaseRequest
>
requestList
)
{
MyHRCaseManager
.
handleGetRequest
(
requestList
);
syncStatus
=
SyncStatus
.
SUCCESS
;
mHrCaseRequestList
=
requestList
;
}
@Override
public
void
onFailApiCall
()
{
syncStatus
=
SyncStatus
.
FAIL
;
}
});
return
syncStatus
;
}
@Override
protected
void
onPostExecute
(
SyncStatus
syncStatus
)
{
super
.
onPostExecute
(
syncStatus
);
if
(
progressDialog
!=
null
&&
progressDialog
.
isShowing
())
{
progressDialog
.
dismiss
();
}
else
{
mRefreshIcon
.
setVisibility
(
View
.
VISIBLE
);
mProgressBar
.
setVisibility
(
View
.
GONE
);
}
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
mHrCaseRequestList
=
MyHRCaseManager
.
getAllRequests
();
isProgressRequire
=
mHrCaseRequestList
.
isEmpty
();
setData
(
mHrCaseRequestList
);
}
else
{
showErrorDialog
(
R
.
string
.
failed_to_fetch_my_request_string
);
}
}
}
@OnItemClick
(
R
.
id
.
my_hr_case_screen_list_view
)
void
listViewOnClicked
(
int
position
)
{
HRCaseRequest
hrCaseRequest
=
mHrCaseRequestList
.
get
(
position
);
String
messageString
=
String
.
format
(
getResources
().
getString
(
R
.
string
.
my_hr_case_item_text_string
),
hrCaseRequest
.
getNumber
(),
Util
.
getDateTimeFromLong
(
hrCaseRequest
.
getUpdateOn
()),
hrCaseRequest
.
getOpenedBy
().
getDisplayValue
());
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
builder
.
setMessage
(
Html
.
fromHtml
(
messageString
))
.
setCancelable
(
false
)
.
setPositiveButton
(
android
.
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
dialog
.
dismiss
();
}
});
AlertDialog
alert
=
builder
.
create
();
alert
.
show
();
}
@OnClick
(
R
.
id
.
toolbar_refresh_icon
)
void
onRefreshClicked
()
{
if
(
mApplication
.
isNetConnected
())
{
new
FetchMyRequestData
().
execute
();
}
else
{
DialogUtils
.
showNoConnectionDialogWithCloseActivity
(
MyHRCaseActivity
.
this
);
}
}
private
void
setData
(
final
List
<
HRCaseRequest
>
reqList
)
{
Collections
.
sort
(
reqList
,
new
StringDateComparator
());
if
(
mAdapter
==
null
)
{
mAdapter
=
new
MyHRCaseAdapter
(
MyHRCaseActivity
.
this
);
mListView
.
setAdapter
(
mAdapter
);
}
mAdapter
.
setRequestList
(
reqList
);
}
class
StringDateComparator
implements
Comparator
<
HRCaseRequest
>
{
public
int
compare
(
HRCaseRequest
lhs
,
HRCaseRequest
rhs
)
{
return
lhs
.
getUpdateOn
()>
rhs
.
getUpdateOn
()
?
-
1
:
1
;
}
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
menuItem
)
{
if
(
menuItem
.
getItemId
()
==
android
.
R
.
id
.
home
)
{
finish
();
}
return
super
.
onOptionsItemSelected
(
menuItem
);
}
private
void
showErrorDialog
(
int
message
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
builder
.
setMessage
(
message
)
.
setCancelable
(
false
)
.
setPositiveButton
(
android
.
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
finish
();
}
});
AlertDialog
alert
=
builder
.
create
();
alert
.
show
();
}
}
app/src/main/java/com/vsoft/servicenow/ui/ViewHRCaseScreen.java
deleted
100644 → 0
View file @
4c7d9383
package
com
.
vsoft
.
servicenow
.
ui
;
import
android.support.v7.app.AppCompatActivity
;
/**
* Created by chaukadev on 4/9/18.
*/
public
class
ViewHRCaseScreen
extends
AppCompatActivity
{
}
app/src/main/java/com/vsoft/servicenow/utils/Constants.java
View file @
fcec8066
...
@@ -62,6 +62,7 @@ public class Constants {
...
@@ -62,6 +62,7 @@ public class Constants {
public
static
final
String
URL_PARAM_TABLE_NAME
=
"table_name"
;
public
static
final
String
URL_PARAM_TABLE_NAME
=
"table_name"
;
public
static
final
String
URL_PARAM_FILE_NAME
=
"file_name"
;
public
static
final
String
URL_PARAM_FILE_NAME
=
"file_name"
;
public
static
final
String
URL_PARAM_SYS_ID
=
"sys_id"
;
public
static
final
String
URL_PARAM_SYS_ID
=
"sys_id"
;
public
static
final
String
URL_PARAM_OPENED_BY
=
"opened_by"
;
/**
/**
* Request Code
* Request Code
...
@@ -148,6 +149,7 @@ public class Constants {
...
@@ -148,6 +149,7 @@ public class Constants {
public
static
final
String
URL_POST_LOGIN_ITEM
=
"/oauth_token.do"
;
public
static
final
String
URL_POST_LOGIN_ITEM
=
"/oauth_token.do"
;
public
static
final
String
URL_REFRESH_LOGIN
=
URL_POST_LOGIN_ITEM
;
public
static
final
String
URL_REFRESH_LOGIN
=
URL_POST_LOGIN_ITEM
;
public
static
final
String
URL_PUT_DEVICE_REGISTERATION
=
"api/now/table/sys_user/{user_sys_id}"
;
public
static
final
String
URL_PUT_DEVICE_REGISTERATION
=
"api/now/table/sys_user/{user_sys_id}"
;
public
static
final
String
URL_GET_USERDETAILS
=
API_PATH
+
"sys_user"
;
/*Catalogue Category API */
/*Catalogue Category API */
public
static
final
String
URL_GET_CATALOGUE
=
DOMAIN
+
AppConfig
.
URL_GET_CATALOGUE
;
public
static
final
String
URL_GET_CATALOGUE
=
DOMAIN
+
AppConfig
.
URL_GET_CATALOGUE
;
...
@@ -165,7 +167,6 @@ public class Constants {
...
@@ -165,7 +167,6 @@ public class Constants {
/*Request API*/
/*Request API*/
public
static
final
String
URL_GET_MYREQUEST
=
API_PATH
+
"sc_req_item"
;
public
static
final
String
URL_GET_MYREQUEST
=
API_PATH
+
"sc_req_item"
;
public
static
final
String
URL_GET_USERDETAILS
=
API_PATH
+
"sys_user"
;
/*Incident API */
/*Incident API */
public
static
final
String
URL_GET_INCIDENTS
=
API_PATH
+
"incident"
;
public
static
final
String
URL_GET_INCIDENTS
=
API_PATH
+
"incident"
;
...
@@ -188,6 +189,10 @@ public class Constants {
...
@@ -188,6 +189,10 @@ public class Constants {
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"
;
/*Get All My HRCase*/
public
static
final
String
URL_GET_MY_HR_CASE
=
API_PATH
+
"hr_case"
;
// https://vsoftconsultingdev.service-now.com/api/now/table/hr_case?opened_by=debf86ee4f1852005ee63d728110c7c7
/**
/**
* Chat Server URL
* Chat Server URL
* */
* */
...
...
app/src/main/res/layout/my_hr_case_list_item.xml
0 → 100644
View file @
fcec8066
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#ffffff"
android:orientation=
"vertical"
android:padding=
"@dimen/normal_margin"
>
<TextView
android:id=
"@+id/number"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentTop=
"true"
android:layout_marginLeft=
"@dimen/my_request_left"
android:layout_marginTop=
"@dimen/my_request_top"
android:text=
"Large Text"
android:textSize=
"@dimen/ruquest_descps_text_size"
android:textStyle=
"bold"
/>
<ImageView
android:id=
"@+id/approval_image"
android:layout_width=
"@dimen/my_request_top"
android:layout_height=
"@dimen/my_request_top"
android:layout_alignLeft=
"@+id/number"
android:layout_alignStart=
"@+id/number"
android:layout_alignTop=
"@+id/approval"
android:layout_marginBottom=
"@dimen/my_request_top"
android:layout_marginTop=
"@dimen/my_request_text_bottom"
android:background=
"@drawable/circle"
/>
<TextView
android:id=
"@+id/approval"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/number"
android:layout_marginLeft=
"@dimen/my_request_right"
android:layout_marginTop=
"@dimen/my_request_new_top"
android:layout_toRightOf=
"@+id/approval_image"
android:text=
"Large Text"
android:textColor=
"#8e8e8e"
android:textSize=
"@dimen/ruquest_status_text_size"
/>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/my_hr_case_list_screen.xml
0 → 100644
View file @
fcec8066
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/screen_bg_color"
android:orientation=
"vertical"
>
<include
layout=
"@layout/toolbar_with_refresh_option"
/>
<ListView
android:id=
"@+id/my_hr_case_screen_list_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_margin=
"@dimen/normal_margin"
android:background=
"@android:color/white"
android:divider=
"#8e8e8e"
android:dividerHeight=
"0.5dp"
android:padding=
"@dimen/normal_margin"
android:scrollbars=
"none"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
fcec8066
...
@@ -172,4 +172,8 @@
...
@@ -172,4 +172,8 @@
<!--HRCase Item Screen-->
<!--HRCase Item Screen-->
<string
name=
"no_hr_case_item_string"
>
No HR Case Items
…
</string>
<string
name=
"no_hr_case_item_string"
>
No HR Case Items
…
</string>
<!--MY All HRCase Screen-->
<string
name=
"my_hr_case_text_string"
>
View HR Case
</string>
<string
name=
"my_hr_case_item_text_string"
>
<![CDATA[<b>Number: </b>%1$s<br><br><b>Updated: </b>%2$s<br><br><b>Opened by: </b>%3$s]]>
</string>
</resources>
</resources>
app/src/vportal/AndroidManifest.xml
View file @
fcec8066
...
@@ -30,6 +30,11 @@
...
@@ -30,6 +30,11 @@
<activity
<activity
android:name=
"com.vsoft.servicenow.ui.HRCaseVariableScreen"
android:name=
"com.vsoft.servicenow.ui.HRCaseVariableScreen"
android:screenOrientation=
"portrait"
android:windowSoftInputMode=
"stateHidden|adjustResize"
/>
<activity
android:name=
"com.vsoft.servicenow.ui.MyHRCaseActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<service
android:name=
".service.NotificationInstanceIdService"
<service
android:name=
".service.NotificationInstanceIdService"
...
...
app/src/vportal/java/com/vsoft/servicenow/AppConfig.java
View file @
fcec8066
...
@@ -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"
;
public
static
final
String
URL_POST_HR_CASE_CATALOGUE_ITEM
=
"api/vsng2/uofl_mobile
/createCase
"
;
/**
/**
* 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