Skip to content

Commit

Permalink
IR-719 remove geographical region for now - due to mapping issues. (#…
Browse files Browse the repository at this point in the history
…2310)

* IR-719 remove geographical region for now - due to mapping issues.

* IR-719 remove geographical region for now - due to mapping issues.

* IR-719 remove geographical region for now - due to mapping issues.

* IR-719 remove geographical region for now - due to mapping issues.
  • Loading branch information
Mjwillis authored Dec 9, 2024
1 parent 4faa0f3 commit ee0babc
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import lombok.Builder;
import lombok.Builder.Default;
import lombok.Data;
import uk.gov.justice.hmpps.prison.api.model.v1.CodeDescription;

import java.time.LocalDate;
import java.util.List;
Expand Down Expand Up @@ -57,10 +56,7 @@ public class Agency {
@Schema(description = "Region of this agency")
private RefCodeAndDescription region;

@Schema(description = "Geographical region for this agency")
private RefCodeAndDescription geographicalRegion;

public Agency(String agencyId, String description, String longDescription, String agencyType, boolean active, String courtType, String courtTypeDescription, LocalDate deactivationDate, List<AddressDto> addresses, List<Telephone> phones, List<Email> emails, RefCodeAndDescription area, RefCodeAndDescription region, RefCodeAndDescription geographicalRegion) {
public Agency(String agencyId, String description, String longDescription, String agencyType, boolean active, String courtType, String courtTypeDescription, LocalDate deactivationDate, List<AddressDto> addresses, List<Telephone> phones, List<Email> emails, RefCodeAndDescription area, RefCodeAndDescription region) {
this.agencyId = agencyId;
this.description = description;
this.longDescription = longDescription;
Expand All @@ -74,7 +70,6 @@ public Agency(String agencyId, String description, String longDescription, Strin
this.emails = emails;
this.area = area;
this.region = region;
this.geographicalRegion = geographicalRegion;
}

public Agency() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ data class AgencyDto(
null,
null,
null,
null,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;
import org.hibernate.type.YesNoConverter;

Expand All @@ -37,7 +39,6 @@

import static uk.gov.justice.hmpps.prison.repository.jpa.model.AgencyLocationType.AGY_LOC_TYPE;
import static uk.gov.justice.hmpps.prison.repository.jpa.model.CourtType.JURISDICTION;
import static uk.gov.justice.hmpps.prison.repository.jpa.model.GeographicRegion.GEOGRAPHIC;

@Data
@Entity
Expand Down Expand Up @@ -71,9 +72,6 @@
@NamedAttributeNode(value = "courtType"),
@NamedAttributeNode(value = "region"),
@NamedAttributeNode(value = "area"),
@NamedAttributeNode(value = "geographicRegion"),


}
)
public class AgencyLocation extends AuditableEntity {
Expand Down Expand Up @@ -144,13 +142,6 @@ public class AgencyLocation extends AuditableEntity {
@JoinColumn(name = "NOMS_REGION_CODE")
private Region region;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumnsOrFormulas(value = {
@JoinColumnOrFormula(formula = @JoinFormula(value = "'" + GEOGRAPHIC + "'", referencedColumnName = "domain")),
@JoinColumnOrFormula(column = @JoinColumn(name = "GEOGRAPHIC_REGION_CODE", referencedColumnName = "code"))
})
private GeographicRegion geographicRegion;

public void removeAddress(final AgencyAddress address) {
addresses.remove(address);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class AgencyLocationFilter implements Specification<AgencyLocation> {

private String region;

private String geographicRegion;

private String establishmentType;

public Predicate toPredicate(final Root<AgencyLocation> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
Expand Down Expand Up @@ -72,10 +70,6 @@ public Predicate toPredicate(final Root<AgencyLocation> root, final CriteriaQuer
predicateBuilder.add(cb.equal(root.get("region").get("code"), region));
}

if (geographicRegion != null) {
predicateBuilder.add(cb.equal(root.get("geographicRegion").get("code"), geographicRegion));
}

if (establishmentType != null) {
predicateBuilder.add(cb.equal(root.get("establishmentTypes").get("establishmentType").get("code"), establishmentType));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ private static AgencyBuilder transformToBuilder(final AgencyLocation agency, fin
.longDescription(agency.getLongDescription())
.deactivationDate(agency.getDeactivationDate())
.area(withAreas ? agency.getArea() != null ? agency.getArea().toDto() : null : null)
.region(withAreas ? agency.getRegion() != null ? agency.getRegion().toDto() : null : null)
.geographicalRegion(withAreas ? agency.getGeographicRegion() != null ? agency.getGeographicRegion().toDto() : null : null);
.region(withAreas ? agency.getRegion() != null ? agency.getRegion().toDto() : null : null);
}

static private String codeOrNull(final ReferenceCode referenceData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,8 @@ class AgencyResourceIntTest : ResourceTest() {
.jsonPath("$[?(@.agencyId=='BMI')].area.code").isEqualTo("WMID")
.jsonPath("$[?(@.agencyId=='BMI')].area.description").isEqualTo("West Midlands")
.jsonPath("$[?(@.agencyId=='BMI')].region.description").isEqualTo("West Midlands")
.jsonPath("$[?(@.agencyId=='BMI')].geographicalRegion.description").isEqualTo("West Midlands")
.jsonPath("$[?(@.agencyId=='WAI')].area.description").isEqualTo("West Midlands")
.jsonPath("$[?(@.agencyId=='WAI')].region.description").isEqualTo("West Midlands")
.jsonPath("$[?(@.agencyId=='WAI')].geographicalRegion.description").isEqualTo("West Midlands")
}

@Test
Expand All @@ -308,7 +306,6 @@ class AgencyResourceIntTest : ResourceTest() {
.jsonPath("$[?(@.agencyId=='BXI')].area.description").isEqualTo("London")
.jsonPath("$[?(@.agencyId=='BXI')].region.code").isEqualTo("LON")
.jsonPath("$[?(@.agencyId=='BXI')].region.description").isEqualTo("London")
.jsonPath("$[?(@.agencyId=='BXI')].geographicalRegion.description").isEqualTo("London")
.jsonPath("$[?(@.agencyId=='BWI')]").doesNotExist()
.jsonPath("$[?(@.agencyId=='MDI')]").doesNotExist()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,6 @@ class AgencyLocationRepositoryTest {
assertThat(agencies).extracting("id").containsAnyOf("BMI", "WAI")
}

@Test
fun findAgenciesWithGeographicCodes() {
val expected = AgencyLocationFilter.builder()
.active(true)
.geographicRegion("WMID")
.build()
val agencies = repository.findAll(expected)
assertThat(agencies).extracting("id").containsAnyOf("BMI", "WAI")
}

@Test
fun findAgenciesWithEstablishmentType() {
val expected = AgencyLocationFilter.builder()
Expand Down

0 comments on commit ee0babc

Please sign in to comment.