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
00a21c21
authored
Feb 17, 2017
by
Kunj
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
In Catalogue Variable - Combined multiple calls in single calls.
parent
9085c295
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
82 deletions
app/src/main/java/com/vsoft/servicenow/api/listeners/get/GetCatalogueVariableApiListener.java
app/src/main/java/com/vsoft/servicenow/api/managers/CatalogueVariableApiManager.java
app/src/main/java/com/vsoft/servicenow/db/models/CatalogueVariable.java
app/src/main/java/com/vsoft/servicenow/db/models/CatalogueVariableResponse.java
app/src/main/java/com/vsoft/servicenow/db/models/UiPolicyItem.java
app/src/main/java/com/vsoft/servicenow/ui/CatalogueVariableScreen.java
app/src/uofl/java/com/vsoft/servicenow/AppConfig.java
app/src/main/java/com/vsoft/servicenow/api/listeners/get/GetCatalogueVariableApiListener.java
View file @
00a21c21
package
com
.
vsoft
.
servicenow
.
api
.
listeners
.
get
;
package
com
.
vsoft
.
servicenow
.
api
.
listeners
.
get
;
import
com.vsoft.servicenow.db.models.CatalogueVariable
;
import
com.vsoft.servicenow.db.models.CatalogueVariableResponse
;
import
com.vsoft.servicenow.db.models.CatalogueVariableSet
;
import
java.util.List
;
/**
/**
* @since 1.0
* @since 1.0
...
@@ -11,6 +8,6 @@ import java.util.List;
...
@@ -11,6 +8,6 @@ import java.util.List;
*
*
*/
*/
public
interface
GetCatalogueVariableApiListener
{
public
interface
GetCatalogueVariableApiListener
{
void
onDoneApiCall
(
List
<
CatalogueVariableSet
>
variableSetList
,
List
<
CatalogueVariable
>
variableList
);
void
onDoneApiCall
(
CatalogueVariableResponse
catalogueVariableResponse
);
void
onFailApiCall
();
void
onFailApiCall
();
}
}
app/src/main/java/com/vsoft/servicenow/api/managers/CatalogueVariableApiManager.java
View file @
00a21c21
This diff is collapsed.
Click to expand it.
app/src/main/java/com/vsoft/servicenow/db/models/CatalogueVariable.java
View file @
00a21c21
...
@@ -48,14 +48,14 @@ public class CatalogueVariable {
...
@@ -48,14 +48,14 @@ public class CatalogueVariable {
@SerializedName
(
"default_value"
)
@SerializedName
(
"default_value"
)
@Expose
@Expose
private
String
defaultValue
;
private
String
defaultValue
;
@SerializedName
(
"question_choice"
)
@Expose
private
List
<
VariableChoice
>
questionChoice
=
null
;
// @SerializedName("type")
// @SerializedName("type")
// @Expose
// @Expose
private
ViewType
type
;
private
ViewType
type
;
private
List
<
VariableChoice
>
mVariableChoiceList
;
/**
/**
*
*
* @return
* @return
...
@@ -185,20 +185,20 @@ public class CatalogueVariable {
...
@@ -185,20 +185,20 @@ public class CatalogueVariable {
}
}
public
List
<
VariableChoice
>
getVariableChoiceList
()
{
public
List
<
VariableChoice
>
getVariableChoiceList
()
{
return
mVariableChoiceList
;
return
questionChoice
;
}
}
public
void
setVariableChoiceList
(
List
<
VariableChoice
>
mVariableChoiceList
)
{
public
void
setVariableChoiceList
(
List
<
VariableChoice
>
mVariableChoiceList
)
{
this
.
mVariableChoiceList
=
mVariableChoiceList
;
this
.
questionChoice
=
mVariableChoiceList
;
}
}
public
String
[]
getDisplayChoiceText
(
Context
context
)
{
public
String
[]
getDisplayChoiceText
(
Context
context
)
{
String
[]
choiceText
;
String
[]
choiceText
;
if
(
defaultValue
!=
null
)
{
if
(
defaultValue
!=
null
)
{
choiceText
=
new
String
[
mVariableChoiceList
.
size
()
+
1
];
choiceText
=
new
String
[
questionChoice
.
size
()
+
1
];
choiceText
[
0
]
=
defaultValue
;
choiceText
[
0
]
=
defaultValue
;
for
(
int
i
=
0
;
i
<
mVariableChoiceList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
questionChoice
.
size
();
i
++)
{
VariableChoice
variableChoice
=
mVariableChoiceList
.
get
(
i
);
VariableChoice
variableChoice
=
questionChoice
.
get
(
i
);
/*(i+1) for add None text as a first Element*/
/*(i+1) for add None text as a first Element*/
if
(
variableChoice
.
getMisc
()
>
0
)
{
if
(
variableChoice
.
getMisc
()
>
0
)
{
choiceText
[
i
+
1
]
=
String
.
format
(
context
.
getString
(
R
.
string
.
variable_form_misc_info_string
),
choiceText
[
i
+
1
]
=
String
.
format
(
context
.
getString
(
R
.
string
.
variable_form_misc_info_string
),
...
@@ -209,10 +209,10 @@ public class CatalogueVariable {
...
@@ -209,10 +209,10 @@ public class CatalogueVariable {
}
}
}
}
}
else
if
(
isNoneRequired
)
{
}
else
if
(
isNoneRequired
)
{
choiceText
=
new
String
[
mVariableChoiceList
.
size
()
+
1
];
choiceText
=
new
String
[
questionChoice
.
size
()
+
1
];
choiceText
[
0
]
=
context
.
getString
(
R
.
string
.
none_string
);
choiceText
[
0
]
=
context
.
getString
(
R
.
string
.
none_string
);
for
(
int
i
=
0
;
i
<
mVariableChoiceList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
questionChoice
.
size
();
i
++)
{
VariableChoice
variableChoice
=
mVariableChoiceList
.
get
(
i
);
VariableChoice
variableChoice
=
questionChoice
.
get
(
i
);
/*(i+1) for add None text as a first Element*/
/*(i+1) for add None text as a first Element*/
if
(
variableChoice
.
getMisc
()
>
0
)
{
if
(
variableChoice
.
getMisc
()
>
0
)
{
choiceText
[
i
+
1
]
=
String
.
format
(
context
.
getString
(
R
.
string
.
variable_form_misc_info_string
),
choiceText
[
i
+
1
]
=
String
.
format
(
context
.
getString
(
R
.
string
.
variable_form_misc_info_string
),
...
@@ -223,9 +223,9 @@ public class CatalogueVariable {
...
@@ -223,9 +223,9 @@ public class CatalogueVariable {
}
}
}
}
}
else
{
}
else
{
choiceText
=
new
String
[
mVariableChoiceList
.
size
()];
choiceText
=
new
String
[
questionChoice
.
size
()];
for
(
int
i
=
0
;
i
<
mVariableChoiceList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
questionChoice
.
size
();
i
++)
{
VariableChoice
variableChoice
=
mVariableChoiceList
.
get
(
i
);
VariableChoice
variableChoice
=
questionChoice
.
get
(
i
);
if
(
variableChoice
.
getMisc
()
>
0
)
{
if
(
variableChoice
.
getMisc
()
>
0
)
{
choiceText
[
i
]
=
String
.
format
(
context
.
getString
(
R
.
string
.
variable_form_misc_info_string
),
choiceText
[
i
]
=
String
.
format
(
context
.
getString
(
R
.
string
.
variable_form_misc_info_string
),
variableChoice
.
getText
(),
variableChoice
.
getText
(),
...
@@ -239,8 +239,8 @@ public class CatalogueVariable {
...
@@ -239,8 +239,8 @@ public class CatalogueVariable {
}
}
public
String
getDisplayChoiceText
(
String
text
)
{
public
String
getDisplayChoiceText
(
String
text
)
{
for
(
int
i
=
0
;
i
<
mVariableChoiceList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
questionChoice
.
size
();
i
++)
{
VariableChoice
variableChoice
=
mVariableChoiceList
.
get
(
i
);
VariableChoice
variableChoice
=
questionChoice
.
get
(
i
);
if
(
variableChoice
.
getText
().
equals
(
text
))
{
if
(
variableChoice
.
getText
().
equals
(
text
))
{
return
variableChoice
.
getValue
();
return
variableChoice
.
getValue
();
}
}
...
@@ -280,7 +280,7 @@ public class CatalogueVariable {
...
@@ -280,7 +280,7 @@ public class CatalogueVariable {
", active="
+
active
+
", active="
+
active
+
", defaultValue='"
+
defaultValue
+
'\''
+
", defaultValue='"
+
defaultValue
+
'\''
+
", type="
+
type
+
", type="
+
type
+
", mVariableChoiceList="
+
mVariableChoiceList
+
", mVariableChoiceList="
+
questionChoice
+
'}'
;
'}'
;
}
}
}
}
app/src/main/java/com/vsoft/servicenow/db/models/CatalogueVariableResponse.java
0 → 100644
View file @
00a21c21
package
com
.
vsoft
.
servicenow
.
db
.
models
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.List
;
/**
* Created by kunj on 16/02/17.
*/
public
class
CatalogueVariableResponse
{
@SerializedName
(
"variables"
)
@Expose
private
List
<
CatalogueVariable
>
variables
=
null
;
@SerializedName
(
"ui_policy"
)
@Expose
private
List
<
UiPolicyItem
>
uiPolicy
=
null
;
@SerializedName
(
"variablesets"
)
@Expose
private
List
<
CatalogueVariableSet
>
variablesets
=
null
;
public
List
<
CatalogueVariable
>
getVariables
()
{
return
variables
;
}
public
void
setVariables
(
List
<
CatalogueVariable
>
variables
)
{
this
.
variables
=
variables
;
}
public
List
<
UiPolicyItem
>
getUiPolicy
()
{
return
uiPolicy
;
}
public
void
setUiPolicy
(
List
<
UiPolicyItem
>
uiPolicy
)
{
this
.
uiPolicy
=
uiPolicy
;
}
public
List
<
CatalogueVariableSet
>
getVariablesets
()
{
return
variablesets
;
}
public
void
setVariablesets
(
List
<
CatalogueVariableSet
>
variablesets
)
{
this
.
variablesets
=
variablesets
;
}
}
app/src/main/java/com/vsoft/servicenow/db/models/UiPolicyItem.java
View file @
00a21c21
...
@@ -12,12 +12,15 @@ import java.util.List;
...
@@ -12,12 +12,15 @@ import java.util.List;
public
class
UiPolicyItem
{
public
class
UiPolicyItem
{
private
List
<
UiPolicyAction
>
uiPolicyActions
;
private
List
<
PartialCondition
>
partialConditions
;
private
List
<
PartialCondition
>
partialConditions
;
@SerializedName
(
"condition"
)
@SerializedName
(
"condition"
)
@Expose
@Expose
private
String
condition
;
private
String
condition
;
@SerializedName
(
"sys_id"
)
@SerializedName
(
"sys_id"
)
private
String
sysId
;
@SerializedName
(
"ui_policy_actions"
)
@Expose
private
List
<
UiPolicyAction
>
uiPolicyActions
;
public
List
<
UiPolicyAction
>
getUiPolicyActions
()
{
public
List
<
UiPolicyAction
>
getUiPolicyActions
()
{
return
uiPolicyActions
;
return
uiPolicyActions
;
...
@@ -52,4 +55,22 @@ public class UiPolicyItem {
...
@@ -52,4 +55,22 @@ public class UiPolicyItem {
public
void
setCondition
(
String
condition
)
{
public
void
setCondition
(
String
condition
)
{
this
.
condition
=
condition
;
this
.
condition
=
condition
;
}
}
/**
*
* @return
* The sys_id
*/
public
String
getSysId
()
{
return
sysId
;
}
/**
*
* @param sysId
* The sys_id
*/
public
void
setSysId
(
String
sysId
)
{
this
.
sysId
=
sysId
;
}
}
}
app/src/main/java/com/vsoft/servicenow/ui/CatalogueVariableScreen.java
View file @
00a21c21
...
@@ -57,6 +57,7 @@ import com.vsoft.servicenow.api.listeners.post.PostVariableFormApiListener;
...
@@ -57,6 +57,7 @@ import com.vsoft.servicenow.api.listeners.post.PostVariableFormApiListener;
import
com.vsoft.servicenow.api.managers.CatalogueVariableApiManager
;
import
com.vsoft.servicenow.api.managers.CatalogueVariableApiManager
;
import
com.vsoft.servicenow.api.managers.VariableChoiceApiManager
;
import
com.vsoft.servicenow.api.managers.VariableChoiceApiManager
;
import
com.vsoft.servicenow.db.models.CatalogueVariable
;
import
com.vsoft.servicenow.db.models.CatalogueVariable
;
import
com.vsoft.servicenow.db.models.CatalogueVariableResponse
;
import
com.vsoft.servicenow.db.models.CatalogueVariableSet
;
import
com.vsoft.servicenow.db.models.CatalogueVariableSet
;
import
com.vsoft.servicenow.db.models.Reference
;
import
com.vsoft.servicenow.db.models.Reference
;
import
com.vsoft.servicenow.db.models.UiPolicyAction
;
import
com.vsoft.servicenow.db.models.UiPolicyAction
;
...
@@ -101,6 +102,8 @@ import butterknife.OnClick;
...
@@ -101,6 +102,8 @@ import butterknife.OnClick;
import
okhttp3.MediaType
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
import
okhttp3.RequestBody
;
import
static
com
.
google
.
android
.
gms
.
analytics
.
internal
.
zzy
.
i
;
/**
/**
* Created by Kunj on 11/8/16.
* Created by Kunj on 11/8/16.
*/
*/
...
@@ -184,25 +187,19 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -184,25 +187,19 @@ public class CatalogueVariableScreen extends AppCompatActivity {
protected
SyncStatus
doInBackground
(
final
String
...
params
)
{
protected
SyncStatus
doInBackground
(
final
String
...
params
)
{
CatalogueVariableApiManager
.
getCatalogueVariable
(
CatalogueVariableScreen
.
this
,
mCatalogueItemSysId
,
new
GetCatalogueVariableApiListener
()
{
CatalogueVariableApiManager
.
getCatalogueVariable
(
CatalogueVariableScreen
.
this
,
mCatalogueItemSysId
,
new
GetCatalogueVariableApiListener
()
{
@Override
@Override
public
void
onDoneApiCall
(
List
<
CatalogueVariableSet
>
variableSetList
,
List
<
CatalogueVariable
>
variableList
)
{
public
void
onDoneApiCall
(
CatalogueVariableResponse
catalogueVariableResponse
/*List<CatalogueVariableSet> variableSetList,
List<CatalogueVariable>
variableList*/
)
{
mSyncStatus
=
SyncStatus
.
SUCCESS
;
mSyncStatus
=
SyncStatus
.
SUCCESS
;
/*For variableset */
/*For variableset */
for
(
int
i
=
0
;
i
<
variableSetList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
catalogueVariableResponse
.
getVariablesets
().
size
();
i
++)
{
CatalogueVariableSet
catalogueVariableSet
=
variableSetList
.
get
(
i
);
CatalogueVariableSet
catalogueVariableSet
=
catalogueVariableResponse
.
getVariablesets
().
get
(
i
);
mSyncStatus
=
setVariableChoiceData
(
catalogueVariableSet
.
getVariables
());
mCatalogueVariableList
.
addAll
(
catalogueVariableSet
.
getVariables
());
if
(
mSyncStatus
==
SyncStatus
.
FAIL
)
break
;
}
}
if
(
mSyncStatus
!=
SyncStatus
.
FAIL
)
{
/*For variable list*/
/*For variable list*/
mSyncStatus
=
setVariableChoiceData
(
variableList
);
mCatalogueVariableList
.
addAll
(
catalogueVariableResponse
.
getVariables
());
if
(
mSyncStatus
!=
SyncStatus
.
FAIL
)
{
mUiPolicyItemList
=
catalogueVariableResponse
.
getUiPolicy
();
CatalogueVariableApiManager
.
getUiPolicy
(
CatalogueVariableScreen
.
this
,
mCatalogueItemSysId
,
new
GetUiPolicyApiListener
()
{
@Override
public
void
onDoneApiCall
(
List
<
UiPolicyItem
>
uiPolicyItemList
)
{
mSyncStatus
=
SyncStatus
.
SUCCESS
;
mUiPolicyItemList
=
uiPolicyItemList
;
for
(
int
i
=
0
;
i
<
mUiPolicyItemList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
mUiPolicyItemList
.
size
();
i
++)
{
UiPolicyItem
uiPolicyItem
=
mUiPolicyItemList
.
get
(
i
);
UiPolicyItem
uiPolicyItem
=
mUiPolicyItemList
.
get
(
i
);
String
condition
=
uiPolicyItem
.
getCondition
();
String
condition
=
uiPolicyItem
.
getCondition
();
...
@@ -241,15 +238,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -241,15 +238,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
mSyncStatus
=
SyncStatus
.
FAIL
;
mSyncStatus
=
SyncStatus
.
FAIL
;
}
}
});
});
}
}
}
@Override
public
void
onFailApiCall
()
{
mSyncStatus
=
SyncStatus
.
FAIL
;
}
});
return
mSyncStatus
;
return
mSyncStatus
;
}
}
...
@@ -270,41 +258,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -270,41 +258,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}
}
}
}
private
SyncStatus
setVariableChoiceData
(
List
<
CatalogueVariable
>
variableList
)
{
if
(!
variableList
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
variableList
.
size
();
i
++)
{
final
CatalogueVariable
catalogueVariable
=
variableList
.
get
(
i
);
if
(
catalogueVariable
.
getType
()
==
ViewType
.
MULTIPLE_CHOICE
||
catalogueVariable
.
getType
()
==
ViewType
.
SELECT_BOX
)
{
/*Fetch multi choice variable values*/
VariableChoiceApiManager
.
getVariableChoice
(
CatalogueVariableScreen
.
this
,
catalogueVariable
.
getSysId
(),
new
GetVariableChoiceApiListener
()
{
@Override
public
void
onDoneApiCall
(
List
<
VariableChoice
>
variableChoiceList
)
{
mSyncStatus
=
SyncStatus
.
SUCCESS
;
/*Sort List of CatalogueOrder*/
Collections
.
sort
(
variableChoiceList
,
new
Comparator
<
VariableChoice
>()
{
@Override
public
int
compare
(
VariableChoice
lhs
,
VariableChoice
rhs
)
{
return
(
lhs
.
getOrder
()
-
rhs
.
getOrder
());
}
});
catalogueVariable
.
setVariableChoiceList
(
variableChoiceList
);
}
@Override
public
void
onFailApiCall
()
{
mSyncStatus
=
SyncStatus
.
FAIL
;
}
});
if
(
mSyncStatus
==
SyncStatus
.
FAIL
)
break
;
}
}
mCatalogueVariableList
.
addAll
(
variableList
);
}
return
mSyncStatus
;
}
private
void
createView
()
{
private
void
createView
()
{
/*For variable list */
/*For variable list */
getCustomLayout
();
getCustomLayout
();
...
...
app/src/uofl/java/com/vsoft/servicenow/AppConfig.java
View file @
00a21c21
...
@@ -26,7 +26,7 @@ public class AppConfig {
...
@@ -26,7 +26,7 @@ public class AppConfig {
public
static
final
String
URL_GET_CATALOGUE_ITEM
=
"api/uno33/uofl_mobile/catalog_item"
;
public
static
final
String
URL_GET_CATALOGUE_ITEM
=
"api/uno33/uofl_mobile/catalog_item"
;
/*Variable form API */
/*Variable form API */
public
static
final
String
URL_GET_VARIABLE
=
"
/api/uno33/uofl_mobile/variables
"
;
public
static
final
String
URL_GET_VARIABLE
=
"
api/uno33/uofl_mobile/catalogue_variable_screen
"
;
public
static
final
String
URL_GET_UI_POLICY
=
"/api/uno33/uofl_mobile/uipolicy"
;
public
static
final
String
URL_GET_UI_POLICY
=
"/api/uno33/uofl_mobile/uipolicy"
;
public
static
final
String
URL_GET_VARIABLE_CHOICE
=
"/api/uno33/uofl_mobile/question_choice"
;
public
static
final
String
URL_GET_VARIABLE_CHOICE
=
"/api/uno33/uofl_mobile/question_choice"
;
public
static
final
String
URL_POST_CATALOGUE_ITEM
=
"api/uno33/uofl_mobile"
;
public
static
final
String
URL_POST_CATALOGUE_ITEM
=
"api/uno33/uofl_mobile"
;
...
...
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