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
Show 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;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Domains
;
import
com.nisum.mytime.model.EmployeeRoles
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.utils.CommomUtil
;
...
...
@@ -79,50 +80,30 @@ public class AccountServiceImpl implements AccountService {
}
else
{
response
=
"Error occured while account creating"
;
}
}
else
if
(
action
!=
null
&&
action
.
equals
(
"U"
)){
//U means updating existing Account
boolean
flag
=
false
;
boolean
nameFlag
=
false
;
boolean
accountExistFlag
=
false
;
List
<
Account
>
accounts
=
accountRepo
.
findAll
();
Account
accountBeforeUpdate
=
accountRepo
.
findByAccountId
(
account
.
getAccountId
());
}
else
if
(
action
!=
null
&&
action
.
equals
(
"U"
)){
List
<
String
>
employeeIds
=
null
;
List
<
String
>
dmsAddedByUser
=
null
;
List
<
String
>
dmsDeletedByUser
=
null
;
nameFlag
=
accountBeforeUpdate
.
getAccountName
().
equalsIgnoreCase
(
account
.
getAccountName
()
);
Map
<
String
,
Integer
>
dmsCount
=
new
HashMap
<
String
,
Integer
>(
);
if
(
accounts
!=
null
&&
!
accounts
.
isEmpty
()
&&
accounts
.
size
()>
0
){
for
(
Account
accObj
:
accounts
){
accountExistFlag
=
accObj
.
getAccountName
().
trim
().
equalsIgnoreCase
(
account
.
getAccountName
().
trim
());
if
(
accountExistFlag
){
break
;
}
}
}
boolean
dupAccChkFlag
=
duplicateAccountCheck
(
account
);
if
(
nameFlag
&&
accountExist
Flag
)
{
if
(
dupAccChk
Flag
)
{
response
=
"Account already exist"
;
return
response
;
}
//if(accountBeforeUpdate.getAccountName().equalsIgnoreCase(account.getAccountName())) {
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
();
List
<
Account
>
accountList
=
accountRepo
.
findAll
();
if
(
accountList
!=
null
&&
!
accountList
.
isEmpty
()
&&
accountList
.
size
()
>
0
)
{
for
(
Account
acc
:
accountList
)
{
...
...
@@ -153,12 +134,6 @@ public class AccountServiceImpl implements AccountService {
response
=
"Updated succesfully"
;
return
response
;
}
//}
return
response
;
}
...
...
@@ -261,12 +236,24 @@ public class AccountServiceImpl implements AccountService {
return
(
MyTimeUtils
.
ACC
+
MyTimeUtils
.
ZERO_
)
+
(
getAccounts
().
size
()
+
MyTimeUtils
.
ONE
);
}
private
boolean
duplicateCheck
(
String
accountName
,
String
accountId
){
boolean
check
=
false
;
List
<
Account
>
accountList
=
accountRepo
.
findByaccountNameAndAccountId
(
accountName
,
accountId
);
if
(
accountList
.
size
()>
0
)
check
=
true
;
return
check
;
private
boolean
duplicateAccountCheck
(
Account
UpdatedAccount
)
{
boolean
flag
=
false
;
Account
accbeforeUpdate
=
accountRepo
.
findByAccountId
(
UpdatedAccount
.
getAccountId
());
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