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
f1fd8a15
Commit
f1fd8a15
authored
Jul 27, 2018
by
bsatyanarayana-nisum-com
Committed by
tdutta-nisum-com
Jul 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MT-97_8 : SNS :: Update_RoleTable_While_Account_CRUD_operations (#85)
parent
d07aff9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
79 deletions
+66
-79
AccountServiceImpl.java
...ain/java/com/nisum/mytime/service/AccountServiceImpl.java
+66
-79
No files found.
src/main/java/com/nisum/mytime/service/AccountServiceImpl.java
View file @
f1fd8a15
...
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
...
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Domains
;
import
com.nisum.mytime.model.EmployeeRoles
;
import
com.nisum.mytime.model.EmployeeRoles
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.utils.CommomUtil
;
import
com.nisum.mytime.utils.CommomUtil
;
...
@@ -79,86 +80,60 @@ public class AccountServiceImpl implements AccountService {
...
@@ -79,86 +80,60 @@ public class AccountServiceImpl implements AccountService {
}
else
{
}
else
{
response
=
"Error occured while account creating"
;
response
=
"Error occured while account creating"
;
}
}
}
else
if
(
action
!=
null
&&
action
.
equals
(
"U"
)){
//U means updating existing Account
}
else
if
(
action
!=
null
&&
action
.
equals
(
"U"
)){
List
<
String
>
employeeIds
=
null
;
List
<
String
>
dmsAddedByUser
=
null
;
List
<
String
>
dmsDeletedByUser
=
null
;
Map
<
String
,
Integer
>
dmsCount
=
new
HashMap
<
String
,
Integer
>();
boolean
dupAccChkFlag
=
duplicateAccountCheck
(
account
);
boolean
flag
=
false
;
if
(
dupAccChkFlag
)
{
boolean
nameFlag
=
false
;
boolean
accountExistFlag
=
false
;
List
<
Account
>
accounts
=
accountRepo
.
findAll
();
Account
accountBeforeUpdate
=
accountRepo
.
findByAccountId
(
account
.
getAccountId
());
nameFlag
=
accountBeforeUpdate
.
getAccountName
().
equalsIgnoreCase
(
account
.
getAccountName
());
if
(
accounts
!=
null
&&
!
accounts
.
isEmpty
()
&&
accounts
.
size
()>
0
){
for
(
Account
accObj
:
accounts
){
accountExistFlag
=
accObj
.
getAccountName
().
trim
().
equalsIgnoreCase
(
account
.
getAccountName
().
trim
());
if
(
accountExistFlag
){
break
;
}
}
}
if
(
nameFlag
&&
accountExistFlag
)
{
response
=
"Account already exist"
;
response
=
"Account already exist"
;
return
response
;
return
response
;
}
}
Account
accountBeforeUpdate
=
accountRepo
.
findByAccountId
(
account
.
getAccountId
());
List
<
String
>
updatedAccDms
=
account
.
getDeliveryManagers
();
List
<
String
>
beforeAccUpdateDms
=
accountBeforeUpdate
.
getDeliveryManagers
();
//if(accountBeforeUpdate.getAccountName().equalsIgnoreCase(account.getAccountName())) {
dmsAddedByUser
=
CommomUtil
.
getAddedManagersList
(
beforeAccUpdateDms
,
updatedAccDms
);
List
<
String
>
employeeIds
=
null
;
dmsDeletedByUser
=
CommomUtil
.
getDeletedManagersList
(
beforeAccUpdateDms
,
updatedAccDms
);
List
<
Account
>
accountList
=
null
;
List
<
String
>
dmsAddedByUser
=
null
;
List
<
String
>
dmsDeletedByUser
=
null
;
Map
<
String
,
Integer
>
dmsCount
=
new
HashMap
<
String
,
Integer
>();
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
;
}
List
<
Account
>
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
;
}
return
response
;
return
response
;
}
}
...
@@ -261,12 +236,24 @@ public class AccountServiceImpl implements AccountService {
...
@@ -261,12 +236,24 @@ public class AccountServiceImpl implements AccountService {
return
(
MyTimeUtils
.
ACC
+
MyTimeUtils
.
ZERO_
)
+
(
getAccounts
().
size
()
+
MyTimeUtils
.
ONE
);
return
(
MyTimeUtils
.
ACC
+
MyTimeUtils
.
ZERO_
)
+
(
getAccounts
().
size
()
+
MyTimeUtils
.
ONE
);
}
}
private
boolean
duplicateCheck
(
String
accountName
,
String
accountId
){
private
boolean
duplicateAccountCheck
(
Account
UpdatedAccount
)
{
boolean
check
=
false
;
boolean
flag
=
false
;
List
<
Account
>
accountList
=
accountRepo
.
findByaccountNameAndAccountId
(
accountName
,
accountId
);
if
(
accountList
.
size
()>
0
)
Account
accbeforeUpdate
=
accountRepo
.
findByAccountId
(
UpdatedAccount
.
getAccountId
());
check
=
true
;
return
check
;
boolean
nameFlag
=
accbeforeUpdate
.
getAccountName
().
equals
(
UpdatedAccount
.
getAccountName
());
boolean
addrFlag
=
accbeforeUpdate
.
getClientAddress
().
equals
(
UpdatedAccount
.
getClientAddress
());
boolean
industryFlag
=
accbeforeUpdate
.
getIndustryType
().
equals
(
UpdatedAccount
.
getIndustryType
());
boolean
dmsFlag
=
accbeforeUpdate
.
getDeliveryManagers
().
toString
().
contentEquals
(
UpdatedAccount
.
getDeliveryManagers
().
toString
());
boolean
ignoreFlag
=
accbeforeUpdate
.
getAccountName
().
equalsIgnoreCase
(
UpdatedAccount
.
getAccountName
());
if
(
nameFlag
||
!
addrFlag
||
!
industryFlag
||
!
dmsFlag
)
{
flag
=
false
;
}
else
if
(
ignoreFlag
){
flag
=
true
;
}
return
flag
;
}
}
}
}
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