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
9f0e55f0
Commit
9f0e55f0
authored
Jun 17, 2019
by
Md Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added deleting functionality for future allocation
parent
18cfe357
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+1
-1
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+14
-11
No files found.
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
9f0e55f0
...
...
@@ -101,7 +101,7 @@ public class ResourceController {
public
ResponseEntity
<?>
deleteResource
(
@RequestBody
Resource
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
resourceService
.
delete
Resource
(
resourceReq
,
loginEmpId
);
resourceService
.
delete
AndUpdateAllocation
(
resourceReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been deleted"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceReq
);
...
...
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
9f0e55f0
...
...
@@ -75,15 +75,9 @@ public class ResourceService implements IResourceService {
Resource
resourcePers
=
null
;
if
(
prevAllocation
!=
null
){
// Resource projectPrevAllocation = this.getLatestAllocation(resourceAllocationList.stream().
// filter(r -> !r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
// projectPrevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// updateExistedResource(projectPrevAllocation);
// prevAllocation.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate()));
prevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
updateExistedResource
(
prevAllocation
);
//updateLatestProjectAllocationToEnd
resourcePers
=
resourceRepo
.
save
(
resourceReq
);
//createNewProjectAllocationtoStart
this
.
updateExistedResource
(
prevAllocation
);
//updateLatestProjectAllocationToEnd
resourcePers
=
resourceRepo
.
save
(
resourceReq
);
//createNewProjectAllocationtoStart
}
return
resourcePers
;
}
...
...
@@ -133,7 +127,7 @@ public class ResourceService implements IResourceService {
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
if
(
resource
!=
null
)
{
if
(
resourceReq
.
getStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
Engaged
_STATUS
)){
if
(
!
resourceReq
.
getStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
RELEASED
_STATUS
)){
Resource
latestAllocation
=
this
.
getLatestAllocation
(
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
()));
if
(
latestAllocation
!=
null
&&
!
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
resourceReq
.
getProjectId
())&&
...
...
@@ -327,9 +321,18 @@ public class ResourceService implements IResourceService {
public
void
deleteResource
(
Resource
resourceReq
,
String
loginEmpId
)
{
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
resourcesList
.
forEach
(
resource
->
resourceRepo
.
delete
(
resource
));
resourceRepo
.
delete
(
resourceReq
);
}
public
void
deleteAndUpdateAllocation
(
Resource
resourceReq
,
String
loginEmpId
){
List
<
Resource
>
empAllAllocations
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
Resource
latestAllocation
=
this
.
getLatestAllocation
(
empAllAllocations
.
stream
().
filter
(
r
->
!
r
.
getId
().
equals
(
resourceReq
.
getId
())).
collect
(
Collectors
.
toList
()));
if
(
latestAllocation
!=
null
&&
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
latestAllocation
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
this
.
updateExistedResource
(
latestAllocation
);
this
.
deleteResource
(
resourceReq
,
loginEmpId
);
}
}
@Override
...
...
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