Skip to content

Commit

Permalink
Po 252 xml to json conversion for legacy response (#393)
Browse files Browse the repository at this point in the history
* update schemas, update defendantaccount details service to retrieve notes

* jaxb util classes

* Add xml annotations to response classes

* Add xml annotations to response classes

* Add unmarshaller to response handler

* Fix tests

* Add xml names for fields in dto layer

* Tests for utils and tidy-up
  • Loading branch information
DeclanClarkeCGI committed Jul 3, 2024
1 parent 450d37c commit 291db44
Show file tree
Hide file tree
Showing 25 changed files with 442 additions and 105 deletions.
8 changes: 8 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/NoteDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@


import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.jackson.Jacksonized;
import uk.gov.hmcts.opal.util.LocalDateTimeAdapter;

import java.time.LocalDateTime;

Expand All @@ -15,6 +20,8 @@
@NoArgsConstructor
@AllArgsConstructor
@Jacksonized
@XmlRootElement(name = "note")
@XmlAccessorType(XmlAccessType.FIELD)
public class NoteDto implements ToJsonString {

private Long noteId;
Expand All @@ -30,6 +37,7 @@ public class NoteDto implements ToJsonString {
private String noteText;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
private LocalDateTime postedDate;

private String postedBy;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/PartyDto.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package uk.gov.hmcts.opal.dto;


import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.jackson.Jacksonized;
import uk.gov.hmcts.opal.util.LocalDateAdapter;
import uk.gov.hmcts.opal.util.LocalDateTimeAdapter;

import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -15,6 +21,8 @@
@NoArgsConstructor
@AllArgsConstructor
@Jacksonized
@XmlRootElement(name = "party")
@XmlAccessorType(XmlAccessType.FIELD)
public class PartyDto implements ToJsonString {
private Long partyId;
private boolean organisation;
Expand All @@ -30,8 +38,10 @@ public class PartyDto implements ToJsonString {
private String addressLine5;
private String postcode;
private String accountType;
@XmlJavaTypeAdapter(LocalDateAdapter.class)
private LocalDate dateOfBirth;
private Short age;
private String niNumber;
@XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
private LocalDateTime lastChangedDate;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -12,9 +15,11 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
@XmlAccessorType(XmlAccessType.FIELD)
public class AccountActivitiesDto {

@JsonProperty(value = "account_activity")
@XmlElement(name = "account_activity")
private List<AccountActivityDto> accountActivity;

}
14 changes: 14 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/legacy/AccountActivityDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import uk.gov.hmcts.opal.util.LocalDateTimeAdapter;

import java.time.LocalDateTime;

Expand All @@ -15,27 +20,36 @@
@AllArgsConstructor
@NoArgsConstructor
@JsonRootName(value = "account_activity")
@XmlAccessorType(XmlAccessType.FIELD)
public class AccountActivityDto {

@JsonProperty("activity_id")
@XmlElement(name = "activity_id")
private Integer activityId;

@JsonProperty("activity_type")
@XmlElement(name = "activity_type")
private String activityType;

@JsonProperty("activity_type_code")
@XmlElement(name = "activity_type_code")
private String activityTypeCode;

@JsonProperty("activity_text")
@XmlElement(name = "activity_text")
private String activityText;

@JsonProperty("posted_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
@XmlElement(name = "posted_date")
private LocalDateTime postedDate;

@JsonProperty("posted_by")
@XmlElement(name = "posted_by")
private String postedBy;

@JsonProperty("amount")
@XmlElement(name = "amount")
private Double amount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import uk.gov.hmcts.opal.util.LocalDateAdapter;

import java.math.BigDecimal;
import java.time.LocalDate;
Expand All @@ -14,64 +19,120 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
@XmlAccessorType(XmlAccessType.FIELD)
public class DefendantAccountDto {

@JsonProperty("defendant_account_id")
@XmlElement(name = "defendant_account_id")
private Long defendantAccountId;

@JsonProperty("account_number")
@XmlElement(name = "account_number")
private String accountNumber;

@JsonProperty("amount_imposed")
@XmlElement(name = "amount_imposed")
private BigDecimal amountImposed;

@JsonProperty("amount_paid")
@XmlElement(name = "amount_paid")
private BigDecimal amountPaid;

@JsonProperty("account_balance")
@XmlElement(name = "account_balance")
private BigDecimal accountBalance;

@JsonProperty("business_unit_id")
@XmlElement(name = "business_unit_id")
private int businessUnitId;

@JsonProperty("business_unit_name")
@XmlElement(name = "business_unit_name")
private String businessUnitName;

@JsonProperty("account_status")
@XmlElement(name = "account_status")
private String accountStatus;

@JsonProperty("originator_name")
@XmlElement(name = "originator_name")
private String originatorName;

@JsonProperty("imposed_hearing_date")
@JsonFormat(pattern = "yyyy-MM-dd")
@XmlJavaTypeAdapter(LocalDateAdapter.class)
@XmlElement(name = "imposed_hearing_date")
private LocalDate imposedHearingDate;

@JsonProperty("imposing_court_code")
@XmlElement(name = "imposing_court_code")
private int imposingCourtCode;

@JsonProperty("last_hearing_date")
@XmlElement(name = "last_hearing_date")
private String lastHearingDate;

@JsonProperty("last_hearing_court_code")
@XmlElement(name = "last_hearing_court_code")
private int lastHearingCourtCode;

@JsonProperty("last_changed_date")
@JsonFormat(pattern = "yyyy-MM-dd")
@XmlJavaTypeAdapter(LocalDateAdapter.class)
@XmlElement(name = "last_changed_date")
private LocalDate lastChangedDate;

@JsonProperty("last_movement_date")
@JsonFormat(pattern = "yyyy-MM-dd")
@XmlJavaTypeAdapter(LocalDateAdapter.class)
@XmlElement(name = "last_movement_date")
private LocalDate lastMovementDate;

@JsonProperty("collection_order")
@XmlElement(name = "collection_order")
private boolean collectionOrder;

@JsonProperty("enforcing_court_code")
@XmlElement(name = "enforcing_court_code")
private int enforcingCourtCode;

@JsonProperty("last_enforcement")
@XmlElement(name = "last_enforcement")
private String lastEnforcement;

@JsonProperty("enf_override_result_id")
@XmlElement(name = "enf_override_result_id")
private String enfOverrideResultId;

@JsonProperty("enf_override_enforcer_code")
@XmlElement(name = "enf_override_enforcer_code")
private Short enfOverrideEnforcerCode;

@JsonProperty("enf_override_tfo_lja_code")
@XmlElement(name = "enf_override_tfo_lja_code")
private int enfOverrideTfoLjaCode;

@JsonProperty("prosecutor_case_reference")
@XmlElement(name = "prosecutor_case_reference")
private String prosecutorCaseReference;

@JsonProperty("account_comments")
@XmlElement(name = "account_comments")
private String accountComments;

@JsonProperty("payment_terms")
@XmlElement(name = "payment_terms")
private PaymentTermsDto paymentTerms;

@JsonProperty("parties")
@XmlElement(name = "parties")
private PartiesDto parties;

@JsonProperty("impositions")
@XmlElement(name = "impositions")
private ImpositionsDto impositions;

@JsonProperty("account_activities")
@XmlElement(name = "account_activities")
private AccountActivitiesDto accountActivities;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.hmcts.opal.dto.legacy;

import jakarta.xml.bind.annotation.XmlRootElement;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -16,6 +17,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement
public class DefendantAccountsSearchResults implements ToJsonString {

List<DefendantAccountSearchResult> defendantAccountsSearchResult;
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/legacy/ImpositionDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -12,35 +15,46 @@
@AllArgsConstructor
@NoArgsConstructor
@JsonRootName(value = "imposition")
@XmlAccessorType(XmlAccessType.FIELD)
public class ImpositionDto {
@JsonProperty("imposition_id")
@XmlElement(name = "imposition_id")
private Integer impositionId;

@JsonProperty("posted_date")
@XmlElement(name = "posted_date")
private String postedDate;

@JsonProperty("result_id")
@XmlElement(name = "result_id")
private String resultId;

@JsonProperty("imposed_date")
@XmlElement(name = "imposed_date")
private String imposedDate;

@JsonProperty("imposing_court_code")
@XmlElement(name = "imposing_court_code")
private Integer imposingCourtCode;

@JsonProperty("imposed_amount")
@XmlElement(name = "imposed_amount")
private Double imposedAmount;

@JsonProperty("paid_amount")
@XmlElement(name = "paid_amount")
private Double paidAmount;

@JsonProperty("offence_title")
@XmlElement(name = "offence_title")
private String offenceTitle;

@JsonProperty("creditor_account_number")
@XmlElement(name = "creditor_account_number")
private String creditorAccountNumber;

@JsonProperty("creditor_name")
@XmlElement(name = "creditor_name")
private String creditorName;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -12,9 +15,11 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
@XmlAccessorType(XmlAccessType.FIELD)
public class ImpositionsDto {

@JsonProperty(value = "imposition")
@XmlElement(name = "imposition")
private List<ImpositionDto> imposition;

}
Loading

0 comments on commit 291db44

Please sign in to comment.