Skip to content

Commit

Permalink
Major Commit: Added all the required methods for Immigration details …
Browse files Browse the repository at this point in the history
…and Client Details.

 Updated the code for adding the Auditing data for the existing entity objects.
 Added all the required static content for the application like the bootstrap and other datatable contents for the application.
  • Loading branch information
mahi-mullapudi committed Sep 6, 2018
1 parent a70fe18 commit 9f85f65
Show file tree
Hide file tree
Showing 76 changed files with 2,503 additions and 1,387 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing
public class EmployeeManagementApplication {

public static void main(String[] args) {
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/tutorialq/entities/AuditModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.tutorialq.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(
value = {"createdAt", "updatedAt"},
allowGetters = true
)
public abstract class AuditModel {
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
@Column(name = "created_at", nullable = false, updatable = false)
@CreatedDate
private LocalDateTime createdAt;

@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
@Column(name = "updated_at", nullable = false)
@LastModifiedDate
private LocalDateTime updatedAt;

}
7 changes: 2 additions & 5 deletions src/main/java/com/tutorialq/entities/ClientDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ClientDetails implements Serializable {
public class ClientDetails extends AuditModel implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "CLIENT_DETAILS_ID", unique = true, nullable = false)
private long clientDetailsId;
private String clientName; //Name of the Client.
private String clientStreet;
private String clientAddress;//Address of the Client.
private String clientCity;
private String clientState;
Expand Down Expand Up @@ -49,10 +50,6 @@ public class ClientDetails implements Serializable {
private Employee employee;
//Audit Information
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateCreated;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateLastModified;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateApproved;
private String nameCreated;
private String nameLastModified;
Expand Down
45 changes: 0 additions & 45 deletions src/main/java/com/tutorialq/entities/DocumentRefData.java

This file was deleted.

21 changes: 2 additions & 19 deletions src/main/java/com/tutorialq/entities/DocumentUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,36 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Entity
@EqualsAndHashCode(exclude = {"employee", "clientDetailsId"})
@EqualsAndHashCode(exclude = {"employee", "documentUploadId"})
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class DocumentUpload implements Serializable {
public class DocumentUpload extends AuditModel implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "DOCUMENT_UPLOAD_ID", unique = true, nullable = false)
private long documentUploadId;
private long documentRefDataId;
private java.sql.Blob blobMessage;
private String dscFileName;
private String rowId;
private long fileSize;
private String dscSectionName; //To get the section name of the uploaded file
private String dscComments;
//Extra fields to be populated from other tables.
private String uploadedUserName;
private String shortDescription; //This stores the display name of the uploaded section name.
private int numOrder;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "EMPLOYEE_ID", nullable = false)
@JsonIgnore
private Employee employee;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DOCUMENT_REF_ID", nullable = false)
@JsonIgnore
private DocumentRefData documentRefData;
//Audit Information
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateCreated;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateLastModified;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateApproved;
private String nameCreated;
private String nameLastModified;
private String nameApproved;

}
20 changes: 1 addition & 19 deletions src/main/java/com/tutorialq/entities/Employee.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;

@Data
@Entity
@ToString(exclude = {"empPassword", "empPassword2"})
@NoArgsConstructor
@AllArgsConstructor
public class Employee implements Serializable {
public class Employee extends AuditModel implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "employee_id", unique = true, nullable = false)
Expand Down Expand Up @@ -60,29 +58,13 @@ public class Employee implements Serializable {
private LocalDate dateInactivated;
private String nameUserInactivated; // Who inactivated this user

@OneToMany(fetch = FetchType.LAZY, mappedBy = "employee")
private Set<Timesheet> timesheetRecords = new HashSet<>(0);

@OneToMany(fetch = FetchType.LAZY, mappedBy = "employee")
private Set<ClientDetails> clientDetails = new HashSet<>(0);

@OneToMany(fetch = FetchType.LAZY, mappedBy = "employee")
private Set<DocumentUpload> documentUploads = new HashSet<>(0);

@OneToMany(fetch = FetchType.LAZY, mappedBy = "employee")
private Set<ImmigrationDetails> immigrationDetails = new HashSet<>(0);

public String getEmployeeFullName() {
return (StringUtils.isNotBlank(this.employeeFirstName) ? this.employeeFirstName : "") +
" " + (StringUtils.isNotBlank(this.employeeLastName) ? this.employeeLastName : "");
}

//Audit Information
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateCreated;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateLastModified;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateApproved;
private String nameCreated;
private String nameLastModified;
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/tutorialq/entities/ImmigrationDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ImmigrationDetails implements Serializable {
public class ImmigrationDetails extends AuditModel implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Expand All @@ -44,10 +43,6 @@ public class ImmigrationDetails implements Serializable {

//Audit Information
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateCreated;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateLastModified;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDate dateApproved;
private String nameCreated;
private String nameLastModified;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/tutorialq/entities/Timesheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;

Expand All @@ -21,7 +23,7 @@
@EqualsAndHashCode(exclude = {"employee", "timesheetId"})
@NoArgsConstructor
@AllArgsConstructor
public class Timesheet implements Serializable {
public class Timesheet extends AuditModel implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "TIMESHEET_ID", unique = true, nullable = false)
Expand Down Expand Up @@ -51,17 +53,15 @@ public class Timesheet implements Serializable {
/* Mapping*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "EMPLOYEE_ID", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JsonIgnore
private Employee employee;
//Audit Information
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateCreated;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateLastModified;
@DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss")
private LocalDateTime dateApproved;
private String nameCreated; //Name of the user Uploaded the timesheet.
private String nameLastModified;
private String nameApproved;


}
21 changes: 21 additions & 0 deletions src/main/java/com/tutorialq/models/DashboardSearch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.tutorialq.models;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDate;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class DashboardSearch implements Serializable {
private long employeeId;
@DateTimeFormat(pattern = "MM/dd/yyyy")
private LocalDate fromDate;
@DateTimeFormat(pattern = "MM/dd/yyyy")
private LocalDate toDate;
private String timesheetStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional(readOnly = true)
public interface ClientDetailsRepository extends JpaRepository<ClientDetails, Long> {

/**
* Returns the list of ClientDetails for a given EmployeeId.
*
* @param employeeId
* @return
*/
List<ClientDetails> findAllByEmployeeEmployeeIdOrderByCreatedAtDesc(long employeeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import com.tutorialq.constants.QueryProperties;
import com.tutorialq.entities.Employee;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

@Transactional(readOnly = true)
public interface EmployeeRepository extends CrudRepository<Employee, Long> {
public interface EmployeeRepository extends JpaRepository<Employee, Long> {

Employee findEmployeeByEmployeeEmailId(String emailId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional(readOnly = true)
public interface ImmigrationDetailsRepository extends JpaRepository<ImmigrationDetails, Long> {

/**
* Returns the List of ImmigrationDetails for a given EmployeeId.
*
* @param employeeId
* @return
*/
List<ImmigrationDetails> findAllByEmployeeEmployeeId(long employeeId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import com.tutorialq.entities.Employee;
import com.tutorialq.entities.Timesheet;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

@Transactional(readOnly = true)
public interface TimesheetRepository extends CrudRepository<Timesheet, Long> {
public interface TimesheetRepository extends JpaRepository<Timesheet, Long> {

public List<Timesheet> findByEmployeeEmployeeId(long employeeId);

/**
* Returns the Timesheet information based on the given End Date of the week.
Expand Down
Loading

0 comments on commit 9f85f65

Please sign in to comment.