From f644ffa214d93bfa0887cf78603b075310dc6191 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Mon, 29 Jun 2020 13:25:49 +0200 Subject: bugfix activated day --- src/org/uic/ticket/api/asn/omv1/FIPTicketData.java | 12 +++++- .../uic/ticket/api/asn/omv1/OpenTicketData.java | 46 +++++++++++++--------- src/org/uic/ticket/api/asn/omv1/PassData.java | 40 ++++++++++++------- 3 files changed, 63 insertions(+), 35 deletions(-) diff --git a/src/org/uic/ticket/api/asn/omv1/FIPTicketData.java b/src/org/uic/ticket/api/asn/omv1/FIPTicketData.java index 79eba9c..eac2ef3 100644 --- a/src/org/uic/ticket/api/asn/omv1/FIPTicketData.java +++ b/src/org/uic/ticket/api/asn/omv1/FIPTicketData.java @@ -261,7 +261,11 @@ public class FIPTicketData extends Object { public void setActivatedDays(Collection dates, Date issuingDate){ - this.activatedDay.clear(); + if (this.activatedDay != null) { + this.activatedDay.clear(); + } else { + this.activatedDay= new SequenceOfActivatedDays(); + } if (dates != null && !dates.isEmpty()) { @@ -277,6 +281,10 @@ public class FIPTicketData extends Object { Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day); + if (this.activatedDay == null) { + this.activatedDay = new SequenceOfActivatedDays(); + } + if (dayDiff != null) { this.activatedDay.add(dayDiff); } @@ -285,6 +293,8 @@ public class FIPTicketData extends Object { public Collection getActivatedDays(Date issuingDate) { + if (this.activatedDay == null) return null; + ArrayList dates = new ArrayList(); for (Long diff: this.getActivatedDay()) { diff --git a/src/org/uic/ticket/api/asn/omv1/OpenTicketData.java b/src/org/uic/ticket/api/asn/omv1/OpenTicketData.java index 8fe20f3..018241a 100644 --- a/src/org/uic/ticket/api/asn/omv1/OpenTicketData.java +++ b/src/org/uic/ticket/api/asn/omv1/OpenTicketData.java @@ -564,10 +564,34 @@ public class OpenTicketData extends Object { } + + + public void setActivatedDays(Collection dates, Date issuingDate){ + + if (this.activatedDay != null) { + this.activatedDay.clear(); + } else { + this.activatedDay= new SequenceOfActivatedDays(); + } + + if (dates != null && !dates.isEmpty()) { + + for (Date day : dates) { + this.addActivatedDay(issuingDate, day); + } + + } + + } + public void addActivatedDay(Date issuingDate, Date day){ Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day); + if (this.activatedDay == null) { + this.activatedDay = new SequenceOfActivatedDays(); + } + if (dayDiff != null) { this.activatedDay.add(dayDiff); } @@ -576,6 +600,8 @@ public class OpenTicketData extends Object { public Collection getActivatedDays(Date issuingDate) { + if (this.activatedDay == null) return null; + ArrayList dates = new ArrayList(); for (Long diff: this.getActivatedDay()) { @@ -590,25 +616,7 @@ public class OpenTicketData extends Object { return dates; - } - - public void setActivatedDays(Collection dates, Date issuingDate){ - - if (dates == null || issuingDate == null || dates.isEmpty()) return; - - - this.activatedDay.clear(); - - if (dates != null && !dates.isEmpty()) { - - for (Date day : dates) { - this.addActivatedDay(issuingDate, day); - } - - } - - } - + } public Long getValidFromUTCOffset() { return validFromUTCOffset; } diff --git a/src/org/uic/ticket/api/asn/omv1/PassData.java b/src/org/uic/ticket/api/asn/omv1/PassData.java index 491b8b7..fd700e0 100644 --- a/src/org/uic/ticket/api/asn/omv1/PassData.java +++ b/src/org/uic/ticket/api/asn/omv1/PassData.java @@ -482,10 +482,32 @@ public class PassData extends Object { } + public void setActivatedDays(Collection dates, Date issuingDate){ + + if (this.activatedDay != null) { + this.activatedDay.clear(); + } else { + this.activatedDay= new SequenceOfActivatedDays(); + } + + if (dates != null && !dates.isEmpty()) { + + for (Date day : dates) { + this.addActivatedDay(issuingDate, day); + } + + } + + } + public void addActivatedDay(Date issuingDate, Date day){ Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day); + if (this.activatedDay == null) { + this.activatedDay = new SequenceOfActivatedDays(); + } + if (dayDiff != null) { this.activatedDay.add(dayDiff); } @@ -494,6 +516,8 @@ public class PassData extends Object { public Collection getActivatedDays(Date issuingDate) { + if (this.activatedDay == null) return null; + ArrayList dates = new ArrayList(); for (Long diff: this.getActivatedDay()) { @@ -508,21 +532,7 @@ public class PassData extends Object { return dates; - } - - public void setActivatedDays(Collection dates, Date issuingDate){ - - this.activatedDay.clear(); - - if (dates != null && !dates.isEmpty()) { - - for (Date day : dates) { - this.addActivatedDay(issuingDate, day); - } - - } - - } + } public Long getValidFromUTCOffset() { return validFromUTCOffset; -- cgit v1.2.3