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
2a843966
Commit
2a843966
authored
May 07, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provided new resource control for new developement for resource management
parent
80aed22b
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
792 additions
and
300 deletions
+792
-300
MyTeamApplication.java
src/main/java/com/nisum/myteam/MyTeamApplication.java
+3
-3
DomainController.java
...in/java/com/nisum/myteam/controller/DomainController.java
+63
-75
EmployeeController.java
.../java/com/nisum/myteam/controller/EmployeeController.java
+1
-1
ProjectController.java
...n/java/com/nisum/myteam/controller/ProjectController.java
+20
-74
ResourceAllocationController.java
...nisum/myteam/controller/ResourceAllocationController.java
+263
-0
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+1
-1
ResourceAllocation.java
...n/java/com/nisum/myteam/model/dao/ResourceAllocation.java
+54
-0
ResourceAllocationRepo.java
...a/com/nisum/myteam/repository/ResourceAllocationRepo.java
+28
-0
IEmployeeVisaService.java
...n/java/com/nisum/myteam/service/IEmployeeVisaService.java
+6
-0
IProjectService.java
src/main/java/com/nisum/myteam/service/IProjectService.java
+5
-1
IResourceAllocationService.java
.../com/nisum/myteam/service/IResourceAllocationService.java
+41
-0
IResourceService.java
src/main/java/com/nisum/myteam/service/IResourceService.java
+25
-22
DomainService.java
...ain/java/com/nisum/myteam/service/impl/DomainService.java
+17
-15
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+14
-6
EmployeeVisaService.java
...va/com/nisum/myteam/service/impl/EmployeeVisaService.java
+14
-0
ProjectService.java
...in/java/com/nisum/myteam/service/impl/ProjectService.java
+33
-75
ResourceAllocationService.java
.../nisum/myteam/service/impl/ResourceAllocationService.java
+78
-0
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+63
-6
DomainStatus.java
src/main/java/com/nisum/myteam/statuscodes/DomainStatus.java
+5
-2
ProjectStatus.java
...main/java/com/nisum/myteam/statuscodes/ProjectStatus.java
+25
-1
MyTeamUtils.java
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
+8
-0
ApplicationRole.java
...ava/com/nisum/myteam/utils/constants/ApplicationRole.java
+25
-0
RoleEnum.java
src/main/java/com/nisum/myteam/utils/constants/RoleEnum.java
+0
-18
No files found.
src/main/java/com/nisum/myteam/MyT
ime
Application.java
→
src/main/java/com/nisum/myteam/MyT
eam
Application.java
View file @
2a843966
...
@@ -16,15 +16,15 @@ import org.springframework.web.filter.CorsFilter;
...
@@ -16,15 +16,15 @@ import org.springframework.web.filter.CorsFilter;
@SpringBootApplication
@SpringBootApplication
@EnableAutoConfiguration
@EnableAutoConfiguration
@EnableMongoRepositories
(
basePackages
=
{
"com.nisum.myteam.repository"
})
@EnableMongoRepositories
(
basePackages
=
{
"com.nisum.myteam.repository"
})
public
class
MyT
ime
Application
extends
SpringBootServletInitializer
{
public
class
MyT
eam
Application
extends
SpringBootServletInitializer
{
@Override
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
return
application
.
sources
(
MyT
ime
Application
.
class
);
return
application
.
sources
(
MyT
eam
Application
.
class
);
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
MyT
ime
Application
.
class
,
args
);
SpringApplication
.
run
(
MyT
eam
Application
.
class
,
args
);
}
}
@Bean
@Bean
...
...
src/main/java/com/nisum/myteam/controller/DomainController.java
View file @
2a843966
package
com
.
nisum
.
myteam
.
controller
;
package
com
.
nisum
.
myteam
.
controller
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.dao.Domain
;
import
com.nisum.myteam.model.dao.Domain
;
import
com.nisum.myteam.service.IDomainService
;
import
com.nisum.myteam.service.IDomainService
;
import
com.nisum.myteam.statuscodes.DomainStatus
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* @author Vijay
* @author Vijay
*
*/
*/
@RestController
@RestController
@Slf4j
@Slf4j
public
class
DomainController
{
public
class
DomainController
{
@Autowired
@Autowired
private
IDomainService
domainService
;
private
IDomainService
domainService
;
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createDomain
(
@RequestBody
Domain
domain
,
HttpServletRequest
request
)
throws
MyTeamException
{
log
.
info
(
"Domain Creation"
);
if
(!
domainService
.
isDomainExists
(
domain
))
{
Domain
domainPeristed
=
domainService
.
create
(
domain
);
ResponseDetails
createRespDetails
=
new
ResponseDetails
(
new
Date
(),
801
,
"Domain has been created"
,
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
"Domain Creation"
,
null
,
""
,
"details"
,
domainPeristed
);
public
ResponseEntity
<?>
createDomain
(
@RequestBody
Domain
domain
,
HttpServletRequest
request
)
return
new
ResponseEntity
<
ResponseDetails
>(
createRespDetails
,
HttpStatus
.
OK
);
throws
MyTeamException
{
}
log
.
info
(
"A domain is already existed with the requested name"
+
domain
.
getDomainName
());
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
802
,
"Domain is already existed"
,
log
.
info
(
"Domain Creation"
);
"Choose the different domain name"
,
null
,
request
.
getRequestURI
(),
"Domain details"
,
domain
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
if
(!
domainService
.
isDomainExists
(
domain
))
{
Domain
domainPeristed
=
domainService
.
create
(
domain
);
}
ResponseDetails
createRespDetails
=
new
ResponseDetails
(
new
Date
(),
DomainStatus
.
CREATE
.
getCode
(),
DomainStatus
.
CREATE
.
getMessage
(),
"Domain Creation"
,
null
,
""
,
"details"
,
domainPeristed
);
return
new
ResponseEntity
<
ResponseDetails
>(
createRespDetails
,
HttpStatus
.
OK
);
}
log
.
info
(
"A domain is already existed with the requested name"
+
domain
.
getDomainName
());
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
DomainStatus
.
ALREADY_EXISTED
.
getCode
(),
DomainStatus
.
ALREADY_EXISTED
.
getMessage
(),
"Choose the different domain name"
,
null
,
request
.
getRequestURI
(),
"Domain details"
,
domain
);
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
public
ResponseEntity
<?>
updateDomain
(
@RequestBody
Domain
domain
,
HttpServletRequest
request
)
throws
MyTeamException
{
boolean
isDomainExists
=
domainService
.
isDomainExists
(
domain
);
}
if
(
isDomainExists
==
true
)
{
Domain
domainPersisted
=
domainService
.
update
(
domain
);
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
802
,
"Domain has been updated"
,
"Domain Updation"
,
null
,
request
.
getRequestURI
(),
"Updation Domain details"
,
domainPersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
updateRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
803
,
"Domain is Not found"
,
"Choose the correct updating domain name"
,
null
,
request
.
getRequestURI
(),
"details"
,
domain
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
updateDomain
(
@RequestBody
Domain
domain
,
HttpServletRequest
request
)
throws
MyTeamException
{
@RequestMapping
(
value
=
"/domains/{domainId}"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
boolean
isDomainExists
=
domainService
.
isDomainExists
(
domain
);
public
ResponseEntity
<?>
deleteDomain
(
@PathVariable
String
domainId
,
HttpServletRequest
request
)
if
(
isDomainExists
==
true
)
{
throws
MyTeamException
{
Domain
domainPersisted
=
domainService
.
update
(
domain
);
domainService
.
delete
(
domainId
);
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
DomainStatus
.
UPDATE
.
getCode
(),
DomainStatus
.
UPDATE
.
getMessage
(),
"Domain Updation"
,
null
,
request
.
getRequestURI
(),
"Updation Domain details"
,
domainPersisted
);
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Domain has been deleted"
,
return
new
ResponseEntity
<
ResponseDetails
>(
updateRespDetails
,
HttpStatus
.
OK
);
"Domain Deletion"
,
null
,
request
.
getRequestURI
(),
"Deletion Domain details"
,
domainId
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
803
,
"Domain is Not found"
,
"Choose the correct updating domain name"
,
null
,
request
.
getRequestURI
(),
"details"
,
domain
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/domains/{domainId}"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
deleteDomain
(
@PathVariable
String
domainId
,
HttpServletRequest
request
)
throws
MyTeamException
{
domainService
.
delete
(
domainId
);
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Domain has been deleted"
,
"Domain Deletion"
,
null
,
request
.
getRequestURI
(),
"Deletion Domain details"
,
domainId
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
}
public
ResponseEntity
<?>
getDomains
(
HttpServletRequest
request
)
throws
MyTeamException
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
804
,
"Retrieved the domains successfully"
,
"Domains list"
,
domainService
.
getDomainsList
(),
request
.
getRequestURI
(),
"details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
}
public
ResponseEntity
<?>
getDomains
(
HttpServletRequest
request
)
throws
MyTeamException
{
//getting domains list under accountId which is an active.
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
DomainStatus
.
GET_DOMIAINS
.
getCode
(),
DomainStatus
.
GET_DOMIAINS
.
getMessage
(),
@RequestMapping
(
value
=
"/domains/{accountId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
"Domains list"
,
domainService
.
getDomainsList
(),
request
.
getRequestURI
(),
"details"
,
null
);
public
ResponseEntity
<
List
<
Domain
>>
getDomains
(
@PathVariable
(
"accountId"
)
String
accountId
)
throws
MyTeamException
{
List
<
Domain
>
domains
=
domainService
.
getDomainsUnderAccount
(
accountId
).
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
domains
,
HttpStatus
.
OK
);
}
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
//getting domains list under accountId which is an active.
@RequestMapping
(
value
=
"/domains/{accountId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Domain
>>
getDomains
(
@PathVariable
(
"accountId"
)
String
accountId
)
throws
MyTeamException
{
List
<
Domain
>
domains
=
domainService
.
getDomainsUnderAccount
(
accountId
).
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
domains
,
HttpStatus
.
OK
);
}
}
}
\ No newline at end of file
src/main/java/com/nisum/myteam/controller/EmployeeController.java
View file @
2a843966
...
@@ -42,7 +42,7 @@ public class EmployeeController {
...
@@ -42,7 +42,7 @@ public class EmployeeController {
public
ResponseEntity
<?>
createEmployee
(
@RequestBody
Employee
employeeReq
,
public
ResponseEntity
<?>
createEmployee
(
@RequestBody
Employee
employeeReq
,
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
if
(
!
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
Employee
employeePersisted
=
empService
.
createEmployee
(
employeeReq
,
loginEmpId
);
Employee
employeePersisted
=
empService
.
createEmployee
(
employeeReq
,
loginEmpId
);
ResponseDetails
createRespDetails
=
new
ResponseDetails
(
new
Date
(),
901
,
"Employee has been created"
,
ResponseDetails
createRespDetails
=
new
ResponseDetails
(
new
Date
(),
901
,
"Employee has been created"
,
...
...
src/main/java/com/nisum/myteam/controller/ProjectController.java
View file @
2a843966
...
@@ -6,7 +6,9 @@ import com.nisum.myteam.model.dao.Account;
...
@@ -6,7 +6,9 @@ import com.nisum.myteam.model.dao.Account;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.statuscodes.ProjectStatus
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -53,8 +55,8 @@ public class ProjectController {
...
@@ -53,8 +55,8 @@ public class ProjectController {
Project
projectPersisted
=
projectService
.
createProject
(
projectReq
,
loginEmpId
);
Project
projectPersisted
=
projectService
.
createProject
(
projectReq
,
loginEmpId
);
if
(
projectPersisted
!=
null
)
{
if
(
projectPersisted
!=
null
)
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
800
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
ProjectStatus
.
CREATE
.
getCode
()
,
"Project has been created"
,
"Project description"
,
null
,
ProjectStatus
.
CREATE
.
getMessage
()
,
"Project description"
,
null
,
request
.
getRequestURI
(),
"details"
,
projectPersisted
);
request
.
getRequestURI
(),
"details"
,
projectPersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
...
@@ -63,8 +65,8 @@ public class ProjectController {
...
@@ -63,8 +65,8 @@ public class ProjectController {
}
}
}
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
801
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
ProjectStatus
.
ALREADY_EXISTED
.
getCode
()
,
"Project is already existed"
,
"Choose the different project name"
,
null
,
ProjectStatus
.
ALREADY_EXISTED
.
getMessage
()
,
"Choose the different project name"
,
null
,
request
.
getRequestURI
(),
"details"
,
projectReq
);
request
.
getRequestURI
(),
"details"
,
projectReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
...
@@ -80,21 +82,21 @@ public class ProjectController {
...
@@ -80,21 +82,21 @@ public class ProjectController {
if
(
projectService
.
isProjectExistsById
(
projectId
))
{
if
(
projectService
.
isProjectExistsById
(
projectId
))
{
if
(
projectService
.
isProjectExists
(
project
.
getProjectName
()))
{
if
(
projectService
.
isProjectExists
(
project
.
getProjectName
()))
{
Project
updatedProject
=
projectService
.
updateProject
(
project
,
loginEmpId
);
Project
updatedProject
=
projectService
.
updateProject
(
project
,
loginEmpId
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
801
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
ProjectStatus
.
UPDATE
.
getCode
()
,
"Project has been updated"
,
"Project Updation Description"
,
null
,
ProjectStatus
.
UPDATE
.
getMessage
()
,
"Project Updation Description"
,
null
,
request
.
getRequestURI
(),
"Project Updation details"
,
updatedProject
);
request
.
getRequestURI
(),
"Project Updation details"
,
updatedProject
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
801
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
ProjectStatus
.
PROJECT_NAME_IS_NOT_EXISTS
.
getCode
()
,
"Project is not existed"
,
"Please provide the valid project name"
,
null
,
ProjectStatus
.
PROJECT_NAME_IS_NOT_EXISTS
.
getMessage
()
,
"Please provide the valid project name"
,
null
,
request
.
getRequestURI
(),
"details"
,
project
);
request
.
getRequestURI
(),
"details"
,
project
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
801
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
ProjectStatus
.
PROJECTID_IS_NOT_EXISTS
.
getCode
()
,
"Project Id is not existed"
,
"Please provide the valid project Id"
,
null
,
ProjectStatus
.
PROJECTID_IS_NOT_EXISTS
.
getMessage
()
,
"Please provide the valid project Id"
,
null
,
request
.
getRequestURI
(),
"details"
,
project
);
request
.
getRequestURI
(),
"details"
,
project
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
...
@@ -106,21 +108,20 @@ public class ProjectController {
...
@@ -106,21 +108,20 @@ public class ProjectController {
if
(
projectService
.
isProjectExistsById
(
projectId
))
{
if
(
projectService
.
isProjectExistsById
(
projectId
))
{
projectService
.
deleteProject
(
projectId
);
projectService
.
deleteProject
(
projectId
);
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
ProjectStatus
.
DELETE
.
getCode
()
,
"Project has been deleted successfully"
,
"Project Deletion description"
,
null
,
request
.
getRequestURI
(),
"Project Deletion details"
,
ProjectStatus
.
DELETE
.
getMessage
()
,
"Project Deletion description"
,
null
,
request
.
getRequestURI
(),
"Project Deletion details"
,
projectId
);
projectId
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
}
}
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
ProjectStatus
.
PROJECTID_IS_NOT_EXISTS
.
getCode
()
,
"Project does not exists"
,
"Please provide valid project id"
,
null
,
request
.
getRequestURI
(),
"Project Deletion details"
,
ProjectStatus
.
PROJECTID_IS_NOT_EXISTS
.
getMessage
()
,
"Please provide valid project id"
,
null
,
request
.
getRequestURI
(),
"Project Deletion details"
,
projectId
);
projectId
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
}
}
// @RequestMapping(value = "/getProjects" //get projects only for DL
// @RequestMapping(value = "/getProjects" //get projects only for DL
@RequestMapping
(
value
=
"/projects/employeeId/{employeeId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/projects/employeeId/{employeeId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getProjectsOnRoleBasis
(
public
ResponseEntity
<?>
getProjectsOnRoleBasis
(
...
@@ -128,9 +129,9 @@ public class ProjectController {
...
@@ -128,9 +129,9 @@ public class ProjectController {
throws
MyTeamException
{
throws
MyTeamException
{
List
<
HashMap
<
Object
,
Object
>>
projects
=
null
;
List
<
HashMap
<
Object
,
Object
>>
projects
=
null
;
if
(
employeeId
!=
null
&&
!
""
.
equalsIgnoreCase
(
employeeId
)
)
{
if
(
employeeId
!=
null
&&
!
""
.
equalsIgnoreCase
(
employeeId
))
{
boolean
isEmployeeHaveAccess
=
employeeService
.
verifyEmployeeRole
(
employeeId
,
MyTeamUtils
.
DL
);
boolean
isEmployeeHaveAccess
=
employeeService
.
verifyEmployeeRole
(
employeeId
,
ApplicationRole
.
DELIVERY_LEAD
.
getRoleId
()
);
if
(
isEmployeeHaveAccess
)
{
if
(
isEmployeeHaveAccess
)
{
//projects = projectService.deliveryLeadProjects(employeeId);
//projects = projectService.deliveryLeadProjects(employeeId);
...
@@ -140,10 +141,8 @@ public class ProjectController {
...
@@ -140,10 +141,8 @@ public class ProjectController {
"Projects list"
,
projects
,
request
.
getRequestURI
(),
"Project details"
,
null
);
"Projects list"
,
projects
,
request
.
getRequestURI
(),
"Project details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
else
{
else
projects
=
projectService
.
getProjectsInsteadOfRole
();
{
projects
=
projectService
.
getProjectsInsteadOfRole
();
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the projects successfully"
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the projects successfully"
,
"Projects list"
,
projects
,
request
.
getRequestURI
(),
"Project details"
,
null
);
"Projects list"
,
projects
,
request
.
getRequestURI
(),
"Project details"
,
null
);
...
@@ -203,56 +202,3 @@ public class ProjectController {
...
@@ -203,56 +202,3 @@ public class ProjectController {
}
}
// checking project duplicateName
// int projectNameCount = 0;
// if (projectReq.getAccountId() != null) {
//
// List<Project> projects=projectService.getProjectsUnderDomain(projectReq.getDomainId());
//
// for (Project existproject : projects) {
// if (projectReq.getProjectName().equalsIgnoreCase(existproject.getProjectName()))
// projectNameCount++;
// }
// }
// if (projectNameCount > MyTeamUtils.INT_ZERO) {
// MyTeamException myTimeException = new MyTeamException("Project name already exist !!! try with new");
// return new ResponseEntity<>(myTimeException, HttpStatus.OK);
// } else {
//
// }
// @RequestMapping(value = "/getProjects" //get projects only for DL
// @RequestMapping(value = "/projects/employeeId/{employeeId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getProjects(
// @PathVariable(value = "employeeId") String employeeId, HttpServletRequest request)
// throws MyTeamException {
// List<HashMap<Object, Object>> projects = null;
//
// if (employeeId != null && !"".equalsIgnoreCase(employeeId) && !"undefined".equalsIgnoreCase(employeeId)) {
// boolean isDl = employeeService.verifyEmployeeRole(employeeId, MyTeamUtils.DL);
// if (isDl) {
// projects = projectService.deliveryLeadProjects(employeeId);
//
// ResponseDetails getRespDetails = new ResponseDetails(new Date(), 604, "Retrieved the projects successfully",
// "Projects list", projects, request.getRequestURI(), "Project details", null);
//
// return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
// }
//
// ResponseDetails getRespDetails = new ResponseDetails(new Date(), 605, "You are not authorized to view Projects.",
// "Only Delivery leads can get the project details", projects, request.getRequestURI(), "Project details", null);
//
// return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
//
// }
//
// ResponseDetails getRespDetails = new ResponseDetails(new Date(), 606, "Please Provide valid employee id",
// "Projects list", null, request.getRequestURI(), "Project details", null);
//
// return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
// }
\ No newline at end of file
src/main/java/com/nisum/myteam/controller/ResourceAllocationController.java
0 → 100644
View file @
2a843966
package
com
.
nisum
.
myteam
.
controller
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.ResourceAllocation
;
import
com.nisum.myteam.repository.EmployeeVisaRepo
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.IResourceAllocationService
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
@RestController
@RequestMapping
public
class
ResourceAllocationController
{
@Autowired
private
IEmployeeService
employeeService
;
@Autowired
private
IProjectService
projectService
;
@Autowired
private
EmployeeVisaRepo
employeeVisaRepo
;
@Autowired
private
IResourceAllocationService
resourceAllocationService
;
@RequestMapping
(
value
=
"/resourceAllocation"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createResource
(
@RequestBody
ResourceAllocation
resourceAllocationReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
resourceAllocationReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
ResourceAllocation
resourcePersisted
=
resourceAllocationService
.
addResourceAllocation
(
resourceAllocationReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been created"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceAllocationReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/resourceAllocation"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
updateResource
(
@RequestBody
ResourceAllocation
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
resourceReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
HashMap
<
String
,
Object
>
responseMap
=
resourceAllocationService
.
updateResource
(
resourceReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
responseMap
.
get
(
"message"
).
toString
(),
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/resourceAllocation"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
deleteResource
(
@RequestBody
Resource
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
Resource
resourceDeleted
=
resourceAllocationService
.
deleteResource
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
(),
resourceReq
.
getId
(),
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been deleted"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceDeleted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/resourceAllocation/employeeId/{employeeId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getResourcesSortByProjectStartDate
(
@PathVariable
(
value
=
"employeeId"
,
required
=
true
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
List
<
ResourceAllocation
>
resourcesList
=
resourceAllocationService
.
getResourcesSortByProjectStartDate
(
employeeId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for an employee"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource List details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//
// @RequestMapping(value = "/resources/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getActiveResources(@RequestParam(value = "employeeId", required = false) String employeeId, HttpServletRequest request)
// throws MyTeamException {
// if (StringUtils.isNotBlank(employeeId)) {
// List<Resource> employeesRoles = resourceService.getActiveResources(employeeId);
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources who are active in the projects", employeesRoles, request.getRequestURI(), "Resource List details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide the valid Employee Id",
// "Employee Id is not valid", null, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
//
// @RequestMapping(value = "/resources/shifts/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getResourcesForShift(@PathVariable(value = "shift", required = true) String shift, HttpServletRequest request)
// throws MyTeamException {
//
// if (StringUtils.isNotBlank(shift)) {
// List<Resource> resourcesList = resourceService.getResourcesForShift(shift);
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for the provided shift", resourcesList, request.getRequestURI(), "Resource List for shift", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide the valid Shift value",
// "List of Resources for the provided shift", null, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
//
// @RequestMapping(value = "/resources/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getResourcesAllocatedForAllProjects(HttpServletRequest request) throws MyTeamException {
//
// List<Resource> resourcesList = resourceService.getResourcesForActiveProjects();
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for the projects", resourcesList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
//
// @RequestMapping(value = "/resources/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getResourcesForProject(@PathVariable(value = "projectId", required = true) String projectId,
// @RequestParam(value = "status", required = false, defaultValue = MyTeamUtils.ACTIVE) String status,
// HttpServletRequest request)
// throws MyTeamException {
//
// if (StringUtils.isNotBlank(projectId)) {
// List<Resource> resourcesList = resourceService.getResourcesForProject(projectId, status);
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for a project", resourcesList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide ProjectId",
// "List of Resources for a project", null, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
//
// @RequestMapping(value = "/resources/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getTeamDetails(@PathVariable(value = "deliveryLeadId", required = true) String deliveryLeadId, HttpServletRequest request)
// throws MyTeamException {
//
// if (StringUtils.isNotBlank(deliveryLeadId)) {
// List<Resource> resourcesList = resourceService.getResourcesUnderDeliveryLead(deliveryLeadId);
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for a project", resourcesList, request.getRequestURI(), "Resource details", null);
// }
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide Valid Delivery Lead Id",
// "List of Resources for DeliveryLead", null, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
//
//
// @RequestMapping(value = "resources/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getUnAssignedEmployees(HttpServletRequest request) throws MyTeamException {
// List<Employee> employeesList = projectService.getUnAssignedEmployees();
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources who are not assigned to project", employeesList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
//
// @RequestMapping(value = "/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getEmployeesDashBoard(HttpServletRequest request) throws MyTeamException {
// List<EmployeeDashboardVO> employeeDashBoardList = projectService.getEmployeesDashBoard();
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for dashboard", employeeDashBoardList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
// @RequestMapping(value = "/getEmployeesHavingVisa", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getEmployeesHavingVisa(@RequestParam("visa") String passport,HttpServletRequest request)
// throws MyTeamException {
// List<Employee> employees = new ArrayList<>();
//
// if (passport != null && !"passport".equalsIgnoreCase(passport)) {
//
// List<EmployeeVisa> employeeVisas = employeeVisaRepo.findByVisaName(passport);
//
// List<String> employeeIds = null;
// if (employeeVisas != null) {
// employeeIds = employeeVisas.stream().map(EmployeeVisa::getEmployeeId).collect(Collectors.toList());
// }
// if (employeeIds != null && !employeeIds.isEmpty()) {
// List<Employee> emps = employeeService.getActiveEmployees();
// for (Employee emp : emps) {
// if (employeeIds.contains(emp.getEmployeeId())) {
// employees.add(emp);
// }
// }
// }
// } else {
// if (employeeService.getActiveEmployees() != null) {
// employees = employeeService.getActiveEmployees().stream()
// .sorted((o1, o2) -> o1.getEmployeeName().compareTo(o2.getEmployeeName()))
// .collect(Collectors.toList());
// }
//
// }
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources who has visa", employees, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
//
//
// @RequestMapping(value = "/addEmployeeToTeamWithCheck", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> addEmployeeToTeamWithCheck(@RequestBody Resource resourceReq,
// @RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
//
// if (StringUtils.isNotBlank(loginEmpId)) {
// HashMap<String, Object> responseMap = projectService.verifyResourceAssignedToAnyProject(resourceReq, loginEmpId);
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, responseMap.get("message").toString(),
// "List of Resources for dashboard", responseMap.get("resourceObj"), request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide Valid Employee Id",
// "Verification of resource in Bench Project", null, request.getRequestURI(), "Resource details", resourceReq);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
}
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
2a843966
...
@@ -251,7 +251,7 @@ public class ResourceController {
...
@@ -251,7 +251,7 @@ public class ResourceController {
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
HashMap
<
String
,
Object
>
responseMap
=
projectService
.
addProjectTeamMateWithCheck
(
resourceReq
,
loginEmpId
);
HashMap
<
String
,
Object
>
responseMap
=
resourceService
.
verifyResourceAssignedToAnyProject
(
resourceReq
,
loginEmpId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
responseMap
.
get
(
"message"
).
toString
(),
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
responseMap
.
get
(
"message"
).
toString
(),
"List of Resources for dashboard"
,
responseMap
.
get
(
"resourceObj"
),
request
.
getRequestURI
(),
"Resource details"
,
null
);
"List of Resources for dashboard"
,
responseMap
.
get
(
"resourceObj"
),
request
.
getRequestURI
(),
"Resource details"
,
null
);
...
...
src/main/java/com/nisum/myteam/model/dao/ResourceAllocation.java
0 → 100644
View file @
2a843966
package
com
.
nisum
.
myteam
.
model
.
dao
;
import
com.nisum.myteam.model.AuditFields
;
import
lombok.*
;
import
org.bson.types.ObjectId
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.format.annotation.DateTimeFormat.ISO
;
import
java.io.Serializable
;
import
java.util.Date
;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"resourceAllocation"
)
public
class
ResourceAllocation
extends
AuditFields
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
ObjectId
id
;
private
String
employeeId
;
private
String
projectId
;
private
String
projectName
;
@DateTimeFormat
(
iso
=
ISO
.
DATE
)
private
String
billableStatus
;
@DateTimeFormat
(
iso
=
ISO
.
DATE
)
private
Date
billingStartDate
;
@DateTimeFormat
(
iso
=
ISO
.
DATE
)
private
Date
billingEndDate
;
//private boolean active;
// private String role;
// @DateTimeFormat(iso = ISO.DATE)
// private Date projectStartDate;
//
// @DateTimeFormat(iso = ISO.DATE)
// private Date projectEndDate;
}
src/main/java/com/nisum/myteam/repository/ResourceAllocationRepo.java
0 → 100644
View file @
2a843966
package
com
.
nisum
.
myteam
.
repository
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.ResourceAllocation
;
import
org.bson.types.ObjectId
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
java.util.List
;
public
interface
ResourceAllocationRepo
extends
MongoRepository
<
ResourceAllocation
,
String
>
{
List
<
Resource
>
findByProjectId
(
String
projectId
);
List
<
Resource
>
findByEmployeeId
(
String
employeeId
);
Resource
findById
(
ObjectId
id
);
Resource
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
// List<Resource> findByEmployeeIdAndProjectIdAndActive(String employeeId, String projectId, boolean status);
// List<Resource> findByAccountAndActiveAndBillableStatus(String account, boolean status, String billableStatus);
}
src/main/java/com/nisum/myteam/service/IEmployeeVisaService.java
0 → 100644
View file @
2a843966
package
com
.
nisum
.
myteam
.
service
;
public
interface
IEmployeeVisaService
{
}
src/main/java/com/nisum/myteam/service/IProjectService.java
View file @
2a843966
...
@@ -34,7 +34,7 @@ public interface IProjectService {
...
@@ -34,7 +34,7 @@ public interface IProjectService {
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
();
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
();
public
HashMap
<
String
,
Object
>
addProjectTeamMateWithCheck
(
Resource
projectTeamMate
,
String
loginEmpId
)
throws
MyTeamException
;
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsForEmployee
(
String
empId
);
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsForEmployee
(
String
empId
);
...
@@ -57,4 +57,8 @@ public interface IProjectService {
...
@@ -57,4 +57,8 @@ public interface IProjectService {
public
List
<
HashMap
<
Object
,
Object
>>
getRoleBasedProjects
(
String
empId
)
throws
MyTeamException
;
public
List
<
HashMap
<
Object
,
Object
>>
getRoleBasedProjects
(
String
empId
)
throws
MyTeamException
;
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsInsteadOfRole
()
throws
MyTeamException
;
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsInsteadOfRole
()
throws
MyTeamException
;
public
Project
getProjectByProjectId
(
String
projectId
);
}
}
src/main/java/com/nisum/myteam/service/IResourceAllocationService.java
0 → 100644
View file @
2a843966
package
com
.
nisum
.
myteam
.
service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.ResourceAllocation
;
import
org.bson.types.ObjectId
;
import
java.util.HashMap
;
import
java.util.List
;
public
interface
IResourceAllocationService
{
ResourceAllocation
addResourceAllocation
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
HashMap
<
String
,
Object
>
updateResource
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
);
// Resource save(Resource resource);
// void addResources(Employee employee, String loginEmpId);
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
List
<
ResourceAllocation
>
getResourcesSortByProjectStartDate
(
String
employeeId
);
// List<Resource> getResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
// List<Resource> getResourcesForProject(String projectId);
// List<Resource> getActiveResources(String empId);
// List<Resource> getResourcesForActiveProjects();
// List<Resource> getResourcesForShift(String shift);
// public List<Resource> getResourcesUnderDeliveryLead(String empId);
}
src/main/java/com/nisum/myteam/service/IResourceService.java
View file @
2a843966
package
com
.
nisum
.
myteam
.
service
;
package
com
.
nisum
.
myteam
.
service
;
import
java.util.List
;
import
org.bson.types.ObjectId
;
import
org.springframework.stereotype.Service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.Resource
;
import
org.bson.types.ObjectId
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
@Service
@Service
public
interface
IResourceService
{
public
interface
IResourceService
{
Resource
addResource
(
Resource
projectTeamMate
,
String
loginEmpId
)
throws
MyTeamException
;
Resource
addResource
(
Resource
projectTeamMate
,
String
loginEmpId
)
throws
MyTeamException
;
String
updateResource
(
Resource
projectTeamMate
,
String
loginEmpId
)
throws
MyTeamException
;
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
);
Resource
save
(
Resource
resource
);
void
addResources
(
Employee
employee
,
String
loginEmpId
);
String
updateResource
(
Resource
projectTeamMate
,
String
loginEmpId
)
throws
MyTeamException
;
void
inactivateResource
(
Employee
employeeReq
,
Employee
employeeUpdated
,
String
loginEmpId
)
;
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
);
List
<
Resource
>
findByAccountAndActiveAndBillableStatus
(
String
account
,
boolean
status
,
String
billableStatus
);
Resource
save
(
Resource
resource
);
List
<
Resource
>
getResourcesSortByStartDate
(
String
employeeId
);
void
addResources
(
Employee
employee
,
String
loginEmpId
);
List
<
Resource
>
getResourcesForProject
(
String
projectId
,
String
status
);
void
inactivateResource
(
Employee
employeeReq
,
Employee
employeeUpdated
,
String
loginE
mpId
);
List
<
Resource
>
getResourcesForEmployee
(
String
e
mpId
);
List
<
Resource
>
findByAccountAndActiveAndBillableStatus
(
String
account
,
boolean
status
,
String
billableStatus
);
List
<
Resource
>
getResourcesForProject
(
String
projectId
);
List
<
Resource
>
getResourcesSortByStartDate
(
String
employee
Id
);
List
<
Resource
>
getActiveResources
(
String
emp
Id
);
List
<
Resource
>
getResourcesForProject
(
String
projectId
,
String
status
);
List
<
Resource
>
getResourcesForActiveProjects
(
);
List
<
Resource
>
getResourcesForEmployee
(
String
empId
);
List
<
Resource
>
getResourcesForShift
(
String
shift
);
List
<
Resource
>
getResourcesForProject
(
String
project
Id
);
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
emp
Id
);
List
<
Resource
>
getActiveResources
(
String
empId
)
;
public
HashMap
<
String
,
Object
>
verifyResourceAssignedToAnyProject
(
Resource
projectTeamMate
,
String
loginEmpId
)
throws
MyTeamException
;
List
<
Resource
>
getResourcesForActiveProjects
();
List
<
Resource
>
getResourcesForShift
(
String
shift
);
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
empId
);
}
}
src/main/java/com/nisum/myteam/service/impl/DomainService.java
View file @
2a843966
...
@@ -158,6 +158,23 @@ public class DomainService implements IDomainService {
...
@@ -158,6 +158,23 @@ public class DomainService implements IDomainService {
return
domainVOS
;
return
domainVOS
;
}
}
public
Domain
getDomainById
(
String
domainId
)
{
Domain
domain
=
null
;
if
(
domainId
!=
null
&&
domainId
.
length
()
>
0
)
{
domain
=
domainRepo
.
findByDomainId
(
domainId
);
}
return
domain
;
}
@Override
public
List
<
Domain
>
getDomainsUnderAccount
(
String
accountId
)
throws
MyTeamException
{
List
<
Domain
>
domains
=
domainRepo
.
findByAccountId
(
accountId
);
return
domains
;
}
@Override
@Override
public
WriteResult
delete
(
String
domainId
)
throws
MyTeamException
{
public
WriteResult
delete
(
String
domainId
)
throws
MyTeamException
{
List
<
String
>
domEmpIds
=
new
ArrayList
<
String
>();
List
<
String
>
domEmpIds
=
new
ArrayList
<
String
>();
...
@@ -243,22 +260,7 @@ public class DomainService implements IDomainService {
...
@@ -243,22 +260,7 @@ public class DomainService implements IDomainService {
return
accIdsSet
;
return
accIdsSet
;
}
}
public
Domain
getDomainById
(
String
domainId
)
{
Domain
domain
=
null
;
if
(
domainId
!=
null
&&
domainId
.
length
()
>
0
)
{
domain
=
domainRepo
.
findByDomainId
(
domainId
);
}
return
domain
;
}
@Override
public
List
<
Domain
>
getDomainsUnderAccount
(
String
accountId
)
throws
MyTeamException
{
List
<
Domain
>
domains
=
domainRepo
.
findByAccountId
(
accountId
);
return
domains
;
}
}
}
\ No newline at end of file
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
2a843966
...
@@ -8,7 +8,9 @@ import com.nisum.myteam.model.dao.Resource;
...
@@ -8,7 +8,9 @@ import com.nisum.myteam.model.dao.Resource;
import
com.nisum.myteam.repository.EmployeeRepo
;
import
com.nisum.myteam.repository.EmployeeRepo
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
...
@@ -286,7 +288,7 @@ public class EmployeeService implements IEmployeeService {
...
@@ -286,7 +288,7 @@ public class EmployeeService implements IEmployeeService {
}
}
@Override
@Override
public
boolean
verifyEmployeeRole
(
String
empId
,
String
role
Name
)
{
public
boolean
verifyEmployeeRole
(
String
empId
,
String
role
IdReq
)
{
boolean
flag
=
false
;
boolean
flag
=
false
;
log
.
info
(
"The employeeId::"
+
empId
);
log
.
info
(
"The employeeId::"
+
empId
);
...
@@ -294,23 +296,29 @@ public class EmployeeService implements IEmployeeService {
...
@@ -294,23 +296,29 @@ public class EmployeeService implements IEmployeeService {
Employee
employee
=
getEmployeeById
(
empId
);
Employee
employee
=
getEmployeeById
(
empId
);
log
.
info
(
"Employee::::in EmployeeService::"
+
employee
);
log
.
info
(
"Employee::::in EmployeeService::"
+
employee
);
String
role
=
employee
.
getRole
();
String
role
Name
=
employee
.
getRole
();
log
.
info
(
"The employee role::"
+
role
);
log
.
info
(
"The employee role::"
+
role
Name
);
if
(
null
!=
role
&&
""
!=
role
&&
!
"Admin"
.
equalsIgnoreCase
(
rol
e
))
{
if
(
StringUtils
.
isNotBlank
(
roleName
)
&&
!
ApplicationRole
.
ADMIN
.
getRoleName
().
equalsIgnoreCase
(
roleNam
e
))
{
if
(
"FM"
.
equalsIgnoreCase
(
role
)
||
"Delivery Lead"
.
equalsIgnoreCase
(
role
))
{
if
(
ApplicationRole
.
FUNCTIONAL_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
roleName
)
||
ApplicationRole
.
DELIVERY_LEAD
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
flag
=
true
;
flag
=
true
;
log
.
info
(
"in if block"
);
}
else
{
}
else
{
log
.
info
(
"in else block"
);
Set
<
String
>
roleSet
=
employeeRoleService
.
empRolesMapInfoByEmpId
(
empId
);
Set
<
String
>
roleSet
=
employeeRoleService
.
empRolesMapInfoByEmpId
(
empId
);
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
roleSet
.
size
())
{
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
roleSet
.
size
())
{
if
(
roleSet
.
contains
(
role
Name
))
{
if
(
roleSet
.
contains
(
role
IdReq
))
{
flag
=
true
;
flag
=
true
;
}
}
}
}
}
}
}
}
log
.
info
(
"before return flag::"
+
flag
);
return
flag
;
return
flag
;
}
}
...
...
src/main/java/com/nisum/myteam/service/impl/EmployeeVisaService.java
0 → 100644
View file @
2a843966
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
com.nisum.myteam.service.IEmployeeVisaService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
EmployeeVisaService
implements
IEmployeeVisaService
{
//
// public getEmployeeVisaByName(String passport)
//
// employeeVisaRepo.findByVisaName(passport);
}
src/main/java/com/nisum/myteam/service/impl/ProjectService.java
View file @
2a843966
package
com
.
nisum
.
myteam
.
service
.
impl
;
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.EmpLoginData
;
import
com.nisum.myteam.model.dao.*
;
import
com.nisum.myteam.model.dao.*
;
import
com.nisum.myteam.model.vo.EmployeeDashboardVO
;
import
com.nisum.myteam.model.vo.EmployeeDashboardVO
;
import
com.nisum.myteam.repository.*
;
import
com.nisum.myteam.repository.*
;
...
@@ -12,6 +11,7 @@ import com.nisum.myteam.service.IProjectService;
...
@@ -12,6 +11,7 @@ import com.nisum.myteam.service.IProjectService;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.PdfReportGenerator
;
import
com.nisum.myteam.utils.PdfReportGenerator
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
...
@@ -28,13 +28,10 @@ import java.util.stream.Collectors;
...
@@ -28,13 +28,10 @@ import java.util.stream.Collectors;
@Slf4j
@Slf4j
public
class
ProjectService
implements
IProjectService
{
public
class
ProjectService
implements
IProjectService
{
@Autowired
private
EmployeeRepo
employeeRepo
;
@Autowired
@Autowired
private
ProjectRepo
projectRepo
;
private
ProjectRepo
projectRepo
;
@Autowired
@Autowired
private
ResourceRepo
resourceRepo
;
private
ResourceRepo
resourceRepo
;
...
@@ -46,12 +43,7 @@ public class ProjectService implements IProjectService {
...
@@ -46,12 +43,7 @@ public class ProjectService implements IProjectService {
@Autowired
@Autowired
private
MongoTemplate
mongoTemplate
;
private
MongoTemplate
mongoTemplate
;
@Autowired
private
AccountRepo
accountRepo
;
@Autowired
private
DomainRepo
domainRepo
;
@Autowired
@Autowired
private
IDomainService
domainService
;
private
IDomainService
domainService
;
...
@@ -123,8 +115,8 @@ public class ProjectService implements IProjectService {
...
@@ -123,8 +115,8 @@ public class ProjectService implements IProjectService {
@Override
@Override
public
Project
createProject
(
Project
project
,
String
loginEmpId
)
throws
MyTeamException
{
public
Project
createProject
(
Project
project
,
String
loginEmpId
)
throws
MyTeamException
{
if
(
project
.
getDomainId
()
==
null
)
{
if
(
project
.
getDomainId
()
==
null
)
{
List
<
Domain
>
domainsList
=
domainRepo
//List<Domain> domainsList = domainRepo.findByAccountId(project.getAccountId());
.
findByAccountId
(
project
.
getAccountId
());
List
<
Domain
>
domainsList
=
domainService
.
getDomainsUnderAccount
(
project
.
getAccountId
());
Domain
savedDomain
=
domainsList
.
get
(
0
);
Domain
savedDomain
=
domainsList
.
get
(
0
);
project
.
setDomainId
(
savedDomain
.
getDomainId
());
project
.
setDomainId
(
savedDomain
.
getDomainId
());
project
.
setDomain
(
savedDomain
.
getDomainName
());
project
.
setDomain
(
savedDomain
.
getDomainName
());
...
@@ -281,8 +273,12 @@ public class ProjectService implements IProjectService {
...
@@ -281,8 +273,12 @@ public class ProjectService implements IProjectService {
projectMap
.
put
(
"id"
,
project
.
getId
());
projectMap
.
put
(
"id"
,
project
.
getId
());
projectMap
.
put
(
"projectId"
,
project
.
getProjectId
());
projectMap
.
put
(
"projectId"
,
project
.
getProjectId
());
projectMap
.
put
(
"projectName"
,
project
.
getProjectName
());
projectMap
.
put
(
"projectName"
,
project
.
getProjectName
());
Account
account
=
accountRepo
.
findByAccountId
(
project
.
getAccountId
());
Domain
domain
=
domainRepo
.
findByDomainId
(
project
.
getDomainId
());
Account
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
//Domain domain = domainRepo.findByDomainId(project.getDomainId());
Domain
domain
=
domainService
.
getDomainById
(
project
.
getDomainId
());
if
(
domain
!=
null
)
if
(
domain
!=
null
)
projectMap
.
put
(
"domain"
,
domain
.
getDomainName
());
projectMap
.
put
(
"domain"
,
domain
.
getDomainName
());
if
(
account
!=
null
)
if
(
account
!=
null
)
...
@@ -448,7 +444,9 @@ public class ProjectService implements IProjectService {
...
@@ -448,7 +444,9 @@ public class ProjectService implements IProjectService {
@Override
@Override
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
()
{
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
()
{
List
<
Employee
>
allEmployees
=
employeeRepo
.
findAll
();
//List<Employee> allEmployees = employeeRepo.findAll();
List
<
Employee
>
allEmployees
=
employeeService
.
getAllEmployees
();
List
<
EmployeeDashboardVO
>
employeeDashboard
=
new
ArrayList
<>();
List
<
EmployeeDashboardVO
>
employeeDashboard
=
new
ArrayList
<>();
Map
<
String
,
Object
>
teamMatesMap
=
new
HashMap
();
Map
<
String
,
Object
>
teamMatesMap
=
new
HashMap
();
Map
<
String
,
Object
>
teamMatesStatusMap
=
new
HashMap
();
Map
<
String
,
Object
>
teamMatesStatusMap
=
new
HashMap
();
...
@@ -512,66 +510,13 @@ public class ProjectService implements IProjectService {
...
@@ -512,66 +510,13 @@ public class ProjectService implements IProjectService {
}
}
@Override
public
HashMap
<
String
,
Object
>
addProjectTeamMateWithCheck
(
Resource
resource
,
String
loginEmpId
)
throws
MyTeamException
{
boolean
flag
=
false
;
String
projectName
=
null
;
String
fromDate
=
null
;
String
toDate
=
null
;
String
result
=
null
;
HashMap
<
String
,
Object
>
responseMap
=
new
HashMap
<>();
Resource
resourcePersisted
=
null
;
List
<
Resource
>
teamMateList
=
resourceRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
()).
stream
()
.
filter
(
e
->
!(
"Nisum0000"
.
equalsIgnoreCase
(
e
.
getProjectId
())))
.
sorted
(
Comparator
.
comparing
(
Resource:
:
getEndDate
).
reversed
())
.
collect
(
Collectors
.
toList
());
// Checking, if resource has existing project assignment.
for
(
Resource
projectMate
:
teamMateList
)
{
if
(
projectMate
.
getEndDate
()
!=
null
&&
(
projectMate
.
getEndDate
().
compareTo
(
new
Date
())
>
0
))
{
flag
=
true
;
projectName
=
projectMate
.
getProjectName
();
fromDate
=
projectMate
.
getStartDate
().
toString
();
toDate
=
projectMate
.
getEndDate
().
toString
();
break
;
}
}
if
(
flag
)
{
// If yes, error thrown to user.
result
=
"Resource "
+
resource
.
getEmployeeId
()
+
" already Assigned to the "
+
projectName
+
" Project"
+
" from "
+
fromDate
+
"to "
+
toDate
;
}
else
{
// If no, validating new project assignment start date against previous project end date.
result
=
validateNewProjectAssignmentStartDate
(
teamMateList
,
resource
);
if
(
result
==
null
)
{
resourcePersisted
=
resourceService
.
addResource
(
resource
,
loginEmpId
);
result
=
"TeamMate added successfuly"
;
}
}
responseMap
.
put
(
"message"
,
result
);
responseMap
.
put
(
"resourceObj"
,
resourcePersisted
);
return
responseMap
;
}
private
String
validateNewProjectAssignmentStartDate
(
List
<
Resource
>
teamMateList
,
Resource
projectTeamMate
)
{
String
response
=
null
;
if
(
teamMateList
!=
null
&&
teamMateList
.
size
()
>
0
)
{
Resource
ptMate
=
teamMateList
.
get
(
0
);
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
ptMate
.
getEndDate
())
<=
0
)
{
response
=
"Resource Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) in "
+
projectTeamMate
.
getProjectName
()
+
" project should be after "
+
ptMate
.
getProjectName
()
+
" project End Date ( "
+
ptMate
.
getEndDate
()
+
")."
;
}
}
else
{
response
=
validateAgainstDOJ
(
projectTeamMate
);
}
return
response
;
}
private
String
validateAgainstDOJ
(
Resource
projectTeamMate
)
{
private
String
validateAgainstDOJ
(
Resource
projectTeamMate
)
{
String
response
=
null
;
String
response
=
null
;
Date
empDoj
=
employeeRepo
.
findByEmployeeId
(
projectTeamMate
.
getEmployeeId
()).
getDateOfJoining
();
//Date empDoj = employeeRepo.findByEmployeeId(projectTeamMate.getEmployeeId()).getDateOfJoining();
Date
empDoj
=
employeeService
.
getEmployeeById
(
projectTeamMate
.
getEmployeeId
()).
getDateOfJoining
();
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
response
=
"Resource Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) in "
+
projectTeamMate
.
getProjectName
()
response
=
"Resource Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) in "
+
projectTeamMate
.
getProjectName
()
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
...
@@ -596,8 +541,10 @@ public class ProjectService implements IProjectService {
...
@@ -596,8 +541,10 @@ public class ProjectService implements IProjectService {
project
=
projectRepo
.
findByProjectId
(
resource
.
getProjectId
());
project
=
projectRepo
.
findByProjectId
(
resource
.
getProjectId
());
account
=
accountRepo
.
findByAccountId
(
resource
.
getAccountId
());
//account = accountRepo.findByAccountId(resource.getAccountId());
domain
=
domainRepo
.
findByDomainId
(
resource
.
getDomainId
());
account
=
accountService
.
getAccountById
(
resource
.
getAccountId
());
//domain = domainRepo.findByDomainId(resource.getDomainId());
domain
=
domainService
.
getDomainById
(
resource
.
getDomainId
());
projectMap
.
put
(
"id"
,
project
.
getId
());
projectMap
.
put
(
"id"
,
project
.
getId
());
projectMap
.
put
(
"projectId"
,
project
.
getProjectId
());
projectMap
.
put
(
"projectId"
,
project
.
getProjectId
());
...
@@ -663,8 +610,10 @@ public class ProjectService implements IProjectService {
...
@@ -663,8 +610,10 @@ public class ProjectService implements IProjectService {
for
(
Project
obj
:
prjts
)
{
for
(
Project
obj
:
prjts
)
{
projectMap
=
new
HashMap
<>();
projectMap
=
new
HashMap
<>();
account
=
accountRepo
.
findByAccountId
(
obj
.
getAccountId
());
//account = accountRepo.findByAccountId(obj.getAccountId());
domain
=
domainRepo
.
findByDomainId
(
obj
.
getDomainId
());
account
=
accountService
.
getAccountById
(
obj
.
getAccountId
());
//domain = domainRepo.findByDomainId(obj.getDomainId());
domain
=
domainService
.
getDomainById
(
obj
.
getDomainId
());
projectMap
.
put
(
"projectId"
,
obj
.
getProjectId
());
projectMap
.
put
(
"projectId"
,
obj
.
getProjectId
());
projectMap
.
put
(
"projectName"
,
obj
.
getProjectName
());
projectMap
.
put
(
"projectName"
,
obj
.
getProjectName
());
...
@@ -755,4 +704,13 @@ public class ProjectService implements IProjectService {
...
@@ -755,4 +704,13 @@ public class ProjectService implements IProjectService {
}
}
public
Project
getProjectByProjectId
(
String
projectId
)
{
Project
project
=
null
;
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
project
=
projectRepo
.
findByProjectId
(
projectId
);
}
return
project
;
}
}
}
src/main/java/com/nisum/myteam/service/impl/ResourceAllocationService.java
0 → 100644
View file @
2a843966
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.ResourceAllocation
;
import
com.nisum.myteam.repository.ResourceAllocationRepo
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.IResourceAllocationService
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.types.ObjectId
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
@Service
@Slf4j
public
class
ResourceAllocationService
implements
IResourceAllocationService
{
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
ResourceAllocationRepo
resourceAllocationRepo
;
@Autowired
private
IProjectService
projectService
;
public
ResourceAllocation
addResourceAllocation
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
{
return
resourceAllocationRepo
.
save
(
resourceAllocation
);
}
public
HashMap
<
String
,
Object
>
updateResource
(
ResourceAllocation
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
{
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
Project
project
=
projectService
.
getProjectByProjectId
(
resourceAllocReq
.
getProjectId
());
if
(
resourceAllocReq
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
}
ResourceAllocation
resourceAllocationPers
=
resourceAllocationRepo
.
save
(
resourceAllocReq
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"resourceObj"
,
resourceAllocationPers
);
return
respMap
;
}
public
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
)
{
return
null
;
}
public
List
<
ResourceAllocation
>
getResourcesSortByProjectStartDate
(
String
employeeId
)
{
Query
query
=
prepareQuery
(
employeeId
,
MyTeamUtils
.
PROJECT_START_DATE
);
return
mongoTemplate
.
find
(
query
,
ResourceAllocation
.
class
);
}
private
Query
prepareQuery
(
String
employeeId
,
String
dateColumn
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
MyTeamUtils
.
EMPLOYEE_ID
).
is
(
employeeId
));
query
.
limit
(
MyTeamUtils
.
ONE
);
query
.
with
(
new
Sort
(
Sort
.
Direction
.
DESC
,
dateColumn
));
return
query
;
}
}
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
2a843966
package
com
.
nisum
.
myteam
.
service
.
impl
;
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Arrays
;
import
java.util.Calendar
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
...
@@ -624,4 +619,66 @@ public class ResourceService implements IResourceService {
...
@@ -624,4 +619,66 @@ public class ResourceService implements IResourceService {
return
resourcesList
;
return
resourcesList
;
}
}
@Override
public
HashMap
<
String
,
Object
>
verifyResourceAssignedToAnyProject
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
boolean
flag
=
false
;
String
projectName
=
null
;
String
fromDate
=
null
;
String
toDate
=
null
;
String
result
=
null
;
HashMap
<
String
,
Object
>
responseMap
=
new
HashMap
<>();
Resource
resourcePersisted
=
null
;
List
<
Resource
>
resourceList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
()).
stream
()
.
filter
(
e
->
!(
"Nisum0000"
.
equalsIgnoreCase
(
e
.
getProjectId
())))
.
sorted
(
Comparator
.
comparing
(
Resource:
:
getEndDate
).
reversed
())
.
collect
(
Collectors
.
toList
());
// Checking, if resource has existing project assignment.
for
(
Resource
resource
:
resourceList
)
{
log
.
info
(
"Resource::"
+
resource
);
if
(
resource
.
getEndDate
()
!=
null
&&
(
resource
.
getEndDate
().
compareTo
(
new
Date
())
>
0
))
{
flag
=
true
;
projectName
=
resource
.
getProjectName
();
fromDate
=
resource
.
getStartDate
().
toString
();
toDate
=
resource
.
getEndDate
().
toString
();
break
;
}
}
if
(
flag
)
{
// If yes, error thrown to user.
result
=
"Resource "
+
resourceReq
.
getEmployeeId
()
+
" already Assigned to the "
+
projectName
+
" Project"
+
" from "
+
fromDate
+
"to "
+
toDate
;
}
else
{
// If no, validating new project assignment start date against previous project end date.
result
=
validateNewProjectAssignmentStartDate
(
resourceList
,
resourceReq
);
if
(
result
==
null
)
{
resourcePersisted
=
this
.
addResource
(
resourceReq
,
loginEmpId
);
result
=
"TeamMate added successfuly"
;
}
}
responseMap
.
put
(
"message"
,
result
);
responseMap
.
put
(
"resourceObj"
,
resourcePersisted
);
return
responseMap
;
}
private
String
validateNewProjectAssignmentStartDate
(
List
<
Resource
>
teamMateList
,
Resource
projectTeamMate
)
{
String
response
=
null
;
if
(
teamMateList
!=
null
&&
teamMateList
.
size
()
>
0
)
{
Resource
ptMate
=
teamMateList
.
get
(
0
);
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
ptMate
.
getEndDate
())
<=
0
)
{
response
=
"Resource Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) in "
+
projectTeamMate
.
getProjectName
()
+
" project should be after "
+
ptMate
.
getProjectName
()
+
" project End Date ( "
+
ptMate
.
getEndDate
()
+
")."
;
}
}
else
{
response
=
validateAgainstDOJ
(
projectTeamMate
);
}
return
response
;
}
}
}
src/main/java/com/nisum/myteam/statuscodes/DomainStatus.java
View file @
2a843966
...
@@ -2,8 +2,11 @@ package com.nisum.myteam.statuscodes;
...
@@ -2,8 +2,11 @@ package com.nisum.myteam.statuscodes;
public
enum
DomainStatus
{
public
enum
DomainStatus
{
CREATE
(
600
,
"Account has been created"
),
CREATE
(
610
,
"Domain has been created"
),
UPDATE
(
601
,
"Account has been updated"
);
UPDATE
(
611
,
"Domain has been updated"
),
ALREADY_EXISTED
(
612
,
"Domain is already existed"
),
IS_NOT_FOUND
(
613
,
"Domain is Not found"
),
GET_DOMIAINS
(
614
,
"Retrieved the domains successfully"
);
private
int
code
;
private
int
code
;
private
String
message
;
private
String
message
;
...
...
src/main/java/com/nisum/myteam/statuscodes/ProjectStatus.java
View file @
2a843966
package
com
.
nisum
.
myteam
.
statuscodes
;
package
com
.
nisum
.
myteam
.
statuscodes
;
public
class
ProjectStatus
{
public
enum
ProjectStatus
{
CREATE
(
700
,
"Project has been created"
),
UPDATE
(
701
,
"Project has been updated"
),
DELETE
(
702
,
"Project has been deleted successfully"
),
ALREADY_EXISTED
(
703
,
"Project is already existed"
),
PROJECTID_IS_NOT_EXISTS
(
704
,
"Project Id is not existed"
),
PROJECT_NAME_IS_NOT_EXISTS
(
705
,
"Project is not existed"
),
IS_NOT_FOUND
(
706
,
"Domain is Not found"
),
GET_DOMIAINS
(
707
,
"Retrieved the domains successfully"
);
private
int
code
;
private
String
message
;
private
ProjectStatus
(
int
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
int
getCode
()
{
return
this
.
code
;
}
public
String
getMessage
()
{
return
this
.
message
;
}
}
}
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
View file @
2a843966
...
@@ -151,4 +151,12 @@ public class MyTeamUtils {
...
@@ -151,4 +151,12 @@ public class MyTeamUtils {
public
final
static
String
CREATE
=
"CREATE"
;
public
final
static
String
CREATE
=
"CREATE"
;
public
final
static
String
UPDATE
=
"UPDATE"
;
public
final
static
String
UPDATE
=
"UPDATE"
;
public
final
static
String
PROJECT_START_DATE
=
"ProjectStartDate"
;
public
final
static
String
PROJECT_END_DATE
=
"ProjectEndDate"
;
public
final
static
String
BILLING_START_DATE
=
"BillingStartDate"
;
public
final
static
String
BILLING_END_DATE
=
"BillingEndDate"
;
}
}
src/main/java/com/nisum/myteam/utils/constants/ApplicationRole.java
0 → 100644
View file @
2a843966
package
com
.
nisum
.
myteam
.
utils
.
constants
;
public
enum
ApplicationRole
{
FUNCTIONAL_MANAGER
(
""
,
"FM"
),
ADMIN
(
""
,
"Admin"
),
DIRECTOR
(
""
,
"Director"
),
DELIVERY_MANAGER
(
"DM"
,
"Delivery Manager"
),
DELIVERY_LEAD
(
"DL"
,
"Delivery Lead"
),
LEAD
(
"L"
,
"Lead"
),
EMPLOYEE
(
""
,
"Employee"
),
HR
(
""
,
"Hr"
);
private
String
roleId
;
private
String
roleName
;
private
ApplicationRole
(
String
roleId
,
String
roleName
)
{
this
.
roleId
=
roleId
;
this
.
roleName
=
roleName
;
}
public
String
getRoleId
()
{
return
this
.
roleId
;
}
public
String
getRoleName
()
{
return
this
.
roleName
;
}
}
src/main/java/com/nisum/myteam/utils/constants/RoleEnum.java
deleted
100644 → 0
View file @
80aed22b
package
com
.
nisum
.
myteam
.
utils
.
constants
;
public
enum
RoleEnum
{
ADMIN
(
"admin"
),
DIRECTOR
(
"Director"
),
DELIVERY_MANAGER
(
"Delivery Manager"
),
DELIVERY_LEAD
(
"Delivery Lead"
),
LEAD
(
"Lead"
),
EMPLOYEE
(
"Employee"
),
HR
(
"hr"
);
private
String
role
;
private
RoleEnum
(
String
role
)
{
this
.
role
=
role
;
}
public
String
getRole
()
{
return
this
.
role
;
}
}
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