Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DST-15503 Fixes for user export changes #819

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build

on:
workflow_dispatch:
release:
types: [published, edited]
push:
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/uk/co/bconline/ndelius/model/ExportResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public final class ExportResult {
private String teams;
@CsvBindByName(column = "LAU")
@CsvBindByPosition(position = 14)
private String lau;
private String localAdminUnit;
@CsvBindByName(column = "PDU")
@CsvBindByPosition(position = 15)
private String pdu;
private String probationDeliveryUnit;
@CsvBindByPosition(position = 16)
private String provider;
@CsvBindByPosition(position = 17)
private String roleDescriptions;
private String roleNames;
}

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/java/uk/co/bconline/ndelius/model/entity/LDUEntity.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,17 @@
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 uk.co.bconline.ndelius.model.entity.converter.YNConverter;

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

@Getter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "BOROUGH")
public class BoroughExportEntity implements Serializable
{
public class BoroughExportEntity implements Serializable {
@Id
@Column(name = "BOROUGH_ID")
@GeneratedValue(generator = "BOROUGH_ID_SEQ")
Expand All @@ -35,11 +26,15 @@ public class BoroughExportEntity implements Serializable
@Column(name = "DESCRIPTION")
private String description;

@Column(name = "SELECTABLE")
@Convert(converter = YNConverter.class)
private boolean selectable;

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

@Column(name = "END_DATE")
@Type(type = "java.time.LocalDate")
private LocalDate endDate;
public String getExportDescription() {
return description + " (" + code + ")" + (isSelectable() ? "" : " [Inactive]");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package uk.co.bconline.ndelius.model.entity.export;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import uk.co.bconline.ndelius.model.entity.converter.YNConverter;

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

@Getter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "DISTRICT")
public class DistrictExportEntity implements Serializable
{
@Id
@Column(name = "DISTRICT_ID")
@GeneratedValue(generator = "DISTRICT_ID_SEQ")
@SequenceGenerator(name = "DISTRICT_ID_SEQ", sequenceName = "DISTRICT_ID_SEQ", allocationSize = 1)
private Long id;

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

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

@Column(name = "SELECTABLE")
@Convert(converter = YNConverter.class)
private boolean selectable;

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

public String getExportDescription() {
return description + " (" + code + ")" + (isSelectable() ? "" : " [Inactive]");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +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 java.time.LocalDate.now;
import static org.hibernate.annotations.CacheConcurrencyStrategy.READ_ONLY;

@Entity
@Getter
Expand All @@ -37,6 +35,6 @@ public class ProbationAreaExportEntity implements Serializable {

public String getExportDescription()
{
return description + " (" + code + ") " + ((getEndDate() != null && getEndDate().isBefore(now())) ? " [Inactive]" : " [Active]");
return description + " (" + code + ")" + ((getEndDate() != null && getEndDate().isBefore(now())) ? " [Inactive]" : "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,15 @@ 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;
private DistrictExportEntity district;

@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;
}
public String getExportDescription() {
return description + " (" + code + ")" + ((getEndDate() != null && getEndDate().isBefore(now())) ? " [Inactive]" : "");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package uk.co.bconline.ndelius.service;

import uk.co.bconline.ndelius.model.entry.RoleAssociationEntry;
import uk.co.bconline.ndelius.model.entry.RoleEntry;

import java.util.List;
Expand All @@ -10,6 +9,7 @@ public interface UserRoleService
{
Set<RoleEntry> getRolesICanAssign();
Set<RoleEntry> getUserRoles(String username);
Set<String> getUserRoleNames(String username);
List<String> getAllUsersWithRole(String role);
Set<RoleEntry> getClientRoles(String clientId);
Set<String> getUserInteractions(String username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ public Set<RoleEntry> getUserRoles(String username) {
return getAssignedRoles(username, usersBase);
}

@Override
public Set<String> getUserRoleNames(String username) {
return stream(getAssignedRoleAssociations(username, usersBase).spliterator(), false)
.map(RoleAssociationEntry::getCn)
.collect(toSet());
}

@Override
public Set<RoleEntry> getClientRoles(String clientId) {
return getAssignedRoles(clientId, clientsBase);
Expand Down
Loading
Loading