use of com.helger.xsds.peppol.smp1.ObjectFactory in project axelor-open-suite by axelor.
the class BankOrderFile00100103Service method generateFile.
/**
* Method to create an XML file for SEPA transfer pain.001.001.03
*
* @throws AxelorException
* @throws DatatypeConfigurationException
* @throws JAXBException
* @throws IOException
*/
@Override
public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
ObjectFactory factory = new ObjectFactory();
ServiceLevel8Choice svcLvl = factory.createServiceLevel8Choice();
svcLvl.setCd("SEPA");
PaymentTypeInformation19 pmtTpInf = factory.createPaymentTypeInformation19();
pmtTpInf.setSvcLvl(svcLvl);
// Payer
PartyIdentification32 dbtr = factory.createPartyIdentification32();
dbtr.setNm(senderBankDetails.getOwnerName());
// IBAN
AccountIdentification4Choice iban = factory.createAccountIdentification4Choice();
iban.setIBAN(senderBankDetails.getIban());
CashAccount16 dbtrAcct = factory.createCashAccount16();
dbtrAcct.setId(iban);
// BIC
FinancialInstitutionIdentification7 finInstnId = factory.createFinancialInstitutionIdentification7();
fillBic(finInstnId, senderBankDetails.getBank());
BranchAndFinancialInstitutionIdentification4 dbtrAgt = factory.createBranchAndFinancialInstitutionIdentification4();
dbtrAgt.setFinInstnId(finInstnId);
PaymentInstructionInformation3 pmtInf = factory.createPaymentInstructionInformation3();
pmtInf.setPmtInfId(bankOrderSeq);
pmtInf.setPmtMtd(PaymentMethod3Code.TRF);
pmtInf.setPmtTpInf(pmtTpInf);
/**
* RequestedExecutionDate Definition : Date at which the initiating party asks the Debtor's Bank
* to process the payment. This is the date on which the debtor's account(s) is (are) to be
* debited. XML Tag : <ReqdExctnDt> Occurrences : [1..1] Format : YYYY-MM-DD Rules : date is
* limited to maximum one year in the future.
*/
pmtInf.setReqdExctnDt(datatypeFactory.newXMLGregorianCalendar(bankOrderDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
pmtInf.setDbtr(dbtr);
pmtInf.setDbtrAcct(dbtrAcct);
pmtInf.setDbtrAgt(dbtrAgt);
CreditTransferTransactionInformation10 cdtTrfTxInf = null;
PaymentIdentification1 pmtId = null;
AmountType3Choice amt = null;
ActiveOrHistoricCurrencyAndAmount instdAmt = null;
PartyIdentification32 cbtr = null;
CashAccount16 cbtrAcct = null;
BranchAndFinancialInstitutionIdentification4 cbtrAgt = null;
RemittanceInformation5 rmtInf = null;
for (BankOrderLine bankOrderLine : bankOrderLineList) {
BankDetails receiverBankDetails = bankOrderLine.getReceiverBankDetails();
// Reference
pmtId = factory.createPaymentIdentification1();
// pmtId.setInstrId(bankOrderLine.getSequence());
pmtId.setEndToEndId(bankOrderLine.getSequence());
// Amount
instdAmt = factory.createActiveOrHistoricCurrencyAndAmount();
instdAmt.setCcy(bankOrderCurrency.getCode());
instdAmt.setValue(bankOrderLine.getBankOrderAmount());
amt = factory.createAmountType3Choice();
amt.setInstdAmt(instdAmt);
// Receiver
cbtr = factory.createPartyIdentification32();
cbtr.setNm(receiverBankDetails.getOwnerName());
// IBAN
iban = factory.createAccountIdentification4Choice();
iban.setIBAN(receiverBankDetails.getIban());
cbtrAcct = factory.createCashAccount16();
cbtrAcct.setId(iban);
// BIC
finInstnId = factory.createFinancialInstitutionIdentification7();
fillBic(finInstnId, receiverBankDetails.getBank());
cbtrAgt = factory.createBranchAndFinancialInstitutionIdentification4();
cbtrAgt.setFinInstnId(finInstnId);
rmtInf = factory.createRemittanceInformation5();
String ustrd = "";
if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverReference())) {
ustrd += bankOrderLine.getReceiverReference();
}
if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverLabel())) {
if (!Strings.isNullOrEmpty(ustrd)) {
ustrd += " - ";
}
ustrd += bankOrderLine.getReceiverLabel();
}
if (!Strings.isNullOrEmpty(ustrd)) {
rmtInf.getUstrd().add(ustrd);
}
// StructuredRemittanceInformation7 strd = factory.createStructuredRemittanceInformation7();
//
// CreditorReferenceInformation2 cdtrRefInf = factory.createCreditorReferenceInformation2();
// cdtrRefInf.setRef(bankOrderLine.getReceiverReference());
//
// strd.setCdtrRefInf(cdtrRefInf);
//
// rmtInf.getStrd().add(strd);
// Transaction
cdtTrfTxInf = factory.createCreditTransferTransactionInformation10();
cdtTrfTxInf.setPmtId(pmtId);
cdtTrfTxInf.setAmt(amt);
cdtTrfTxInf.setCdtr(cbtr);
cdtTrfTxInf.setCdtrAcct(cbtrAcct);
cdtTrfTxInf.setCdtrAgt(cbtrAgt);
cdtTrfTxInf.setRmtInf(rmtInf);
pmtInf.getCdtTrfTxInf().add(cdtTrfTxInf);
}
// Header
GroupHeader32 grpHdr = factory.createGroupHeader32();
/**
* Référence du message qui n'est pas utilisée comme référence fonctionnelle.
*/
grpHdr.setMsgId(bankOrderSeq);
/**
* CreationDateTime Definition : Date and Time at which a (group of) payment instruction(s) was
* created by the instructing party. XML Tag : <CreDtTm> Occurrences : [1..1] Format :
* YYYY-MM-DDThh:mm:ss
*/
grpHdr.setCreDtTm(datatypeFactory.newXMLGregorianCalendar(generationDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))));
grpHdr.setNbOfTxs(Integer.toString(nbOfLines));
grpHdr.setCtrlSum(arithmeticTotal);
grpHdr.setInitgPty(dbtr);
// Parent
CustomerCreditTransferInitiationV03 customerCreditTransferInitiationV03 = factory.createCustomerCreditTransferInitiationV03();
customerCreditTransferInitiationV03.setGrpHdr(grpHdr);
customerCreditTransferInitiationV03.getPmtInf().add(pmtInf);
// Document
Document xml = factory.createDocument();
xml.setCstmrCdtTrfInitn(customerCreditTransferInitiationV03);
fileToCreate = factory.createDocument(xml);
return super.generateFile();
}
use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.
the class GpxPositionExtension method setHeading.
public void setHeading(Double heading) {
if (wptType.getExtensions() == null)
wptType.setExtensions(new ObjectFactory().createExtensionsType());
List<Object> anys = wptType.getExtensions().getAny();
boolean foundHeading = false;
for (Object any : anys) {
if (any instanceof JAXBElement) {
Object anyValue = ((JAXBElement) any).getValue();
if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
trackPoint.setCourse(formatHeading(heading));
foundHeading = true;
}
} else if (any instanceof Element) {
Element element = (Element) any;
if ("course".equalsIgnoreCase(element.getLocalName())) {
element.setTextContent(formatHeadingAsString(heading));
foundHeading = true;
}
}
}
if (!foundHeading) {
slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
trackPointExtensionT.setCourse(formatHeading(heading));
anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
}
}
use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.
the class GpxPositionExtension method setTemperature.
public void setTemperature(Double temperature) {
if (wptType.getExtensions() == null)
wptType.setExtensions(new ObjectFactory().createExtensionsType());
List<Object> anys = wptType.getExtensions().getAny();
boolean foundTemperature = false;
for (Object any : anys) {
if (any instanceof JAXBElement) {
Object anyValue = ((JAXBElement) any).getValue();
if (anyValue instanceof slash.navigation.gpx.garmin3.TrackPointExtensionT) {
slash.navigation.gpx.garmin3.TrackPointExtensionT trackPoint = (slash.navigation.gpx.garmin3.TrackPointExtensionT) anyValue;
trackPoint.setTemperature(formatTemperatureAsDouble(temperature));
foundTemperature = true;
} else if (anyValue instanceof slash.navigation.gpx.trackpoint1.TrackPointExtensionT) {
slash.navigation.gpx.trackpoint1.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint1.TrackPointExtensionT) anyValue;
if (isEmpty(trackPoint.getAtemp()) && isEmpty(temperature))
trackPoint.setWtemp(null);
trackPoint.setAtemp(formatTemperatureAsDouble(temperature));
foundTemperature = true;
} else if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
if (isEmpty(trackPoint.getAtemp()) && isEmpty(temperature))
trackPoint.setWtemp(null);
trackPoint.setAtemp(formatTemperatureAsDouble(temperature));
foundTemperature = true;
}
} else if (any instanceof Element) {
Element element = (Element) any;
if ("temperature".equalsIgnoreCase(element.getLocalName())) {
element.setTextContent(formatTemperatureAsString(temperature));
foundTemperature = true;
}
}
}
// create new TrackPointExtension v2 element if there was no existing value found
if (!foundTemperature) {
slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
trackPointExtensionT.setAtemp(formatTemperatureAsDouble(temperature));
anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
}
}
use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.
the class GpxPositionExtension method setSpeed.
public void setSpeed(Double speed) {
if (wptType.getExtensions() == null)
wptType.setExtensions(new ObjectFactory().createExtensionsType());
List<Object> anys = wptType.getExtensions().getAny();
boolean foundSpeed = false;
for (Object any : anys) {
if (any instanceof JAXBElement) {
Object anyValue = ((JAXBElement) any).getValue();
if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
trackPoint.setSpeed(formatSpeedAsDouble(kmhToMs(speed)));
foundSpeed = true;
}
} else if (any instanceof Element) {
Element element = (Element) any;
if ("speed".equalsIgnoreCase(element.getLocalName())) {
element.setTextContent(formatSpeedAsString(kmhToMs(speed)));
foundSpeed = true;
}
}
}
// create new TrackPointExtension v2 element if there was no existing value found
if (!foundSpeed) {
slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
trackPointExtensionT.setSpeed(formatSpeedAsDouble(kmhToMs(speed)));
anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
}
}
use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.
the class GpxPositionExtension method setHeartBeat.
public void setHeartBeat(Short heartBeat) {
if (wptType.getExtensions() == null)
wptType.setExtensions(new ObjectFactory().createExtensionsType());
List<Object> anys = wptType.getExtensions().getAny();
boolean foundHeartBeat = false;
for (Object any : anys) {
if (any instanceof JAXBElement) {
Object anyValue = ((JAXBElement) any).getValue();
if (anyValue instanceof slash.navigation.gpx.trackpoint1.TrackPointExtensionT) {
slash.navigation.gpx.trackpoint1.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint1.TrackPointExtensionT) anyValue;
trackPoint.setHr(heartBeat);
foundHeartBeat = true;
} else if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
trackPoint.setHr(heartBeat);
foundHeartBeat = true;
}
} else if (any instanceof Element) {
Element element = (Element) any;
if ("hr".equalsIgnoreCase(element.getLocalName())) {
element.setTextContent(formatShortAsString(heartBeat));
foundHeartBeat = true;
}
}
}
// create new TrackPointExtension v2 element if there was no existing value found
if (!foundHeartBeat) {
slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
trackPointExtensionT.setHr(heartBeat);
anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
}
}
Aggregations