1515 */
1616package software .xdev .bzst .dip .client .xmldocument ;
1717
18+ import java .math .BigDecimal ;
1819import java .time .LocalDate ;
1920import java .time .LocalDateTime ;
21+ import java .util .GregorianCalendar ;
2022import java .util .List ;
2123import java .util .UUID ;
2224
25+ import javax .xml .datatype .DatatypeConfigurationException ;
26+ import javax .xml .datatype .DatatypeFactory ;
27+ import javax .xml .datatype .XMLGregorianCalendar ;
28+
2329import org .slf4j .Logger ;
2430import org .slf4j .LoggerFactory ;
2531
4450import software .xdev .bzst .dip .client .xmldocument .model .ObjectFactory ;
4551import software .xdev .bzst .dip .client .xmldocument .model .TINType ;
4652import software .xdev .bzst .dip .client .xmldocument .model .cesop .CESOP ;
53+ import software .xdev .bzst .dip .client .xmldocument .model .cesop .MSCountryCodeType ;
54+ import software .xdev .bzst .dip .client .xmldocument .model .cesop .MessageTypeIndicType ;
55+ import software .xdev .bzst .dip .client .xmldocument .model .cesop .MessageTypeType ;
56+ import software .xdev .bzst .dip .client .xmldocument .model .cesop .PaymentDataBodyType ;
57+ import software .xdev .bzst .dip .client .xmldocument .model .cesop .ReportingPeriodType ;
4758
4859
4960public class XMLDocumentBodyCreator
@@ -58,25 +69,44 @@ public XMLDocumentBodyCreator(final BzstDipConfiguration configuration)
5869
5970 public DipBodyType createBody (
6071 final List <CorrectableReportableSellerType > correctableReportableSellerTypes ,
61- final CorrectablePlatformOperatorType platformOperatorType )
72+ final CorrectablePlatformOperatorType platformOperatorType ) throws DatatypeConfigurationException
6273 {
6374 final DipBodyType dipBodyType = new DipBodyType ();
6475 dipBodyType .getConsignmentItem ()
6576 .add (this .createConsignmentItem (correctableReportableSellerTypes , platformOperatorType ));
6677 return dipBodyType ;
6778 }
6879
80+ public DipBodyType createBody (
81+ final PaymentDataBodyType paymentDataBodyType ) throws DatatypeConfigurationException
82+ {
83+ final DipBodyType dipBodyType = new DipBodyType ();
84+ dipBodyType .getConsignmentItem ()
85+ .add (this .createConsignmentItem (paymentDataBodyType ));
86+ return dipBodyType ;
87+ }
88+
6989 private ConsignmentItemType createConsignmentItem (
7090 final List <CorrectableReportableSellerType > correctableReportableSellerTypes ,
7191 final CorrectablePlatformOperatorType platformOperatorType
72- )
92+ ) throws DatatypeConfigurationException
7393 {
7494 final ConsignmentItemType consignmentItem = new ConsignmentItemType ();
7595 consignmentItem .setData (this .createData (correctableReportableSellerTypes , platformOperatorType ));
7696
7797 return consignmentItem ;
7898 }
7999
100+ private ConsignmentItemType createConsignmentItem (
101+ final PaymentDataBodyType paymentDataBodyType
102+ ) throws DatatypeConfigurationException
103+ {
104+ final ConsignmentItemType consignmentItem = new ConsignmentItemType ();
105+ consignmentItem .setData (this .createData (paymentDataBodyType ));
106+
107+ return consignmentItem ;
108+ }
109+
80110 private Object createData (
81111 final List <CorrectableReportableSellerType > correctableReportableSellerTypes ,
82112 final CorrectablePlatformOperatorType platformOperatorType )
@@ -93,11 +123,28 @@ private Object createData(
93123 dpioecd .setVersion ("1.0" );
94124 dataType .setDpioecd (dpioecd );
95125 }
96- else if (this .configuration .getApplicationCode ().equals (BzstDipConfiguration .SupportedApplicationCode .CESOP ))
126+ else
127+ {
128+ throw new IllegalArgumentException (
129+ "Unsupported application code: " + this .configuration .getApplicationCode ()
130+ );
131+ }
132+
133+ return dataType ;
134+ }
135+
136+ private Object createData (
137+ final PaymentDataBodyType paymentDataBodyType ) throws DatatypeConfigurationException
138+ {
139+ LOGGER .debug ("Creating data..." );
140+
141+ final DataType dataType = new DataType ();
142+
143+ if (this .configuration .getApplicationCode ().equals (BzstDipConfiguration .SupportedApplicationCode .CESOP ))
97144 {
98145 final CESOP cesop = new CESOP ();
99146 cesop .setMessageSpec (this .createMessageSpecCesop ());
100- // TODO
147+ cesop . setVersion ( new BigDecimal ( "1.0" ));
101148 dataType .setCesop (cesop );
102149 }
103150 else
@@ -136,8 +183,6 @@ private DPIBodyType createDPIBody(
136183 return dpiBodyType ;
137184 }
138185
139-
140-
141186 private static DocSpecType createPlatformDocSpec (final BzstDipConfiguration configuration )
142187 {
143188 final BzstDipOecdDocType docTypeIndic = configuration .getDocType ();
@@ -198,8 +243,6 @@ public static CorrectablePlatformOperatorType createPlatformOperatorFromConfigur
198243 return correctablePlatformOperatorType ;
199244 }
200245
201-
202-
203246 protected static AddressType createAddress (
204247 final AddressFixType address ,
205248 final OECDLegalAddressTypeEnumType legalAddressTypeEnumType )
@@ -215,10 +258,32 @@ protected static AddressType createAddress(
215258 }
216259
217260 private software .xdev .bzst .dip .client .xmldocument .model .cesop .MessageSpecType createMessageSpecCesop ()
261+ throws DatatypeConfigurationException
218262 {
219263 LOGGER .debug ("Creating messageSpec..." );
220264
221- // TODO
265+ final software .xdev .bzst .dip .client .xmldocument .model .cesop .MessageSpecType messageSpecType =
266+ new software .xdev .bzst .dip .client .xmldocument .model .cesop .MessageSpecType ();
267+
268+ messageSpecType .setTransmittingCountry (MSCountryCodeType .fromValue (this .configuration .getTransmittingCountry ()
269+ .name ()));
270+ messageSpecType .setMessageType (MessageTypeType .fromValue (this .configuration .getMessageType ().value ()));
271+ messageSpecType .setMessageTypeIndic (MessageTypeIndicType .fromValue (this .configuration .getMessageTypeIndic ()
272+ .name ()));
273+ messageSpecType .setMessageRefId (this .configuration .getMessageRefId ());
274+
275+ final ReportingPeriodType reportingPeriodType = new ReportingPeriodType ();
276+ reportingPeriodType .setQuarter (this .configuration .getReportingPeriodCesopQuarter ());
277+ reportingPeriodType .setYear (this .configuration .getReportingPeriodCesopYear ());
278+ messageSpecType .setReportingPeriod (reportingPeriodType );
279+
280+ final GregorianCalendar gregorianCalendar = GregorianCalendar .from (this .configuration .getTimestamp ());
281+ final XMLGregorianCalendar xmlGregorianCalendar =
282+ DatatypeFactory .newInstance ().newXMLGregorianCalendar (gregorianCalendar );
283+
284+ messageSpecType .setTimestamp (xmlGregorianCalendar );
285+
286+ return messageSpecType ;
222287 }
223288
224289 private MessageSpecType createMessageSpecDac7 ()
0 commit comments