Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmpt-370-group-project-group26
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eyan Cunningham (esc568)
cmpt-370-group-project-group26
Commits
be597272
Commit
be597272
authored
3 years ago
by
Rafi Zereselasie (raz070)
Browse files
Options
Downloads
Patches
Plain Diff
Added comments.
parent
ab0775aa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SchedulerApp/src/main/java/com/example/scheduler_server/TimeOff.java
+57
-4
57 additions, 4 deletions
...p/src/main/java/com/example/scheduler_server/TimeOff.java
with
57 additions
and
4 deletions
SchedulerApp/src/main/java/com/example/scheduler_server/TimeOff.java
+
57
−
4
View file @
be597272
...
...
@@ -9,12 +9,32 @@ import java.sql.*;
*/
public
class
TimeOff
{
// Object that facilitates the connection to the database
private
final
Connection
dbConnection
;
/*
Name: TimeOff Constructor
Parameters:
Connection c: The connection to the database.
Description: Instantiates a TimeOff object and sets the global connection for the methods.
Return: TimeOff Object
*/
protected
TimeOff
(
Connection
c
)
{
this
.
dbConnection
=
c
;
}
/*
Name: addTimeOff
Parameters:
int employeeID: The ID of an employee.
String startDate: The start date of the time off in "yyyy-mm-dd" format.
String endDate: The end date of the time off in "yyyy-mm-dd" format.
boolean approved: True if the time off is approved by a manager.
String reason: Why the time off was requested.
Description:
Return:
String: The details of the time off separated by commas.
*/
protected
String
addTimeOff
(
int
employeeID
,
String
startDate
,
String
endDate
,
boolean
approved
,
String
reason
){
String
newTimeOff
=
""
;
try
{
...
...
@@ -36,6 +56,14 @@ public class TimeOff {
return
newTimeOff
;
}
/*
Name: removeTimeOff
Parameters:
int timeOffID: The id of the time off request.
Description: Removes the time off request.
Return:
String: The time off id of the shift if it was removed, and -1 if there was a problem with the query.
*/
protected
int
removeTimeOff
(
int
timeOffID
){
try
{
Statement
myStatement
=
dbConnection
.
createStatement
();
...
...
@@ -47,13 +75,23 @@ public class TimeOff {
return
timeOffID
;
}
protected
String
setTimeOffApproval
(
int
ID
,
String
approved
){
/*
Name: setTimeOffApproval
Parameters:
int timeOffID: The id of the time off request.
String approved: "true" if its approved and "false" if it's not.
Description: Change the approval status of a request.
Return:
String: If the time off approval was successfully changed than it returns the id and the approval separated by
commas, or if there was an error with the query then it returns an empty string.
*/
protected
String
setTimeOffApproval
(
int
timeOffID
,
String
approved
){
String
editedTimeOff
=
""
;
System
.
out
.
println
(
ID
+
" and "
+
approved
);
System
.
out
.
println
(
timeOff
ID
+
" and "
+
approved
);
try
{
Statement
myStatement
=
dbConnection
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_READ_ONLY
);
myStatement
.
executeUpdate
(
"update TimeOff set approved="
+
approved
+
" where ID="
+
ID
);
ResultSet
myRs
=
myStatement
.
executeQuery
(
"select * from TimeOff where ID="
+
ID
);
myStatement
.
executeUpdate
(
"update TimeOff set approved="
+
approved
+
" where ID="
+
timeOff
ID
);
ResultSet
myRs
=
myStatement
.
executeQuery
(
"select * from TimeOff where ID="
+
timeOff
ID
);
if
(
myRs
.
last
())
{
editedTimeOff
=
myRs
.
getString
(
"ID"
)
+
","
+
myRs
.
getString
(
"approved"
);
}
...
...
@@ -65,6 +103,13 @@ public class TimeOff {
return
editedTimeOff
;
}
/*
Name: removeAllTimeOffByID
Parameters:
int employeeID: The id of an employee.
Description: Removes all time off request for a specified employee.
Return: void
*/
protected
void
removeAllTimeOffByID
(
int
employeeID
)
{
try
{
Statement
myStatement
=
dbConnection
.
createStatement
();
...
...
@@ -74,6 +119,14 @@ public class TimeOff {
}
}
/*
Name: allTimeOff
Parameters: none
Description: Gets all the time off request.
Return:
String: All the time off data where all the time offs are separated by slashes and each detail is separated by
commas.
*/
protected
String
allTimeOff
(){
StringBuilder
response
=
new
StringBuilder
(
"allTimeOff"
);
try
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment