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
2f30a641
Commit
2f30a641
authored
May 21, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the duplicated method in account service
parent
d11c5abe
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
115 deletions
+90
-115
AccountController.java
...n/java/com/nisum/myteam/controller/AccountController.java
+2
-2
IAccountService.java
src/main/java/com/nisum/myteam/service/IAccountService.java
+1
-5
AccountService.java
...in/java/com/nisum/myteam/service/impl/AccountService.java
+11
-17
DomainService.java
...ain/java/com/nisum/myteam/service/impl/DomainService.java
+9
-9
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+1
-1
ProjectService.java
...in/java/com/nisum/myteam/service/impl/ProjectService.java
+66
-81
No files found.
src/main/java/com/nisum/myteam/controller/AccountController.java
View file @
2f30a641
...
...
@@ -96,7 +96,7 @@ public class AccountController {
@RequestMapping
(
value
=
"/accounts/names"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getAccountNames
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Account
>
acountsList
=
accountService
.
getAccounts
();
List
<
Account
>
acountsList
=
accountService
.
getA
llA
ccounts
();
List
<
String
>
accountNamesList
=
new
ArrayList
<>();
for
(
Account
account
:
acountsList
)
{
...
...
@@ -116,7 +116,7 @@ public class AccountController {
//get the accounts based on status(Active or inactive)
@RequestMapping
(
value
=
"/accounts/status"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Account
>>
getAccounts
(
@RequestParam
(
"status"
)
String
status
)
throws
MyTeamException
{
List
<
Account
>
accountsList
=
accountService
.
getA
ccountsAll
().
stream
()
List
<
Account
>
accountsList
=
accountService
.
getA
llAccounts
().
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
accountsList
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/nisum/myteam/service/IAccountService.java
View file @
2f30a641
...
...
@@ -23,14 +23,10 @@ public interface IAccountService {
public
Account
getAccountById
(
String
accountId
);
List
<
Account
>
getAccounts
()
throws
MyTeamException
;
List
<
Account
>
getA
llA
ccounts
()
throws
MyTeamException
;
List
<
Map
<
Object
,
Object
>>
getAccountsList
()
throws
MyTeamException
;
Account
deleteAccount
(
String
accountId
)
throws
MyTeamException
;
public
List
<
Account
>
getAccountsAll
()
throws
MyTeamException
;
}
src/main/java/com/nisum/myteam/service/impl/AccountService.java
View file @
2f30a641
...
...
@@ -31,10 +31,10 @@ public class AccountService implements IAccountService {
private
MongoTemplate
mongoTemplate
;
@Autowired
private
IRoleService
role
Info
Service
;
private
IRoleService
roleService
;
@Autowired
private
IEmployeeRoleService
roleMapping
Service
;
private
IEmployeeRoleService
empRole
Service
;
@Override
...
...
@@ -51,9 +51,9 @@ public class AccountService implements IAccountService {
if
(
accountPersisted
!=
null
)
{
List
<
String
>
accountDmsList
=
accountReq
.
getDeliveryManagers
();
if
(
accountDmsList
!=
null
&&
!
accountDmsList
.
isEmpty
()
&&
accountDmsList
.
size
()
>
0
)
{
String
roleId
=
role
Info
Service
.
getRole
(
MyTeamUtils
.
ACCOUNT
);
String
roleId
=
roleService
.
getRole
(
MyTeamUtils
.
ACCOUNT
);
log
.
info
(
"Going to add DM role id for account delivery managers::::"
+
accountDmsList
);
roleMapping
Service
.
saveUniqueEmployeeAndRole
(
accountDmsList
,
roleId
);
empRole
Service
.
saveUniqueEmployeeAndRole
(
accountDmsList
,
roleId
);
log
.
info
(
"Added roleids for delivery managers in rolemapping collection"
);
}
...
...
@@ -71,7 +71,7 @@ public class AccountService implements IAccountService {
accountUpdating
.
setAccountName
(
accountUpdating
.
getAccountName
().
trim
());
log
.
info
(
"Updating the roleids of DeliveryManagers in RoleMapping Collection"
);
final
String
roleId
=
role
Info
Service
.
getRole
(
MyTeamUtils
.
ACCOUNT
);
final
String
roleId
=
roleService
.
getRole
(
MyTeamUtils
.
ACCOUNT
);
updateRoleIdsForDeliveryManager
(
accountUpdating
,
roleId
);
log
.
info
(
"Deleting the roleids of DeliveryManagers in RoleMapping Collection"
);
...
...
@@ -125,7 +125,7 @@ public class AccountService implements IAccountService {
@Override
public
List
<
Account
>
getAccounts
()
throws
MyTeamException
{
public
List
<
Account
>
getA
llA
ccounts
()
throws
MyTeamException
{
return
accountRepo
.
findAll
();
}
...
...
@@ -166,7 +166,7 @@ public class AccountService implements IAccountService {
// generating the account id.
// accountId format is "Acc001"
private
String
generateAccountId
()
throws
MyTeamException
{
return
(
MyTeamUtils
.
ACC
+
MyTeamUtils
.
ZERO_
)
+
(
getAccounts
().
size
()
+
MyTeamUtils
.
ONE
);
return
(
MyTeamUtils
.
ACC
+
MyTeamUtils
.
ZERO_
)
+
(
getA
llA
ccounts
().
size
()
+
MyTeamUtils
.
ONE
);
}
private
void
updateRoleIdsForDeliveryManager
(
Account
accountReq
,
String
roleId
)
throws
MyTeamException
{
...
...
@@ -175,7 +175,7 @@ public class AccountService implements IAccountService {
List
<
String
>
persistedDmsList
=
accountRepo
.
findByAccountId
(
accountReq
.
getAccountId
()).
getDeliveryManagers
();
List
<
String
>
dmsAddedByUser
=
CommomUtil
.
getAddedManagersList
(
persistedDmsList
,
updatingDmsList
);
roleMapping
Service
.
saveUniqueEmployeeAndRole
(
dmsAddedByUser
,
roleId
);
empRole
Service
.
saveUniqueEmployeeAndRole
(
dmsAddedByUser
,
roleId
);
}
private
void
deleteRoleIdsForDeliveryManager
(
Account
accountUpdating
,
String
roleId
)
throws
MyTeamException
{
...
...
@@ -206,7 +206,7 @@ public class AccountService implements IAccountService {
for
(
String
empId
:
dmsListDeletedByUser
)
{
if
(
dmsCountMap
.
get
(
empId
)
==
1
)
{
// Service call for RoleMapping
roleMapping
Service
.
deleteRole
(
empId
,
roleId
);
empRole
Service
.
deleteRole
(
empId
,
roleId
);
}
}
}
...
...
@@ -244,7 +244,7 @@ public class AccountService implements IAccountService {
List
<
String
>
accountDms
=
null
;
List
<
String
>
tempDmsList
=
new
ArrayList
<
String
>();
String
roleId
=
role
Info
Service
.
getRole
(
MyTeamUtils
.
ACCOUNT
);
String
roleId
=
roleService
.
getRole
(
MyTeamUtils
.
ACCOUNT
);
allAccountsList
=
accountRepo
.
findAll
();
List
<
String
>
accountDmsList
=
accountRepo
.
findByAccountId
(
accountId
).
getDeliveryManagers
();
...
...
@@ -262,18 +262,12 @@ public class AccountService implements IAccountService {
occurrences
=
Collections
.
frequency
(
tempDmsList
,
dmId
);
if
(
occurrences
==
1
)
{
// Service call for RoleMapping
roleMapping
Service
.
deleteRole
(
dmId
,
roleId
);
empRole
Service
.
deleteRole
(
dmId
,
roleId
);
}
}
}
@Override
public
List
<
Account
>
getAccountsAll
()
throws
MyTeamException
{
return
accountRepo
.
findAll
();
}
}
src/main/java/com/nisum/myteam/service/impl/DomainService.java
View file @
2f30a641
...
...
@@ -38,10 +38,10 @@ public class DomainService implements IDomainService {
private
MongoTemplate
mongoTemplate
;
@Autowired
private
IRoleService
role
Info
Service
;
private
IRoleService
roleService
;
@Autowired
private
IEmployeeRoleService
roleMapping
Service
;
private
IEmployeeRoleService
empRole
Service
;
@Autowired
private
IAccountService
accountService
;
...
...
@@ -83,7 +83,7 @@ public class DomainService implements IDomainService {
public
Domain
update
(
Domain
domainReq
)
throws
MyTeamException
{
log
.
info
(
"updating the roles for DeliveryManager in EmployeeRoleMapping collection"
);
final
String
roleId
=
role
Info
Service
.
getRole
(
MyTeamUtils
.
DOMAIN
);
final
String
roleId
=
roleService
.
getRole
(
MyTeamUtils
.
DOMAIN
);
updateRoleIdsForDMs
(
domainReq
,
roleId
);
log
.
info
(
"deleting roleids for DeliveryManagers in EmployeeRoleMapping collection"
);
deleteRoleIdsForDMs
(
domainReq
,
roleId
);
...
...
@@ -104,7 +104,7 @@ public class DomainService implements IDomainService {
List
dmsListReq
=
domainReq
.
getDeliveryManagers
();
List
<
String
>
managersAddedByUser
=
managersAddedByUser
=
CommomUtil
.
getAddedManagersListForDM
(
dmssListDAO
,
dmsListReq
);
roleMapping
Service
.
saveUniqueEmployeeAndRole
(
managersAddedByUser
,
roleId
);
empRole
Service
.
saveUniqueEmployeeAndRole
(
managersAddedByUser
,
roleId
);
}
...
...
@@ -131,7 +131,7 @@ public class DomainService implements IDomainService {
for
(
String
managerId
:
managersDeletedByUser
)
{
if
(
managersDomainCount
.
get
(
managerId
)
==
1
)
{
// Call service to delete manager
roleMapping
Service
.
deleteRole
(
managerId
,
roleId
);
empRole
Service
.
deleteRole
(
managerId
,
roleId
);
}
}
}
...
...
@@ -178,7 +178,7 @@ public class DomainService implements IDomainService {
@Override
public
WriteResult
delete
(
String
domainId
)
throws
MyTeamException
{
List
<
String
>
domEmpIds
=
new
ArrayList
<
String
>();
String
roleId
=
role
Info
Service
.
getRole
(
MyTeamUtils
.
DOMAIN
);
String
roleId
=
roleService
.
getRole
(
MyTeamUtils
.
DOMAIN
);
List
<
Domain
>
domainsPersistedList
=
domainRepo
.
findAll
();
Query
selectedDomainQuery
=
new
Query
(
Criteria
.
where
(
MyTeamUtils
.
DOMAIN_ID
).
in
(
domainId
).
and
(
MyTeamUtils
.
STATUS
).
in
(
MyTeamUtils
.
ACTIVE
));
...
...
@@ -194,7 +194,7 @@ public class DomainService implements IDomainService {
int
occurrences
=
Collections
.
frequency
(
domEmpIds
,
empId
.
toString
());
if
(
occurrences
==
1
)
{
// Service call for RoleMapping
roleMapping
Service
.
deleteRole
(
empId
.
toString
(),
roleId
);
empRole
Service
.
deleteRole
(
empId
.
toString
(),
roleId
);
}
}
Update
update
=
new
Update
();
...
...
@@ -203,9 +203,9 @@ public class DomainService implements IDomainService {
}
private
void
saveEmployeeRole
(
Domain
domainReq
)
throws
MyTeamException
{
String
roleId
=
role
Info
Service
.
getRole
(
MyTeamUtils
.
DOMAIN
);
String
roleId
=
roleService
.
getRole
(
MyTeamUtils
.
DOMAIN
);
List
dmsList
=
domainReq
.
getDeliveryManagers
();
roleMapping
Service
.
saveUniqueEmployeeAndRole
(
dmsList
,
roleId
);
empRole
Service
.
saveUniqueEmployeeAndRole
(
dmsList
,
roleId
);
}
private
List
<
HashMap
<
String
,
String
>>
prepareEmployeeList
(
Domain
domainPersisted
)
{
...
...
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
2f30a641
...
...
@@ -223,7 +223,7 @@ public class EmployeeService implements IEmployeeService {
@Override
public
List
<
Account
>
getAccounts
()
throws
MyTeamException
{
return
accountService
.
getAccounts
();
return
accountService
.
getA
llA
ccounts
();
}
...
...
src/main/java/com/nisum/myteam/service/impl/ProjectService.java
View file @
2f30a641
...
...
@@ -3,12 +3,8 @@ package com.nisum.myteam.service.impl;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.*
;
import
com.nisum.myteam.repository.ProjectRepo
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IDomainService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.service.PdfReportGenerator
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -40,57 +36,15 @@ public class ProjectService implements IProjectService {
private
IDomainService
domainService
;
@Autowired
private
ResourceService
resourceService
;
private
I
ResourceService
resourceService
;
@Autowired
private
IEmployeeService
employeeService
;
@Autowired
private
IAccountService
accountService
;
@Override
public
List
<
Project
>
getProjectsUnderDomain
(
String
domainId
)
{
return
projectRepo
.
findByDomainId
(
domainId
);
}
public
boolean
isProjectExistsByName
(
String
projectName
)
{
boolean
isProjectExists
=
false
;
if
(
projectName
!=
null
&&
!
""
.
equalsIgnoreCase
(
projectName
))
{
Project
project
=
projectRepo
.
findByProjectName
(
projectName
);
isProjectExists
=
(
project
==
null
)
?
false
:
true
;
}
return
isProjectExists
;
}
public
boolean
isProjectExistsById
(
String
projectId
)
{
boolean
isProjectExists
=
false
;
if
(
projectId
!=
null
&&
!
""
.
equalsIgnoreCase
(
projectId
))
{
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
isProjectExists
=
(
project
==
null
)
?
false
:
true
;
}
return
isProjectExists
;
}
public
long
getProjectsCount
()
{
return
projectRepo
.
count
();
}
public
Account
getProjectAccount
(
String
accountId
)
{
Account
account
=
null
;
if
(
accountId
!=
null
&&
!
""
.
equalsIgnoreCase
(
accountId
))
{
return
accountService
.
getAccountById
(
accountId
);
}
return
account
;
}
public
Account
updateProjSeqinAccount
(
Account
account
)
throws
MyTeamException
{
return
accountService
.
updateAccountSequence
(
account
);
}
@Override
public
Project
createProject
(
Project
project
,
String
loginEmpId
)
throws
MyTeamException
{
if
(
project
.
getDomainId
()
==
null
)
{
...
...
@@ -104,7 +58,6 @@ public class ProjectService implements IProjectService {
return
projectRepo
.
save
(
project
);
}
@Override
public
Project
updateProject
(
Project
project
,
String
loginEmpId
)
throws
MyTeamException
{
Project
existingProject
=
projectRepo
.
findByProjectId
(
project
.
getProjectId
());
...
...
@@ -122,8 +75,9 @@ public class ProjectService implements IProjectService {
return
existingProject
;
}
public
Account
updateProjSeqinAccount
(
Account
account
)
throws
MyTeamException
{
return
accountService
.
updateAccountSequence
(
account
);
}
@Override
public
void
deleteProject
(
String
projectId
)
{
...
...
@@ -133,6 +87,67 @@ public class ProjectService implements IProjectService {
resourceService
.
deleteResourcesUnderProject
(
projectId
);
}
public
boolean
isProjectExistsByName
(
String
projectName
)
{
boolean
isProjectExists
=
false
;
if
(
projectName
!=
null
&&
!
""
.
equalsIgnoreCase
(
projectName
))
{
Project
project
=
projectRepo
.
findByProjectName
(
projectName
);
isProjectExists
=
(
project
==
null
)
?
false
:
true
;
}
return
isProjectExists
;
}
public
boolean
isProjectExistsById
(
String
projectId
)
{
boolean
isProjectExists
=
false
;
if
(
projectId
!=
null
&&
!
""
.
equalsIgnoreCase
(
projectId
))
{
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
isProjectExists
=
(
project
==
null
)
?
false
:
true
;
}
return
isProjectExists
;
}
@Override
public
List
<
Project
>
getAllProjects
()
{
return
projectRepo
.
findAll
();
}
public
long
getProjectsCount
()
{
return
projectRepo
.
count
();
}
public
Project
getProjectByProjectId
(
String
projectId
)
{
Project
project
=
null
;
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
project
=
projectRepo
.
findByProjectId
(
projectId
);
}
return
project
;
}
public
List
<
Project
>
getActiveProjects
()
throws
MyTeamException
{
List
<
Project
>
projects
=
projectRepo
.
findAll
();
return
projects
.
stream
().
filter
(
project
->
project
.
getStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
ACTIVE
)).
collect
(
Collectors
.
toList
());
}
public
List
<
Project
>
getProjectsForDeliveryLead
(
String
deliveryLeadId
)
{
List
<
Project
>
projectsList
=
projectRepo
.
findByDeliveryLeadIds
(
deliveryLeadId
);
return
projectsList
;
}
@Override
public
List
<
Project
>
getProjectsUnderDomain
(
String
domainId
)
{
return
projectRepo
.
findByDomainId
(
domainId
);
}
public
Account
getProjectAccount
(
String
accountId
)
{
Account
account
=
null
;
if
(
accountId
!=
null
&&
!
""
.
equalsIgnoreCase
(
accountId
))
{
return
accountService
.
getAccountById
(
accountId
);
}
return
account
;
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getProjects
()
throws
MyTeamException
{
...
...
@@ -233,12 +248,6 @@ public class ProjectService implements IProjectService {
return
projectList
;
}
@Override
public
List
<
Project
>
getAllProjects
()
{
return
projectRepo
.
findAll
();
}
@Override
public
List
<
Project
>
getOnlyActiveProjects
()
{
return
getAllProjects
().
stream
()
...
...
@@ -246,7 +255,6 @@ public class ProjectService implements IProjectService {
.
collect
(
Collectors
.
toList
());
}
private
String
validateAgainstDOJ
(
Resource
resource
)
{
String
response
=
null
;
Date
empDoj
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getDateOfJoining
();
...
...
@@ -375,29 +383,6 @@ public class ProjectService implements IProjectService {
}
public
List
<
Project
>
getActiveProjects
()
throws
MyTeamException
{
List
<
Project
>
projects
=
projectRepo
.
findAll
();
return
projects
.
stream
().
filter
(
project
->
project
.
getStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
ACTIVE
)).
collect
(
Collectors
.
toList
());
}
public
Project
getProjectByProjectId
(
String
projectId
)
{
Project
project
=
null
;
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
project
=
projectRepo
.
findByProjectId
(
projectId
);
}
return
project
;
}
public
List
<
Project
>
getProjectsForDeliveryLead
(
String
deliveryLeadId
)
{
List
<
Project
>
projectsList
=
projectRepo
.
findByDeliveryLeadIds
(
deliveryLeadId
);
return
projectsList
;
}
}
...
...
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