|
18 | 18 | import java.io.InputStream; |
19 | 19 | import java.time.Duration; |
20 | 20 | import java.time.LocalDate; |
| 21 | +import java.time.ZonedDateTime; |
21 | 22 | import java.util.function.Supplier; |
22 | 23 |
|
23 | 24 | import software.xdev.bzst.dip.client.exception.PropertyNotSetException; |
| 25 | +import software.xdev.bzst.dip.client.model.message.cesop.BzstCesopMessageTypeEnum; |
| 26 | +import software.xdev.bzst.dip.client.model.message.cesop.BzstCesopMessageTypeIndicEnum; |
| 27 | +import software.xdev.bzst.dip.client.model.message.cesop.BzstCesopReportingPeriod; |
24 | 28 | import software.xdev.bzst.dip.client.model.message.dac7.BzstDipAddressFix; |
| 29 | +import software.xdev.bzst.dip.client.model.message.dac7.BzstDipCountryCode; |
25 | 30 |
|
26 | 31 |
|
27 | 32 | /** |
@@ -115,6 +120,66 @@ public class BzstDipConfigurationBuilder |
115 | 120 | * @see BzstDipConfiguration#getPlatformOperatorAddress() |
116 | 121 | */ |
117 | 122 | private BzstDipAddressFix platformOperatorAddress; |
| 123 | + /** |
| 124 | + * @see BzstDipConfiguration#getApplicationCode() |
| 125 | + */ |
| 126 | + private BzstDipConfiguration.SupportedApplicationCode applicationCode; |
| 127 | + |
| 128 | + private BzstDipCountryCode transmittingCountry; |
| 129 | + private BzstCesopMessageTypeEnum messageType; |
| 130 | + private String messageRefId; |
| 131 | + private BzstCesopReportingPeriod reportingPeriodCESOP; |
| 132 | + private ZonedDateTime timestamp; |
| 133 | + private int reportingPeriodCesopQuarter; |
| 134 | + private String reportingPeriodCesopYear; |
| 135 | + private BzstCesopMessageTypeIndicEnum messageTypeIndicCesop; |
| 136 | + |
| 137 | + public void setRetryQueryResultsAmount(final Integer retryQueryResultsAmount) |
| 138 | + { |
| 139 | + this.retryQueryResultsAmount = retryQueryResultsAmount; |
| 140 | + } |
| 141 | + |
| 142 | + public BzstDipConfigurationBuilder setReportingPeriodCesopQuarter(final int reportingPeriodCesopQuarter) |
| 143 | + { |
| 144 | + this.reportingPeriodCesopQuarter = reportingPeriodCesopQuarter; |
| 145 | + return this; |
| 146 | + } |
| 147 | + |
| 148 | + public BzstDipConfigurationBuilder setMessageTypeIndicCesop(final BzstCesopMessageTypeIndicEnum messageTypeIndicCesop) |
| 149 | + { |
| 150 | + this.messageTypeIndicCesop = messageTypeIndicCesop; |
| 151 | + return this; |
| 152 | + } |
| 153 | + |
| 154 | + public BzstDipConfigurationBuilder setReportingPeriodCesopYear(final String reportingPeriodCesopYear) |
| 155 | + { |
| 156 | + this.reportingPeriodCesopYear = reportingPeriodCesopYear; |
| 157 | + return this; |
| 158 | + } |
| 159 | + |
| 160 | + public BzstDipConfigurationBuilder setTransmittingCountry(final BzstDipCountryCode transmittingCountry) |
| 161 | + { |
| 162 | + this.transmittingCountry = transmittingCountry; |
| 163 | + return this; |
| 164 | + } |
| 165 | + |
| 166 | + public BzstDipConfigurationBuilder setMessageType(final BzstCesopMessageTypeEnum messageType) |
| 167 | + { |
| 168 | + this.messageType = messageType; |
| 169 | + return this; |
| 170 | + } |
| 171 | + |
| 172 | + public BzstDipConfigurationBuilder setMessageRefId(final String messageRefId) |
| 173 | + { |
| 174 | + this.messageRefId = messageRefId; |
| 175 | + return this; |
| 176 | + } |
| 177 | + |
| 178 | + public BzstDipConfigurationBuilder setTimestamp(final ZonedDateTime timestamp) |
| 179 | + { |
| 180 | + this.timestamp = timestamp; |
| 181 | + return this; |
| 182 | + } |
118 | 183 |
|
119 | 184 | public BzstDipConfigurationBuilder(final PropertiesSupplier propertiesSupplier) |
120 | 185 | { |
@@ -328,14 +393,54 @@ public BzstDipConfigurationBuilder setPlatformOperatorAddress(final BzstDipAddre |
328 | 393 | return this; |
329 | 394 | } |
330 | 395 |
|
| 396 | + /** |
| 397 | + * @param applicationCode {@link #applicationCode} |
| 398 | + * @return itself |
| 399 | + */ |
| 400 | + public BzstDipConfigurationBuilder setApplicationCode(final BzstDipConfiguration.SupportedApplicationCode applicationCode) |
| 401 | + { |
| 402 | + this.applicationCode = applicationCode; |
| 403 | + return this; |
| 404 | + } |
| 405 | + |
331 | 406 | /** |
332 | 407 | * @return a new created {@link BzstDipConfiguration} with the values provided by this builder. |
333 | 408 | */ |
334 | 409 | public BzstDipConfiguration buildAndValidate() |
335 | 410 | { |
336 | 411 | final BzstDipConfiguration configuration = new BzstDipConfiguration( |
337 | | - // TODO Read from file or property (see below) |
338 | | - "", |
| 412 | + this.getSetPropertyOrReadFromFileTransmittingCountry( |
| 413 | + this.transmittingCountry, |
| 414 | + PropertiesSupplier.PROPERTY_NAME_TRANSMITTING_COUNTRY |
| 415 | + ), |
| 416 | + this.getSetPropertyOrReadFromFileMessageType( |
| 417 | + this.messageType, |
| 418 | + PropertiesSupplier.PROPERTY_NAME_MESSAGE_TYPE |
| 419 | + ), |
| 420 | + this.getSetPropertyOrReadFromFile( |
| 421 | + this.messageRefId, |
| 422 | + PropertiesSupplier.PROPERTY_NAME_MESSAGE_REF_ID |
| 423 | + ), |
| 424 | + this.getSetPropertyOrReadFromFile( |
| 425 | + this.reportingPeriodCesopYear, |
| 426 | + PropertiesSupplier.PROPERTY_NAME_REPORTING_PERIOD_CESOP_YEAR |
| 427 | + ), |
| 428 | + this.getSetPropertyOrReadFromFileInteger( |
| 429 | + this.reportingPeriodCesopQuarter, |
| 430 | + PropertiesSupplier.PROPERTY_NAME_REPORTING_PERIOD_CESOP_QUARTER, |
| 431 | + 1 |
| 432 | + ), |
| 433 | + this.getSetPropertyOrReadFromFileTimestamp( |
| 434 | + this.timestamp, |
| 435 | + PropertiesSupplier.PROPERTY_NAME_TIMESTAMP |
| 436 | + ), |
| 437 | + this.getSetPropertyOrReadFromFileMessageTypeIndicCesop( |
| 438 | + this.messageTypeIndicCesop, |
| 439 | + PropertiesSupplier.PROPERTY_NAME_MESSAGE_TYPE_INDIC_CESOP |
| 440 | + ), |
| 441 | + this.getSetPropertyOrReadFromFile( |
| 442 | + this.applicationCode.value, |
| 443 | + PropertiesSupplier.PROPERTY_NAME_APPLICATION_CODE), |
339 | 444 | this.getSetPropertyOrReadFromFile( |
340 | 445 | this.certificateKeystorePassword, |
341 | 446 | PropertiesSupplier.PROPERTY_NAME_CERTIFICATE_KEYSTORE_PASSWORD, |
@@ -584,4 +689,54 @@ private String getSetPropertyOrReadFromFile( |
584 | 689 | } |
585 | 690 | return propertyFromFile; |
586 | 691 | } |
| 692 | + |
| 693 | + private ZonedDateTime getSetPropertyOrReadFromFileTimestamp( |
| 694 | + final ZonedDateTime builderProperty, |
| 695 | + final String propertyNameInFile) |
| 696 | + { |
| 697 | + if(builderProperty != null) |
| 698 | + { |
| 699 | + return builderProperty; |
| 700 | + } |
| 701 | + return ZonedDateTime.parse(this.getSetPropertyOrReadFromFile(null, propertyNameInFile)); |
| 702 | + } |
| 703 | + |
| 704 | + private BzstDipCountryCode getSetPropertyOrReadFromFileTransmittingCountry( |
| 705 | + final BzstDipCountryCode builderProperty, |
| 706 | + final String propertyNameInFile) |
| 707 | + { |
| 708 | + if(builderProperty != null) |
| 709 | + { |
| 710 | + return builderProperty; |
| 711 | + } |
| 712 | + return BzstDipCountryCode.valueOf(this.getSetPropertyOrReadFromFile( |
| 713 | + null, |
| 714 | + propertyNameInFile)); |
| 715 | + } |
| 716 | + |
| 717 | + private BzstCesopMessageTypeEnum getSetPropertyOrReadFromFileMessageType( |
| 718 | + final BzstCesopMessageTypeEnum builderProperty, |
| 719 | + final String propertyNameInFile) |
| 720 | + { |
| 721 | + if(builderProperty != null) |
| 722 | + { |
| 723 | + return builderProperty; |
| 724 | + } |
| 725 | + return BzstCesopMessageTypeEnum.valueOf(this.getSetPropertyOrReadFromFile( |
| 726 | + null, |
| 727 | + propertyNameInFile)); |
| 728 | + } |
| 729 | + |
| 730 | + private BzstCesopMessageTypeIndicEnum getSetPropertyOrReadFromFileMessageTypeIndicCesop( |
| 731 | + final BzstCesopMessageTypeIndicEnum builderProperty, |
| 732 | + final String propertyNameInFile) |
| 733 | + { |
| 734 | + if(builderProperty != null) |
| 735 | + { |
| 736 | + return builderProperty; |
| 737 | + } |
| 738 | + return BzstCesopMessageTypeIndicEnum.valueOf(this.getSetPropertyOrReadFromFile( |
| 739 | + null, |
| 740 | + propertyNameInFile)); |
| 741 | + } |
587 | 742 | } |
0 commit comments