Company XYZ is managing its leave module by maintaining 2 CSV files in their "Leaves" directory
- EmployeeData.csv
- Leaves.csv
empId | name | leavesTaken | availableLeaves |
---|---|---|---|
1 | Mayank | 2 | 18 |
2 | Keyur | 5 | 15 |
3 | Rahim | 18 | 2 |
An employee can apply for leave by adding an entry in the Leaves.csv file in below format.
empId | appliedLeaves |
---|---|
1 | 4 |
2 | 3 |
The program will initially read data from the EmployeeData.csv file and continuously monitor Leaves.csv.
When any employee has applied for leaves then perform below operations every minute - The program will initially read data from the EmployeeData.csv file and continuously monitor Leaves.csv.
When any employee has applied for leaves then perform below operations every minute -
- Check whether the employee is eligible for the leave(s) or not based on available Leaves
value
- If the employee is eligible for the leave then print in the console: <name> is eligible for the leave.
- If the employee is not eligible for the leave then print in the console: <name> is not eligible for the leave.
- if the employee is eligible for the leave, then remove the entry from Leaves.csv and update the "leavesTaken" and "available Leaves" in EmployeeData.csv.
- If the employee is not eligible for the leave then remove the entry from Leaves.csv.
- Reading from File System [Super CSV](http://super-csv.github.io/super-csv/index.html)
- Schedule the program [Timer Task](https://docs.oracle.com/javase/7/docs/api/java/util/TimerTask.html)
- Application must schedule on time frequency
- Application should not create new CSV files, must be use old file and update if needed
- Create a cron job to run program after time frequency
- First read the Leaves.csv if any leave application found then read the EmployeeData.csv else skip the processing
- Schedule frequency should be user configurable.