Skip to content

Commit

Permalink
Code format and added "spring-servlet file" to Git
Browse files Browse the repository at this point in the history
  • Loading branch information
Vane101 committed Jan 22, 2015
1 parent a2fa22e commit 3fbdcf2
Show file tree
Hide file tree
Showing 76 changed files with 13,375 additions and 10,077 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea
leavetrack.iml
target
src/main/webapp/WEB-INF/spring-servlet.xml
src/main/resources/config.properties
94 changes: 48 additions & 46 deletions leaveDatabase.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,54 @@ CREATE DATABASE leaveDatabase;

USE leaveDatabase;

Create table LeaveDays(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
yearEmployed DATE NOT NULL,
sickDaysLeft INT UNSIGNED NOT NULL DEFAULT 0,
sickDaysTotal INT UNSIGNED NOT NULL DEFAULT 0,
familyDaysLeft INT UNSIGNED NOT NULL DEFAULT 0,
familyDaysTotal INT UNSIGNED NOT NULL DEFAULT 0,
maternityDaysLeft INT UNSIGNED NOT NULL DEFAULT 0,
maternityDaysTotal INT UNSIGNED NOT NULL DEFAULT 0,
annualDaysLeft INT UNSIGNED NOT NULL DEFAULT 0,
annualDaysTotal INT UNSIGNED NOT NULL DEFAULT 0 );

Create table Employee(id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
leaveId BIGINT UNSIGNED NOT NULL,
FOREIGN KEY (leaveId) REFERENCES leavedays (id),
username varchar (20) NOT NULL,
firstName varchar (255) NOT NULL,
lastName varchar (255) NOT NULL ,
phoneNumber varchar (255) NOT NULL,
email varchar (255) NOT NULL,
jobTitle varchar (255),
supervisorId BIGINT unsigned,
FOREIGN KEY (supervisorId) REFERENCES Employee (id),
active Boolean NOT NULL DEFAULT TRUE,
password varchar(255) NOT NULL,
role varchar(255) NOT NULL DEFAULT 'employee',
version INT UNSIGNED DEFAULT 0);

Create table Request(
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
employeeid BIGINT UNSIGNED NOT NULL,
FOREIGN KEY (employeeid) REFERENCES Employee (id),
timestamp timestamp NOT NULL ,
leaveType varchar (255) NOT NULL ,
reason TEXT NOT NULL ,
startDate Date NOT NULL ,
endDate Date NOT NULL ,
state varchar (255),
comment TEXT);


INSERT INTO leavedays(yearEmployed) VALUE ('2006-01-01');
INSERT INTO Employee (leaveId,username,firstName,lastName,phoneNumber,email,jobTitle,password)VALUES (1,'Vzulu','Vane','Zulu','27718903620','[email protected]','Trainee','$2a$10$HTwDZJ1tLQobcObmlQH28.DC3fe1coMj.9H1dXj.Ul7A0q9Ktk9P.');
CREATE TABLE LeaveDays (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
yearEmployed DATE NOT NULL,
sickDaysLeft INT UNSIGNED NOT NULL DEFAULT 0,
sickDaysTotal INT UNSIGNED NOT NULL DEFAULT 0,
familyDaysLeft INT UNSIGNED NOT NULL DEFAULT 0,
familyDaysTotal INT UNSIGNED NOT NULL DEFAULT 0,
maternityDaysLeft INT UNSIGNED NOT NULL DEFAULT 0,
maternityDaysTotal INT UNSIGNED NOT NULL DEFAULT 0,
annualDaysLeft INT UNSIGNED NOT NULL DEFAULT 0,
annualDaysTotal INT UNSIGNED NOT NULL DEFAULT 0);

CREATE TABLE Employee (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
leaveId BIGINT UNSIGNED NOT NULL,
FOREIGN KEY (leaveId) REFERENCES leavedays (id),
username VARCHAR(20) NOT NULL,
firstName VARCHAR(255) NOT NULL,
lastName VARCHAR(255) NOT NULL,
phoneNumber VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
jobTitle VARCHAR(255),
supervisorId BIGINT UNSIGNED,
FOREIGN KEY (supervisorId) REFERENCES Employee (id),
active BOOLEAN NOT NULL DEFAULT TRUE,
password VARCHAR(255) NOT NULL,
role VARCHAR(255) NOT NULL DEFAULT 'employee',
version INT UNSIGNED DEFAULT 0);

CREATE TABLE Request (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
employeeid BIGINT UNSIGNED NOT NULL,
FOREIGN KEY (employeeid) REFERENCES Employee (id),
timestamp TIMESTAMP NOT NULL,
leaveType VARCHAR(255) NOT NULL,
reason TEXT NOT NULL,
startDate DATE NOT NULL,
endDate DATE NOT NULL,
state VARCHAR(255),
comment TEXT);


INSERT INTO leavedays (yearEmployed) VALUE ('2006-01-01');
INSERT INTO Employee (leaveId, username, firstName, lastName, phoneNumber, email, jobTitle, password) VALUES
(1, 'Vzulu', 'Vane', 'Zulu', '27718903620', '[email protected]', 'Trainee',
'$2a$10$HTwDZJ1tLQobcObmlQH28.DC3fe1coMj.9H1dXj.Ul7A0q9Ktk9P.');



8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springapp</groupId>
Expand Down Expand Up @@ -72,7 +72,7 @@
</dependency>

<!-- Hibernate -->
<dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
Expand Down Expand Up @@ -146,7 +146,7 @@
<version>${security.version}</version>
</dependency>

<!---JODA TIME -->
<!---JODA TIME -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
Expand Down Expand Up @@ -177,7 +177,7 @@
<version>2.0.6</version>
</dependency>

<!-- SLF4J and LogBack -->
<!-- SLF4J and LogBack -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/ubiquitech/leaveTrack/SessionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import javax.servlet.http.HttpSessionListener;

/**
* Created by vane on 2014/12/01.
* vane created on 2014/12/01.
*/
public class SessionListener implements HttpSessionListener{
public class SessionListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
System.out.println("session created");
}

@Override
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
System.out.println("session destroyed");
System.out.println("session destroyed");
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.ubiquitech.leaveTrack.calendar;

/**
* Created by vane on 2015/01/16.
* vane created on 2015/01/16.
*/
public class FullCalendar {
String start;
String end;
String title;
String color;

public FullCalendar(String color, String title, String start,String end) {
public FullCalendar(String color, String title, String start, String end) {
this.color = color;
this.title = title;
this.end = end;
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/ubiquitech/leaveTrack/dao/EmployeeDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
import java.util.List;

/**
* Created by vane on 2014/11/20.
* vane created on 2014/11/20.
*/
public interface EmployeeDao {
public void createEmployee(Employee emp);
public List<Object[]> getEmployeeNames();
public Boolean checkUsername(String username);
public Employee getEmployee(String username);
public Employee getEmployeeById(Long id);
void createEmployee(Employee emp);

List<Object[]> getEmployeeNames();

Boolean checkUsername(String username);

Employee getEmployee(String username);

Employee getEmployeeById(Long id);
}
11 changes: 5 additions & 6 deletions src/main/java/com/ubiquitech/leaveTrack/dao/EmployeeDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* Created by vane on 2014/11/20.
* vane created on 2014/11/20.
*/
@Repository
@SuppressWarnings("unchecked")
public class EmployeeDaoImpl implements EmployeeDao {
@Autowired
private SessionFactory sessionFactory;
@Autowired
private SessionFactory sessionFactory;

@Override
@Override
public void createEmployee(Employee employee) {
Session session = this.sessionFactory.getCurrentSession();
session.saveOrUpdate(employee);
Expand All @@ -27,7 +26,7 @@ public void createEmployee(Employee employee) {
@Override
public Employee getEmployeeById(Long id) {
Session session = sessionFactory.getCurrentSession();
return (Employee) session.get(Employee.class,id);
return (Employee) session.get(Employee.class, id);
}

@Override
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/ubiquitech/leaveTrack/dao/RequestDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
import java.util.List;

/**
* Created by vane on 2014/12/08.
* vane created on 2014/12/08.
*/
public interface RequestDao {
public void createRequest(Request request);

public List getRequestsByStatusAndSupervisorId(String status, Long id);
public List getRequestsByStatusAndRequestId(String status,Long id);

public List getRequestsByStatusAndRequestId(String status, Long id);

public List getRequestsByState(String status);

public List getQueriedRequests(RequestQueryForm requestQueryForm);
}
63 changes: 31 additions & 32 deletions src/main/java/com/ubiquitech/leaveTrack/dao/RequestImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
import java.util.List;

/**
* Created by vane on 2014/12/08.
* vane created on 2014/12/08.
*/

@Repository
@SuppressWarnings("unchecked")
public class RequestImpl implements RequestDao {
Expand All @@ -33,20 +32,20 @@ public List getRequestsByStatusAndSupervisorId(String state, Long id) {
Session session = sessionFactory.openSession();
Criteria request = session.createCriteria(Request.class);
Criteria employee = request.createCriteria("employee");
Criteria supervisor=employee.createCriteria("supervisor");
supervisor.add(Restrictions.eq("id",id));
request.add((Restrictions.eq("state",state)));
Criteria supervisor = employee.createCriteria("supervisor");
supervisor.add(Restrictions.eq("id", id));
request.add((Restrictions.eq("state", state)));
return request.list();
}

@Override
public List getRequestsByStatusAndRequestId(String state, Long id) {
Session session = sessionFactory.openSession();
Criteria request = session.createCriteria(Request.class);
request.add(Restrictions.eq("id",id));
request.add(Restrictions.eq("id", id));

if(!state.equals("")){
request.add(Restrictions.and(Restrictions.eq("state",state)));
if (!state.equals("")) {
request.add(Restrictions.and(Restrictions.eq("state", state)));
}
return request.list();
}
Expand All @@ -55,52 +54,52 @@ public List getRequestsByStatusAndRequestId(String state, Long id) {
public List getRequestsByState(String state) {
Session session = sessionFactory.openSession();
Criteria request = session.createCriteria(Request.class);
request.add(Restrictions.eq("state",state));
request.add(Restrictions.eq("state", state));
return request.list();
}

@Override
public List getQueriedRequests(RequestQueryForm requestQueryForm) {
String state=requestQueryForm.getState();
String leaveType=requestQueryForm.getLeaveType();
String employeeFirstName=requestQueryForm.getEmployeeFirstName();
String employeeLastName=requestQueryForm.getEmployeeLastName();
String supervisorFirstName=requestQueryForm.getSupervisorFirstName();
String supervisorLastName=requestQueryForm.getEmployeeLastName();
Long requestId=requestQueryForm.getRequestId();
String state = requestQueryForm.getState();
String leaveType = requestQueryForm.getLeaveType();
String employeeFirstName = requestQueryForm.getEmployeeFirstName();
String employeeLastName = requestQueryForm.getEmployeeLastName();
String supervisorFirstName = requestQueryForm.getSupervisorFirstName();
String supervisorLastName = requestQueryForm.getEmployeeLastName();
Long requestId = requestQueryForm.getRequestId();

Session session = sessionFactory.openSession();

Criteria request = session.createCriteria(Request.class);
Criteria employee=request.createCriteria("employee");
Criteria supervisor=employee.createCriteria("supervisor");
Criteria employee = request.createCriteria("employee");
Criteria supervisor = employee.createCriteria("supervisor");

if(!state.equals("")){
request.add(Restrictions.and(Restrictions.eq("state",state)));
if (!state.equals("")) {
request.add(Restrictions.and(Restrictions.eq("state", state)));
}

if(!leaveType.equals("")){
request.add(Restrictions.and(Restrictions.eq("leaveType",leaveType)));
if (!leaveType.equals("")) {
request.add(Restrictions.and(Restrictions.eq("leaveType", leaveType)));
}

if(!(requestId==null)){
request.add(Restrictions.and(Restrictions.eq("id",requestId)));
if (!(requestId == null)) {
request.add(Restrictions.and(Restrictions.eq("id", requestId)));
}

if(!employeeFirstName.equals("")){
employee.add(Restrictions.and(Restrictions.eq("firstName",employeeFirstName)));
if (!employeeFirstName.equals("")) {
employee.add(Restrictions.and(Restrictions.eq("firstName", employeeFirstName)));
}

if(!employeeLastName.equals("")){
employee.add(Restrictions.and(Restrictions.eq("lastName",employeeLastName)));
if (!employeeLastName.equals("")) {
employee.add(Restrictions.and(Restrictions.eq("lastName", employeeLastName)));
}

if(!supervisorFirstName.equals("")){
supervisor.add(Restrictions.and(Restrictions.eq("firstName",supervisorFirstName)));
if (!supervisorFirstName.equals("")) {
supervisor.add(Restrictions.and(Restrictions.eq("firstName", supervisorFirstName)));
}

if(!supervisorLastName.equals("")){
supervisor.add(Restrictions.and(Restrictions.eq("lastName",supervisorLastName)));
if (!supervisorLastName.equals("")) {
supervisor.add(Restrictions.and(Restrictions.eq("lastName", supervisorLastName)));
}

return request.list();
Expand Down
Loading

0 comments on commit 3fbdcf2

Please sign in to comment.