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
4ac1c2dd
Unverified
Commit
4ac1c2dd
authored
Aug 10, 2018
by
mshaik-nisum-com
Committed by
GitHub
Aug 10, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #146 from nisum-inc/FEATURE/ProjectDuplicateNameCheck
ProjectDuplicateNameCheck
parents
35fe87d0
1bead970
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
10 deletions
+111
-10
ProjectController.java
...n/java/com/nisum/mytime/controller/ProjectController.java
+34
-3
ProjectRepo.java
src/main/java/com/nisum/mytime/repository/ProjectRepo.java
+4
-0
ProjectService.java
src/main/java/com/nisum/mytime/service/ProjectService.java
+1
-1
ProjectServiceImpl.java
...ain/java/com/nisum/mytime/service/ProjectServiceImpl.java
+62
-2
UserServiceImpl.java
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
+9
-4
VisaServiceImpl.java
src/main/java/com/nisum/mytime/service/VisaServiceImpl.java
+1
-0
No files found.
src/main/java/com/nisum/mytime/controller/ProjectController.java
View file @
4ac1c2dd
...
...
@@ -18,6 +18,7 @@ import com.nisum.mytime.model.Account;
import
com.nisum.mytime.model.EmployeeRoles
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.repository.ProjectRepo
;
import
com.nisum.mytime.service.ProjectService
;
import
com.nisum.mytime.service.UserService
;
import
com.nisum.mytime.utils.MyTimeUtils
;
...
...
@@ -34,7 +35,8 @@ public class ProjectController {
@Autowired
private
AccountRepo
accountRepo
;
@Autowired
private
ProjectRepo
projectRepo
;
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
getEmployeeRole
(
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
...
...
@@ -43,7 +45,22 @@ public class ProjectController {
}
@RequestMapping
(
value
=
"/addProject"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Project
>
addProject
(
@RequestBody
Project
projectAdded
)
throws
MyTimeException
{
public
ResponseEntity
<?>
addProject
(
@RequestBody
Project
projectAdded
)
throws
MyTimeException
{
// checking project duplicateName
int
projectNameCount
=
0
;
if
(
projectAdded
.
getAccountId
()
!=
null
)
{
List
<
Project
>
projects
=
projectRepo
.
findByAccountId
(
projectAdded
.
getAccountId
());
for
(
Project
existproject
:
projects
)
{
if
(
projectAdded
.
getProjectName
().
equalsIgnoreCase
(
existproject
.
getProjectName
()))
projectNameCount
++;
}
}
if
(
projectNameCount
>
0
)
{
MyTimeException
myTimeException
=
new
MyTimeException
(
"Project name already exist !!! try with new"
);
return
new
ResponseEntity
<>(
myTimeException
,
HttpStatus
.
OK
);
}
else
{
String
accountName
=
""
;
String
accountId
=
projectAdded
.
getAccountId
();
// String accountName=projectAdded.getAccount();
...
...
@@ -57,10 +74,24 @@ public class ProjectController {
projectAdded
.
setProjectId
(
projectId
);
Project
project
=
projectService
.
addProject
(
projectAdded
);
return
new
ResponseEntity
<>(
project
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/updateProject"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Project
>
updateEmployeeRole
(
@RequestBody
Project
project
)
throws
MyTimeException
{
public
ResponseEntity
<?>
updateEmployeeRole
(
@RequestBody
Project
project
)
throws
MyTimeException
{
// checking project duplicateName
int
projectNameCount
=
0
;
if
(
project
.
getAccountId
()
!=
null
)
{
List
<
Project
>
projects
=
projectRepo
.
findByAccountId
(
project
.
getAccountId
());
for
(
Project
existproject
:
projects
)
{
if
(
project
.
getProjectName
().
equalsIgnoreCase
(
existproject
.
getProjectName
()))
projectNameCount
++;
}
}
if
(
projectNameCount
>
1
)
{
MyTimeException
myTimeException
=
new
MyTimeException
(
"Project name already exist !!! try with new"
);
return
new
ResponseEntity
<>(
myTimeException
,
HttpStatus
.
OK
);
}
Project
updatedProject
=
projectService
.
updateProject
(
project
);
return
new
ResponseEntity
<>(
updatedProject
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/nisum/mytime/repository/ProjectRepo.java
View file @
4ac1c2dd
...
...
@@ -16,4 +16,8 @@ public interface ProjectRepo extends MongoRepository<Project, String> {
// List<Project> findByManagerId(String managerId);
List
<
Project
>
findByAccountIdIn
(
Set
<
String
>
accIdsSet
);
List
<
Project
>
findByAccountId
(
String
accountId
);
}
\ No newline at end of file
src/main/java/com/nisum/mytime/service/ProjectService.java
View file @
4ac1c2dd
...
...
@@ -30,7 +30,7 @@ public interface ProjectService {
void
deleteProject
(
String
projectId
);
Project
updateProject
(
Project
project
);
Project
updateProject
(
Project
project
)
throws
MyTimeException
;
EmployeeRoles
getEmployeesRoleData
(
String
empId
);
...
...
src/main/java/com/nisum/mytime/service/ProjectServiceImpl.java
View file @
4ac1c2dd
package
com
.
nisum
.
mytime
.
service
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Calendar
;
...
...
@@ -155,7 +156,7 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public
Project
addProject
(
Project
project
)
throws
MyTimeException
{
public
Project
addProject
(
Project
project
)
throws
MyTimeException
{
if
(
project
.
getDomainId
()
==
null
)
{
Domains
domain
=
new
Domains
();
domain
.
setAccountId
(
project
.
getAccountId
());
...
...
@@ -169,6 +170,7 @@ public class ProjectServiceImpl implements ProjectService {
project
.
setDomainId
(
savedDomain
.
getDomainId
());
project
.
setDomain
(
savedDomain
.
getDomainName
());
}
return
projectRepo
.
save
(
project
);
}
...
...
@@ -189,7 +191,64 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public
Project
updateProject
(
Project
project
)
{
public
Project
updateProject
(
Project
project
)
throws
MyTimeException
{
//Inactivate the Project based on endDate
Project
existingProject
=
projectRepo
.
findByProjectId
(
project
.
getProjectId
());
List
<
ProjectTeamMate
>
existingTeammates
=
projectTeamMatesRepo
.
findByProjectId
(
project
.
getProjectId
());
if
(
project
.
getProjectEndDate
().
compareTo
(
new
Date
())
<=
0
&&
project
.
getProjectEndDate
().
compareTo
(
existingProject
.
getProjectEndDate
())
!=
0
)
{
existingProject
.
setStatus
(
MyTimeUtils
.
IN_ACTIVE
);
existingProject
.
setProjectEndDate
(
project
.
getProjectEndDate
());
projectRepo
.
save
(
existingProject
);
for
(
ProjectTeamMate
existingTeammate
:
existingTeammates
)
{
existingTeammate
.
setActive
(
false
);
existingTeammate
.
setEndDate
(
project
.
getProjectEndDate
());
BillingDetails
billingDetails
=
new
BillingDetails
();
billingDetails
.
setBillableStatus
(
MyTimeUtils
.
BENCH_BILLABILITY_STATUS
);
List
<
BillingDetails
>
listBD
=
getEmployeeActiveBillingDetails
(
existingTeammate
.
getEmployeeId
(),
existingTeammate
.
getProjectId
());
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
BillingDetails
billingDetailsExisting
=
listBD
.
get
(
0
);
billingDetailsExisting
.
setBillingEndDate
(
project
.
getProjectEndDate
());
billingDetailsExisting
.
setActive
(
false
);
updateEmployeeBilling
(
billingDetailsExisting
);
}
Date
sd
=
project
.
getProjectEndDate
();
billingDetails
.
setBillingStartDate
(
sd
);
billingDetails
.
setAccount
(
MyTimeUtils
.
BENCH_ACCOUNT
);
billingDetails
.
setActive
(
true
);
billingDetails
.
setEmployeeId
(
existingTeammate
.
getEmployeeId
());
billingDetails
.
setEmployeeName
(
existingTeammate
.
getEmployeeName
());
billingDetails
.
setCreateDate
(
new
Date
());
billingDetails
.
setProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
billingDetails
.
setProjectName
(
MyTimeUtils
.
FREE_POLL
);
addEmployeeBillingDetails
(
billingDetails
);
projectTeamMatesRepo
.
save
(
existingTeammate
);
ProjectTeamMate
newBenchAllocation
=
new
ProjectTeamMate
();
Project
benchProject
=
projectRepo
.
findByProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
if
(
benchProject
!=
null
)
newBenchAllocation
.
setAccountId
(
benchProject
.
getAccountId
());
newBenchAllocation
.
setBillableStatus
(
MyTimeUtils
.
BENCH_BILLABILITY_STATUS
);
newBenchAllocation
.
setDesignation
(
existingTeammate
.
getDesignation
());
newBenchAllocation
.
setEmailId
(
existingTeammate
.
getEmailId
());
newBenchAllocation
.
setEmployeeId
(
existingTeammate
.
getEmployeeId
());
newBenchAllocation
.
setActive
(
true
);
newBenchAllocation
.
setEmployeeName
(
existingTeammate
.
getEmployeeName
());
newBenchAllocation
.
setProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
newBenchAllocation
.
setStartDate
(
sd
);
newBenchAllocation
.
setProjectName
(
benchProject
.
getProjectName
());
projectTeamMatesRepo
.
save
(
newBenchAllocation
);
updateShiftDetails
(
existingTeammate
);
}
return
existingProject
;
}
else
{
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
project
.
getProjectId
()));
Update
update
=
new
Update
();
...
...
@@ -229,6 +288,7 @@ public class ProjectServiceImpl implements ProjectService {
}
}
return
projectDB
;
}
}
@Override
...
...
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
View file @
4ac1c2dd
...
...
@@ -156,19 +156,24 @@ public class UserServiceImpl implements UserService {
}
ProjectTeamMate
newBenchAllocation
=
new
ProjectTeamMate
();
newBenchAllocation
.
setAccount
(
"Nisum"
);
newBenchAllocation
.
setBillableStatus
(
"Non-Billable"
);
newBenchAllocation
.
setAccount
(
MyTimeUtils
.
BENCH_ACCOUNT
);
newBenchAllocation
.
setBillableStatus
(
MyTimeUtils
.
BENCH_BILLABILITY_STATUS
);
newBenchAllocation
.
setDesignation
(
employeeRoles
.
getDesignation
());
newBenchAllocation
.
setEmailId
(
employeeRoles
.
getEmailId
());
newBenchAllocation
.
setEmployeeId
(
employeeRoles
.
getEmployeeId
());
newBenchAllocation
.
setMobileNumber
(
employeeRoles
.
getMobileNumber
());
newBenchAllocation
.
setActive
(
true
);
newBenchAllocation
.
setEmployeeName
(
employeeRoles
.
getEmployeeName
());
newBenchAllocation
.
setProjectId
(
"Nisum0000"
);
newBenchAllocation
.
setProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
newBenchAllocation
.
setStartDate
(
employeeRoles
.
getDateOfJoining
()
!=
null
?
employeeRoles
.
getDateOfJoining
()
:
new
Date
());
Project
p
=
projectRepo
.
findByProjectId
(
"Nisum0000"
);
Project
p
=
projectRepo
.
findByProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
newBenchAllocation
.
setProjectName
(
p
.
getProjectName
());
newBenchAllocation
.
setAccountId
(
p
.
getAccountId
());
newBenchAllocation
.
setDomainId
(
p
.
getDomainId
());
newBenchAllocation
.
setEndDate
(
employeeRoles
.
getEndDate
());
newBenchAllocation
.
setRole
(
employeeRoles
.
getRole
());
// newBenchAllocation.setManagerId(p.getManagerId());
//newBenchAllocation.setManagerName(p.getManagerName());
try
{
...
...
src/main/java/com/nisum/mytime/service/VisaServiceImpl.java
View file @
4ac1c2dd
...
...
@@ -157,6 +157,7 @@ public class VisaServiceImpl implements VisaService {
* log.info("Inserted Employee record with Id: {}",
* employee.getEmployeeId());
*/
if
(
employee
.
getRole
()!=
null
)
employee
.
setRole
(
"Employee"
);
EmployeeRoles
emp
=
userService
...
...
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