Skip to content

Commit

Permalink
DST-15503 : Improvements for Export Users spreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmccormackbconline committed Aug 7, 2024
1 parent b6154c6 commit 6696c0b
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 30 deletions.
25 changes: 20 additions & 5 deletions src/main/java/uk/co/bconline/ndelius/model/ExportResult.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.co.bconline.ndelius.model;

import com.opencsv.bean.CsvBindByName;
import com.opencsv.bean.CsvBindByPosition;
import lombok.*;

Expand All @@ -26,16 +27,30 @@ public final class ExportResult {
private LocalDate startDate;
@CsvBindByPosition(position = 6)
private LocalDate endDate;
@CsvBindByName(column = "Last Accessed Delius")
@CsvBindByPosition(position = 7)
private String homeArea;
private String lastAccessedDate;
@CsvBindByPosition(position = 8)
private String datasets;
private String homeArea;
@CsvBindByPosition(position = 9)
private String sector;
private String datasets;
@CsvBindByPosition(position = 10)
private String staffCode;
private String sector;
@CsvBindByPosition(position = 11)
private String staffGrade;
private String staffCode;
@CsvBindByPosition(position = 12)
private String staffGrade;
@CsvBindByName(column = "Team")
@CsvBindByPosition(position = 13)
private String teams;
@CsvBindByName(column = "LAU")
@CsvBindByPosition(position = 14)
private String lau;
@CsvBindByName(column = "PDU")
@CsvBindByPosition(position = 15)
private String pdu;
@CsvBindByPosition(position = 16)
private String provider;
@CsvBindByPosition(position = 17)
private String roleDescriptions;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package uk.co.bconline.ndelius.model.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import uk.co.bconline.ndelius.model.entity.export.ProbationAreaExportEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.io.Serializable;

@Getter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "BOROUGH")
public class BoroughEntity implements Serializable
{
@Id
@Column(name = "BOROUGH_ID")
@GeneratedValue(generator = "BOROUGH_ID_SEQ")
@SequenceGenerator(name = "BOROUGH_ID_SEQ", sequenceName = "BOROUGH_ID_SEQ", allocationSize = 1)
private Long id;

@Column(name = "CODE")
private String code;

@Column(name = "DESCRIPTION")
private String description;

@ManyToOne
@JoinColumn(name = "PROBATION_AREA_ID")
private ProbationAreaExportEntity probationArea;
}
33 changes: 33 additions & 0 deletions src/main/java/uk/co/bconline/ndelius/model/entity/LDUEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package uk.co.bconline.ndelius.model.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.io.Serializable;

@Getter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "LOCAL_DELIVERY_UNIT")
public class LDUEntity implements Serializable
{
@Id
@Column(name = "LOCAL_DELIVERY_UNIT_ID")
@GeneratedValue(generator = "LOCAL_DELIVERY_UNIT_ID_SEQ")
@SequenceGenerator(name = "LOCAL_DELIVERY_UNIT_ID_SEQ", sequenceName = "LOCAL_DELIVERY_UNIT_ID_SEQ", allocationSize = 1)
private Long id;

@Column(name = "CODE")
private String code;

@Column(name = "DESCRIPTION")
private String description;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public class UserEntity implements Serializable
@Column(name = "LAST_UPDATED_DATETIME")
private LocalDateTime updatedAt;

@Column(name = "LAST_ACCESSED_DATETIME")
@Type(type = "java.time.LocalDate")
private LocalDate lastAccessedDate;

@Setter
@Builder.Default
@OneToMany(mappedBy = "user")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package uk.co.bconline.ndelius.model.entity.export;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.io.Serializable;
import java.time.LocalDate;

@Getter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "BOROUGH")
public class BoroughExportEntity implements Serializable
{
@Id
@Column(name = "BOROUGH_ID")
@GeneratedValue(generator = "BOROUGH_ID_SEQ")
@SequenceGenerator(name = "BOROUGH_ID_SEQ", sequenceName = "BOROUGH_ID_SEQ", allocationSize = 1)
private Long id;

@Column(name = "CODE")
private String code;

@Column(name = "DESCRIPTION")
private String description;

@ManyToOne
@JoinColumn(name = "PROBATION_AREA_ID")
private ProbationAreaExportEntity probationArea;

@Column(name = "END_DATE")
@Type(type = "java.time.LocalDate")
private LocalDate endDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package uk.co.bconline.ndelius.model.entity.export;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.io.Serializable;
import java.time.LocalDate;

@Getter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "LOCAL_DELIVERY_UNIT")
public class LDUExportEntity implements Serializable
{
@Id
@Column(name = "LOCAL_DELIVERY_UNIT_ID")
@GeneratedValue(generator = "LOCAL_DELIVERY_UNIT_ID_SEQ")
@SequenceGenerator(name = "LOCAL_DELIVERY_UNIT_ID_SEQ", sequenceName = "LOCAL_DELIVERY_UNIT_ID_SEQ", allocationSize = 1)
private Long id;

@Column(name = "CODE")
private String code;

@Column(name = "DESCRIPTION")
private String description;

@Column(name = "END_DATE")
@Type(type = "java.time.LocalDate")
private LocalDate endDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.Type;

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

import static java.time.LocalDate.now;
import static org.hibernate.annotations.CacheConcurrencyStrategy.READ_ONLY;

@Entity
Expand All @@ -27,4 +30,13 @@ public class ProbationAreaExportEntity implements Serializable {

@Column(name = "DESCRIPTION")
private String description;

@Column(name = "END_DATE")
@Type(type = "java.time.LocalDate")
private LocalDate endDate;

public String getExportDescription()
{
return description + " (" + code + ") " + ((getEndDate() != null && getEndDate().isBefore(now())) ? " [Inactive]" : " [Active]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.Type;

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

import static org.hibernate.annotations.CacheConcurrencyStrategy.READ_ONLY;
import static java.time.LocalDate.now;

@Getter
@Entity
Expand All @@ -27,4 +28,41 @@ public class TeamExportEntity implements Serializable {

@Column(name = "DESCRIPTION")
private String description;

@ManyToOne
@JoinColumn(name = "LOCAL_DELIVERY_UNIT_ID")
private LDUExportEntity localDeliveryUnit;

@ManyToOne
@JoinColumn(name = "DISTRICT_ID")
private BoroughExportEntity borough;

@Column(name = "END_DATE")
@Type(type = "java.time.LocalDate")
private LocalDate endDate;

public String getExportDescription()
{
return description + " (" + code + ") " + ((getEndDate() != null && getEndDate().isBefore(now())) ? " [Inactive]" : " [Active]");
}

public String getLDUDescription()
{
if (localDeliveryUnit != null)
{
return localDeliveryUnit.getDescription() + " (" + localDeliveryUnit.getCode() + ") " + ((localDeliveryUnit.getEndDate() != null && localDeliveryUnit.getEndDate().isBefore(now())) ? " [Inactive]" : " [Active]");
} else {
return null;
}
}

public String getBoroughDescription()
{
if (borough != null)
{
return borough.getDescription() + " (" + borough.getCode() + ") " + ((borough.getEndDate() != null && borough.getEndDate().isBefore(now())) ? " [Inactive]" : " [Active]");
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Getter
Expand Down Expand Up @@ -56,4 +57,8 @@ public class UserExportEntity implements Serializable
joinColumns = @JoinColumn(name = "USER_ID"),
inverseJoinColumns = @JoinColumn(name = "PROBATION_AREA_ID"))
private List<ProbationAreaExportEntity> datasets;

@Column(name = "LAST_ACCESSED_DATETIME")
@Type(type = "java.time.LocalDateTime")
private LocalDateTime lastAccessedDate;
}
Loading

0 comments on commit 6696c0b

Please sign in to comment.