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
afdeb36f
Commit
afdeb36f
authored
Jul 24, 2018
by
Rajashekar jadala
Committed by
rbonthala-nisum-com
Jul 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MT-80: Sent employee assigned role to UI (#50)
parent
c8e144f5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
254 additions
and
262 deletions
+254
-262
UserController.java
...main/java/com/nisum/mytime/controller/UserController.java
+176
-219
RoleInfo.java
src/main/java/com/nisum/mytime/model/RoleInfo.java
+1
-0
RoleInfoRepo.java
src/main/java/com/nisum/mytime/repository/RoleInfoRepo.java
+3
-0
RoleMappingInfoRepo.java
...java/com/nisum/mytime/repository/RoleMappingInfoRepo.java
+4
-0
EmployeeDataService.java
...in/java/com/nisum/mytime/service/EmployeeDataService.java
+39
-43
RoleMappingService.java
...ain/java/com/nisum/mytime/service/RoleMappingService.java
+2
-0
RoleMappingServiceImpl.java
...java/com/nisum/mytime/service/RoleMappingServiceImpl.java
+29
-0
No files found.
src/main/java/com/nisum/mytime/controller/UserController.java
View file @
afdeb36f
package
com
.
nisum
.
mytime
.
controller
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -28,6 +27,7 @@ import com.nisum.mytime.model.Location;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.model.Skill
;
import
com.nisum.mytime.service.RoleMappingService
;
import
com.nisum.mytime.service.UserService
;
@RestController
...
...
@@ -37,182 +37,143 @@ public class UserController {
@Autowired
private
UserService
userService
;
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
getEmployeeRole
(
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
@Autowired
private
RoleMappingService
roleMappingService
;
@RequestMapping
(
value
=
"/employee"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
getEmployeeRole
(
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
EmployeeRoles
employeesRole
=
userService
.
getEmployeesRole
(
emailId
);
String
roleName
=
roleMappingService
.
getEmployeeRole
(
employeesRole
.
getEmployeeId
());
if
(
roleName
!=
null
)
{
employeesRole
.
setRole
(
roleName
);
}
System
.
out
.
println
(
"emailId"
+
emailId
+
"result"
+
employeesRole
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/assignEmployeeRole"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
assigingEmployeeRole
(
@RequestBody
EmployeeRoles
employeeRoles
)
throws
MyTimeException
{
EmployeeRoles
employeeRole
=
userService
.
assigingEmployeeRole
(
employeeRoles
);
@RequestMapping
(
value
=
"/assignEmployeeRole"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
assigingEmployeeRole
(
@RequestBody
EmployeeRoles
employeeRoles
)
throws
MyTimeException
{
EmployeeRoles
employeeRole
=
userService
.
assigingEmployeeRole
(
employeeRoles
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/updateEmployeeRole"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
updateEmployeeRole
(
@RequestBody
EmployeeRoles
employeeRoles
)
throws
MyTimeException
{
EmployeeRoles
employeeRole
=
userService
.
updateEmployeeRole
(
employeeRoles
);
@RequestMapping
(
value
=
"/updateEmployeeRole"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
updateEmployeeRole
(
@RequestBody
EmployeeRoles
employeeRoles
)
throws
MyTimeException
{
EmployeeRoles
employeeRole
=
userService
.
updateEmployeeRole
(
employeeRoles
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/deleteEmployee"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
TEXT_PLAIN_VALUE
)
public
ResponseEntity
<
String
>
deleteEmployee
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
@RequestMapping
(
value
=
"/deleteEmployee"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
TEXT_PLAIN_VALUE
)
public
ResponseEntity
<
String
>
deleteEmployee
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
userService
.
deleteEmployee
(
empId
);
return
new
ResponseEntity
<>(
"Success"
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getUserRoles"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeRoles
>>
getUserRoles
()
throws
MyTimeException
{
@RequestMapping
(
value
=
"/getUserRoles"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeRoles
>>
getUserRoles
()
throws
MyTimeException
{
List
<
EmployeeRoles
>
employeesRoles
=
userService
.
getEmployeeRoles
();
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
getEmployeeRoleData
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
getEmployeeRoleData
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
EmployeeRoles
employeesRole
=
userService
.
getEmployeesRoleData
(
empId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeeLocations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeLocationDetails
>>
getEmployeeLocations
(
@RequestParam
(
"employeeId"
)
String
empId
)
throws
MyTimeException
{
List
<
EmployeeLocationDetails
>
employeeLocationDetails
=
userService
.
getEmployeeLocationDetails
(
empId
);
@RequestMapping
(
value
=
"/getEmployeeLocations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeLocationDetails
>>
getEmployeeLocations
(
@RequestParam
(
"employeeId"
)
String
empId
)
throws
MyTimeException
{
List
<
EmployeeLocationDetails
>
employeeLocationDetails
=
userService
.
getEmployeeLocationDetails
(
empId
);
return
new
ResponseEntity
<>(
employeeLocationDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getManagers"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeRoles
>>
getManagers
()
throws
MyTimeException
{
@RequestMapping
(
value
=
"/getManagers"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeRoles
>>
getManagers
()
throws
MyTimeException
{
List
<
EmployeeRoles
>
employeesRoles
=
userService
.
getEmployeeRoles
();
List
<
EmployeeRoles
>
managers
=
employeesRoles
.
stream
()
.
filter
(
e
->
(
"Director"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Delivery Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"HR Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Lead"
.
equalsIgnoreCase
(
e
.
getRole
())))
.
sorted
(
Comparator
.
comparing
(
EmployeeRoles:
:
getEmployeeName
))
.
collect
(
Collectors
.
toList
());
||
"Delivery Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"HR Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Lead"
.
equalsIgnoreCase
(
e
.
getRole
())))
.
sorted
(
Comparator
.
comparing
(
EmployeeRoles:
:
getEmployeeName
)).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
managers
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getAllShifts"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/getAllShifts"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getAllShifts
()
throws
MyTimeException
{
List
<
String
>
shifts
=
userService
.
getAllShifts
().
stream
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
()))
List
<
String
>
shifts
=
userService
.
getAllShifts
().
stream
().
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
()))
.
map
(
Shift:
:
getShiftName
).
sorted
().
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
shifts
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getAllDesignations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getAllDesignations
()
throws
MyTimeException
{
@RequestMapping
(
value
=
"/getAllDesignations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getAllDesignations
()
throws
MyTimeException
{
List
<
String
>
designations
=
userService
.
getAllDesignations
().
stream
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
()))
.
map
(
Designation:
:
getDesignationName
).
sorted
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
())).
map
(
Designation:
:
getDesignationName
).
sorted
()
.
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
designations
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getSkills"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getTechnologies
()
throws
MyTimeException
{
@RequestMapping
(
value
=
"/getSkills"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getTechnologies
()
throws
MyTimeException
{
List
<
String
>
technologies
=
userService
.
getTechnologies
().
stream
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
())
)
.
map
(
Skill:
:
getSkillName
).
sorted
()
.
collect
(
Collectors
.
toList
());
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
())).
map
(
Skill:
:
getSkillName
).
sorted
(
)
.
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
technologies
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getLocations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/getLocations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getLocations
()
throws
MyTimeException
{
System
.
out
.
println
(
" userService.getLocations()"
+
userService
.
getLocations
());
List
<
String
>
locations
=
userService
.
getLocations
().
stream
()
.
filter
(
e
->
(
e
.
isActiveStatus
()
==
true
))
.
map
(
Location:
:
getLocation
).
sorted
()
.
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
" userService.getLocations()"
+
userService
.
getLocations
());
List
<
String
>
locations
=
userService
.
getLocations
().
stream
().
filter
(
e
->
(
e
.
isActiveStatus
()
==
true
))
.
map
(
Location:
:
getLocation
).
sorted
().
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
"getLocations################ "
+
locations
);
return
new
ResponseEntity
<>(
locations
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/updateProfile"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
updateProfile
(
@RequestBody
EmployeeRoles
employeeRoles
)
throws
MyTimeException
{
@RequestMapping
(
value
=
"/updateProfile"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
updateProfile
(
@RequestBody
EmployeeRoles
employeeRoles
)
throws
MyTimeException
{
EmployeeRoles
employeeRole
=
userService
.
updateProfile
(
employeeRoles
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getAccounts"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/getAccounts"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Account
>>
getAccounts
()
throws
MyTimeException
{
List
<
Account
>
technologies
=
userService
.
getAccounts
().
stream
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getStatus
()))
List
<
Account
>
technologies
=
userService
.
getAccounts
().
stream
().
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getStatus
()))
// .map(Account::getAccountName).sorted()
.
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
technologies
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeeRoleDataForSearchCriteria"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
getEmployeeRoleDataForSearchCriteria
(
@RequestParam
(
"searchId"
)
String
searchId
,
@RequestParam
(
"searchAttribute"
)
String
searchAttribute
)
throws
MyTimeException
{
EmployeeRoles
employeesRole
=
userService
.
getEmployeeRoleDataForSearchCriteria
(
searchId
,
searchAttribute
);
@RequestMapping
(
value
=
"/getEmployeeRoleDataForSearchCriteria"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
EmployeeRoles
>
getEmployeeRoleDataForSearchCriteria
(
@RequestParam
(
"searchId"
)
String
searchId
,
@RequestParam
(
"searchAttribute"
)
String
searchAttribute
)
throws
MyTimeException
{
EmployeeRoles
employeesRole
=
userService
.
getEmployeeRoleDataForSearchCriteria
(
searchId
,
searchAttribute
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeeDetailsForAutocomplete"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getEmployeeDetailsForAutocomplete
()
throws
MyTimeException
{
@RequestMapping
(
value
=
"/getEmployeeDetailsForAutocomplete"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getEmployeeDetailsForAutocomplete
()
throws
MyTimeException
{
List
<
String
>
details
=
userService
.
getEmployeeDetailsForAutocomplete
();
return
new
ResponseEntity
<>(
details
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getMasterData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Map
<
String
,
List
<
String
>>>
getMasterData
()
throws
MyTimeException
{
@RequestMapping
(
value
=
"/getMasterData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Map
<
String
,
List
<
String
>>>
getMasterData
()
throws
MyTimeException
{
Map
<
String
,
List
<
String
>>
masterDataMap
=
new
HashMap
<>();
Map
<
String
,
List
<
MasterData
>>
result
=
userService
.
getMasterData
()
.
stream
()
.
filter
(
e
->
(
e
.
isActiveStatus
()
==
true
))
Map
<
String
,
List
<
MasterData
>>
result
=
userService
.
getMasterData
().
stream
()
.
filter
(
e
->
(
e
.
isActiveStatus
()
==
true
))
.
collect
(
Collectors
.
groupingBy
(
MasterData:
:
getMasterDataType
));
for
(
String
key
:
result
.
keySet
())
{
List
<
MasterData
>
valueList
=
result
.
get
(
key
);
List
<
String
>
technologies
=
valueList
.
stream
()
.
map
(
MasterData:
:
getMasterDataName
).
sorted
()
List
<
String
>
technologies
=
valueList
.
stream
().
map
(
MasterData:
:
getMasterDataName
).
sorted
()
.
collect
(
Collectors
.
toList
());
masterDataMap
.
put
(
key
,
technologies
);
}
...
...
@@ -220,36 +181,32 @@ public class UserController {
}
@RequestMapping
(
value
=
"/getEmployeeByStatus"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeRoles
>>
getEmployeeByStatus
(
@RequestParam
(
"status"
)
String
status
)
{
@RequestMapping
(
value
=
"/getEmployeeByStatus"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeRoles
>>
getEmployeeByStatus
(
@RequestParam
(
"status"
)
String
status
)
{
List
<
EmployeeRoles
>
employeesRoles
=
userService
.
getEmployeesByStatus
(
status
);
List
<
EmployeeRoles
>
employeesRoles
=
userService
.
getEmployeesByStatus
(
status
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getDeliveryLeads"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/getDeliveryLeads"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
HashMap
<
String
,
String
>>>
getDeliveryLeads
(
@RequestParam
(
"domainId"
)
String
domainId
)
throws
MyTimeException
{
List
<
HashMap
<
String
,
String
>>
managers
=
userService
.
getDeliveryLeads
(
domainId
);
return
new
ResponseEntity
<>(
managers
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getAccountsInfo"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/getAccountsInfo"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
AccountInfo
>>
getAccountsInfo
()
throws
MyTimeException
{
List
<
AccountInfo
>
technologies
=
userService
.
getAccountsInfo
().
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
()))
.
collect
(
Collectors
.
toList
());
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
technologies
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getDomains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Domains
>>
getDomains
(
@RequestParam
(
"accountId"
)
String
accountId
)
throws
MyTimeException
{
List
<
Domains
>
domains
=
userService
.
getDomains
(
accountId
).
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
@RequestMapping
(
value
=
"/getDomains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Domains
>>
getDomains
(
@RequestParam
(
"accountId"
)
String
accountId
)
throws
MyTimeException
{
List
<
Domains
>
domains
=
userService
.
getDomains
(
accountId
).
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
domains
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/nisum/mytime/model/RoleInfo.java
View file @
afdeb36f
...
...
@@ -24,6 +24,7 @@ public class RoleInfo implements Serializable {
@Id
private
ObjectId
id
;
private
int
priority
;
private
String
roleId
;
private
String
roleName
;
private
String
roleDescription
;
...
...
src/main/java/com/nisum/mytime/repository/RoleInfoRepo.java
View file @
afdeb36f
...
...
@@ -5,5 +5,8 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import
com.nisum.mytime.model.RoleInfo
;
public
interface
RoleInfoRepo
extends
MongoRepository
<
RoleInfo
,
String
>
{
RoleInfo
findByRoleName
(
String
roleName
);
RoleInfo
findByRoleId
(
String
roleId
);
}
\ No newline at end of file
src/main/java/com/nisum/mytime/repository/RoleMappingInfoRepo.java
View file @
afdeb36f
package
com
.
nisum
.
mytime
.
repository
;
import
java.util.List
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.RoleMappingInfo
;
...
...
@@ -7,4 +9,6 @@ import com.nisum.mytime.model.RoleMappingInfo;
public
interface
RoleMappingInfoRepo
extends
MongoRepository
<
RoleMappingInfo
,
String
>
{
RoleMappingInfo
findByEmployeeIdAndRoleId
(
String
employeeId
,
String
roleId
);
List
<
RoleMappingInfo
>
findByEmployeeId
(
String
employeeId
);
}
\ No newline at end of file
src/main/java/com/nisum/mytime/service/EmployeeDataService.java
View file @
afdeb36f
...
...
@@ -29,16 +29,19 @@ public class EmployeeDataService {
public
List
<
EmpLoginData
>
fetchEmployeeLoginsBasedOnDates
(
long
employeeId
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
{
long
start_ms
=
System
.
currentTimeMillis
();
String
querys
=
MyTimeUtils
.
ABESENT_STATUS_QUERY
+
"'"
+
fromDate
+
"'"
+
MyTimeUtils
.
ABESENT_STATUS_QUERY1
+
"'"
+
toDate
+
"'"
+
MyTimeUtils
.
ABESENT_STATUS_QUERY2
+
employeeId
+
MyTimeUtils
.
ABESENT_STATUS_QUERY3
;
System
.
out
.
println
(
"fetch employee details"
+
querys
);
String
querys
=
null
;
if
(
employeeId
==
0
)
querys
=
MyTimeUtils
.
ABESENT_STATUS_QUERY
+
"'"
+
fromDate
+
"'"
+
MyTimeUtils
.
ABESENT_STATUS_QUERY1
+
"'"
+
toDate
+
"'"
+
MyTimeUtils
.
ABESENT_STATUS_QUERY3
;
else
querys
=
MyTimeUtils
.
ABESENT_STATUS_QUERY
+
"'"
+
fromDate
+
"'"
+
MyTimeUtils
.
ABESENT_STATUS_QUERY1
+
"'"
+
toDate
+
"'"
+
MyTimeUtils
.
ABESENT_STATUS_QUERY2
+
employeeId
+
MyTimeUtils
.
ABESENT_STATUS_QUERY3
;
int
countHours
=
0
;
List
<
EmpLoginData
>
listOfEmpLoginData
=
new
ArrayList
<>();
try
(
Connection
connection
=
dbConnection
.
getDBConnection
();
try
(
Connection
connection
=
dbConnection
.
getDBConnection
();
Statement
statement
=
connection
.
createStatement
();
ResultSet
resultSet
=
statement
.
executeQuery
(
querys
.
toString
()))
{
if
(
employeeId
>
0
)
{
ResultSet
resultSet
=
statement
.
executeQuery
(
querys
.
toString
()))
{
while
(
resultSet
.
next
())
{
EmpLoginData
empLoginData
=
new
EmpLoginData
();
empLoginData
.
setEmployeeId
(
resultSet
.
getString
(
"EmployeeCode"
));
...
...
@@ -48,14 +51,14 @@ public class EmployeeDataService {
empLoginData
.
setLastLogout
(
resultSet
.
getTime
(
"LastLogin"
).
toString
());
Time
from
=
resultSet
.
getTime
(
"FirstLogin"
);
Time
to
=
resultSet
.
getTime
(
"LastLogin"
);
long
milliseconds
=
to
.
getTime
()
-
from
.
getTime
();
long
milliseconds
=
to
.
getTime
()
-
from
.
getTime
();
int
seconds
=
(
int
)
milliseconds
/
1000
;
int
hours
=
seconds
/
3600
;
int
minutes
=
(
seconds
%
3600
)
/
60
;
seconds
=
(
seconds
%
3600
)
%
60
;
empLoginData
.
setTotalLoginTime
(
hours
+
":"
+
minutes
+
":"
+
seconds
);
empLoginData
.
setTotalLoginTime
(
hours
+
":"
+
minutes
+
":"
+
seconds
);
empLoginData
.
setTotalLoginTime
(
hours
+
":"
+
minutes
+
":"
+
seconds
);
empLoginData
.
setTotalLoginTime
(
hours
+
":"
+
minutes
+
":"
+
seconds
);
Date
d
=
MyTimeUtils
.
tdf
.
parse
(
empLoginData
.
getTotalLoginTime
());
countHours
+=
d
.
getTime
();
listOfEmpLoginData
.
add
(
empLoginData
);
...
...
@@ -65,16 +68,9 @@ public class EmployeeDataService {
.
setTotalAvgTime
(
MyTimeUtils
.
tdf
.
format
(
countHours
/
listOfEmpLoginData
.
size
()));
}
MyTimeLogger
.
getInstance
().
info
(
" Time Taken fecth Employee data based on Dates ::: "
+
(
System
.
currentTimeMillis
()
-
start_ms
));
MyTimeLogger
.
getInstance
().
info
(
" Time Taken fecth Employee data based on Dates ::: "
+
(
System
.
currentTimeMillis
()
-
start_ms
));
}
else
if
(
employeeId
==
0
)
{
listOfEmpLoginData
=
null
;
MyTimeLogger
.
getInstance
().
info
(
"Time Taken for with fecth All Employees data based on Dates ::: "
+
(
System
.
currentTimeMillis
()
-
start_ms
));
}
}
catch
(
Exception
e
)
{
MyTimeLogger
.
getInstance
().
error
(
e
.
getMessage
());
throw
new
MyTimeException
(
e
.
getMessage
());
...
...
src/main/java/com/nisum/mytime/service/RoleMappingService.java
View file @
afdeb36f
...
...
@@ -10,4 +10,6 @@ public interface RoleMappingService {
void
saveUniqueEmployeeAndRole
(
List
<
String
>
employeeIds
,
String
roleId
)
throws
MyTimeException
;
WriteResult
deleteRole
(
String
employeeId
,
String
roleId
)
throws
MyTimeException
;
String
getEmployeeRole
(
String
employeeId
);
}
src/main/java/com/nisum/mytime/service/RoleMappingServiceImpl.java
View file @
afdeb36f
package
com
.
nisum
.
mytime
.
service
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
...
@@ -12,6 +15,7 @@ import org.springframework.stereotype.Service;
import
com.mongodb.WriteResult
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.RoleMappingInfo
;
import
com.nisum.mytime.repository.RoleInfoRepo
;
import
com.nisum.mytime.repository.RoleMappingInfoRepo
;
import
com.nisum.mytime.utils.MyTimeUtils
;
...
...
@@ -21,6 +25,9 @@ public class RoleMappingServiceImpl implements RoleMappingService {
@Autowired
private
RoleMappingInfoRepo
roleMappingInfoRepo
;
@Autowired
private
RoleInfoRepo
roleInfoRepo
;
@Autowired
private
MongoTemplate
mongoTemplate
;
...
...
@@ -49,4 +56,26 @@ public class RoleMappingServiceImpl implements RoleMappingService {
return
mongoTemplate
.
upsert
(
query
,
update
,
RoleMappingInfo
.
class
);
}
@Override
public
String
getEmployeeRole
(
String
employeeId
)
{
Map
<
Integer
,
String
>
roleInfoMap
=
new
LinkedHashMap
<
Integer
,
String
>();
List
<
RoleMappingInfo
>
listOfEmployeeRoles
=
roleMappingInfoRepo
.
findByEmployeeId
(
employeeId
);
for
(
RoleMappingInfo
employee
:
listOfEmployeeRoles
)
{
roleInfoMap
.
put
((
roleInfoRepo
.
findByRoleId
(
employee
.
getRoleId
())).
getPriority
(),
employee
.
getRoleId
());
}
roleInfoMap
=
roleInfoMap
.
entrySet
().
stream
().
sorted
(
Map
.
Entry
.
comparingByKey
()).
collect
(
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
Map
.
Entry
::
getValue
,
(
oldValue
,
newValue
)
->
oldValue
,
LinkedHashMap:
:
new
));
String
roleName
=
null
;
if
(!
roleInfoMap
.
isEmpty
())
{
Map
.
Entry
<
Integer
,
String
>
entry
=
roleInfoMap
.
entrySet
().
iterator
().
next
();
roleName
=
entry
.
getValue
();
}
else
{
roleName
=
null
;
}
return
roleName
;
}
}
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