Skip to content

Commit 2d0267c

Browse files
committed
Added configurable variables to the builder so the user can change these
1 parent 22584b8 commit 2d0267c

File tree

2 files changed

+219
-3
lines changed

2 files changed

+219
-3
lines changed

bzst-dip-java-client/src/main/java/software/xdev/bzst/dip/client/model/configuration/BzstDipConfiguration.java

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717

1818
import java.io.InputStream;
1919
import java.time.LocalDate;
20+
import java.time.ZonedDateTime;
2021
import java.util.function.Supplier;
2122

23+
import software.xdev.bzst.dip.client.model.message.cesop.BzstCesopMessageTypeEnum;
24+
import software.xdev.bzst.dip.client.model.message.cesop.BzstCesopMessageTypeIndicEnum;
2225
import software.xdev.bzst.dip.client.model.message.dac7.BzstDipAddressFix;
26+
import software.xdev.bzst.dip.client.model.message.dac7.BzstDipCountryCode;
2327

2428

2529
/**
@@ -55,7 +59,15 @@ public enum SupportedApplicationCode
5559
}
5660

5761

58-
final String applicationCode;
62+
private final BzstDipCountryCode transmittingCountry;
63+
private final BzstCesopMessageTypeEnum messageType;
64+
private final String messageRefId;
65+
private final String reportingPeriodCesopYear;
66+
private final int reportingPeriodCesopQuarter;
67+
private final ZonedDateTime timestamp;
68+
private final BzstCesopMessageTypeIndicEnum messageTypeIndicEnum;
69+
70+
private final String applicationCode;
5971

6072
/**
6173
* This is the provided production endpoint url of the BZST.
@@ -182,6 +194,13 @@ public enum SupportedApplicationCode
182194

183195
@SuppressWarnings("PMD.ExcessiveParameterList")
184196
public BzstDipConfiguration(
197+
final BzstDipCountryCode transmittingCountry,
198+
final BzstCesopMessageTypeEnum messageType,
199+
final String messageRefId,
200+
final String reportingPeriodCesopYear,
201+
final int reportingPeriodCesopQuarter,
202+
final ZonedDateTime timestamp,
203+
final BzstCesopMessageTypeIndicEnum messageTypeIndicEnum,
185204
final String applicationCode,
186205
final String certificateKeystorePassword,
187206
final String keyStorePrivateKeyAlias,
@@ -202,6 +221,13 @@ public BzstDipConfiguration(
202221
final String platformOperatorPlatformName,
203222
final BzstDipAddressFix platformOperatorAddress)
204223
{
224+
this.transmittingCountry = transmittingCountry;
225+
this.messageType = messageType;
226+
this.messageRefId = messageRefId;
227+
this.reportingPeriodCesopYear = reportingPeriodCesopYear;
228+
this.reportingPeriodCesopQuarter = reportingPeriodCesopQuarter;
229+
this.timestamp = timestamp;
230+
this.messageTypeIndicEnum = messageTypeIndicEnum;
205231
this.applicationCode = applicationCode;
206232
this.certificateKeystorePassword = certificateKeystorePassword;
207233
this.keyStorePrivateKeyAlias = keyStorePrivateKeyAlias;
@@ -317,4 +343,39 @@ public String getApplicationCode()
317343
{
318344
return this.applicationCode;
319345
}
346+
347+
public BzstDipCountryCode getTransmittingCountry()
348+
{
349+
return this.transmittingCountry;
350+
}
351+
352+
public BzstCesopMessageTypeEnum getMessageType()
353+
{
354+
return this.messageType;
355+
}
356+
357+
public String getMessageRefId()
358+
{
359+
return this.messageRefId;
360+
}
361+
362+
public int getReportingPeriodCesopQuarter()
363+
{
364+
return this.reportingPeriodCesopQuarter;
365+
}
366+
367+
public String getReportingPeriodCesopYear()
368+
{
369+
return this.reportingPeriodCesopYear;
370+
}
371+
372+
public ZonedDateTime getTimestamp()
373+
{
374+
return this.timestamp;
375+
}
376+
377+
public BzstCesopMessageTypeIndicEnum getMessageTypeIndicEnum()
378+
{
379+
return this.messageTypeIndicEnum;
380+
}
320381
}

bzst-dip-java-client/src/main/java/software/xdev/bzst/dip/client/model/configuration/BzstDipConfigurationBuilder.java

Lines changed: 157 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@
1818
import java.io.InputStream;
1919
import java.time.Duration;
2020
import java.time.LocalDate;
21+
import java.time.ZonedDateTime;
2122
import java.util.function.Supplier;
2223

2324
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;
2428
import software.xdev.bzst.dip.client.model.message.dac7.BzstDipAddressFix;
29+
import software.xdev.bzst.dip.client.model.message.dac7.BzstDipCountryCode;
2530

2631

2732
/**
@@ -115,6 +120,66 @@ public class BzstDipConfigurationBuilder
115120
* @see BzstDipConfiguration#getPlatformOperatorAddress()
116121
*/
117122
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+
}
118183

119184
public BzstDipConfigurationBuilder(final PropertiesSupplier propertiesSupplier)
120185
{
@@ -328,14 +393,54 @@ public BzstDipConfigurationBuilder setPlatformOperatorAddress(final BzstDipAddre
328393
return this;
329394
}
330395

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+
331406
/**
332407
* @return a new created {@link BzstDipConfiguration} with the values provided by this builder.
333408
*/
334409
public BzstDipConfiguration buildAndValidate()
335410
{
336411
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),
339444
this.getSetPropertyOrReadFromFile(
340445
this.certificateKeystorePassword,
341446
PropertiesSupplier.PROPERTY_NAME_CERTIFICATE_KEYSTORE_PASSWORD,
@@ -584,4 +689,54 @@ private String getSetPropertyOrReadFromFile(
584689
}
585690
return propertyFromFile;
586691
}
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+
}
587742
}

0 commit comments

Comments
 (0)