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
3cd9ee2f
Unverified
Commit
3cd9ee2f
authored
Sep 07, 2018
by
mshaik-nisum-com
Committed by
GitHub
Sep 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #190 from nisum-inc/FEATURE/MT-53_4_ImportEmployeeDataValidations
MT-53_4 :SNS :: ImportEmployeeDataValidations
parents
6148852a
07d177ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
49 deletions
+64
-49
UserController.java
...main/java/com/nisum/mytime/controller/UserController.java
+1
-1
UserService.java
src/main/java/com/nisum/mytime/service/UserService.java
+1
-2
UserServiceImpl.java
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
+54
-36
DataValidations.java
src/main/java/com/nisum/mytime/utils/DataValidations.java
+8
-10
No files found.
src/main/java/com/nisum/mytime/controller/UserController.java
View file @
3cd9ee2f
...
@@ -286,7 +286,7 @@ public class UserController {
...
@@ -286,7 +286,7 @@ public class UserController {
public
ResponseEntity
<
String
>
exportDataFromFile
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
,
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
public
ResponseEntity
<
String
>
exportDataFromFile
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
,
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
throws
MyTimeException
{
log
.
info
(
"Uploaded file: {} with size: {}"
,
file
.
getOriginalFilename
(),
file
.
getSize
());
log
.
info
(
"Uploaded file: {} with size: {}"
,
file
.
getOriginalFilename
(),
file
.
getSize
());
String
result
=
userService
.
ex
portDataFromExcelFile
(
file
,
loginEmpId
);
String
result
=
userService
.
im
portDataFromExcelFile
(
file
,
loginEmpId
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
...
...
src/main/java/com/nisum/mytime/service/UserService.java
View file @
3cd9ee2f
...
@@ -3,7 +3,6 @@ package com.nisum.mytime.service;
...
@@ -3,7 +3,6 @@ package com.nisum.mytime.service;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -86,5 +85,5 @@ public interface UserService {
...
@@ -86,5 +85,5 @@ public interface UserService {
public
boolean
verifyRole
(
String
empId
,
String
roleName
);
public
boolean
verifyRole
(
String
empId
,
String
roleName
);
String
ex
portDataFromExcelFile
(
MultipartFile
file
,
String
empId
)
throws
MyTimeException
;
String
im
portDataFromExcelFile
(
MultipartFile
file
,
String
empId
)
throws
MyTimeException
;
}
}
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
View file @
3cd9ee2f
...
@@ -553,7 +553,7 @@ public class UserServiceImpl implements UserService {
...
@@ -553,7 +553,7 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
String
ex
portDataFromExcelFile
(
MultipartFile
file
,
String
logInEmpId
)
throws
MyTimeException
{
public
String
im
portDataFromExcelFile
(
MultipartFile
file
,
String
logInEmpId
)
throws
MyTimeException
{
String
result
=
""
;
String
result
=
""
;
try
{
try
{
PoijiOptions
options
=
PoijiOptions
.
PoijiOptionsBuilder
.
settings
().
preferNullOverDefault
(
true
).
datePattern
(
"dd-MMM-yyyy"
).
build
();
PoijiOptions
options
=
PoijiOptions
.
PoijiOptionsBuilder
.
settings
().
preferNullOverDefault
(
true
).
datePattern
(
"dd-MMM-yyyy"
).
build
();
...
@@ -590,17 +590,20 @@ public class UserServiceImpl implements UserService {
...
@@ -590,17 +590,20 @@ public class UserServiceImpl implements UserService {
if
(
employee
.
getRole
().
trim
().
isEmpty
())
{
if
(
employee
.
getRole
().
trim
().
isEmpty
())
{
employee
.
setRole
(
MyTimeUtils
.
EMPLOYEE
);
employee
.
setRole
(
MyTimeUtils
.
EMPLOYEE
);
}
}
if
(
employee
.
getEmploymentType
().
trim
().
isEmpty
())
{
if
(
employee
.
getEmploymentType
().
trim
().
isEmpty
())
{
employee
.
setEmploymentType
(
MyTimeUtils
.
FULL_TIME
);
employee
.
setEmploymentType
(
MyTimeUtils
.
FULL_TIME
);
}
}
String
empStatus
=
employee
.
getEmpStatus
().
trim
();
if
(
employee
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
ACTIVE
)
||
employee
.
getEmpStatus
().
trim
().
isEmpty
())
{
if
(
empStatus
.
isEmpty
()
)
{
employee
.
setEmpStatus
(
MyTimeUtils
.
ACTIVE
);
if
(
null
==
employee
.
getEndDate
())
{
}
else
{
employee
.
setEmpStatus
(
MyTimeUtils
.
ACTIVE
);
}
else
{
employee
.
setEmpStatus
(
MyTimeUtils
.
IN_ACTIVE_SPACE
);
}
}
else
if
(
(
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE
)
||
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
)
||
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_HYPEN_ACTIVE_SPACE
))
&&
null
!=
employee
.
getEndDate
()
)
{
employee
.
setEmpStatus
(
MyTimeUtils
.
IN_ACTIVE_SPACE
);
employee
.
setEmpStatus
(
MyTimeUtils
.
IN_ACTIVE_SPACE
);
}
}
if
(!
employee
.
getGender
().
trim
().
isEmpty
())
{
if
(!
employee
.
getGender
().
trim
().
isEmpty
())
{
if
(
employee
.
getGender
().
equalsIgnoreCase
(
MyTimeUtils
.
MALE
))
{
if
(
employee
.
getGender
().
equalsIgnoreCase
(
MyTimeUtils
.
MALE
))
{
employee
.
setGender
(
MyTimeUtils
.
MALE
);
employee
.
setGender
(
MyTimeUtils
.
MALE
);
...
@@ -631,35 +634,12 @@ public class UserServiceImpl implements UserService {
...
@@ -631,35 +634,12 @@ public class UserServiceImpl implements UserService {
for
(
EmployeeRoles
emp
:
employees
)
{
for
(
EmployeeRoles
emp
:
employees
)
{
rowNumber
+=
1
;
rowNumber
+=
1
;
mandatoryFlag
=
importExcelMandatoryColumnsValidation
(
emp
);
mandatoryFlag
=
importExcelMandatoryColumnsValidation
(
emp
);
if
(
mandatoryFlag
)
{
if
(!
DataValidations
.
isAgeGreaterThanTwenty
(
emp
.
getDateOfBirth
(),
emp
.
getDateOfJoining
()))
{
if
(
mandatoryFlag
)
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
importExcelAdditionalColumnVAlidation
(
emp
,
inValidEmpRecList
,
invalidEmpRecs
,
rowNumber
);
continue
;
}
if
(
MyTimeUtils
.
YES
.
equalsIgnoreCase
(
emp
.
getHasPassort
())
||
MyTimeUtils
.
STRING_Y
.
equalsIgnoreCase
(
emp
.
getHasPassort
())){
mandatoryFlag
=
DataValidations
.
isFutureDate
(
emp
.
getPassportExpiryDate
());
if
(!
mandatoryFlag
)
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
continue
;
}
}
else
{
mandatoryFlag
=
false
;
}
if
(
mandatoryFlag
&&
(
MyTimeUtils
.
YES
.
equals
(
emp
.
getHasB1
())
||
MyTimeUtils
.
STRING_Y
.
equals
(
emp
.
getHasB1
()))
&&
!
DataValidations
.
isFutureDate
(
emp
.
getB1ExpiryDate
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
continue
;
}
if
(!
MyTimeUtils
.
EMPTY_STRING
.
equals
(
emp
.
getEmpStatus
().
trim
())
)
{
String
empStatus
=
emp
.
getEmpStatus
().
trim
();
if
((
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE
)
||
MyTimeUtils
.
IN_ACTIVE_SPACE
.
equalsIgnoreCase
(
empStatus
)
||
MyTimeUtils
.
IN_HYPEN_ACTIVE_SPACE
.
equalsIgnoreCase
(
empStatus
))
&&
!
DataValidations
.
isValidDate
(
emp
.
getEndDate
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
}
}
}
else
{
}
else
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
}
}
}
}
if
(
invalidEmpRecs
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
if
(
invalidEmpRecs
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
employees
.
removeAll
(
invalidEmpRecs
);
employees
.
removeAll
(
invalidEmpRecs
);
...
@@ -759,9 +739,47 @@ public class UserServiceImpl implements UserService {
...
@@ -759,9 +739,47 @@ public class UserServiceImpl implements UserService {
mandatoryFlag
=
false
;
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isYesOrNo
(
emp
.
getHasB1
()))
{
}
else
if
(!
DataValidations
.
isYesOrNo
(
emp
.
getHasB1
()))
{
mandatoryFlag
=
false
;
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidEmail
(
emp
.
getEmailId
()))
{
mandatoryFlag
=
false
;
}
return
mandatoryFlag
;
}
private
void
importExcelAdditionalColumnVAlidation
(
EmployeeRoles
emp
,
List
<
String
>
inValidEmpRecList
,
List
<
EmployeeRoles
>
invalidEmpRecs
,
int
rowNumber
)
{
if
(!
DataValidations
.
isAgeGreaterThanTwenty
(
emp
.
getDateOfBirth
(),
emp
.
getDateOfJoining
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(
MyTimeUtils
.
YES
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
())||
MyTimeUtils
.
STRING_Y
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
()))
{
if
(!
DataValidations
.
isFutureDate
(
emp
.
getPassportExpiryDate
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
if
(
emp
.
getHasPassort
().
trim
().
isEmpty
()
||
MyTimeUtils
.
NO
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
())||
MyTimeUtils
.
STRING_N
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
()))
{
if
(
null
!=
emp
.
getPassportExpiryDate
()
||
null
!=
emp
.
getHasB1
().
trim
()
||
null
!=
emp
.
getB1ExpiryDate
())
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
if
((
MyTimeUtils
.
YES
.
equals
(
emp
.
getHasB1
())
||
MyTimeUtils
.
STRING_Y
.
equals
(
emp
.
getHasB1
()))&&
!
DataValidations
.
isFutureDate
(
emp
.
getB1ExpiryDate
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(!
emp
.
getEmpStatus
().
trim
().
isEmpty
())
{
if
(
null
!=
emp
.
getEndDate
()
&&
(
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE
)
||
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
)
||
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_HYPEN_ACTIVE_SPACE
)
))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
ACTIVE
)
&&
null
!=
emp
.
getEndDate
())
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
}
return
mandatoryFlag
;
}
}
private
String
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
List
<
EmployeeRoles
>
employees
)
{
private
String
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
List
<
EmployeeRoles
>
employees
)
{
...
...
src/main/java/com/nisum/mytime/utils/DataValidations.java
View file @
3cd9ee2f
...
@@ -50,17 +50,15 @@ public class DataValidations {
...
@@ -50,17 +50,15 @@ public class DataValidations {
return
flag
;
return
flag
;
}
}
public
static
boolean
validate
Email
(
String
email
)
{
public
static
boolean
isValid
Email
(
String
email
)
{
boolean
flag
=
false
;
boolean
flag
=
false
;
email
=
email
.
trim
();
email
=
email
.
trim
();
if
(
!
MyTimeUtils
.
EMPTY_STRING
.
equals
(
email
))
{
if
(
!
MyTimeUtils
.
EMPTY_STRING
.
equals
(
email
)
&&
email
.
endsWith
(
"@nisum.com"
))
{
if
(
email
.
trim
().
endsWith
(
"@nisum.com"
))
{
String
regx
=
"^[\\p{L}]+$"
;
String
regx
=
"^[\\p{L}]+$"
;
email
=
email
.
replace
(
"@nisum.com"
,
""
);
email
=
email
.
substring
(
0
,
email
.
indexOf
(
"@"
)-
1
);
Pattern
pattern
=
Pattern
.
compile
(
regx
,
Pattern
.
CASE_INSENSITIVE
);
Pattern
pattern
=
Pattern
.
compile
(
regx
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
matcher
=
pattern
.
matcher
(
email
);
Matcher
matcher
=
pattern
.
matcher
(
email
);
flag
=
matcher
.
find
();
flag
=
matcher
.
find
();
}
}
}
return
flag
;
return
flag
;
}
}
...
@@ -122,7 +120,7 @@ public class DataValidations {
...
@@ -122,7 +120,7 @@ public class DataValidations {
public
static
boolean
isFutureDate
(
Date
date
)
{
public
static
boolean
isFutureDate
(
Date
date
)
{
boolean
flag
=
false
;
boolean
flag
=
false
;
if
(
null
!=
date
)
{
if
(
null
!=
date
)
{
flag
=
new
Date
().
after
(
date
)
;
flag
=
date
.
after
(
new
Date
()
)
;
}
}
return
flag
;
return
flag
;
}
}
...
...
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