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
7ae70cfd
authored
Aug 30, 2016
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
For each API call create different interface.
parent
39d51751
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
48 deletions
app/src/main/java/com/vsoft/uofl_catalogue/api/interfaces/CatalogueCategoryApi.java
app/src/main/java/com/vsoft/uofl_catalogue/api/interfaces/CatalogueCategoryItemApi.java
app/src/main/java/com/vsoft/uofl_catalogue/api/interfaces/CatalogueApi.java → app/src/main/java/com/vsoft/uofl_catalogue/api/interfaces/CatalogueVariableApi.java
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/CatalogueApiManager.java
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/CatalogueItemApiManager.java
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/CatalogueVariableApiManager.java
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/LoginApiManger.java
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/VariableChoiceApiManager.java
app/src/main/java/com/vsoft/uofl_catalogue/ui/CatalogueVariableScreen.java
app/src/main/java/com/vsoft/uofl_catalogue/api/interfaces/CatalogueCategoryApi.java
0 → 100644
View file @
7ae70cfd
package
com
.
vsoft
.
uofl_catalogue
.
api
.
interfaces
;
import
com.vsoft.uofl_catalogue.utils.Constants
;
import
okhttp3.ResponseBody
;
import
retrofit2.Call
;
import
retrofit2.http.GET
;
import
retrofit2.http.Query
;
/**
* @since 1.0
* @author Kunj on 11/8/16.
*
*/
public
interface
CatalogueCategoryApi
{
// Get Catalogue API
@GET
(
Constants
.
URL_GET_CATALOGUE
)
Call
<
ResponseBody
>
getCatalogue
(
@Query
(
Constants
.
URL_PARAM_SYSPRM_QUERY
)
String
sysparmQuery
,
@Query
(
Constants
.
URL_PARAM_SYSPRM_FIELDS
)
String
sysParmFields
);
}
app/src/main/java/com/vsoft/uofl_catalogue/api/interfaces/CatalogueCategoryItemApi.java
0 → 100644
View file @
7ae70cfd
package
com
.
vsoft
.
uofl_catalogue
.
api
.
interfaces
;
import
com.vsoft.uofl_catalogue.utils.Constants
;
import
okhttp3.ResponseBody
;
import
retrofit2.Call
;
import
retrofit2.http.GET
;
import
retrofit2.http.Query
;
/**
* @since 1.0
* @author Kunj on 11/8/16.
*
*/
public
interface
CatalogueCategoryItemApi
{
// Get Catalogue Item API
@GET
(
Constants
.
URL_GET_CATALOGUE_ITEM
)
Call
<
ResponseBody
>
getCatalogueItem
(
@Query
(
Constants
.
URL_PARAM_SYSPRM_QUERY
)
String
sysparmQuery
,
@Query
(
Constants
.
URL_PARAM_SYSPRM_FIELDS
)
String
sysParmFields
);
}
app/src/main/java/com/vsoft/uofl_catalogue/api/interfaces/CatalogueApi.java
→
app/src/main/java/com/vsoft/uofl_catalogue/api/interfaces/Catalogue
Variable
Api.java
View file @
7ae70cfd
...
...
@@ -19,17 +19,7 @@ import retrofit2.http.Url;
* @author Kunj on 11/8/16.
*
*/
public
interface
CatalogueApi
{
// Get Catalogue API
@GET
(
Constants
.
URL_GET_CATALOGUE
)
Call
<
ResponseBody
>
getCatalogue
(
@Query
(
Constants
.
URL_PARAM_SYSPRM_QUERY
)
String
sysparmQuery
,
@Query
(
Constants
.
URL_PARAM_SYSPRM_FIELDS
)
String
sysParmFields
);
// Get Catalogue Item API
@GET
(
Constants
.
URL_GET_CATALOGUE_ITEM
)
Call
<
ResponseBody
>
getCatalogueItem
(
@Query
(
Constants
.
URL_PARAM_SYSPRM_QUERY
)
String
sysparmQuery
,
@Query
(
Constants
.
URL_PARAM_SYSPRM_FIELDS
)
String
sysParmFields
);
public
interface
CatalogueVariableApi
{
// Get Variable API
@GET
(
Constants
.
URL_GET_VARIABLE
)
Call
<
ResponseBody
>
getVariable
(
@Query
(
CatalogueVariable
.
Json
.
SYS_ID
)
String
sysId
);
...
...
@@ -47,7 +37,6 @@ public interface CatalogueApi {
// Get Reference API
@GET
Call
<
ResponseBody
>
getReference
(
@Url
String
url
,
@Query
(
Reference
.
Json
.
FIRST_NAME
)
String
firstName
);
}
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/CatalogueApiManager.java
View file @
7ae70cfd
...
...
@@ -7,8 +7,8 @@ import com.google.gson.JsonDeserializer;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonParseException
;
import
com.vsoft.uofl_catalogue.api.RestClient
;
import
com.vsoft.uofl_catalogue.api.interfaces.CatalogueCategoryApi
;
import
com.vsoft.uofl_catalogue.db.models.Catalogue
;
import
com.vsoft.uofl_catalogue.api.interfaces.CatalogueApi
;
import
com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueApiListener
;
import
com.vsoft.uofl_catalogue.enums.SyncStatus
;
import
com.vsoft.uofl_catalogue.utils.CatalogueLog
;
...
...
@@ -43,7 +43,7 @@ public class CatalogueApiManager {
CatalogueLog
.
d
(
"CatalogueApiManager: getCatalogues: request parameter: "
+
stringBuilder
.
toString
());
final
Retrofit
retrofit
=
RestClient
.
getInitializedRestAdapter
(
Constants
.
API_AUTH_PARAM_USER_NAME
,
Constants
.
API_AUTH_PARAM_PASSWORD
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
CatalogueApi
.
class
).
getCatalogue
(
stringBuilder
.
toString
(),
"sys_id,title,description"
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
Catalogue
Category
Api
.
class
).
getCatalogue
(
stringBuilder
.
toString
(),
"sys_id,title,description"
);
try
{
//Retrofit synchronous call
Response
<
ResponseBody
>
response
=
call
.
execute
();
...
...
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/CatalogueItemApiManager.java
View file @
7ae70cfd
...
...
@@ -7,7 +7,7 @@ import com.google.gson.JsonDeserializer;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonParseException
;
import
com.vsoft.uofl_catalogue.api.RestClient
;
import
com.vsoft.uofl_catalogue.api.interfaces.CatalogueApi
;
import
com.vsoft.uofl_catalogue.api.interfaces.Catalogue
CategoryItem
Api
;
import
com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueItemApiListener
;
import
com.vsoft.uofl_catalogue.db.models.CatalogueItem
;
import
com.vsoft.uofl_catalogue.enums.SyncStatus
;
...
...
@@ -43,7 +43,7 @@ public class CatalogueItemApiManager {
CatalogueLog
.
d
(
"CatalogueItemApiManager: getCatalogueItems: request parameter: "
+
stringBuilder
.
toString
());
final
Retrofit
retrofit
=
RestClient
.
getInitializedRestAdapter
(
Constants
.
API_AUTH_PARAM_USER_NAME
,
Constants
.
API_AUTH_PARAM_PASSWORD
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
CatalogueApi
.
class
).
getCatalogueItem
(
stringBuilder
.
toString
(),
"sys_id,short_description,name,description"
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
Catalogue
CategoryItem
Api
.
class
).
getCatalogueItem
(
stringBuilder
.
toString
(),
"sys_id,short_description,name,description"
);
try
{
//Retrofit synchronous call
Response
<
ResponseBody
>
response
=
call
.
execute
();
...
...
@@ -125,26 +125,4 @@ public class CatalogueItemApiManager {
return
SyncStatus
.
FAIL
;
}
}
public
static
SyncStatus
submitCatalogueItem
(
String
catalogueItemSysId
,
JSONArray
catalogueJsonArray
)
{
CatalogueLog
.
d
(
"submitCatalogueItem: "
+
catalogueJsonArray
);
String
expenseJsonString
=
catalogueJsonArray
.
toString
();
final
Retrofit
retrofit
=
RestClient
.
getInitializedRestAdapter
(
Constants
.
API_AUTH_PARAM_USER_NAME
,
Constants
.
API_AUTH_PARAM_PASSWORD
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
CatalogueApi
.
class
).
postCatalogueItem
(
catalogueItemSysId
,
expenseJsonString
);
try
{
//Retrofit synchronous call
Response
<
ResponseBody
>
response
=
call
.
execute
();
if
(
response
.
isSuccessful
())
{
return
SyncStatus
.
SUCCESS
;
}
else
{
return
SyncStatus
.
FAIL
;
}
}
catch
(
IOException
e
)
{
CatalogueLog
.
e
(
"CatalogueItemApiManager: submitCatalogueItem: IOException: "
,
e
);
return
SyncStatus
.
FAIL
;
}
catch
(
NullPointerException
e
){
CatalogueLog
.
e
(
"CatalogueItemApiManager: submitCatalogueItem: IOException: "
,
e
);
return
SyncStatus
.
FAIL
;
}
}
}
\ No newline at end of file
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/CatalogueVariableApiManager.java
View file @
7ae70cfd
...
...
@@ -7,7 +7,7 @@ import com.google.gson.JsonDeserializer;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonParseException
;
import
com.vsoft.uofl_catalogue.api.RestClient
;
import
com.vsoft.uofl_catalogue.api.interfaces.CatalogueApi
;
import
com.vsoft.uofl_catalogue.api.interfaces.Catalogue
Variable
Api
;
import
com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueVariableApiListener
;
import
com.vsoft.uofl_catalogue.db.models.CatalogueVariable
;
import
com.vsoft.uofl_catalogue.enums.SyncStatus
;
...
...
@@ -37,7 +37,7 @@ public class CatalogueVariableApiManager {
public
static
SyncStatus
getCatalogueVariable
(
String
catalogueItemSysId
,
GetCatalogueVariableApiListener
listener
)
{
CatalogueLog
.
d
(
"CatalogueVariableApiManager: getCatalogueVariable: "
);
final
Retrofit
retrofit
=
RestClient
.
getInitializedRestAdapter
(
Constants
.
API_AUTH_PARAM_USER_NAME
,
Constants
.
API_AUTH_PARAM_PASSWORD
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
CatalogueApi
.
class
).
getVariable
(
catalogueItemSysId
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
Catalogue
Variable
Api
.
class
).
getVariable
(
catalogueItemSysId
);
try
{
//Retrofit synchronous call
Response
<
ResponseBody
>
response
=
call
.
execute
();
...
...
@@ -121,4 +121,26 @@ public class CatalogueVariableApiManager {
return
SyncStatus
.
FAIL
;
}
}
public
static
SyncStatus
submitVariableForm
(
String
catalogueItemSysId
,
JSONArray
catalogueJsonArray
)
{
CatalogueLog
.
d
(
"submitVariableForm: "
+
catalogueJsonArray
);
String
expenseJsonString
=
catalogueJsonArray
.
toString
();
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
);
try
{
//Retrofit synchronous call
Response
<
ResponseBody
>
response
=
call
.
execute
();
if
(
response
.
isSuccessful
())
{
return
SyncStatus
.
SUCCESS
;
}
else
{
return
SyncStatus
.
FAIL
;
}
}
catch
(
IOException
e
)
{
CatalogueLog
.
e
(
"CatalogueVariableApiManager: submitVariableForm: IOException: "
,
e
);
return
SyncStatus
.
FAIL
;
}
catch
(
NullPointerException
e
){
CatalogueLog
.
e
(
"CatalogueVariableApiManager: submitVariableForm: IOException: "
,
e
);
return
SyncStatus
.
FAIL
;
}
}
}
\ No newline at end of file
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/LoginApiManger.java
View file @
7ae70cfd
...
...
@@ -29,10 +29,10 @@ public class LoginApiManger {
return
SyncStatus
.
FAIL
;
}
}
catch
(
IOException
e
)
{
CatalogueLog
.
e
(
"
CatalogueItemApiManager: submitCatalogueItem
: IOException: "
,
e
);
CatalogueLog
.
e
(
"
LoginApiManger: submitLoginValues
: IOException: "
,
e
);
return
SyncStatus
.
FAIL
;
}
catch
(
NullPointerException
e
)
{
CatalogueLog
.
e
(
"
CatalogueItemApiManager: submitCatalogueItem
: IOException: "
,
e
);
CatalogueLog
.
e
(
"
LoginApiManger: submitLoginValues
: IOException: "
,
e
);
return
SyncStatus
.
FAIL
;
}
}
...
...
app/src/main/java/com/vsoft/uofl_catalogue/api/managers/VariableChoiceApiManager.java
View file @
7ae70cfd
...
...
@@ -7,7 +7,7 @@ import com.google.gson.JsonDeserializer;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonParseException
;
import
com.vsoft.uofl_catalogue.api.RestClient
;
import
com.vsoft.uofl_catalogue.api.interfaces.CatalogueApi
;
import
com.vsoft.uofl_catalogue.api.interfaces.Catalogue
Variable
Api
;
import
com.vsoft.uofl_catalogue.api.listeners.get.GetReferenceApiListener
;
import
com.vsoft.uofl_catalogue.api.listeners.get.GetVariableChoiceApiListener
;
import
com.vsoft.uofl_catalogue.db.models.Reference
;
...
...
@@ -45,7 +45,7 @@ public class VariableChoiceApiManager {
CatalogueLog
.
d
(
"VariableChoiceApiManager: getVariableChoice: request parameter: "
+
stringBuilder
.
toString
());
final
Retrofit
retrofit
=
RestClient
.
getInitializedRestAdapter
(
Constants
.
API_AUTH_PARAM_USER_NAME
,
Constants
.
API_AUTH_PARAM_PASSWORD
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
CatalogueApi
.
class
).
getVariableChoice
(
stringBuilder
.
toString
(),
"text,value,order,misc"
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
Catalogue
Variable
Api
.
class
).
getVariableChoice
(
stringBuilder
.
toString
(),
"text,value,order,misc"
);
try
{
//Retrofit synchronous call
Response
<
ResponseBody
>
response
=
call
.
execute
();
...
...
@@ -132,7 +132,7 @@ public class VariableChoiceApiManager {
CatalogueLog
.
d
(
"VariableChoiceApiManager: getReference: tableName: "
+
tableName
);
final
Retrofit
retrofit
=
RestClient
.
getInitializedRestAdapter
(
Constants
.
API_AUTH_PARAM_USER_NAME
,
Constants
.
API_AUTH_PARAM_PASSWORD
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
CatalogueApi
.
class
).
getReference
(
Constants
.
URL_GET_REFERENCE
+
tableName
,
firstName
);
Call
<
ResponseBody
>
call
=
retrofit
.
create
(
Catalogue
Variable
Api
.
class
).
getReference
(
Constants
.
URL_GET_REFERENCE
+
tableName
,
firstName
);
try
{
//Retrofit synchronous call
Response
<
ResponseBody
>
response
=
call
.
execute
();
...
...
app/src/main/java/com/vsoft/uofl_catalogue/ui/CatalogueVariableScreen.java
View file @
7ae70cfd
...
...
@@ -28,7 +28,6 @@ import com.vsoft.uofl_catalogue.CatalogueApplication;
import
com.vsoft.uofl_catalogue.R
;
import
com.vsoft.uofl_catalogue.api.listeners.get.GetCatalogueVariableApiListener
;
import
com.vsoft.uofl_catalogue.api.listeners.get.GetVariableChoiceApiListener
;
import
com.vsoft.uofl_catalogue.api.managers.CatalogueItemApiManager
;
import
com.vsoft.uofl_catalogue.api.managers.CatalogueVariableApiManager
;
import
com.vsoft.uofl_catalogue.api.managers.VariableChoiceApiManager
;
import
com.vsoft.uofl_catalogue.db.models.CatalogueVariable
;
...
...
@@ -463,7 +462,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
@Override
protected
SyncStatus
doInBackground
(
String
...
params
)
{
SyncStatus
syncStatus
=
Catalogue
ItemApiManager
.
submitCatalogueIte
m
(
mCatalogueItemSysId
,
mJsonArray
);
SyncStatus
syncStatus
=
Catalogue
VariableApiManager
.
submitVariableFor
m
(
mCatalogueItemSysId
,
mJsonArray
);
return
syncStatus
;
}
...
...
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