Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
5718d05f
Commit
5718d05f
authored
Jul 27, 2018
by
bsatyanarayana-nisum-com
Committed by
rbonthala-nisum-com
Jul 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MT-97_4 : SNS :: Update_RoleTable_While_Account_CRUD_operations (#80)
parent
ca4be969
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
158 additions
and
47 deletions
+158
-47
AccountServiceImpl.java
...ain/java/com/nisum/mytime/service/AccountServiceImpl.java
+158
-47
No files found.
src/main/java/com/nisum/mytime/service/AccountServiceImpl.java
View file @
5718d05f
...
...
@@ -44,9 +44,10 @@ public class AccountServiceImpl implements AccountService {
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
ACCOUNT
);
List
<
Account
>
accounts
=
validateAccounts
(
account
.
getAccountName
());
if
(
action
!=
null
&&
action
.
equals
(
MyTimeUtils
.
STRING_N
))
{
//N means adding New Account
//List<Account> accounts = accountRepo.findAll();
/* if( action != null && action.equals(MyTimeUtils.STRING_N)) {//N means adding New Account
if( !accounts.isEmpty() && accounts.size() > 0){
response ="Account already exist";
...
...
@@ -69,8 +70,16 @@ public class AccountServiceImpl implements AccountService {
}else if(action != null && action.equals("U")){//U means updating existing Account
if( !accounts.isEmpty() && accounts.size() > 0){
response
=
"Account already exist with updated name"
;
}
else
{
for(Account accObj : accounts) {
if(!accObj.getAccountId().equals(account.getAccountId()) && accObj.getAccountName().equalsIgnoreCase(account.getAccountName())){
response ="Account already exist with updated account name";
return response;
}
}
//response ="Account already exist";
}
List<String> employeeIds = null;
List<Account> accountList = null;
List<String> dmsAddedByUser = null;
...
...
@@ -114,7 +123,109 @@ public class AccountServiceImpl implements AccountService {
accountResult = accountRepo.save(account);
roleMappingService.saveUniqueEmployeeAndRole(dmsAddedByUser, roleId);
response="Updated succesfully";
}*/
if
(
action
!=
null
&&
action
.
equals
(
MyTimeUtils
.
STRING_N
))
{
//N means adding New Account
boolean
flag
=
false
;
List
<
Account
>
accounts
=
accountRepo
.
findAll
();
if
(
accounts
!=
null
&&
!
accounts
.
isEmpty
()
&&
accounts
.
size
()>
0
){
for
(
Account
accObj
:
accounts
){
flag
=
accObj
.
getAccountName
().
trim
().
equalsIgnoreCase
(
account
.
getAccountName
().
trim
());
if
(
flag
){
break
;
}
}
}
if
(
flag
){
response
=
"Account already exist"
;
return
response
;
}
List
<
String
>
accDms
=
account
.
getDeliveryManagers
();
account
.
setAccountId
(
generateAccountId
());
account
.
setAccountName
(
account
.
getAccountName
().
trim
());
account
.
setStatus
(
MyTimeUtils
.
STRING_Y
);
accountResult
=
accountRepo
.
save
(
account
);
if
(
accDms
!=
null
&&
!
accDms
.
isEmpty
()
&&
accDms
.
size
()
>
0
)
{
roleMappingService
.
saveUniqueEmployeeAndRole
(
accDms
,
roleId
);
}
if
(
accountResult
.
getId
()
!=
null
)
{
response
=
"Saved succesfully"
;
}
else
{
response
=
"Error occured while account creating"
;
}
}
else
if
(
action
!=
null
&&
action
.
equals
(
"U"
)){
//U means updating existing Account
boolean
flag
=
false
;
List
<
Account
>
accounts
=
accountRepo
.
findAll
();
if
(
accounts
!=
null
&&
!
accounts
.
isEmpty
()
&&
accounts
.
size
()>
0
){
for
(
Account
accObj
:
accounts
){
flag
=
accObj
.
getAccountName
().
trim
().
equalsIgnoreCase
(
account
.
getAccountName
().
trim
());
if
(
flag
){
break
;
}
}
}
if
(
flag
)
{
response
=
"Account Already exist with update account name"
;
return
response
;
}
List
<
String
>
employeeIds
=
null
;
List
<
Account
>
accountList
=
null
;
List
<
String
>
dmsAddedByUser
=
null
;
List
<
String
>
dmsDeletedByUser
=
null
;
Map
<
String
,
Integer
>
dmsCount
=
new
HashMap
<
String
,
Integer
>();
Account
accountBeforeUpdate
=
accountRepo
.
findByAccountId
(
account
.
getAccountId
());
List
<
String
>
updatedAccDms
=
account
.
getDeliveryManagers
();
List
<
String
>
beforeAccUpdateDms
=
accountBeforeUpdate
.
getDeliveryManagers
();
dmsAddedByUser
=
CommomUtil
.
getAddedManagersList
(
beforeAccUpdateDms
,
updatedAccDms
);
dmsDeletedByUser
=
CommomUtil
.
getDeletedManagersList
(
beforeAccUpdateDms
,
updatedAccDms
);
accountList
=
accountRepo
.
findAll
();
if
(
accountList
!=
null
&&
!
accountList
.
isEmpty
()
&&
accountList
.
size
()
>
0
)
{
for
(
Account
acc
:
accountList
)
{
employeeIds
=
acc
.
getDeliveryManagers
();
if
(
employeeIds
!=
null
&&
!
employeeIds
.
isEmpty
()
&&
employeeIds
.
size
()
>
0
)
{
for
(
String
eId:
employeeIds
)
{
if
(
dmsCount
.
get
(
eId
)
!=
null
)
dmsCount
.
put
(
eId
,
dmsCount
.
get
(
eId
)+
1
);
else
dmsCount
.
put
(
eId
,
1
);
employeeIds
=
null
;
}
}
}
}
for
(
String
empId
:
dmsDeletedByUser
)
{
if
(
dmsCount
.
get
(
empId
)==
1
)
{
//Service call for RoleMapping
roleMappingService
.
deleteRole
(
empId
,
roleId
);
}
}
account
.
setStatus
(
accountBeforeUpdate
.
getStatus
());
account
.
setAccountName
(
account
.
getAccountName
().
trim
());
accountResult
=
accountRepo
.
save
(
account
);
roleMappingService
.
saveUniqueEmployeeAndRole
(
dmsAddedByUser
,
roleId
);
response
=
"Updated succesfully"
;
}
return
response
;
}
...
...
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