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
49d725f8
Commit
49d725f8
authored
May 21, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed the references of ResourceAlloc to resources in all other files
parent
066543e3
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
158 additions
and
161 deletions
+158
-161
ReportsController.java
...n/java/com/nisum/myteam/controller/ReportsController.java
+8
-9
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+31
-31
Resource.java
src/main/java/com/nisum/myteam/model/dao/Resource.java
+1
-1
ResourceRepo.java
src/main/java/com/nisum/myteam/repository/ResourceRepo.java
+6
-7
IProjectService.java
src/main/java/com/nisum/myteam/service/IProjectService.java
+2
-2
IResourceService.java
src/main/java/com/nisum/myteam/service/IResourceService.java
+12
-12
DashboardService.java
.../java/com/nisum/myteam/service/impl/DashboardService.java
+3
-4
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+1
-1
ProjectService.java
...in/java/com/nisum/myteam/service/impl/ProjectService.java
+8
-8
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+86
-86
No files found.
src/main/java/com/nisum/myteam/controller/ReportsController.java
View file @
49d725f8
...
@@ -4,12 +4,11 @@ import com.nisum.myteam.exception.handler.MyTeamException;
...
@@ -4,12 +4,11 @@ import com.nisum.myteam.exception.handler.MyTeamException;
import
com.nisum.myteam.model.ColumnChartData
;
import
com.nisum.myteam.model.ColumnChartData
;
import
com.nisum.myteam.model.GroupByCount
;
import
com.nisum.myteam.model.GroupByCount
;
import
com.nisum.myteam.model.ReportSeriesRecord
;
import
com.nisum.myteam.model.ReportSeriesRecord
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
Allocation
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IResource
Allocation
Service
;
import
com.nisum.myteam.service.IResourceService
;
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.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
@@ -47,7 +46,7 @@ public class ReportsController {
...
@@ -47,7 +46,7 @@ public class ReportsController {
private
IEmployeeService
employeeService
;
private
IEmployeeService
employeeService
;
@Autowired
@Autowired
private
IResource
Allocation
Service
resourceService
;
private
IResourceService
resourceService
;
//Ok Response
//Ok Response
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup1"
,
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup1"
,
...
@@ -132,7 +131,7 @@ public class ReportsController {
...
@@ -132,7 +131,7 @@ public class ReportsController {
// Convert the aggregation result into a List
// Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults = mongoTemplate.aggregate(aggregate, Resource
Allocation
.class,
AggregationResults<ColumnChartData> groupResults = mongoTemplate.aggregate(aggregate, Resource.class,
ColumnChartData.class);
ColumnChartData.class);
List<ColumnChartData> result = groupResults.getMappedResults();
List<ColumnChartData> result = groupResults.getMappedResults();
List<String> statusList = new ArrayList();
List<String> statusList = new ArrayList();
...
@@ -246,7 +245,7 @@ public class ReportsController {
...
@@ -246,7 +245,7 @@ public class ReportsController {
// Convert the aggregation result into a List
// Convert the aggregation result into a List
AggregationResults
<
ColumnChartData
>
groupResults1
=
mongoTemplate
AggregationResults
<
ColumnChartData
>
groupResults1
=
mongoTemplate
.
aggregate
(
agg1
,
Resource
Allocation
.
class
,
.
aggregate
(
agg1
,
Resource
.
class
,
ColumnChartData
.
class
);
ColumnChartData
.
class
);
List
<
ColumnChartData
>
result1
=
groupResults1
.
getMappedResults
();
List
<
ColumnChartData
>
result1
=
groupResults1
.
getMappedResults
();
...
@@ -341,11 +340,11 @@ public class ReportsController {
...
@@ -341,11 +340,11 @@ public class ReportsController {
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByDateBillability"
,
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByDateBillability"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Resource
Allocation
>>
fetchEmployeeDetailsByDateBillability
(
public
ResponseEntity
<
List
<
Resource
>>
fetchEmployeeDetailsByDateBillability
(
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
,
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
,
@RequestParam
(
"reportDate"
)
String
reportDateString
)
@RequestParam
(
"reportDate"
)
String
reportDateString
)
throws
MyTeamException
{
throws
MyTeamException
{
List
<
Resource
Allocation
>
empList
=
new
ArrayList
<>();
List
<
Resource
>
empList
=
new
ArrayList
<>();
if
(
reportDateString
!=
null
&&
!
reportDateString
.
isEmpty
())
{
if
(
reportDateString
!=
null
&&
!
reportDateString
.
isEmpty
())
{
String
pattern
=
"MM-dd-yyyy"
;
String
pattern
=
"MM-dd-yyyy"
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
pattern
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
pattern
);
...
@@ -368,7 +367,7 @@ public class ReportsController {
...
@@ -368,7 +367,7 @@ public class ReportsController {
criteriaV1
.
orOperator
(
criteriaV21
,
criteriaV22
));
criteriaV1
.
orOperator
(
criteriaV21
,
criteriaV22
));
Query
query
=
new
Query
();
Query
query
=
new
Query
();
query
.
addCriteria
(
criteriaV221
);
query
.
addCriteria
(
criteriaV221
);
empList
=
mongoTemplate
.
find
(
query
,
Resource
Allocation
.
class
);
empList
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
}
}
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
}
}
...
...
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
49d725f8
...
@@ -4,13 +4,13 @@ package com.nisum.myteam.controller;
...
@@ -4,13 +4,13 @@ package com.nisum.myteam.controller;
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.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
Allocation
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.repository.EmployeeVisaRepo
;
import
com.nisum.myteam.repository.EmployeeVisaRepo
;
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.service.impl.Resource
Allocation
Service
;
import
com.nisum.myteam.service.impl.ResourceService
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -27,7 +27,7 @@ import java.util.List;
...
@@ -27,7 +27,7 @@ import java.util.List;
@RestController
@RestController
@RequestMapping
@RequestMapping
@Slf4j
@Slf4j
public
class
Resource
Allocation
Controller
{
public
class
ResourceController
{
@Autowired
@Autowired
private
IEmployeeService
employeeService
;
private
IEmployeeService
employeeService
;
...
@@ -39,19 +39,19 @@ public class ResourceAllocationController {
...
@@ -39,19 +39,19 @@ public class ResourceAllocationController {
private
EmployeeVisaRepo
employeeVisaRepo
;
private
EmployeeVisaRepo
employeeVisaRepo
;
@Autowired
@Autowired
private
Resource
AllocationService
resourceAlloc
Service
;
private
Resource
Service
resource
Service
;
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createResource
(
@RequestBody
Resource
Allocation
resourceAllocationReq
,
public
ResponseEntity
<?>
createResource
(
@RequestBody
Resource
resourceAllocationReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
resourceAllocationReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
resourceAllocationReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
if
(
resource
Alloc
Service
.
validateBillingStartEndDateAgainstProjectStartEndDate
(
resourceAllocationReq
,
loginEmpId
))
{
if
(
resourceService
.
validateBillingStartEndDateAgainstProjectStartEndDate
(
resourceAllocationReq
,
loginEmpId
))
{
if
(
resource
Alloc
Service
.
validateBillingStartDateAgainstDOJ
(
resourceAllocationReq
))
{
if
(
resourceService
.
validateBillingStartDateAgainstDOJ
(
resourceAllocationReq
))
{
if
(!
resource
Alloc
Service
.
isResourceAssignedToAnyProject
(
resourceAllocationReq
))
{
if
(!
resourceService
.
isResourceAssignedToAnyProject
(
resourceAllocationReq
))
{
if
(!
resource
Alloc
Service
.
isResourceExistsForProject
(
resourceAllocationReq
.
getEmployeeId
(),
resourceAllocationReq
.
getProjectId
()))
{
if
(!
resourceService
.
isResourceExistsForProject
(
resourceAllocationReq
.
getEmployeeId
(),
resourceAllocationReq
.
getProjectId
()))
{
Resource
Allocation
resourcePersisted
=
resourceAllocService
.
addResourceAllocation
(
resourceAllocationReq
,
loginEmpId
);
Resource
resourcePersisted
=
resourceService
.
addResource
(
resourceAllocationReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
800
,
"Resource has been created"
,
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
800
,
"Resource has been created"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
...
@@ -61,7 +61,7 @@ public class ResourceAllocationController {
...
@@ -61,7 +61,7 @@ public class ResourceAllocationController {
}
}
}
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
Integer
.
parseInt
(
resource
AllocService
.
respMap
.
get
(
"statusCode"
).
toString
()),
resourceAlloc
Service
.
respMap
.
get
(
"message"
).
toString
(),
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
Integer
.
parseInt
(
resource
Service
.
respMap
.
get
(
"statusCode"
).
toString
()),
resource
Service
.
respMap
.
get
(
"message"
).
toString
(),
"Error message desc"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceAllocationReq
);
"Error message desc"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceAllocationReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
...
@@ -73,21 +73,21 @@ public class ResourceAllocationController {
...
@@ -73,21 +73,21 @@ public class ResourceAllocationController {
}
}
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
updateResource
(
@RequestBody
Resource
Allocation
resourceAllocationReq
,
public
ResponseEntity
<?>
updateResource
(
@RequestBody
Resource
resourceAllocationReq
,
@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
))
{
resourceAllocationReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
resourceAllocationReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
if
(
resource
Alloc
Service
.
isResourceExistsForProject
(
resourceAllocationReq
.
getEmployeeId
(),
resourceAllocationReq
.
getProjectId
()))
{
if
(
resourceService
.
isResourceExistsForProject
(
resourceAllocationReq
.
getEmployeeId
(),
resourceAllocationReq
.
getProjectId
()))
{
resource
Alloc
Service
.
updateResourceDetails
(
resourceAllocationReq
,
loginEmpId
);
resourceService
.
updateResourceDetails
(
resourceAllocationReq
,
loginEmpId
);
// resource
AllocService.insertNewResourceAlloc
WithNewStatus(resourceAllocationReq, loginEmpId);
// resource
Service.insertNewResource
WithNewStatus(resourceAllocationReq, loginEmpId);
}
}
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
Integer
.
parseInt
(
resource
Alloc
Service
.
respMap
.
get
(
"statusCode"
).
toString
()),
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
Integer
.
parseInt
(
resourceService
.
respMap
.
get
(
"statusCode"
).
toString
()),
resource
Alloc
Service
.
respMap
.
get
(
"message"
).
toString
(),
"Resource description"
,
null
,
request
.
getContextPath
(),
resourceService
.
respMap
.
get
(
"message"
).
toString
(),
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceAllocationReq
);
"Resource details"
,
resourceAllocationReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
}
...
@@ -97,10 +97,10 @@ public class ResourceAllocationController {
...
@@ -97,10 +97,10 @@ public class ResourceAllocationController {
}
}
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
deleteResource
(
@RequestBody
Resource
Allocation
resourceReq
,
public
ResponseEntity
<?>
deleteResource
(
@RequestBody
Resource
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
resource
Alloc
Service
.
deleteResource
(
resourceReq
,
loginEmpId
);
resourceService
.
deleteResource
(
resourceReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been deleted"
,
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been deleted"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceReq
);
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceReq
);
...
@@ -120,7 +120,7 @@ public class ResourceAllocationController {
...
@@ -120,7 +120,7 @@ public class ResourceAllocationController {
throws
MyTeamException
{
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
List
<
ResourceVO
>
resourcesList
=
resource
Alloc
Service
.
getResourcesForProject
(
projectId
,
status
);
List
<
ResourceVO
>
resourcesList
=
resourceService
.
getResourcesForProject
(
projectId
,
status
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for a project"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
"List of Resources for a project"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
...
@@ -137,7 +137,7 @@ public class ResourceAllocationController {
...
@@ -137,7 +137,7 @@ public class ResourceAllocationController {
if
(
employeeId
!=
null
&&
!
""
.
equalsIgnoreCase
(
employeeId
))
{
if
(
employeeId
!=
null
&&
!
""
.
equalsIgnoreCase
(
employeeId
))
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the project allocations successfully"
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the project allocations successfully"
,
"Projects allocations for an employee"
,
resource
Alloc
Service
.
getWorkedProjectsForResource
(
employeeId
),
request
.
getRequestURI
(),
"Project details"
,
null
);
"Projects allocations for an employee"
,
resourceService
.
getWorkedProjectsForResource
(
employeeId
),
request
.
getRequestURI
(),
"Project details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
...
@@ -154,7 +154,7 @@ public class ResourceAllocationController {
...
@@ -154,7 +154,7 @@ public class ResourceAllocationController {
@RequestMapping
(
value
=
"/resources/projects"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources/projects"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getResourcesAllocatedForAllProjects
(
HttpServletRequest
request
)
throws
MyTeamException
{
public
ResponseEntity
<?>
getResourcesAllocatedForAllProjects
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Resource
Allocation
>
resourcesList
=
resourceAlloc
Service
.
getAllResourcesForAllActiveProjects
();
List
<
Resource
>
resourcesList
=
resource
Service
.
getAllResourcesForAllActiveProjects
();
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for the projects"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
"List of Resources for the projects"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
...
@@ -168,7 +168,7 @@ public class ResourceAllocationController {
...
@@ -168,7 +168,7 @@ public class ResourceAllocationController {
throws
MyTeamException
{
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
List
<
Resource
Allocation
>
resourcesList
=
resourceAlloc
Service
.
getResourcesSortByBillingStartDate
(
employeeId
);
List
<
Resource
>
resourcesList
=
resource
Service
.
getResourcesSortByBillingStartDate
(
employeeId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
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
);
"List of Resources for an employee"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource List details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
...
@@ -185,7 +185,7 @@ public class ResourceAllocationController {
...
@@ -185,7 +185,7 @@ public class ResourceAllocationController {
public
ResponseEntity
<?>
getActiveResources
(
@RequestParam
(
value
=
"employeeId"
,
required
=
false
)
String
employeeId
,
HttpServletRequest
request
)
public
ResponseEntity
<?>
getActiveResources
(
@RequestParam
(
value
=
"employeeId"
,
required
=
false
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
List
<
ResourceVO
>
employeesRoles
=
resource
Alloc
Service
.
getActiveResources
(
employeeId
);
List
<
ResourceVO
>
employeesRoles
=
resourceService
.
getActiveResources
(
employeeId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
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
);
"List of Resources who are active in the projects"
,
employeesRoles
,
request
.
getRequestURI
(),
"Resource List details"
,
null
);
...
@@ -204,7 +204,7 @@ public class ResourceAllocationController {
...
@@ -204,7 +204,7 @@ public class ResourceAllocationController {
throws
MyTeamException
{
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
deliveryLeadId
))
{
if
(
StringUtils
.
isNotBlank
(
deliveryLeadId
))
{
List
<
Resource
Allocation
>
resourcesList
=
resourceAlloc
Service
.
getResourcesUnderDeliveryLead
(
deliveryLeadId
);
List
<
Resource
>
resourcesList
=
resource
Service
.
getResourcesUnderDeliveryLead
(
deliveryLeadId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for a Delivery Lead"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
"List of Resources for a Delivery Lead"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
...
@@ -219,7 +219,7 @@ public class ResourceAllocationController {
...
@@ -219,7 +219,7 @@ public class ResourceAllocationController {
@RequestMapping
(
value
=
"/resources/unAssignedEmployees"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources/unAssignedEmployees"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getUnAssignedEmployees
(
HttpServletRequest
request
)
throws
MyTeamException
{
public
ResponseEntity
<?>
getUnAssignedEmployees
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Employee
>
employeesList
=
resource
Alloc
Service
.
getUnAssignedEmployees
();
List
<
Employee
>
employeesList
=
resourceService
.
getUnAssignedEmployees
();
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
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
);
"List of Resources who are not assigned to project"
,
employeesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
...
@@ -230,14 +230,14 @@ public class ResourceAllocationController {
...
@@ -230,14 +230,14 @@ public class ResourceAllocationController {
@RequestMapping
(
value
=
"/resources/billing"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources/billing"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ResourceVO
>>
getAllBillingsForEmployee
(
@RequestParam
(
"employeeId"
)
String
employeeId
)
public
ResponseEntity
<
List
<
ResourceVO
>>
getAllBillingsForEmployee
(
@RequestParam
(
"employeeId"
)
String
employeeId
)
throws
MyTeamException
{
throws
MyTeamException
{
List
<
ResourceVO
>
resourceAllocList
=
resource
Alloc
Service
.
getBillingsForEmployee
(
employeeId
);
List
<
ResourceVO
>
resourceAllocList
=
resourceService
.
getBillingsForEmployee
(
employeeId
);
return
new
ResponseEntity
<>(
resourceAllocList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
resourceAllocList
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/resources/billing/project/{projectId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/resources/billing/project/{projectId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Resource
Allocation
>>
getBillingsForProject
(
@PathVariable
(
"projectId"
)
String
projectId
,
public
ResponseEntity
<
List
<
Resource
>>
getBillingsForProject
(
@PathVariable
(
"projectId"
)
String
projectId
,
@RequestParam
(
"employeeId"
)
String
employeeId
)
throws
MyTeamException
{
@RequestParam
(
"employeeId"
)
String
employeeId
)
throws
MyTeamException
{
List
<
Resource
Allocation
>
resourceAllocList
=
resourceAlloc
Service
.
getBillingsForProject
(
employeeId
,
projectId
);
List
<
Resource
>
resourceAllocList
=
resource
Service
.
getBillingsForProject
(
employeeId
,
projectId
);
return
new
ResponseEntity
<>(
resourceAllocList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
resourceAllocList
,
HttpStatus
.
OK
);
}
}
...
@@ -247,7 +247,7 @@ public class ResourceAllocationController {
...
@@ -247,7 +247,7 @@ public class ResourceAllocationController {
throws
MyTeamException
{
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
shift
))
{
if
(
StringUtils
.
isNotBlank
(
shift
))
{
List
<
EmployeeShiftsVO
>
resourcesList
=
resource
Alloc
Service
.
getResourcesForShift
(
shift
);
List
<
EmployeeShiftsVO
>
resourcesList
=
resourceService
.
getResourcesForShift
(
shift
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
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
);
"List of Resources for the provided shift"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource List for shift"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
...
...
src/main/java/com/nisum/myteam/model/dao/Resource.java
View file @
49d725f8
...
@@ -17,7 +17,7 @@ import java.util.Date;
...
@@ -17,7 +17,7 @@ import java.util.Date;
@NoArgsConstructor
@NoArgsConstructor
@ToString
@ToString
@Document
(
collection
=
"resourceAllocation"
)
@Document
(
collection
=
"resourceAllocation"
)
public
class
Resource
Allocation
extends
AuditFields
implements
Serializable
{
public
class
Resource
extends
AuditFields
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
src/main/java/com/nisum/myteam/repository/ResourceRepo.java
View file @
49d725f8
...
@@ -2,22 +2,21 @@ package com.nisum.myteam.repository;
...
@@ -2,22 +2,21 @@ package com.nisum.myteam.repository;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.ResourceAllocation
;
import
org.bson.types.ObjectId
;
import
org.bson.types.ObjectId
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
java.util.List
;
import
java.util.List
;
public
interface
Resource
Allocation
Repo
public
interface
ResourceRepo
extends
MongoRepository
<
Resource
Allocation
,
String
>
{
extends
MongoRepository
<
Resource
,
String
>
{
List
<
Resource
Allocation
>
findByProjectId
(
String
projectId
);
List
<
Resource
>
findByProjectId
(
String
projectId
);
List
<
Resource
Allocation
>
findByEmployeeId
(
String
employeeId
);
List
<
Resource
>
findByEmployeeId
(
String
employeeId
);
Resource
Allocation
findById
(
ObjectId
id
);
Resource
findById
(
ObjectId
id
);
List
<
Resource
Allocation
>
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
List
<
Resource
>
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
...
...
src/main/java/com/nisum/myteam/service/IProjectService.java
View file @
49d725f8
...
@@ -4,7 +4,7 @@ import com.nisum.myteam.exception.handler.MyTeamException;
...
@@ -4,7 +4,7 @@ import com.nisum.myteam.exception.handler.MyTeamException;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.EmpLoginData
;
import
com.nisum.myteam.model.dao.EmpLoginData
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Resource
Allocation
;
import
com.nisum.myteam.model.dao.Resource
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -58,7 +58,7 @@ public interface IProjectService {
...
@@ -58,7 +58,7 @@ public interface IProjectService {
public
List
<
Project
>
getProjectsForDeliveryLead
(
String
deliveryLeadId
);
public
List
<
Project
>
getProjectsForDeliveryLead
(
String
deliveryLeadId
);
List
<
Resource
Allocation
>
getResourcesUnderProject
(
String
empId
);
List
<
Resource
>
getResourcesUnderProject
(
String
empId
);
}
}
src/main/java/com/nisum/myteam/service/IResourceService.java
View file @
49d725f8
...
@@ -2,40 +2,40 @@ package com.nisum.myteam.service;
...
@@ -2,40 +2,40 @@ package com.nisum.myteam.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
Allocation
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
java.util.List
;
import
java.util.List
;
public
interface
IResource
Allocation
Service
{
public
interface
IResourceService
{
Resource
Allocation
addResourceAllocation
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
Resource
addResource
(
Resource
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
public
void
updateExistedResource
Alloc
(
ResourceAllocation
resourceAlloc
)
throws
MyTeamException
;
public
void
updateExistedResource
(
Resource
resourceAlloc
)
throws
MyTeamException
;
public
void
insertNewResource
AllocWithNewStatus
(
ResourceAllocation
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
;
public
void
insertNewResource
WithNewStatus
(
Resource
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
;
void
deleteResource
(
Resource
Allocation
resource
,
String
loginEmpId
);
void
deleteResource
(
Resource
resource
,
String
loginEmpId
);
List
<
Resource
Allocation
>
getAllResourcesForAllActiveProjects
();
List
<
Resource
>
getAllResourcesForAllActiveProjects
();
List
<
Resource
Allocation
>
getResourcesSortByBillingStartDate
(
String
employeeId
);
List
<
Resource
>
getResourcesSortByBillingStartDate
(
String
employeeId
);
List
<
ResourceVO
>
getActiveResources
(
String
empId
);
List
<
ResourceVO
>
getActiveResources
(
String
empId
);
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
);
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
);
public
List
<
Resource
Allocation
>
getResourcesUnderDeliveryLead
(
String
empId
);
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
empId
);
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
);
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
);
public
List
<
Resource
Allocation
>
getBillingsForProject
(
String
empId
,
String
projectId
);
public
List
<
Resource
>
getBillingsForProject
(
String
empId
,
String
projectId
);
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
);
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
);
...
@@ -43,13 +43,13 @@ public interface IResourceAllocationService {
...
@@ -43,13 +43,13 @@ public interface IResourceAllocationService {
public
List
<
Employee
>
getUnAssignedEmployees
();
public
List
<
Employee
>
getUnAssignedEmployees
();
public
List
<
Resource
Allocation
>
getAllResources
();
public
List
<
Resource
>
getAllResources
();
public
List
<
ResourceVO
>
getAllResourcesVO
();
public
List
<
ResourceVO
>
getAllResourcesVO
();
public
void
deleteResourcesUnderProject
(
String
projectId
);
public
void
deleteResourcesUnderProject
(
String
projectId
);
public
Resource
Allocation
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
;
public
Resource
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
;
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
);
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
);
...
...
src/main/java/com/nisum/myteam/service/impl/DashboardService.java
View file @
49d725f8
...
@@ -2,13 +2,12 @@ package com.nisum.myteam.service.impl;
...
@@ -2,13 +2,12 @@ package com.nisum.myteam.service.impl;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.ResourceAllocation
;
import
com.nisum.myteam.model.vo.EmployeeDashboardVO
;
import
com.nisum.myteam.model.vo.EmployeeDashboardVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.service.IDashboardService
;
import
com.nisum.myteam.service.IDashboardService
;
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.service.IResource
Allocation
Service
;
import
com.nisum.myteam.service.IResourceService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -24,7 +23,7 @@ public class DashboardService implements IDashboardService {
...
@@ -24,7 +23,7 @@ public class DashboardService implements IDashboardService {
private
IEmployeeService
employeeService
;
private
IEmployeeService
employeeService
;
@Autowired
@Autowired
private
IResource
Allocation
Service
resourceService
;
private
IResourceService
resourceService
;
@Autowired
@Autowired
private
IProjectService
projectService
;
private
IProjectService
projectService
;
...
@@ -39,7 +38,7 @@ public class DashboardService implements IDashboardService {
...
@@ -39,7 +38,7 @@ public class DashboardService implements IDashboardService {
Map
<
String
,
Object
>
teamMatesStatusMap
=
new
HashMap
();
Map
<
String
,
Object
>
teamMatesStatusMap
=
new
HashMap
();
// Find all active employees
// Find all active employees
//List<Resource
Allocation
> resources = resourceService.getAllResources();
//List<Resource> resources = resourceService.getAllResources();
List
<
ResourceVO
>
resources
=
resourceService
.
getAllResourcesVO
();
List
<
ResourceVO
>
resources
=
resourceService
.
getAllResourcesVO
();
...
...
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
49d725f8
...
@@ -49,7 +49,7 @@ public class EmployeeService implements IEmployeeService {
...
@@ -49,7 +49,7 @@ public class EmployeeService implements IEmployeeService {
private
IEmployeeLocationService
empLocationService
;
private
IEmployeeLocationService
empLocationService
;
@Autowired
@Autowired
private
IResource
Allocation
Service
resourceService
;
private
IResourceService
resourceService
;
@Override
@Override
public
Employee
createEmployee
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
public
Employee
createEmployee
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
...
...
src/main/java/com/nisum/myteam/service/impl/ProjectService.java
View file @
49d725f8
...
@@ -40,7 +40,7 @@ public class ProjectService implements IProjectService {
...
@@ -40,7 +40,7 @@ public class ProjectService implements IProjectService {
private
IDomainService
domainService
;
private
IDomainService
domainService
;
@Autowired
@Autowired
private
Resource
AllocationService
resourceAlloc
Service
;
private
Resource
Service
resource
Service
;
@Autowired
@Autowired
private
IEmployeeService
employeeService
;
private
IEmployeeService
employeeService
;
...
@@ -130,7 +130,7 @@ public class ProjectService implements IProjectService {
...
@@ -130,7 +130,7 @@ public class ProjectService implements IProjectService {
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
projectRepo
.
delete
(
project
);
projectRepo
.
delete
(
project
);
resource
Alloc
Service
.
deleteResourcesUnderProject
(
projectId
);
resourceService
.
deleteResourcesUnderProject
(
projectId
);
}
}
...
@@ -198,19 +198,19 @@ public class ProjectService implements IProjectService {
...
@@ -198,19 +198,19 @@ public class ProjectService implements IProjectService {
}
}
@Override
@Override
public
List
<
Resource
Allocation
>
getResourcesUnderProject
(
String
empId
)
{
public
List
<
Resource
>
getResourcesUnderProject
(
String
empId
)
{
List
<
String
>
projectsIdsList
=
new
ArrayList
<>();
List
<
String
>
projectsIdsList
=
new
ArrayList
<>();
List
<
Resource
Allocation
>
resourcesList
=
new
ArrayList
<>();
List
<
Resource
>
resourcesList
=
new
ArrayList
<>();
List
<
Project
>
projectsList
=
projectRepo
.
findByDeliveryLeadIds
(
empId
);
List
<
Project
>
projectsList
=
projectRepo
.
findByDeliveryLeadIds
(
empId
);
for
(
Project
project
:
projectsList
)
for
(
Project
project
:
projectsList
)
projectsIdsList
.
add
(
project
.
getProjectId
());
projectsIdsList
.
add
(
project
.
getProjectId
());
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectsIdsList
));
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectsIdsList
));
List
<
Resource
Allocation
>
resourcesListPersisted
=
mongoTemplate
.
find
(
query
,
ResourceAllocation
.
class
);
List
<
Resource
>
resourcesListPersisted
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
for
(
Resource
Allocation
resource
:
resourcesListPersisted
)
{
for
(
Resource
resource
:
resourcesListPersisted
)
{
if
(!
resource
.
getEmployeeId
().
equals
(
empId
))
if
(!
resource
.
getEmployeeId
().
equals
(
empId
))
resourcesList
.
add
(
resource
);
resourcesList
.
add
(
resource
);
}
}
...
@@ -247,7 +247,7 @@ public class ProjectService implements IProjectService {
...
@@ -247,7 +247,7 @@ public class ProjectService implements IProjectService {
}
}
private
String
validateAgainstDOJ
(
Resource
Allocation
resource
)
{
private
String
validateAgainstDOJ
(
Resource
resource
)
{
String
response
=
null
;
String
response
=
null
;
Date
empDoj
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getDateOfJoining
();
Date
empDoj
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getDateOfJoining
();
if
(
resource
.
getBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
if
(
resource
.
getBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
...
@@ -405,7 +405,7 @@ public class ProjectService implements IProjectService {
...
@@ -405,7 +405,7 @@ public class ProjectService implements IProjectService {
// public Resource addNewBeanchAllocation(Employee employee, String loginEmpId) {
// public Resource addNewBeanchAllocation(Employee employee, String loginEmpId) {
// Resource
Allocation
resourcePersisted = null;
// Resource resourcePersisted = null;
// Resource resourceBench = new Resource();
// Resource resourceBench = new Resource();
// resourceBench.setAccount(MyTeamUtils.BENCH_ACCOUNT);
// resourceBench.setAccount(MyTeamUtils.BENCH_ACCOUNT);
// resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
// resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
...
...
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
49d725f8
...
@@ -5,7 +5,7 @@ import com.nisum.myteam.model.dao.*;
...
@@ -5,7 +5,7 @@ import com.nisum.myteam.model.dao.*;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.repository.Resource
Allocation
Repo
;
import
com.nisum.myteam.repository.ResourceRepo
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
...
@@ -24,13 +24,13 @@ import java.util.stream.Collectors;
...
@@ -24,13 +24,13 @@ import java.util.stream.Collectors;
@Service
@Service
@Slf4j
@Slf4j
public
class
Resource
AllocationService
implements
IResourceAllocation
Service
{
public
class
Resource
Service
implements
IResource
Service
{
@Autowired
@Autowired
private
MongoTemplate
mongoTemplate
;
private
MongoTemplate
mongoTemplate
;
@Autowired
@Autowired
private
Resource
AllocationRepo
resourceAllocation
Repo
;
private
Resource
Repo
resource
Repo
;
@Autowired
@Autowired
private
IAccountService
accountService
;
private
IAccountService
accountService
;
...
@@ -50,15 +50,15 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -50,15 +50,15 @@ public class ResourceAllocationService implements IResourceAllocationService {
public
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
public
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
public
Resource
Allocation
addResourceAllocation
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
{
public
Resource
addResource
(
Resource
resource
,
String
loginEmpId
)
throws
MyTeamException
{
return
resource
AllocationRepo
.
save
(
resourceAllocation
);
return
resource
Repo
.
save
(
resource
);
}
}
public
boolean
isResourceExistsForProject
(
String
employeeId
,
String
projectId
)
{
public
boolean
isResourceExistsForProject
(
String
employeeId
,
String
projectId
)
{
boolean
isExists
=
false
;
boolean
isExists
=
false
;
List
<
Resource
Allocation
>
resourceList
=
resourceAllocation
Repo
.
findByEmployeeIdAndProjectId
(
employeeId
,
projectId
);
List
<
Resource
>
resourceList
=
resource
Repo
.
findByEmployeeIdAndProjectId
(
employeeId
,
projectId
);
if
(
resourceList
!=
null
&&
resourceList
.
size
()
>
0
)
{
if
(
resourceList
!=
null
&&
resourceList
.
size
()
>
0
)
{
isExists
=
true
;
isExists
=
true
;
respMap
.
put
(
"message"
,
"Resourse is already in the project"
);
respMap
.
put
(
"message"
,
"Resourse is already in the project"
);
...
@@ -72,40 +72,40 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -72,40 +72,40 @@ public class ResourceAllocationService implements IResourceAllocationService {
public
void
updateResourceDetails
(
Resource
Allocation
resourceAlloc
Req
,
String
loginEmpId
)
throws
MyTeamException
{
public
void
updateResourceDetails
(
Resource
resource
Req
,
String
loginEmpId
)
throws
MyTeamException
{
List
<
Resource
Allocation
>
resourceAllocList
=
resourceAllocationRepo
.
findByEmployeeIdAndProjectId
(
resourceAllocReq
.
getEmployeeId
(),
resourceAlloc
Req
.
getProjectId
());
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resource
Req
.
getProjectId
());
List
<
Resource
Allocation
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
List
<
Resource
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
Resource
Allocation
resourceAlloc
Prev
=
resourceListWithLatestRecord
.
get
(
0
);
//latest resource record.
Resource
resource
Prev
=
resourceListWithLatestRecord
.
get
(
0
);
//latest resource record.
log
.
info
(
"Requsting Resource Allocation BillingStart Date::::"
+
resource
Alloc
Req
.
getBillingStartDate
());
log
.
info
(
"Requsting Resource Allocation BillingStart Date::::"
+
resourceReq
.
getBillingStartDate
());
log
.
info
(
"The before date is::"
+
MyTeamDateUtils
.
getDayLessThanDate
(
resource
Alloc
Req
.
getBillingStartDate
()));
log
.
info
(
"The before date is::"
+
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
if
(!
resource
AllocPrev
.
getBillableStatus
().
equals
(
resourceAlloc
Req
.
getBillableStatus
()))
{
if
(!
resource
Prev
.
getBillableStatus
().
equals
(
resource
Req
.
getBillableStatus
()))
{
if
(
resource
Alloc
Prev
.
getBillingEndDate
().
compareTo
(
new
Date
())
==
0
)
{
if
(
resourcePrev
.
getBillingEndDate
().
compareTo
(
new
Date
())
==
0
)
{
resource
Alloc
Prev
.
setBillingEndDate
(
new
Date
());
resourcePrev
.
setBillingEndDate
(
new
Date
());
}
else
{
}
else
{
resource
AllocPrev
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceAlloc
Req
.
getBillingStartDate
()));
//adding resource.
resource
Prev
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resource
Req
.
getBillingStartDate
()));
//adding resource.
}
}
insertNewResource
AllocWithNewStatus
(
resourceAlloc
Req
,
loginEmpId
);
insertNewResource
WithNewStatus
(
resource
Req
,
loginEmpId
);
}
else
{
}
else
{
resource
AllocPrev
.
setResourceRole
(
resourceAlloc
Req
.
getResourceRole
());
resource
Prev
.
setResourceRole
(
resource
Req
.
getResourceRole
());
resource
AllocPrev
.
setBillingStartDate
(
resourceAlloc
Req
.
getBillingStartDate
());
resource
Prev
.
setBillingStartDate
(
resource
Req
.
getBillingStartDate
());
resource
AllocPrev
.
setBillingEndDate
(
resourceAlloc
Req
.
getBillingEndDate
());
resource
Prev
.
setBillingEndDate
(
resource
Req
.
getBillingEndDate
());
//resourceAllocPrev.setBillingEndDate(); //adding resource.
//resourceAllocPrev.setBillingEndDate(); //adding resource.
}
}
log
.
info
(
"After setting the date:::before saving the Resource::"
+
resource
Alloc
Prev
);
log
.
info
(
"After setting the date:::before saving the Resource::"
+
resourcePrev
);
this
.
updateExistedResource
Alloc
(
resourceAlloc
Prev
);
this
.
updateExistedResource
(
resource
Prev
);
}
}
}
}
public
void
updateExistedResource
Alloc
(
ResourceAllocation
resourceAlloc
)
{
public
void
updateExistedResource
(
Resource
resource
)
{
if
(
resource
Alloc
!=
null
)
{
if
(
resource
!=
null
)
{
Resource
Allocation
resourcePers
=
resourceAllocationRepo
.
save
(
resourceAlloc
);
Resource
resourcePers
=
resourceRepo
.
save
(
resource
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"resourceObj"
,
resourcePers
);
respMap
.
put
(
"resourceObj"
,
resourcePers
);
...
@@ -114,53 +114,53 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -114,53 +114,53 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
}
public
void
insertNewResource
AllocWithNewStatus
(
ResourceAllocation
resourceAlloc
Req
,
String
loginEmpId
)
throws
MyTeamException
{
public
void
insertNewResource
WithNewStatus
(
Resource
resource
Req
,
String
loginEmpId
)
throws
MyTeamException
{
resource
Alloc
Req
.
setId
(
null
);
resourceReq
.
setId
(
null
);
Resource
Allocation
resourceAllocationPers
=
resourceAllocationRepo
.
insert
(
resourceAlloc
Req
);
Resource
resourcePers
=
resourceRepo
.
insert
(
resource
Req
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"resourceObj"
,
resource
Allocation
Pers
);
respMap
.
put
(
"resourceObj"
,
resourcePers
);
}
}
public
boolean
validateBillingStartEndDateAgainstProjectStartEndDate
(
Resource
Allocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
{
public
boolean
validateBillingStartEndDateAgainstProjectStartEndDate
(
Resource
resource
,
String
loginEmpId
)
throws
MyTeamException
{
boolean
isValid
=
true
;
boolean
isValid
=
true
;
Project
project
=
projectService
.
getProjectByProjectId
(
resource
Allocation
.
getProjectId
());
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
log
.
info
(
"Project::"
+
project
);
log
.
info
(
"Project::"
+
project
);
if
(!
resource
Allocation
.
getBillingStartDate
().
after
(
project
.
getProjectStartDate
()))
{
if
(!
resource
.
getBillingStartDate
().
after
(
project
.
getProjectStartDate
()))
{
log
.
info
(
"Billing start date should be after Project start date"
);
log
.
info
(
"Billing start date should be after Project start date"
);
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"message"
,
"Billing start date should be after Project start date"
);
respMap
.
put
(
"message"
,
"Billing start date should be after Project start date"
);
isValid
=
false
;
isValid
=
false
;
}
}
if
(!
resource
Allocation
.
getBillingStartDate
().
before
(
resourceAllocation
.
getBillingEndDate
()))
{
if
(!
resource
.
getBillingStartDate
().
before
(
resource
.
getBillingEndDate
()))
{
log
.
info
(
"Billing start date should be before Billing End Date."
);
log
.
info
(
"Billing start date should be before Billing End Date."
);
respMap
.
put
(
"statusCode"
,
812
);
respMap
.
put
(
"statusCode"
,
812
);
respMap
.
put
(
"message"
,
"Billing start date should be before Billing End Date."
);
respMap
.
put
(
"message"
,
"Billing start date should be before Billing End Date."
);
isValid
=
false
;
isValid
=
false
;
}
}
log
.
info
(
"ResourceALloc Req::"
+
resource
Allocation
);
log
.
info
(
"ResourceALloc Req::"
+
resource
);
log
.
info
(
""
+
project
.
getProjectEndDate
().
toString
());
log
.
info
(
""
+
project
.
getProjectEndDate
().
toString
());
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
if
(!(
resource
Allocation
.
getBillingEndDate
().
compareTo
(
project
.
getProjectEndDate
())<=
0
))
{
if
(!(
resource
.
getBillingEndDate
().
compareTo
(
project
.
getProjectEndDate
())<=
0
))
{
log
.
info
(
"Billing end date should be on or before Project End Date."
);
log
.
info
(
"Billing end date should be on or before Project End Date."
);
respMap
.
put
(
"statusCode"
,
813
);
respMap
.
put
(
"statusCode"
,
813
);
respMap
.
put
(
"message"
,
"Billing end date should be before Project End Date."
);
respMap
.
put
(
"message"
,
"Billing end date should be before Project End Date."
);
isValid
=
false
;
isValid
=
false
;
}
}
respMap
.
put
(
"resourceObj"
,
resource
Allocation
);
respMap
.
put
(
"resourceObj"
,
resource
);
return
isValid
;
return
isValid
;
}
}
public
boolean
validateBillingStartDateAgainstDOJ
(
Resource
Allocation
resource
)
{
public
boolean
validateBillingStartDateAgainstDOJ
(
Resource
resource
)
{
String
message
=
""
;
String
message
=
""
;
boolean
isValid
=
true
;
boolean
isValid
=
true
;
...
@@ -178,22 +178,22 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -178,22 +178,22 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
}
public
boolean
isResourceAssignedToAnyProject
(
Resource
Allocation
resourceAlloc
Req
)
{
public
boolean
isResourceAssignedToAnyProject
(
Resource
resource
Req
)
{
boolean
isAssigned
=
false
;
boolean
isAssigned
=
false
;
String
message
=
""
;
String
message
=
""
;
//List<Resource
Allocation> resourceAllocList = resourceAllocation
Repo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
//List<Resource
> resourceAllocList = resource
Repo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
List
<
Resource
Allocation
>
resourceAllocList
=
resourceAllocationRepo
.
findByEmployeeId
(
resourceAlloc
Req
.
getEmployeeId
());
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeId
(
resource
Req
.
getEmployeeId
());
List
<
Resource
Allocation
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
List
<
Resource
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
Resource
Allocation
resourceAlloc
Prev
=
resourceListWithLatestRecord
.
get
(
0
);
//latest resource record.
Resource
resource
Prev
=
resourceListWithLatestRecord
.
get
(
0
);
//latest resource record.
if
(!
resource
Alloc
Prev
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
))
{
if
(!
resourcePrev
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
))
{
message
=
"Resource "
+
resource
Alloc
Prev
.
getEmployeeId
()
+
" already Assigned to the "
message
=
"Resource "
+
resourcePrev
.
getEmployeeId
()
+
" already Assigned to the "
+
projectService
.
getProjectByProjectId
(
resource
Alloc
Prev
.
getProjectId
()).
getProjectName
()
+
projectService
.
getProjectByProjectId
(
resourcePrev
.
getProjectId
()).
getProjectName
()
+
" Project"
+
" from "
+
resource
AllocPrev
.
getBillingStartDate
()
+
"to "
+
resourceAlloc
Prev
.
getBillingEndDate
();
+
" Project"
+
" from "
+
resource
Prev
.
getBillingStartDate
()
+
"to "
+
resource
Prev
.
getBillingEndDate
();
isAssigned
=
true
;
isAssigned
=
true
;
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"message"
,
message
);
respMap
.
put
(
"message"
,
message
);
...
@@ -207,15 +207,15 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -207,15 +207,15 @@ public class ResourceAllocationService implements IResourceAllocationService {
public
void
deleteResource
(
Resource
Allocation
resourceReq
,
String
loginEmpId
)
{
public
void
deleteResource
(
Resource
resourceReq
,
String
loginEmpId
)
{
List
<
Resource
Allocation
>
resourcesList
=
resourceAllocation
Repo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
List
<
Resource
>
resourcesList
=
resource
Repo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
resourcesList
.
forEach
(
resource
->
resource
Allocation
Repo
.
delete
(
resource
));
resourcesList
.
forEach
(
resource
->
resourceRepo
.
delete
(
resource
));
}
}
@Override
@Override
public
List
<
Resource
Allocation
>
getAllResources
()
{
public
List
<
Resource
>
getAllResources
()
{
return
resource
Allocation
Repo
.
findAll
();
return
resourceRepo
.
findAll
();
}
}
...
@@ -267,9 +267,9 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -267,9 +267,9 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
}
public
List
<
Resource
Allocation
>
getResourcesSortByBillingStartDate
(
String
employeeId
)
{
public
List
<
Resource
>
getResourcesSortByBillingStartDate
(
String
employeeId
)
{
Query
query
=
prepareQuery
(
employeeId
,
MyTeamUtils
.
BILLING_START_DATE
);
Query
query
=
prepareQuery
(
employeeId
,
MyTeamUtils
.
BILLING_START_DATE
);
return
mongoTemplate
.
find
(
query
,
Resource
Allocation
.
class
);
return
mongoTemplate
.
find
(
query
,
Resource
.
class
);
}
}
private
Query
prepareQuery
(
String
employeeId
,
String
dateColumn
)
{
private
Query
prepareQuery
(
String
employeeId
,
String
dateColumn
)
{
...
@@ -283,7 +283,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -283,7 +283,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override
@Override
public
List
<
ResourceVO
>
getActiveResources
(
String
empId
)
{
public
List
<
ResourceVO
>
getActiveResources
(
String
empId
)
{
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
for
(
Resource
Allocation
resource
:
resourceAllocation
Repo
.
findByEmployeeId
(
empId
))
{
for
(
Resource
resource
:
resource
Repo
.
findByEmployeeId
(
empId
))
{
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
resourcesList
.
addAll
(
prepareProjectTeamMembersList
(
resource
.
getProjectId
()));
resourcesList
.
addAll
(
prepareProjectTeamMembersList
(
resource
.
getProjectId
()));
}
}
...
@@ -296,7 +296,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -296,7 +296,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
List
<
ResourceVO
>
finalResourcesList
=
new
ArrayList
<>();
List
<
ResourceVO
>
finalResourcesList
=
new
ArrayList
<>();
Employee
employee
=
null
;
Employee
employee
=
null
;
for
(
Resource
Allocation
resource
:
getAllResourcesForProject
(
projectId
))
{
for
(
Resource
resource
:
getAllResourcesForProject
(
projectId
))
{
ResourceVO
resourceVO
=
new
ResourceVO
();
ResourceVO
resourceVO
=
new
ResourceVO
();
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setId
(
resource
.
getId
());
...
@@ -328,14 +328,14 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -328,14 +328,14 @@ public class ResourceAllocationService implements IResourceAllocationService {
return
finalResourcesList
;
return
finalResourcesList
;
}
}
public
List
<
Resource
Allocation
>
getAllResourcesForProject
(
String
projectId
)
{
public
List
<
Resource
>
getAllResourcesForProject
(
String
projectId
)
{
return
resource
Allocation
Repo
.
findByProjectId
(
projectId
);
return
resourceRepo
.
findByProjectId
(
projectId
);
}
}
@Override
@Override
public
List
<
Resource
Allocation
>
getAllResourcesForAllActiveProjects
()
{
public
List
<
Resource
>
getAllResourcesForAllActiveProjects
()
{
List
<
Resource
Allocation
>
resourceList
=
new
ArrayList
<>();
List
<
Resource
>
resourceList
=
new
ArrayList
<>();
for
(
Project
activeProject
:
projectService
.
getOnlyActiveProjects
())
{
for
(
Project
activeProject
:
projectService
.
getOnlyActiveProjects
())
{
resourceList
.
addAll
(
getAllResourcesForProject
(
activeProject
.
getProjectId
()));
resourceList
.
addAll
(
getAllResourcesForProject
(
activeProject
.
getProjectId
()));
...
@@ -349,7 +349,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -349,7 +349,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
)
{
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
)
{
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
for
(
Resource
Allocation
resource
:
resourceAllocation
Repo
.
findByProjectId
(
projectId
))
{
for
(
Resource
resource
:
resource
Repo
.
findByProjectId
(
projectId
))
{
Date
billingEndDate
=
resource
.
getBillingEndDate
();
Date
billingEndDate
=
resource
.
getBillingEndDate
();
if
(
billingEndDate
!=
null
)
{
if
(
billingEndDate
!=
null
)
{
...
@@ -395,10 +395,10 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -395,10 +395,10 @@ public class ResourceAllocationService implements IResourceAllocationService {
Employee
employee
=
null
;
Employee
employee
=
null
;
List
<
MyProjectAllocationVO
>
myProjectList
=
new
ArrayList
<>();
List
<
MyProjectAllocationVO
>
myProjectList
=
new
ArrayList
<>();
List
<
Resource
Allocation
>
resourcesAllocatedList
=
resourceAllocation
Repo
.
findByEmployeeId
(
empId
);
List
<
Resource
>
resourcesAllocatedList
=
resource
Repo
.
findByEmployeeId
(
empId
);
if
(
null
!=
resourcesAllocatedList
&&
!
resourcesAllocatedList
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
resourcesAllocatedList
.
size
())
{
if
(
null
!=
resourcesAllocatedList
&&
!
resourcesAllocatedList
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
resourcesAllocatedList
.
size
())
{
for
(
Resource
Allocation
resourceAlloc
:
resourcesAllocatedList
)
{
for
(
Resource
resourceAlloc
:
resourcesAllocatedList
)
{
project
=
projectService
.
getProjectByProjectId
(
resourceAlloc
.
getProjectId
());
project
=
projectService
.
getProjectByProjectId
(
resourceAlloc
.
getProjectId
());
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
...
@@ -434,17 +434,17 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -434,17 +434,17 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override
@Override
public
List
<
Resource
Allocation
>
getResourcesUnderDeliveryLead
(
String
deliveryLeadId
)
{
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
deliveryLeadId
)
{
List
<
String
>
projectIdsList
=
new
ArrayList
<>();
List
<
String
>
projectIdsList
=
new
ArrayList
<>();
List
<
Resource
Allocation
>
resourcesList
=
new
ArrayList
<>();
List
<
Resource
>
resourcesList
=
new
ArrayList
<>();
for
(
Project
project
:
projectService
.
getProjectsForDeliveryLead
(
deliveryLeadId
))
for
(
Project
project
:
projectService
.
getProjectsForDeliveryLead
(
deliveryLeadId
))
projectIdsList
.
add
(
project
.
getProjectId
());
projectIdsList
.
add
(
project
.
getProjectId
());
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectIdsList
));
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectIdsList
));
List
<
Resource
Allocation
>
resourcesListPersisted
=
mongoTemplate
.
find
(
query
,
ResourceAllocation
.
class
);
List
<
Resource
>
resourcesListPersisted
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
for
(
Resource
Allocation
resourceAlloc
:
resourcesListPersisted
)
{
for
(
Resource
resourceAlloc
:
resourcesListPersisted
)
{
if
(!
resourceAlloc
.
getEmployeeId
().
equals
(
deliveryLeadId
))
if
(!
resourceAlloc
.
getEmployeeId
().
equals
(
deliveryLeadId
))
resourcesList
.
add
(
resourceAlloc
);
resourcesList
.
add
(
resourceAlloc
);
}
}
...
@@ -456,11 +456,11 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -456,11 +456,11 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override
@Override
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
)
{
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
)
{
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
List
<
Resource
Allocation
>
resourcesList
=
resourceAllocation
Repo
.
findByEmployeeId
(
empId
);
List
<
Resource
>
resourcesList
=
resource
Repo
.
findByEmployeeId
(
empId
);
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
log
.
info
(
"The resources billing list before sorting::"
+
resourcesList
);
log
.
info
(
"The resources billing list before sorting::"
+
resourcesList
);
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List
<
Resource
Allocation
>
sortedList
=
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
ResourceAllocation
:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
List
<
Resource
>
sortedList
=
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
Resource
:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
finalList
=
convertResourcesToResourcesVO
(
sortedList
);
finalList
=
convertResourcesToResourcesVO
(
sortedList
);
}
}
...
@@ -468,14 +468,14 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -468,14 +468,14 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
}
@Override
@Override
public
List
<
Resource
Allocation
>
getBillingsForProject
(
String
empId
,
String
projectId
)
{
public
List
<
Resource
>
getBillingsForProject
(
String
empId
,
String
projectId
)
{
List
<
Resource
Allocation
>
resourcesList
=
resourceAllocation
Repo
.
findByEmployeeIdAndProjectId
(
empId
,
projectId
);
List
<
Resource
>
resourcesList
=
resource
Repo
.
findByEmployeeIdAndProjectId
(
empId
,
projectId
);
if
(
resourcesList
==
null
||
resourcesList
.
size
()
==
0
)
{
if
(
resourcesList
==
null
||
resourcesList
.
size
()
==
0
)
{
return
resourcesList
;
return
resourcesList
;
}
else
{
}
else
{
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
Resource
Allocation
:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
return
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
Resource:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
}
}
}
}
...
@@ -487,7 +487,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -487,7 +487,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
List
<
Employee
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
Employee
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
String
>
resourceIdsList
=
new
ArrayList
<>();
List
<
String
>
resourceIdsList
=
new
ArrayList
<>();
for
(
Resource
Allocation
resource
:
this
.
getAllResources
())
{
for
(
Resource
resource
:
this
.
getAllResources
())
{
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
&&
project
.
getStatus
()
!=
null
&&
!
"Completed"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
if
(
project
!=
null
&&
project
.
getStatus
()
!=
null
&&
!
"Completed"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
resourceIdsList
.
add
(
resource
.
getEmployeeId
());
resourceIdsList
.
add
(
resource
.
getEmployeeId
());
...
@@ -505,13 +505,13 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -505,13 +505,13 @@ public class ResourceAllocationService implements IResourceAllocationService {
public
void
deleteResourcesUnderProject
(
String
projectId
)
{
public
void
deleteResourcesUnderProject
(
String
projectId
)
{
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
List
<
Resource
Allocation
>
list
=
mongoTemplate
.
find
(
query
,
ResourceAllocation
.
class
);
List
<
Resource
>
list
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
resource
Allocation
Repo
.
delete
(
list
);
resourceRepo
.
delete
(
list
);
}
}
private
List
<
ResourceVO
>
convertResourcesToResourcesVO
(
List
<
Resource
Allocation
>
resourcesList
)
{
private
List
<
ResourceVO
>
convertResourcesToResourcesVO
(
List
<
Resource
>
resourcesList
)
{
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
...
@@ -565,10 +565,10 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -565,10 +565,10 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override
@Override
public
Resource
Allocation
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
public
Resource
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
Resource
Allocation
resourcePersisted
=
null
;
Resource
resourcePersisted
=
null
;
Resource
Allocation
resourceBench
=
new
ResourceAllocation
();
Resource
resourceBench
=
new
Resource
();
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setResourceRole
(
employee
.
getRole
());
resourceBench
.
setResourceRole
(
employee
.
getRole
());
...
@@ -576,7 +576,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -576,7 +576,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setBillingEndDate
(
employee
.
getEndDate
());
resourceBench
.
setBillingEndDate
(
employee
.
getEndDate
());
resourcePersisted
=
addResource
Allocation
(
resourceBench
,
loginEmpId
);
resourcePersisted
=
addResource
(
resourceBench
,
loginEmpId
);
return
resourcePersisted
;
return
resourcePersisted
;
...
@@ -585,7 +585,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -585,7 +585,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override
@Override
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
)
{
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
)
{
List
<
Resource
Allocation
>
resourcesListPers
=
null
;
List
<
Resource
>
resourcesListPers
=
null
;
List
<
EmployeeShiftsVO
>
resourcesList
=
new
ArrayList
<>();
List
<
EmployeeShiftsVO
>
resourcesList
=
new
ArrayList
<>();
List
<
Project
>
projects
=
projectService
.
getAllProjects
();
List
<
Project
>
projects
=
projectService
.
getAllProjects
();
...
@@ -593,7 +593,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -593,7 +593,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
if
(
"Active"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
if
(
"Active"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
resourcesListPers
=
getAllResourcesForProject
(
project
.
getProjectId
());
resourcesListPers
=
getAllResourcesForProject
(
project
.
getProjectId
());
for
(
Resource
Allocation
resource
:
resourcesListPers
)
{
for
(
Resource
resource
:
resourcesListPers
)
{
// EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId());
// EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId());
// if (empShift != null) {
// if (empShift != null) {
...
@@ -643,17 +643,17 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -643,17 +643,17 @@ public class ResourceAllocationService implements IResourceAllocationService {
// public List<ResourceVO> getActiveResources(String empId) {
// public List<ResourceVO> getActiveResources(String empId) {
// List<ResourceVO> finalResourcesList = new ArrayList<>();
// List<ResourceVO> finalResourcesList = new ArrayList<>();
//
//
// List<Resource
Allocation> resourceList = resourceAllocation
Repo.findByEmployeeId(empId);
// List<Resource
> resourceList = resource
Repo.findByEmployeeId(empId);
// if (resourceList != null && resourceList.size() > 0) {
// if (resourceList != null && resourceList.size() > 0) {
//
//
// Resource
Allocation
resourceAlloc=resourceList.get(0);
// Resource resourceAlloc=resourceList.get(0);
//
//
//
//
//
//
//
//
// }
// }
//
//
// for (Resource
Allocation resource : resourceAllocation
Repo.findByEmployeeId(empId)) {
// for (Resource
resource : resource
Repo.findByEmployeeId(empId)) {
//
//
// ResourceVO resourceVO=new ResourceVO();
// ResourceVO resourceVO=new ResourceVO();
// resourceVO.setEmployeeId(resource.getEmployeeId());
// resourceVO.setEmployeeId(resource.getEmployeeId());
...
@@ -682,8 +682,8 @@ public class ResourceAllocationService implements IResourceAllocationService {
...
@@ -682,8 +682,8 @@ public class ResourceAllocationService implements IResourceAllocationService {
// List<ResourceVO> finalResourcesList = new ArrayList<>();
// List<ResourceVO> finalResourcesList = new ArrayList<>();
// Employee employee = null;
// Employee employee = null;
//
//
// List<Resource
Allocation> resourceList = resourceAllocation
Repo.findByEmployeeId(empId);
// List<Resource
> resourceList = resource
Repo.findByEmployeeId(empId);
// Optional<Resource
Allocation
> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
// Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
// if (optionalResource.isPresent()) {
// if (optionalResource.isPresent()) {
// finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
// finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
// }
// }
...
...
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