Commit 5f8cc022 by chengzhuoshen

完成MT103转pacs008001

1.Mt103转自定义的VoCustomerCreditTransfer
2.VoCustomerCreditTransfer转pacs008001报文
parent c66ce0aa
package com.brilliance.swift.context;
import java.util.List;
/**
* The container to store objects
* @author chengzhuoshen
*/
public interface Context {
/**
* To get the stored object
* @param identifier
* - String
* @return Object
*/
Object get(String identifier);
/**
* To get the stored object
* @param identifier
* - String
* @param returnNull
* - boolean
* @return Object
*/
Object get(String identifier, boolean returnNull);
/**
* To get the stored object by class name
* @param cls
* - Class
* @return Object
*/
<T> T get(Class<T> cls);
/**
* To set object
* @param identifier
* - String
* @param object
* - Object
*/
void set(String identifier, Object object);
/**
* To set object with specified class <u>cls</u> name as identifier
* @param cls
* - Class
* @param object
* - Object
*/
void set(Class<?> cls, Object object);
/**
* To set object with its actual class name as identifier
* @param object
* - Object
*/
void set(Object object);
/**
* To get a list of object with specified class type <u>objType</u>.
* @param objType
* - Class
* @return List
*/
<T> List<T> getList(Class<T> objType);
/**
* To get a list of object with specified class type <u>objType</u>.
* @param objType
* - Class
* @param returnNull
* - boolean
* @return List
*/
<T> List<T> getList(Class<T> objType, boolean returnNull);
/**
* To set a list of object with specified class type <u>objType</u>.
* @param objType
* - Class
* @param objects
* - List
*/
void setList(Class<?> objType, List<?> objects);
/**
* To set a context delegate which has held objects
* @param delegate
* - Context
* @return Context
*/
Context setDelegate(Context delegate);
/**
* To clear all stored objects.
*/
void clear();
/**
* To remove object
* @param identifier
* the object identifier in the context, refer to
*/
void remove(String identifier);
}
package com.brilliance.swift.context;
import java.io.Serializable;
import java.util.*;
public class ContextImpl implements Context, Serializable {
private static final long serialVersionUID = -4922248550014245078L;
/**
* The underlying container implementation
*/
private Map<String, Object> map = new HashMap<String, Object>();
@Override
public Object get(String identifier) {
Object obj = map.get(identifier);
if (null == obj) {
throw new RuntimeException("the context missing value for (" + identifier + "). Please join it first!");
}
return obj;
}
@Override
public Object get(String identifier, boolean returnNull) {
Object value = map.get(identifier);
if(!returnNull) {
throw new RuntimeException("the context missing value for (" + identifier + "). Please join it first!");
}
return value;
}
@Override
public void set(String identifier, Object object) {
map.put(identifier, object);
}
@Override
public Context setDelegate(Context delegate) {
if (delegate instanceof ContextImpl) {
map.putAll(((ContextImpl)delegate).map);
}
return this;
}
@Override
public void clear() {
map.clear();
}
@Override
public void remove(String identifier) {
map.remove(identifier);
}
@Override
public void set(Object object) {
this.set(object.getClass(), object);
}
@Override
public void set(Class<?> cls, Object object) {
this.set(cls.getName(), object);
}
@Override
public <T> T get(Class<T> cls) {
return cls.cast(get(cls.getName()));
}
@Override
public void setList(Class<?> objType, List<?> objects) {
this.set(objType.getName() + "List", objects);
}
@Override
public <T> List<T> getList(Class<T> objType) {
@SuppressWarnings("unchecked")
List<T> list = (List<T>)get(objType.getName() + "List");
return list;
}
@Override
public <T> List<T> getList(Class<T> objType, boolean returnNull) {
@SuppressWarnings("unchecked")
List<T> list = (List<T>)get(objType.getName() + "List", returnNull);
return list;
}
/**
* Copies every mapping in the specified <code>paramMap</code> to this Map.
* @param paramMap
* - Map, the map to copy mappings from
*/
public void putAll(Map<?, ?> paramMap) {
if (null == paramMap || paramMap.isEmpty()) {
return;
}
paramMap.forEach((key, value) -> map.put(key.toString(), paramMap.get(value)));
}
}
package com.brilliance.swift.mt2mx;
import com.brilliance.swift.constants.Mx2MtConstants;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.SwiftDto;
import com.brilliance.swift.vo.common.MessagePriority;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mx.dic.*;
import java.util.Date;
public abstract class AbstractMt2MxCreator implements Mt2MxCreator{
protected Mt2MxContext context;
public Mt2MxContext getContext() {
return context;
}
public void setContext(Mt2MxContext context) {
this.context = context;
}
@Override
public void preProcess() throws SwiftException {
try {
SwiftDto swiftDto = new SwiftDto();
AbstractMT abstractMT = context.get(AbstractMT.class);
String senderBic = abstractMT.getSender();
if (senderBic.endsWith(Mx2MtConstants.BICSUFFIX)) {
senderBic = senderBic.substring(0, 8);
} else {
senderBic = senderBic.substring(0, 8) + senderBic.substring(9, 12);
}
swiftDto.setSenderBic(senderBic);
String receiverBic = abstractMT.getReceiver();
if (receiverBic.endsWith(Mx2MtConstants.BICSUFFIX)) {
receiverBic = receiverBic.substring(0, 8);
} else {
receiverBic = receiverBic.substring(0, 8) + receiverBic.substring(9, 12);
}
swiftDto.setReceiverBic(receiverBic);
swiftDto.setCreateDate(new Date());
String priority = abstractMT.getMessagePriority();
if ("N".equals(priority)) {
swiftDto.setMessagePriority(MessagePriority.NORM);
} else if ("U".equals(priority) || "S".equals(priority)) {
swiftDto.setMessagePriority(MessagePriority.HIGH);
}
String uetr = abstractMT.getSwiftMessage().getUETR();
if (StringUtil.isNotEmpty(uetr)) {
swiftDto.setUetr(uetr);
}
context.set(swiftDto);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
protected BranchAndFinancialInstitutionIdentification6 partyDtoConvertAgt(PartyDto partyDto) {
BranchAndFinancialInstitutionIdentification6 agt = new BranchAndFinancialInstitutionIdentification6();
FinancialInstitutionIdentification18 finInstnId = new FinancialInstitutionIdentification18();
finInstnId.setBICFI(partyDto.getPartyBic());
finInstnId.setNm(partyDto.getPartyName());
if (partyDto.getAddressList().size() > 0) {
PostalAddress24 pstlAdr = new PostalAddress24();
for (int i=0; i<partyDto.getAddressList().size(); i++) {
pstlAdr.addAdrLine(partyDto.getAddressList().get(i));
}
finInstnId.setPstlAdr(pstlAdr);
}
agt.setFinInstnId(finInstnId);
return agt;
}
protected CashAccount38 partyDtoConvertAgtAccount(PartyDto partyDto) {
CashAccount38 cashAccount38 = null;
String partyIBANAcct = partyDto.getPartyIBANAcct();
String partyAcct = partyDto.getPartyAcct();
if (StringUtil.isNotEmpty(partyAcct) || StringUtil.isNotEmpty(partyIBANAcct)) {
cashAccount38 = new CashAccount38();
AccountIdentification4Choice id = new AccountIdentification4Choice();
if (StringUtil.isNotEmpty(partyAcct)) {
GenericAccountIdentification1 othr = new GenericAccountIdentification1();
othr.setId(partyAcct);
id.setOthr(othr);
}
if (StringUtil.isNotEmpty(partyIBANAcct)) {
id.setIBAN(partyIBANAcct);
}
cashAccount38.setId(id);
}
return cashAccount38;
}
protected PartyIdentification135 partyDtoConvertTr(PartyDto partyDto) {
PartyIdentification135 tr = new PartyIdentification135();
tr.setNm(partyDto.getPartyName());
if (StringUtil.isNotEmpty(partyDto.getPartyBic())) {
Party38Choice id = new Party38Choice();
OrganisationIdentification29 orgId = new OrganisationIdentification29();
orgId.setAnyBIC(partyDto.getPartyBic());
id.setOrgId(orgId);
tr.setId(id);
}
if (partyDto.getAddressList().size() > 0) {
PostalAddress24 pstlAdr = new PostalAddress24();
for (int i=0; i<partyDto.getAddressList().size(); i++) {
pstlAdr.addAdrLine(partyDto.getAddressList().get(i));
}
tr.setPstlAdr(pstlAdr);
}
return tr;
}
}
package com.brilliance.swift.mt2mx;
public abstract class AbstractMt2MxParseFields implements Mt2MxParseFields{
protected Mt2MxContext context;
public Mt2MxContext getContext() {
return context;
}
public void setContext(Mt2MxContext context) {
this.context = context;
}
}
package com.brilliance.swift.mt2mx;
import com.brilliance.swift.context.ContextImpl;
public class Mt2MxContext extends ContextImpl {
private static final long serialVersionUID = 1720388698305926316L;
}
package com.brilliance.swift.mt2mx;
public class Mt2MxContextIdentifier {
public static final String MT_TO_MX_OUTPUT_FILE_PATH = "mt.to.mx.output.filepath";
public static final String MT_TO_MX_XML = "mt.to.mx.xml";
public static final String MX_UETR = "mt.uetr";
public static final String MX_APP_HEADER = "mt.app.header";
/**
* 20
*/
public static final String MX_MSG_ID = "mx.msgid";
/**
* 13C
*/
public static final String MX_DEBIT_DATETIME = "mx.debit.datetime";
public static final String MX_CREDIT_DATETIME = "mx.credit.datetime";
public static final String MX_CLS_DATETIME = "mx.cls.datetime";
/**
* 23B
*/
public static final String MX_BUSINESS_CODE = "mx.business.code";
/**
* 23E
*/
public static final String MX_INSTRUCTION_CODE = "mx.Instruction.code.list";
/**
* 26T
*/
public static final String MX_TRANSACTION_TYPE_CODE = "mx.transaction.type.code";
/**
* 32A date
*/
public static final String MX_VALUE_DATE = "mx.value.date";
/**
* 32A ccy amt
*/
public static final String MX_SETTLE_CCY_AMOUNT = "mx.settle.ccy.amount";
/**
* 33B ccy amt
*/
public static final String MX_INSTRUCTED_CCY_AMOUNT = "mx.instructed.ccy.amount";
/**
* 36 exchangeRate
*/
public static final String MX_EXCHANGE_RATE = "mx.exchange.rate";
/**
* 70 Remittance Information
*/
public static final String MX_REMITTANCE_INFORMATION = "mx.remittance.information.list";
/**
* 71 ChargeFor
*/
public static final String MX_CHARGE_FOR = "mx.charge_for";
/**
* 71 chargeCcyAmount
*/
public static final String MX_CHARGE_CCY_AMOUNT = "mx.charge_ccy.amount";
/**
* 72 Sender to Receiver Information
*/
public static final String MX_SENDER_TO_RECEIVER_INFORMATION = "mx.sender.to.receiver.information.list";
/**
* 77 Regulatory Reporting
*/
public static final String MX_REGULATORY_REPORTING = "mx.regulatory.reporting.list";
}
package com.brilliance.swift.mt2mx;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.pacs008001.Mt2MxPacs00801Creator;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.List;
import java.util.Map;
public class Mt2MxCreateManager {
public AbstractMT abstractMT = null;
public void init(String mtStr) {
try {
abstractMT = AbstractMT.parse(mtStr);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
public String mt2mx(File file, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
String mtStr = FileUtils.readFileToString(file);
init(mtStr);
return convert(outPutFilePath, extraMap);
}
public String mt2mx(File file, String outPutFilePath) throws Exception {
return mt2mx(file, outPutFilePath, null);
}
public String mt2mx(File file) throws Exception {
return mt2mx(file, null, null);
}
public String mt2mx(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
init(mtStr);
return convert(outPutFilePath, extraMap);
}
public String mt2mx(String mtStr, String outPutFilePath) throws Exception {
return mt2mx(mtStr, outPutFilePath, null);
}
public String mt2mx(String mtStr) throws Exception {
return mt2mx(mtStr, null, null);
}
public String convert(String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
AbstractMt2MxCreator creator = getMt2MxCreator();
Mt2MxContext context = new Mt2MxContext();
context.set(AbstractMT.class, abstractMT);
context.set(Mt2MxContextIdentifier.MT_TO_MX_OUTPUT_FILE_PATH, outPutFilePath);
context.putAll(extraMap);
creator.setContext(context);
creator.preProcess();
List<Mt2MxParseFields> parseFields = creator.getParseFieldsList();
for (int i=0; i<parseFields.size(); i++) {
AbstractMt2MxParseFields parseField = (AbstractMt2MxParseFields) parseFields.get(i);
parseField.setContext(context);
parseField.parseFields();
}
creator.postProcess();
String xmlStr = (String)context.get(Mt2MxContextIdentifier.MT_TO_MX_XML);
return xmlStr;
}
public AbstractMt2MxCreator getMt2MxCreator() throws SwiftException {
String messageType = abstractMT.getMessageType();
if ("103".equals(messageType)) {
return new Mt2MxPacs00801Creator();
} else {
throw new SwiftException("Invalid message type");
}
}
}
package com.brilliance.swift.mt2mx;
import com.brilliance.swift.exception.SwiftException;
import java.util.List;
public interface Mt2MxCreator {
void preProcess() throws SwiftException;
List<Mt2MxParseFields> getParseFieldsList() throws SwiftException;
void postProcess() throws SwiftException;
}
package com.brilliance.swift.mt2mx;
import com.brilliance.swift.exception.SwiftException;
public interface Mt2MxParseFields {
public void parseFields() throws SwiftException;
}
package com.brilliance.swift.mt2mx.pacs008001;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxCreator;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.mt2mx.Mt2MxParseFields;
import com.brilliance.swift.mt2mx.pacs008001.impl.*;
import com.brilliance.swift.mx.SwiftDto2MxCreatorManager;
import com.brilliance.swift.vo.SwiftDto;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import java.util.ArrayList;
import java.util.List;
public class Mt2MxPacs00801Creator extends AbstractMt2MxCreator {
@Override
public void preProcess() throws SwiftException {
try {
super.preProcess();
SwiftDto swiftDto = context.get(SwiftDto.class);
VoCustomerCreditTransfer customerCreditTransfer = new VoCustomerCreditTransfer();
customerCreditTransfer.setSenderBic(swiftDto.getSenderBic());
customerCreditTransfer.setReceiverBic(swiftDto.getReceiverBic());
customerCreditTransfer.setCreateDate(swiftDto.getCreateDate());
customerCreditTransfer.setMessagePriority(swiftDto.getMessagePriority());
customerCreditTransfer.setUetr(swiftDto.getUetr());
context.set(customerCreditTransfer);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
@Override
public List<Mt2MxParseFields> getParseFieldsList() throws SwiftException {
List<Mt2MxParseFields> list = new ArrayList<>();
list.add(new Pacs00801Parse20Field());
list.add(new Pacs00801Parse13CField());
list.add(new Pacs00801Parse23BField());
list.add(new Pacs00801Parse23EField());
list.add(new Pacs00801Parse26TField());
list.add(new Pacs00801Parse32AField());
list.add(new Pacs00801Parse33BField());
list.add(new Pacs00801Parse36Field());
list.add(new Pacs00801Parse50Field());
list.add(new Pacs00801Parse52Field());
list.add(new Pacs00801Parse53Field());
list.add(new Pacs00801Parse54Field());
list.add(new Pacs00801Parse55Field());
list.add(new Pacs00801Parse56Field());
list.add(new Pacs00801Parse57Field());
list.add(new Pacs00801Parse59Field());
list.add(new Pacs00801Parse70Field());
list.add(new Pacs00801Parse71Field());
list.add(new Pacs00801Parse72Field());
list.add(new Pacs00801Parse77BField());
return list;
}
@Override
public void postProcess() throws SwiftException {
try {
String outputFilePath = (String)context.get(Mt2MxContextIdentifier.MT_TO_MX_OUTPUT_FILE_PATH, true);
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
String xmlStr = new SwiftDto2MxCreatorManager().swiftDto2Mx(customerCreditTransfer, outputFilePath);
context.set(Mt2MxContextIdentifier.MT_TO_MX_XML, xmlStr);
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field13C;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.Date;
import java.util.List;
public class Pacs00801Parse13CField extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
MT103 mt103 = (MT103)context.get(AbstractMT.class);
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
List<Field13C> field13CList = mt103.getField13C();
if (field13CList.size() > 0) {
String dateStr = DateUtil.formatNow("yyyy-MM-dd'T'HH:mm:ss.SSS");
for (int i=0; i<field13CList.size(); i++) {
Field13C field13C = field13CList.get(i);
String timeStr = dateStr.substring(0, 11)
+ field13C.getTime().substring(0,2)
+ ":" + field13C.getTime().substring(2,4)
+ ":00.000"
+ field13C.getSign()
+ field13C.getOffset().substring(0, 2)
+ ":" + field13C.getOffset().substring(2, 4);
XMLGregorianCalendar dateTime = DatatypeFactory.newInstance().newXMLGregorianCalendar(timeStr);
Date date = DateUtil.parseDate(dateTime);
if ("SNDTIME".equals(field13C.getCode())) {
customerCreditTransfer.setDebitDate(date);
} else if ("RNCTIME".equals(field13C.getCode())) {
customerCreditTransfer.setCreditDate(date);
} else if ("CLSTIME".equals(field13C.getCode())) {
customerCreditTransfer.setClsDate(date);
}
}
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field20;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse20Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field20 field20 = mt103.getField20();
if (field20 != null) {
customerCreditTransfer.setMessageId(field20.getValue());
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field23B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse23BField extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field23B field23B = mt103.getField23B();
if (field23B != null) {
String value = field23B.getValue();
if ("CRED".equals(value)) {
value = "SDVA";
}
customerCreditTransfer.setBussinessCode(value);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.InstructionCode;
import com.prowidesoftware.swift.model.field.Field23E;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.ArrayList;
import java.util.List;
public class Pacs00801Parse23EField extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
List<Field23E> field23EList = mt103.getField23E();
if (field23EList.size() > 0) {
for (int i=0; i<field23EList.size(); i++) {
Field23E field23E = field23EList.get(i);
InstructionCode instructionCode = new InstructionCode();
instructionCode.setCode(field23E.getCode());
instructionCode.setCode(field23E.getAdditionalInformation());
customerCreditTransfer.addInstructionCode(instructionCode);
}
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field26T;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse26TField extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field26T field26T = mt103.getField26T();
if (field26T != null) {
customerCreditTransfer.setTxnTypeCode(field26T.getValue());
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.field.Field32A;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse32AField extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field32A field32A = mt103.getField32A();
if (field32A != null) {
customerCreditTransfer.setSettledDate(DateUtil.parseDate("20"+field32A.getDate(), "yyyyMMdd"));
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field32A.getCurrency());
cfa.setAmt(field32A.amount());
customerCreditTransfer.setSettledCcyFormatAmount(cfa);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.prowidesoftware.swift.model.field.Field33B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse33BField extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field33B field33B = mt103.getField33B();
if (field33B != null) {
CcyFormatAmount cfa = new CcyFormatAmount();
cfa.setCcy(field33B.getCurrency());
cfa.setAmt(field33B.amount());
customerCreditTransfer.setInstructedCcyFormatAmount(cfa);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field36;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.math.BigDecimal;
public class Pacs00801Parse36Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
Field36 field36 = mt103.getField36();
if (field36 != null) {
customerCreditTransfer.setExchangeRate(new BigDecimal(field36.getRateAsNumber().toString()));
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.brilliance.swift.vo.common.PartyTypeEnum;
import com.prowidesoftware.swift.model.field.Field50A;
import com.prowidesoftware.swift.model.field.Field50K;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse50Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField50A() != null) {
Field50A field50A = mt103.getField50A();
partyDto = new PartyDto(PartyTypeEnum.OC);
if (StringUtil.isNotEmpty(field50A.getAccount())) {
if (field50A.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field50A.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field50A.getAccount());
}
}
partyDto.setPartyBic(field50A.getBIC());
} else if (mt103.getField50F() != null) {
//TODO
} else if (mt103.getField50K() != null) {
Field50K field50K = mt103.getField50K();
partyDto = new PartyDto(PartyTypeEnum.OC);
if (StringUtil.isNotEmpty(field50K.getAccount())) {
if (field50K.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field50K.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field50K.getAccount());
}
}
partyDto.setPartyName(field50K.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine2())) {
partyDto.addAddress(field50K.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine3())) {
partyDto.addAddress(field50K.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field50K.getNameAndAddressLine4())) {
partyDto.addAddress(field50K.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.addPartyDto(partyDto);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.brilliance.swift.vo.common.PartyTypeEnum;
import com.prowidesoftware.swift.model.field.Field52A;
import com.prowidesoftware.swift.model.field.Field52D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse52Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField52A() != null) {
Field52A field52A = mt103.getField52A();
partyDto = new PartyDto(PartyTypeEnum.OI);
if (StringUtil.isNotEmpty(field52A.getAccount())) {
if (field52A.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field52A.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field52A.getAccount());
}
}
partyDto.setPartyBic(field52A.getBIC());
} else if (mt103.getField52D() != null) {
Field52D field52D = mt103.getField52D();
partyDto = new PartyDto(PartyTypeEnum.OI);
if (StringUtil.isNotEmpty(field52D.getAccount())) {
if (field52D.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field52D.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field52D.getAccount());
}
}
partyDto.setPartyName(field52D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine2())) {
partyDto.addAddress(field52D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine3())) {
partyDto.addAddress(field52D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field52D.getNameAndAddressLine4())) {
partyDto.addAddress(field52D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.addPartyDto(partyDto);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.brilliance.swift.vo.common.PartyTypeEnum;
import com.prowidesoftware.swift.model.field.Field53A;
import com.prowidesoftware.swift.model.field.Field53B;
import com.prowidesoftware.swift.model.field.Field53D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse53Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField53A() != null) {
Field53A field53A = mt103.getField53A();
partyDto = new PartyDto(PartyTypeEnum.SC);
if (StringUtil.isNotEmpty(field53A.getAccount())) {
if (field53A.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field53A.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field53A.getAccount());
}
}
partyDto.setPartyBic(field53A.getBIC());
} else if (mt103.getField53B() != null) {
Field53B field53B = mt103.getField53B();
//TODO
} else if (mt103.getField53D() != null) {
Field53D field53D = mt103.getField53D();
partyDto = new PartyDto(PartyTypeEnum.SC);
if (StringUtil.isNotEmpty(field53D.getAccount())) {
if (field53D.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field53D.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field53D.getAccount());
}
}
partyDto.setPartyName(field53D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine2())) {
partyDto.addAddress(field53D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine3())) {
partyDto.addAddress(field53D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field53D.getNameAndAddressLine4())) {
partyDto.addAddress(field53D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.addPartyDto(partyDto);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.brilliance.swift.vo.common.PartyTypeEnum;
import com.prowidesoftware.swift.model.field.Field54A;
import com.prowidesoftware.swift.model.field.Field54B;
import com.prowidesoftware.swift.model.field.Field54D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse54Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField54A() != null) {
Field54A field54A = mt103.getField54A();
partyDto = new PartyDto(PartyTypeEnum.RC);
if (StringUtil.isNotEmpty(field54A.getAccount())) {
if (field54A.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field54A.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field54A.getAccount());
}
}
partyDto.setPartyBic(field54A.getBIC());
} else if (mt103.getField54B() != null) {
Field54B field54B = mt103.getField54B();
//TODO
} else if (mt103.getField54D() != null) {
Field54D field54D = mt103.getField54D();
partyDto = new PartyDto(PartyTypeEnum.RC);
if (StringUtil.isNotEmpty(field54D.getAccount())) {
if (field54D.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field54D.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field54D.getAccount());
}
}
partyDto.setPartyName(field54D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine2())) {
partyDto.addAddress(field54D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine3())) {
partyDto.addAddress(field54D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field54D.getNameAndAddressLine4())) {
partyDto.addAddress(field54D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.addPartyDto(partyDto);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.brilliance.swift.vo.common.PartyTypeEnum;
import com.prowidesoftware.swift.model.field.Field55A;
import com.prowidesoftware.swift.model.field.Field55B;
import com.prowidesoftware.swift.model.field.Field55D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse55Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103)context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField55A() != null) {
Field55A field55A = mt103.getField55A();
partyDto = new PartyDto(PartyTypeEnum.RI);
if (StringUtil.isNotEmpty(field55A.getAccount())) {
if (field55A.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field55A.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field55A.getAccount());
}
}
partyDto.setPartyBic(field55A.getBIC());
} else if (mt103.getField55B() != null) {
Field55B field55B = mt103.getField55B();
//TODO
} else if (mt103.getField55D() != null) {
Field55D field55D = mt103.getField55D();
partyDto = new PartyDto(PartyTypeEnum.RI);
if (StringUtil.isNotEmpty(field55D.getAccount())) {
if (field55D.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field55D.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field55D.getAccount());
}
}
partyDto.setPartyName(field55D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field55D.getNameAndAddressLine2())) {
partyDto.addAddress(field55D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field55D.getNameAndAddressLine3())) {
partyDto.addAddress(field55D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field55D.getNameAndAddressLine4())) {
partyDto.addAddress(field55D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.addPartyDto(partyDto);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.brilliance.swift.vo.common.PartyTypeEnum;
import com.prowidesoftware.swift.model.field.Field56A;
import com.prowidesoftware.swift.model.field.Field56C;
import com.prowidesoftware.swift.model.field.Field56D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse56Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField56A() != null) {
Field56A field56A = mt103.getField56A();
partyDto = new PartyDto(PartyTypeEnum.II);
if (StringUtil.isNotEmpty(field56A.getAccount())) {
if (field56A.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field56A.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field56A.getAccount());
}
}
partyDto.setPartyBic(field56A.getBIC());
} else if (mt103.getField56C() != null) {
Field56C field56C = mt103.getField56C();
partyDto = new PartyDto(PartyTypeEnum.II);
partyDto.setPartyAcct(field56C.getAccount());
} else if (mt103.getField56D() != null) {
Field56D field56D = mt103.getField56D();
partyDto = new PartyDto(PartyTypeEnum.II);
if (StringUtil.isNotEmpty(field56D.getAccount())) {
if (field56D.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field56D.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field56D.getAccount());
}
}
partyDto.setPartyName(field56D.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine2())) {
partyDto.addAddress(field56D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine3())) {
partyDto.addAddress(field56D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field56D.getNameAndAddressLine4())) {
partyDto.addAddress(field56D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.addPartyDto(partyDto);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.brilliance.swift.vo.common.PartyTypeEnum;
import com.prowidesoftware.swift.model.field.Field57A;
import com.prowidesoftware.swift.model.field.Field57B;
import com.prowidesoftware.swift.model.field.Field57C;
import com.prowidesoftware.swift.model.field.Field57D;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse57Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField57A() != null) {
Field57A field57A = mt103.getField57A();
partyDto = new PartyDto(PartyTypeEnum.AI);
if (StringUtil.isNotEmpty(field57A.getAccount())) {
if (field57A.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field57A.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field57A.getAccount());
}
}
partyDto.setPartyBic(field57A.getBIC());
} else if (mt103.getField57B() != null) {
Field57B field57B = mt103.getField57B();
//TODO
} else if (mt103.getField57C() != null) {
Field57C field57C = mt103.getField57C();
partyDto = new PartyDto(PartyTypeEnum.AI);
partyDto.setPartyAcct(field57C.getAccount());
} else if (mt103.getField57D() != null) {
Field57D field57D = mt103.getField57D();
partyDto = new PartyDto(PartyTypeEnum.AI);
if (StringUtil.isNotEmpty(field57D.getAccount())) {
if (field57D.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field57D.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field57D.getAccount());
}
}
partyDto.setPartyName(field57D.getName());
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine2())) {
partyDto.addAddress(field57D.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine3())) {
partyDto.addAddress(field57D.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field57D.getNameAndAddressLine4())) {
partyDto.addAddress(field57D.getNameAndAddressLine4());
}
}
if (partyDto != null) {
customerCreditTransfer.addPartyDto(partyDto);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.PartyDto;
import com.brilliance.swift.vo.common.PartyTypeEnum;
import com.prowidesoftware.swift.model.field.Field59;
import com.prowidesoftware.swift.model.field.Field59A;
import com.prowidesoftware.swift.model.field.Field59F;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse59Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
PartyDto partyDto = null;
if (mt103.getField59() != null) {
Field59 field59 = mt103.getField59();
partyDto = new PartyDto(PartyTypeEnum.BC);
if (StringUtil.isNotEmpty(field59.getAccount())) {
if (field59.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field59.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field59.getAccount());
}
}
partyDto.setPartyName(field59.getNameAndAddressLine1());
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine2())) {
partyDto.addAddress(field59.getNameAndAddressLine2());
}
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine3())) {
partyDto.addAddress(field59.getNameAndAddressLine3());
}
if (StringUtil.isNotEmpty(field59.getNameAndAddressLine4())) {
partyDto.addAddress(field59.getNameAndAddressLine4());
}
} else if (mt103.getField59A() != null) {
Field59A field59A = mt103.getField59A();
partyDto = new PartyDto(PartyTypeEnum.BC);
if (StringUtil.isNotEmpty(field59A.getAccount())) {
if (field59A.getAccount().startsWith("CH")) {
partyDto.setPartyAcct(field59A.getAccount().substring(2));
} else {
partyDto.setPartyIBANAcct(field59A.getAccount());
}
}
partyDto.setPartyBic(field59A.getBIC());
} else if (mt103.getField59F() != null) {
Field59F field59F = mt103.getField59F();
//TODO
}
if (partyDto != null) {
customerCreditTransfer.addPartyDto(partyDto);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field70;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse70Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
List<Field70> field70List = mt103.getField70List();
if (field70List.size() > 0) {
for (int i=0; i<field70List.size(); i++) {
customerCreditTransfer.addRemittanceInfo(field70List.get(i).getValue());
}
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.mt2mx.Mt2MxContextIdentifier;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.CcyFormatAmount;
import com.brilliance.swift.vo.common.ChargeForEnum;
import com.prowidesoftware.swift.model.field.Field71A;
import com.prowidesoftware.swift.model.field.Field71F;
import com.prowidesoftware.swift.model.field.Field71G;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.util.List;
public class Pacs00801Parse71Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
Field71A field71A = mt103.getField71A();
if (field71A != null) {
String chargeFor = "";
if (ChargeForEnum.DEBT.desc().equals(field71A.getValue())) {
customerCreditTransfer.setChargeFor(ChargeForEnum.DEBT);
} else if (ChargeForEnum.CRED.desc().equals(field71A.getValue())) {
customerCreditTransfer.setChargeFor(ChargeForEnum.CRED);
} else if (ChargeForEnum.SHAR.desc().equals(field71A.getValue())) {
customerCreditTransfer.setChargeFor(ChargeForEnum.SHAR);
}
}
CcyFormatAmount cfa = null;
List<Field71F> field71FList = mt103.getField71F();
if (field71FList.size() > 0) {
cfa = new CcyFormatAmount();
cfa.setCcy(field71FList.get(0).getCurrency());
cfa.setAmt(field71FList.get(0).amount());
}
Field71G field71G = mt103.getField71G();
if (field71G != null) {
cfa = new CcyFormatAmount();
cfa.setCcy(field71G.getCurrency());
cfa.setAmt(field71G.amount());
}
if (cfa != null) {
customerCreditTransfer.setChargeCcyFormatAmount(cfa);
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.SenderToReceiverInformation;
import com.brilliance.swift.vo.common.SenderToReceiverInformationType;
import com.prowidesoftware.swift.model.field.Field72;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse72Field extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
Field72 field72 = mt103.getField72();
if (field72 != null) {
String field72Value = field72.getValue().replace("\r\n//", "");
String[] lines = field72Value.split("\r\n");
for (int i=0; i<lines.length; i++) {
String line = lines[i];
SenderToReceiverInformation strInfo = null;
if (line.startsWith("/INS/")) {
strInfo = new SenderToReceiverInformation();
strInfo.setType(SenderToReceiverInformationType.PIA);
strInfo.setInstructionInformation(line.substring(5));
}
if (line.startsWith("/ACC/")) {
strInfo = new SenderToReceiverInformation();
strInfo.setType(SenderToReceiverInformationType.IFCA);
strInfo.setInstructionInformation(line.substring(5));
}
if (line.startsWith("/REC/")) {
strInfo = new SenderToReceiverInformation();
strInfo.setType(SenderToReceiverInformationType.IFNA);
strInfo.setInstructionInformation(line.substring(5));
}
if (strInfo != null) {
customerCreditTransfer.addSenderToReceiverInformation(strInfo);
}
}
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mt2mx.pacs008001.impl;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2mx.AbstractMt2MxParseFields;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.prowidesoftware.swift.model.field.Field77B;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mt1xx.MT103;
public class Pacs00801Parse77BField extends AbstractMt2MxParseFields {
@Override
public void parseFields() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = context.get(VoCustomerCreditTransfer.class);
MT103 mt103 = (MT103) context.get(AbstractMT.class);
Field77B field77B = mt103.getField77B();
if (field77B != null) {
for (int i=0; i<field77B.getLines().size(); i++) {
customerCreditTransfer.addRegulatoryReporting(field77B.getLines().get(i));
}
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
package com.brilliance.swift.mx;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.vo.common.PartyDto;
import com.prowidesoftware.swift.model.mx.dic.*;
public abstract class AbstractSwiftDto2MxCreator implements SwiftDto2MxCreator{
protected SwiftDto2MxContext context;
public SwiftDto2MxContext getContext() {
return context;
}
public AbstractSwiftDto2MxCreator setContext(SwiftDto2MxContext context) {
this.context = context;
return this;
}
protected BranchAndFinancialInstitutionIdentification6 partyDtoConvertAgt(PartyDto partyDto) {
BranchAndFinancialInstitutionIdentification6 agt = new BranchAndFinancialInstitutionIdentification6();
FinancialInstitutionIdentification18 finInstnId = new FinancialInstitutionIdentification18();
finInstnId.setBICFI(partyDto.getPartyBic());
finInstnId.setNm(partyDto.getPartyName());
if (partyDto.getAddressList().size() > 0) {
PostalAddress24 pstlAdr = new PostalAddress24();
for (int i=0; i<partyDto.getAddressList().size(); i++) {
pstlAdr.addAdrLine(partyDto.getAddressList().get(i));
}
finInstnId.setPstlAdr(pstlAdr);
}
agt.setFinInstnId(finInstnId);
return agt;
}
protected CashAccount38 partyDtoConvertAgtAccount(PartyDto partyDto) {
CashAccount38 cashAccount38 = null;
String partyIBANAcct = partyDto.getPartyIBANAcct();
String partyAcct = partyDto.getPartyAcct();
if (StringUtil.isNotEmpty(partyAcct) || StringUtil.isNotEmpty(partyIBANAcct)) {
cashAccount38 = new CashAccount38();
AccountIdentification4Choice id = new AccountIdentification4Choice();
if (StringUtil.isNotEmpty(partyAcct)) {
GenericAccountIdentification1 othr = new GenericAccountIdentification1();
othr.setId(partyAcct);
id.setOthr(othr);
}
if (StringUtil.isNotEmpty(partyIBANAcct)) {
id.setIBAN(partyIBANAcct);
}
cashAccount38.setId(id);
}
return cashAccount38;
}
protected PartyIdentification135 partyDtoConvertTr(PartyDto partyDto) {
PartyIdentification135 tr = new PartyIdentification135();
tr.setNm(partyDto.getPartyName());
if (StringUtil.isNotEmpty(partyDto.getPartyBic())) {
Party38Choice id = new Party38Choice();
OrganisationIdentification29 orgId = new OrganisationIdentification29();
orgId.setAnyBIC(partyDto.getPartyBic());
id.setOrgId(orgId);
tr.setId(id);
}
if (partyDto.getAddressList().size() > 0) {
PostalAddress24 pstlAdr = new PostalAddress24();
for (int i=0; i<partyDto.getAddressList().size(); i++) {
pstlAdr.addAdrLine(partyDto.getAddressList().get(i));
}
tr.setPstlAdr(pstlAdr);
}
return tr;
}
}
package com.brilliance.swift.mx;
import com.brilliance.swift.context.ContextImpl;
public class SwiftDto2MxContext extends ContextImpl {
private static final long serialVersionUID = 3038256754067380826L;
}
package com.brilliance.swift.mx;
public class SwiftDto2MxContextIdentifier {
public static final String MX_OUTPUT_FILE_PATH = "mx.output.filepath";
public static final String MX_XML = "mx.xml";
public static final String SWIFT_DTO_OBJ = "swift.dto.obj";
}
package com.brilliance.swift.mx;
import com.brilliance.swift.exception.SwiftException;
public interface SwiftDto2MxCreator {
void create() throws SwiftException;
}
package com.brilliance.swift.mx;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx.pacs00801.SwiftDto2MxPacs008001Creator;
import com.brilliance.swift.vo.SwiftDto;
public class SwiftDto2MxCreatorManager {
public String swiftDto2Mx(SwiftDto swiftDto, String fileOutputPath) throws SwiftException {
try {
SwiftDto2MxContext context = new SwiftDto2MxContext();
context.set(SwiftDto2MxContextIdentifier.SWIFT_DTO_OBJ, swiftDto);
context.set(SwiftDto2MxContextIdentifier.MX_OUTPUT_FILE_PATH, fileOutputPath);
AbstractSwiftDto2MxCreator creator = getCreator(swiftDto.getMessageType());
creator.setContext(context).create();
String xmlStr = (String)context.get(SwiftDto2MxContextIdentifier.MX_XML);
return xmlStr;
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
public AbstractSwiftDto2MxCreator getCreator(String messageType) {
if ("pacs.008.001".equals(messageType)) {
return new SwiftDto2MxPacs008001Creator();
} else {
throw new SwiftException("Invalid message type");
}
}
}
package com.brilliance.swift.mx.pacs00801;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mx.AbstractSwiftDto2MxCreator;
import com.brilliance.swift.mx.SwiftDto2MxContextIdentifier;
import com.brilliance.swift.util.DateUtil;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.vo.VoCustomerCreditTransfer;
import com.brilliance.swift.vo.common.*;
import com.prowidesoftware.swift.model.mx.BusinessAppHdrV02;
import com.prowidesoftware.swift.model.mx.MxPacs00800109;
import com.prowidesoftware.swift.model.mx.dic.*;
import javax.xml.datatype.XMLGregorianCalendar;
import java.io.File;
import java.math.BigDecimal;
import java.util.List;
public class SwiftDto2MxPacs008001Creator extends AbstractSwiftDto2MxCreator {
@Override
public void create() throws SwiftException {
try {
VoCustomerCreditTransfer customerCreditTransfer = (VoCustomerCreditTransfer)context.get(SwiftDto2MxContextIdentifier.SWIFT_DTO_OBJ, true);
if (customerCreditTransfer == null) {
return;
}
MxPacs00800109 mxPacs00800109 = new MxPacs00800109();
List<PartyDto> partyDtos = customerCreditTransfer.getPartyDtoList();
PartyDto instructingReimbursementParty = null;//53
PartyDto instructedReimbursementParty = null;//54
PartyDto thirdReimbursementParty = null;//55
PartyDto dbtrParty = null;//50
PartyDto dbtrAgtParty = null;//52
PartyDto intrmyAgt1Party = null;//56
PartyDto cdtrAgtParty = null;//57
PartyDto cdtrParty = null;//59
for (PartyDto partyDto : partyDtos) {
if (PartyTypeEnum.SC.equals(partyDto.getPartyType())) {
instructingReimbursementParty = partyDto;
}
if (PartyTypeEnum.RC.equals(partyDto.getPartyType())) {
instructedReimbursementParty = partyDto;
}
if (PartyTypeEnum.RI.equals(partyDto.getPartyType())) {
thirdReimbursementParty = partyDto;
}
if (PartyTypeEnum.OC.equals(partyDto.getPartyType())) {
dbtrParty = partyDto;
}
if (PartyTypeEnum.OI.equals(partyDto.getPartyType())) {
dbtrAgtParty = partyDto;
}
if (PartyTypeEnum.II.equals(partyDto.getPartyType())) {
intrmyAgt1Party = partyDto;
}
if (PartyTypeEnum.AI.equals(partyDto.getPartyType())) {
cdtrAgtParty = partyDto;
}
if (PartyTypeEnum.BC.equals(partyDto.getPartyType())) {
cdtrParty = partyDto;
}
}
//set AppHdr
BusinessAppHdrV02 businessAppHdrV02 = new BusinessAppHdrV02();
Party44Choice fr = new Party44Choice();
PartyIdentification135 frOrgId = new PartyIdentification135();
Party38Choice frId = new Party38Choice();
OrganisationIdentification29 frIdOrgId = new OrganisationIdentification29();
frIdOrgId.setAnyBIC(customerCreditTransfer.getSenderBic());
frId.setOrgId(frIdOrgId);
frOrgId.setId(frId);
fr.setOrgId(frOrgId);
businessAppHdrV02.setFr(fr);
Party44Choice to = new Party44Choice();
PartyIdentification135 toOrgId = new PartyIdentification135();
Party38Choice toId = new Party38Choice();
OrganisationIdentification29 toIdOrgId = new OrganisationIdentification29();
toIdOrgId.setAnyBIC(customerCreditTransfer.getReceiverBic());
toId.setOrgId(toIdOrgId);
toOrgId.setId(toId);
to.setOrgId(toOrgId);
businessAppHdrV02.setTo(to);
XMLGregorianCalendar creDt = DateUtil.parseXMLGregorianCalendar(customerCreditTransfer.getCreateDate());
businessAppHdrV02.setCreDt(creDt);
if (MessagePriority.NORM.equals(customerCreditTransfer.getMessagePriority())) {
businessAppHdrV02.setPrty(Priority2Code.NORM.value());
} else if (MessagePriority.HIGH.equals(customerCreditTransfer.getMessagePriority())) {
businessAppHdrV02.setPrty(Priority2Code.HIGH.value());
}
businessAppHdrV02.setMsgDefIdr("pacs.008.001.09");
businessAppHdrV02.setBizMsgIdr(customerCreditTransfer.getMessageId());
mxPacs00800109.setAppHdr(businessAppHdrV02);
FIToFICustomerCreditTransferV09 fiToFICstmrCdtTrf = new FIToFICustomerCreditTransferV09();
mxPacs00800109.setFIToFICstmrCdtTrf(fiToFICstmrCdtTrf);
//set GroupHeader
GroupHeader93 grpHdr = new GroupHeader93();
grpHdr.setMsgId(customerCreditTransfer.getMessageId());
grpHdr.setCreDtTm(DateUtil.parseXMLGregorianCalendar(customerCreditTransfer.getCreateDate()));
grpHdr.setNbOfTxs("1");
SettlementInstruction7 sttlmInf = new SettlementInstruction7();
sttlmInf.setSttlmMtd(SettlementMethod1Code.INDA);
if (instructingReimbursementParty != null) {
BranchAndFinancialInstitutionIdentification6 instgRmbrsmntAgt = partyDtoConvertAgt(instructingReimbursementParty);
sttlmInf.setInstgRmbrsmntAgt(instgRmbrsmntAgt);
CashAccount38 instgRmbrsmntAgtAcct = partyDtoConvertAgtAccount(instructingReimbursementParty);
sttlmInf.setInstgRmbrsmntAgtAcct(instgRmbrsmntAgtAcct);
}
if (instructedReimbursementParty != null) {
BranchAndFinancialInstitutionIdentification6 instdRmbrsmntAgt = partyDtoConvertAgt(instructedReimbursementParty);
sttlmInf.setInstdRmbrsmntAgt(instdRmbrsmntAgt);
CashAccount38 instdRmbrsmntAgtAcct = partyDtoConvertAgtAccount(instructedReimbursementParty);
sttlmInf.setInstdRmbrsmntAgtAcct(instdRmbrsmntAgtAcct);
}
if (thirdReimbursementParty != null) {
BranchAndFinancialInstitutionIdentification6 thrdRmbrsmntAgt = partyDtoConvertAgt(thirdReimbursementParty);
sttlmInf.setThrdRmbrsmntAgt(thrdRmbrsmntAgt);
CashAccount38 thrdRmbrsmntAgtAcct = partyDtoConvertAgtAccount(thirdReimbursementParty);
sttlmInf.setThrdRmbrsmntAgtAcct(thrdRmbrsmntAgtAcct);
}
grpHdr.setSttlmInf(sttlmInf);
fiToFICstmrCdtTrf.setGrpHdr(grpHdr);
CreditTransferTransaction43 cdtTrfTxInf = new CreditTransferTransaction43();
fiToFICstmrCdtTrf.addCdtTrfTxInf(cdtTrfTxInf);
//PmtId
PaymentIdentification13 pmtId = new PaymentIdentification13();
pmtId.setInstrId(customerCreditTransfer.getMessageId());
pmtId.setEndToEndId("NOTPROVIDED");
pmtId.setUETR(customerCreditTransfer.getUetr());
cdtTrfTxInf.setPmtId(pmtId);
//SttlmTmIndctn SttlmTmReq
SettlementDateTimeIndication1 sttlmTmIndctn = null;
XMLGregorianCalendar debitDt = DateUtil.parseXMLGregorianCalendar(customerCreditTransfer.getDebitDate());
if (debitDt != null) {
if (sttlmTmIndctn == null) {
sttlmTmIndctn = new SettlementDateTimeIndication1();
}
sttlmTmIndctn.setDbtDtTm(debitDt);
}
XMLGregorianCalendar creditDt = DateUtil.parseXMLGregorianCalendar(customerCreditTransfer.getCreditDate());
if (creditDt != null) {
if (sttlmTmIndctn == null) {
sttlmTmIndctn = new SettlementDateTimeIndication1();
}
sttlmTmIndctn.setCdtDtTm(creditDt);
}
cdtTrfTxInf.setSttlmTmIndctn(sttlmTmIndctn);
SettlementTimeRequest2 sttlmTmReq = null;
XMLGregorianCalendar clsDt = DateUtil.parseXMLGregorianCalendar(customerCreditTransfer.getClsDate());
if (clsDt != null) {
sttlmTmReq = new SettlementTimeRequest2();
sttlmTmReq.setCLSTm(clsDt);
}
cdtTrfTxInf.setSttlmTmReq(sttlmTmReq);
//PmtTpInf
String businessCode = customerCreditTransfer.getBussinessCode();
if (StringUtil.isNotEmpty(businessCode)) {
PaymentTypeInformation28 pmtTpInf = new PaymentTypeInformation28();
ServiceLevel8Choice svcLvl = new ServiceLevel8Choice();
if ("SDVA".equals(businessCode)) {
svcLvl.setCd(businessCode);
} else {
svcLvl.setPrtry(businessCode);
}
pmtTpInf.addSvcLvl(svcLvl);
cdtTrfTxInf.setPmtTpInf(pmtTpInf);
}
//Purp
String txnTypeCode = customerCreditTransfer.getTxnTypeCode();
if (StringUtil.isNotEmpty(txnTypeCode)) {
Purpose2Choice purp = new Purpose2Choice();
purp.setPrtry(txnTypeCode);
cdtTrfTxInf.setPurp(purp);
}
//IntrBkSttlmAmt
CcyFormatAmount settledCfa = customerCreditTransfer.getSettledCcyFormatAmount();
if (settledCfa != null) {
ActiveCurrencyAndAmount intrBkSttlmAmt = new ActiveCurrencyAndAmount();
intrBkSttlmAmt.setCcy(settledCfa.getCcy());
intrBkSttlmAmt.setValue(settledCfa.getAmt());
cdtTrfTxInf.setIntrBkSttlmAmt(intrBkSttlmAmt);
}
//IntrBkSttlmDt
XMLGregorianCalendar xmlValueDate = DateUtil.parseXMLGregorianCalendar(customerCreditTransfer.getSettledDate());
if (xmlValueDate != null) {
cdtTrfTxInf.setIntrBkSttlmDt(xmlValueDate);
}
//InstdAmt
CcyFormatAmount instructedCfa = customerCreditTransfer.getInstructedCcyFormatAmount();
if (instructedCfa != null) {
ActiveOrHistoricCurrencyAndAmount instdAmt = new ActiveOrHistoricCurrencyAndAmount();
instdAmt.setCcy(instructedCfa.getCcy());
instdAmt.setValue(instructedCfa.getAmt());
cdtTrfTxInf.setInstdAmt(instdAmt);
}
//XchgRate
BigDecimal exchangeRate = customerCreditTransfer.getExchangeRate();
if (exchangeRate != null) {
cdtTrfTxInf.setXchgRate(exchangeRate);
}
//Dbtr DbtrAcct
if (dbtrParty != null) {
PartyIdentification135 dbtr = partyDtoConvertTr(dbtrParty);
cdtTrfTxInf.setDbtr(dbtr);
CashAccount38 dbtrAcct = partyDtoConvertAgtAccount(dbtrParty);
cdtTrfTxInf.setDbtrAcct(dbtrAcct);
}
//DbtrAgt DbtrAgtAcct
if (dbtrAgtParty != null) {
BranchAndFinancialInstitutionIdentification6 dbtrAgt = partyDtoConvertAgt(dbtrAgtParty);
cdtTrfTxInf.setDbtrAgt(dbtrAgt);
CashAccount38 dbtrAgtAcct = partyDtoConvertAgtAccount(dbtrAgtParty);
cdtTrfTxInf.setDbtrAgtAcct(dbtrAgtAcct);
}
//IntrmyAgt1 IntrmyAgt1Acct
if (intrmyAgt1Party != null) {
BranchAndFinancialInstitutionIdentification6 intrmyAgt1 = partyDtoConvertAgt(intrmyAgt1Party);
cdtTrfTxInf.setIntrmyAgt1(intrmyAgt1);
CashAccount38 intrmyAgt1Acct = partyDtoConvertAgtAccount(intrmyAgt1Party);
cdtTrfTxInf.setIntrmyAgt1Acct(intrmyAgt1Acct);
}
//CdtrAgt CdtrAgtAcct
if (cdtrAgtParty != null) {
BranchAndFinancialInstitutionIdentification6 cdtrAgt = partyDtoConvertAgt(cdtrAgtParty);
cdtTrfTxInf.setCdtrAgt(cdtrAgt);
CashAccount38 cdtrAgtAcct = partyDtoConvertAgtAccount(cdtrAgtParty);
cdtTrfTxInf.setCdtrAgtAcct(cdtrAgtAcct);
}
//Cdtr CdtrAcct
if (cdtrParty != null) {
PartyIdentification135 cdtr = partyDtoConvertTr(cdtrParty);
cdtTrfTxInf.setCdtr(cdtr);
CashAccount38 cdtrAcct = partyDtoConvertAgtAccount(cdtrParty);
cdtTrfTxInf.setCdtrAcct(cdtrAcct);
}
//RmtInf
List<String> remittanceInfolist = customerCreditTransfer.getRemittanceInfoList();
if (remittanceInfolist != null && remittanceInfolist.size() > 0) {
RemittanceInformation16 rmtInf = new RemittanceInformation16();
String ustrd = "";
for (String remittanceInfo : remittanceInfolist) {
ustrd += remittanceInfo;
}
rmtInf.addUstrd(ustrd);
cdtTrfTxInf.setRmtInf(rmtInf);
}
//ChrgBr ChrgsInf
ChargeForEnum chargeForEnum = customerCreditTransfer.getChargeFor();
if (chargeForEnum != null) {
cdtTrfTxInf.setChrgBr(ChargeBearerType1Code.fromValue(chargeForEnum.value()));
CcyFormatAmount cfa = customerCreditTransfer.getChargeCcyFormatAmount();
if (cfa != null) {
Charges7 chrgsInf = new Charges7();
ActiveOrHistoricCurrencyAndAmount amt = new ActiveOrHistoricCurrencyAndAmount();
amt.setCcy(cfa.getCcy());
amt.setValue(cfa.getAmt());
chrgsInf.setAmt(amt);
if (ChargeBearerType1Code.CRED.equals(cdtTrfTxInf.getChrgBr()) || ChargeBearerType1Code.SHAR.equals(cdtTrfTxInf.getChrgBr())) {
chrgsInf.setAgt(partyDtoConvertAgt(instructingReimbursementParty));
} else if (ChargeBearerType1Code.DEBT.equals(cdtTrfTxInf.getChrgBr())) {
chrgsInf.setAgt(partyDtoConvertAgt(instructedReimbursementParty));
}
cdtTrfTxInf.addChrgsInf(chrgsInf);
}
}
//PrvsInstgAgt1 InstrForCdtrAgt InstrForNxtAgt
List<SenderToReceiverInformation> strInfolist = customerCreditTransfer.getSenderToReceiverInformationList();
if (strInfolist != null && strInfolist.size() > 0) {
for (int i=0; i<strInfolist.size(); i++) {
SenderToReceiverInformation strInfo = strInfolist.get(i);
String instInfo = strInfo.getInstructionInformation();
if (SenderToReceiverInformationType.PIA.equals(strInfo.getType())) {
BranchAndFinancialInstitutionIdentification6 prvsInstgAgt1 = new BranchAndFinancialInstitutionIdentification6();
FinancialInstitutionIdentification18 finInstnId = new FinancialInstitutionIdentification18();
if (SwiftTransferUtil.isBIC(instInfo)) {
finInstnId.setBICFI(instInfo);
} else {
finInstnId.setNm(instInfo);
}
prvsInstgAgt1.setFinInstnId(finInstnId);
cdtTrfTxInf.setPrvsInstgAgt1(prvsInstgAgt1);
}
if (SenderToReceiverInformationType.IFCA.equals(strInfo.getType())) {
InstructionForCreditorAgent3 instructionForCreditorAgent3 = new InstructionForCreditorAgent3();
instructionForCreditorAgent3.setInstrInf(instInfo);
cdtTrfTxInf.addInstrForCdtrAgt(instructionForCreditorAgent3);
}
if (SenderToReceiverInformationType.IFNA.equals(strInfo.getType())) {
InstructionForNextAgent1 instructionForNextAgent1 = new InstructionForNextAgent1();
instructionForNextAgent1.setInstrInf(instInfo);
cdtTrfTxInf.addInstrForNxtAgt(instructionForNextAgent1);
}
}
}
//RgltryRptg
List<String> rpList = customerCreditTransfer.getRegulatoryReportingList();
if (rpList != null && rpList.size() > 0) {
for (String rp : rpList) {
RegulatoryReporting3 regulatoryReporting3 = new RegulatoryReporting3();
StructuredRegulatoryReporting3 dtl = new StructuredRegulatoryReporting3();
dtl.addInf(rp);
regulatoryReporting3.addDtls(dtl);
cdtTrfTxInf.addRgltryRptg(regulatoryReporting3);
}
}
String xmlStr = mxPacs00800109.message();
context.set(SwiftDto2MxContextIdentifier.MX_XML, xmlStr);
String outputFilePath = (String)context.get(SwiftDto2MxContextIdentifier.MX_OUTPUT_FILE_PATH, true);
if (StringUtil.isNotEmpty(outputFilePath)) {
mxPacs00800109.write(new File(outputFilePath));
}
} catch (Exception e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
}
......@@ -193,8 +193,8 @@ public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
.append(bicCode)
.append(sessionNumber)
.append(sequenceNumber)
.append(outTimeStr)
.append(outDateStr)
.append(outTimeStr)
.append(priority);
head2 = sb.toString();
}
......
......@@ -25,11 +25,11 @@ public class Field77BGenerate extends AbstractMx2MtFieldsGenerate {
for (int i=0; i<size; i++) {
if (i == 3) break;
String dtlsInf = getXmlNodeValue(Mx2MtConstants.MAINBODY_PARENT_ELEMENT_NAME, document, "CdtTrfTxInf.RgltryRptg("+i+").Dtls.Inf");
if (i == 0) {
/*if (i == 0) {
dtlsInf = "/" + dtlsInf;
} else {
dtlsInf = "//" + dtlsInf;
}
}*/
if (dtlsInf.length() > 35) {
dtlsInf = dtlsInf.substring(0, 35);
}
......
......@@ -10,9 +10,7 @@ import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.*;
public class DateUtil {
......@@ -225,12 +223,29 @@ public class DateUtil {
xgc.setYear(c.get(Calendar.YEAR));
xgc.setMonth(c.get(Calendar.MONTH) + 1);
xgc.setDay(c.get(Calendar.DAY_OF_MONTH));
xgc.setTimezone(new GregorianCalendar().getTimeZone().getOffset(System.currentTimeMillis()) / 1000 / 60);
} catch (Exception e) {
throw new SwiftException("00404", "parse date error.", e);
}
return xgc;
}
public static XMLGregorianCalendar parseXMLGregorianCalendar2(String time) {
XMLGregorianCalendar xgc = null;
try {
xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar();
Date date = DateUtil.parseDate(time.substring(0, 8), "yyyyMMdd");
Calendar c = Calendar.getInstance();
c.setTime(date);
xgc.setYear(c.get(Calendar.YEAR));
xgc.setMonth(c.get(Calendar.MONTH) + 1);
xgc.setDay(c.get(Calendar.DAY_OF_MONTH));
xgc.setTimezone(new GregorianCalendar().getTimeZone().getOffset(System.currentTimeMillis()) / 1000 / 60);
} catch (Exception e) {
throw new SwiftException("00404", "parse date error.", e);
}
return xgc;
}
/**
* XML时间转化为Date
*
......
......@@ -3,6 +3,9 @@ package com.brilliance.swift.util;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
public class SwiftTransferUtil {
......@@ -18,4 +21,495 @@ public class SwiftTransferUtil {
XMLGregorianCalendar now = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);
return now;
}
/**
* Validate the field format notation types of character: A type of
* character. Its explanation is:
* <em>a = alphabetic letters (A through Z), upper case only: A-Z</em>
* @param s
* - String, a string to be tested
* @return boolean, true indicating it belongs to
*/
public static boolean belongstoA(String s) {
String[] a =
new String[] {
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z" };
return eachCharIn(s, a);
}
/**
* Test if matching the A type of character (A-Z) at least min times and at
* most max times. *
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param s
* - String, the string to be tested
* @param min
* - int, at least min times
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToA(String s, int min, int max) {
String restrictOccur = buildRegexQuantifier(min, max);
return (!StringUtil.isEmpty(s) && s.matches("[A-Z]" + restrictOccur));
}
/**
* Validate the field format notation types of character: C type of
* character. Its explanation is:
* <em>c = alphabetic letters (upper case) and digits only: A-Z0-9</em>
* @param s
* - String, a string to be tested
* @return boolean, true indicating it belongs to
*/
public static boolean belongstoC(String s) {
String[] a =
new String[] {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
return eachCharIn(s, a);
}
/**
* Test if matching the C type of character (A-Z0-9) at least one time and
* at most max times. *
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param s
* - String, the string to be tested
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToC(String s, int max) {
return belongsToC(s, 1, max);
}
/**
* Test if matching the C type of character (A-Z0-9) at least min times and
* at most max times.
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param s
* - String, the string to be tested
* @param min
* - int, at least min times
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToC(String s, int min, int max) {
String restrictOccur = buildRegexQuantifier(min, max);
return (!StringUtil.isEmpty(s) && s.matches("[A-Z0-9]" + restrictOccur));
}
/**
* Validate the field format notation types of character: D type of
* character. Its explanation is:
* <em>d = digits with a decimal comma: 0-9,</em>
* @param s
* - String, a string to be tested
* @return boolean, true indicating it belongs to
*/
public static boolean belongstoD(String s) {
String[] a = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "," };
return eachCharIn(s, a);
}
/**
* Test if matching the D type of character (0-9,) at least one time and at
* most max times.
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param s
* - String, the string to be tested
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToD(String s, int max) {
return belongsToD(s, 1, max);
}
/**
* Test if matching the D type of character (0-9,) at least min times and at
* most max times.
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param s
* - String, the string to be tested
* @param min
* - int, at least min times
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToD(String s, int min, int max) {
String restrictOccur = buildRegexQuantifier(min, max);
return (!StringUtil.isEmpty(s) && !s.matches("[\\d+,\\d*]" + restrictOccur));
}
/**
* Validate the field format notation types of character: N type of
* character. Its explanation is:
* <em>n = numeric digits (0 through 9) only: 0-9</em>
* @param s
* - String, a string to be tested
* @return boolean, true indicating it belongs to
*/
public static boolean belongstoN(String s) {
String[] a = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
return eachCharIn(s, a);
}
/**
* Test if matching the N type of character (0-9) at least one time and at
* most max times.
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param
* - String, the string to be tested
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToN(String tag, int max) {
return belongsToN(tag, 1, max);
}
/**
* Test if matching the N type of character (0-9) at least min times and at
* most max times.
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param s
* - String, the string to be tested
* @param min
* - int, at least min times
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToN(String s, int min, int max) {
String restrictOccur = buildRegexQuantifier(min, max);
return (!StringUtil.isEmpty(s) && s.matches("[0-9]" + restrictOccur));
}
/**
* Test if matching the X type of character (A-Z a-z 0-9 / - ? : ( ) . , ' +
* SPACE CrLf) at least one time and at most max times.
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param s
* - String, the string to be tested
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToX(String s, int max) {
return belongsToX(s, 1, max);
}
/**
* Test if matching the x type of character (A-Z a-z 0-9 / - ? : ( ) . , ' +
* SPACE CrLf) at least min times and at most max times.
*
* <pre>
* 4!a ==> belongsToA(s, 0, 4)
* 3!c ==> belongsToC(s, 0, 3)
* 16x ==> belongsToX(s, 16) or belongsToX(s, 1, 16)
* 15d ==> belongsToD(s, 15) or belongsToD(s, 1, 15)
* 15n ==> belongsToN(s, 15) or belongsToN(s, 1, 15)
* </pre>
* @param s
* - String, the string to be tested
* @param min
* - int, at least min times
* @param max
* - int, at most max times
* @return boolean, true indicating it matches
*/
public static boolean belongsToX(String s, int min, int max) {
String restrictOccur = buildRegexQuantifier(min, max);
//sample: 35x
String regexp = "^" + "[[A-Za-z0-9](/|\\-|\\?|:|(|)|\'|,|.|\\+|\" \")]" + restrictOccur + "$";
return (!StringUtil.isEmpty(s) && s.matches(regexp));
}
/**
* To build regular expression quantifier. The rule as follow:
*
* <pre>
* [0,0] or [2,0] or [2,-1] ==> +
* [0,3] ==> {3}
* [1,3] ==> {1,3}
* </pre>
* @param min
* - int, at least min times
* @param max
* - int, at most max times
* @return String
*/
private static String buildRegexQuantifier(int min, int max) {
String restrictOccur = "";
if (max <= 0) {
restrictOccur = "+";
} else if (min == 0) {
restrictOccur = "{" + max + "}";
} else {
restrictOccur = "{" + min + "," + max + "}";
}
return restrictOccur;
}
/**
* To check if each character in parameter <code>s</code> belongs to
* specified character collection.
* @param s
* - String, a string
* @param legalCharacters
* - String[], specified character collection
* @return boolean, true indicating they belongs to
*/
private static boolean eachCharIn(String s, final String[] legalCharacters) {
if (StringUtil.isEmpty(s)) {
return false;
}
boolean flag = false;
for (int i = 0; i < s.length(); ++i) {
flag = false;
String tmp = s.substring(i, i + 1);
int len = legalCharacters.length;
for (int j = 0; j < len; ++j) {
if (tmp.equals(legalCharacters[j])) {
flag = true;
break;
}
}
if (!flag) {
break;
}
}
return flag;
}
/**
* To check if bic is correct SWIFT BIC (SWIFT code or BIC) with format
* "4!a2!a2!c[3!c]".
* @param bic
* - String, the string to be tested
* @return boolean, true indicating it is correct BIC
*/
public static boolean isBIC(String bic) {
if (StringUtil.isEmpty(bic)) {
return false;
}
boolean flag = true;
if (bic.length() != 8 && bic.length() != 11) {
flag = false;
} else {
String e = bic.substring(0, 4);//bank code
String s2 = bic.substring(4, 6);//country code
String s3 = bic.substring(6, 8);//location code
flag = belongsToA(e, 0, 4) && belongsToA(s2, 0, 2) && belongsToC(s3, 0, 2);
if (flag) {
String s4 = "";
if (bic.length() != 8) {
s4 = bic.substring(8);//branch code
flag = belongsToC(s4, 0, 3);
}
}
}
return flag;
}
/**
* To check if the date is pattern "YYMMDD"
* @param dateString
* - String, date string
* @return boolean, true indicating the date has correct format
*/
public static boolean isDateYYMMDD(String dateString) {
boolean flag = true;
dateString = dateString.trim();
try {
if (dateString.length() != 6) {
return false;
}
String e = dateString.substring(0, 2);
String smm = dateString.substring(2, 4);
String sdd = dateString.substring(4);
int yy = Integer.parseInt(e);
int mm = Integer.parseInt(smm);
int dd = Integer.parseInt(sdd);
if (yy < 80 && yy > 60) {
flag = false;
}
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
String yyyy = "";
if (yy >= 0 && yy <= 60) {
yyyy = "20" + e;
} else {
yyyy = "19" + e;
}
Date tmpdate = sdf.parse(dd + "." + mm + "." + yyyy);
String s = sdf.format(tmpdate);
int tdd = Integer.parseInt(s.substring(0, 2));
int tmm = Integer.parseInt(s.substring(3, 5));
int tyy = Integer.parseInt(s.substring(8));
if (yy != tyy || mm != tmm || dd != tdd) {
flag = false;
}
} catch (Exception var15) {
flag = false;
}
return flag;
}
/**
* To check if the date is pattern "YYYYMMDD"
* @param
* - String, date string
* @return boolean, true indicating the date has correct format
*/
public static boolean isDateYYYYMMDD(String dateString) {
boolean result = true;
if (belongsToN(dateString, 8, 8)) {
try {
SimpleDateFormat e = new SimpleDateFormat("yyyyMMdd");
e.setLenient(false);
e.parse(dateString);
} catch (Exception e) {
result = false;
}
} else {
result = false;
}
return result;
}
/**
* To test if the amount is valid
* @param amount
* - String, amount text
* @param fractionalDigits
* - Integer
* @return boolean, true indicating amount is valid
*/
public static boolean isAmountValid(String amount, Integer fractionalDigits) {
if (!amount.matches("^\\d*.*$") || !amount.matches("^[^,]*.\\d{0," + fractionalDigits + "}$")) {
return false;
}
return true;
}
/**
* whether number string is null or zero
* @param fieldValue
* - the number string
* @return true if null or zero
*/
public static boolean isNumNull(String fieldValue) {
Integer fAmount = null;
if (StringUtil.isEmpty(fieldValue))
return true;
else {
try {
fAmount = new Integer(fieldValue.trim());
if (fAmount.intValue() == 0)
return true;
} catch (Exception ex) {
return true;
}
}
return false;
}
/**
* whether amount is null or 0.0
* @param fieldValue
* - the amount
* @return true if null or 0.0
*/
public static boolean isAmountNull(String fieldValue) {
BigDecimal fAmount = BigDecimal.ZERO;
if (StringUtil.isEmpty(fieldValue))
return true;
else {
try {
fAmount = new BigDecimal(fieldValue.trim());
if (fAmount.compareTo(new BigDecimal(0.0)) == 0) {
return true;
}
} catch (Exception ex) {
return true;
}
}
return false;
}
/**
* To check the length of field value
* @param value
* - String, value of field
* @param minLength
* - int, required minimum length
* @param maxLength
* - int, required maximum length
* @return boolean, true indicating it is valid
*/
public static boolean checkLength(String value, int minLength, int maxLength) {
boolean result = true;
if (StringUtil.isEmpty(value) || value.length() < minLength || value.length() > maxLength) {
result = false;
}
return result;
}
/**
* To check the number of line
* @param rowNum
* - int, number of actual lines
* @param min
* - int, the required minimum number of lines
* @param max
* - int, the required maximum number of lines
* @return boolean, true indicating the number of line is valid
*/
public static boolean checkRowCount(int rowNum, int min, int max) {
boolean result = true;
if ((min > 0 && rowNum < min) || (rowNum > max)) {
result = false;
}
return result;
}
}
package com.brilliance.swift.vo;
import com.brilliance.swift.vo.common.MessagePriority;
import java.util.Date;
public class SwiftDto {
protected String messageType;
protected String senderBic;
protected String receiverBic;
protected Date createDate;
protected MessagePriority messagePriority;
protected String messageId;
protected String uetr;
public String getMessageType() {
return messageType;
}
public void setMessageType(String messageType) {
this.messageType = messageType;
}
public String getSenderBic() {
return senderBic;
}
public void setSenderBic(String senderBic) {
this.senderBic = senderBic;
}
public String getReceiverBic() {
return receiverBic;
}
public void setReceiverBic(String receiverBic) {
this.receiverBic = receiverBic;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public MessagePriority getMessagePriority() {
return messagePriority;
}
public void setMessagePriority(MessagePriority messagePriority) {
this.messagePriority = messagePriority;
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public String getUetr() {
return uetr;
}
public void setUetr(String uetr) {
this.uetr = uetr;
}
}
package com.brilliance.swift.vo;
import com.brilliance.swift.vo.common.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Mapping pacs.008.001.xx
*/
public class VoCustomerCreditTransfer extends SwiftDto {
protected Date debitDate;
protected Date creditDate;
protected Date clsDate;
protected String bussinessCode;
protected List<InstructionCode> instructionCodes;
protected String txnTypeCode;
protected Date settledDate;
protected CcyFormatAmount settledCcyFormatAmount;
protected CcyFormatAmount InstructedCcyFormatAmount;
protected BigDecimal exchangeRate;
protected List<PartyDto> partyDtos;
protected List<String> remittanceInfos;
protected ChargeForEnum chargeFor;
protected CcyFormatAmount chargeCcyFormatAmount;
protected List<SenderToReceiverInformation> senderToReceiverInformations;
protected List<String> regulatoryReportings;
public Date getDebitDate() {
return debitDate;
}
public void setDebitDate(Date debitDate) {
this.debitDate = debitDate;
}
public Date getCreditDate() {
return creditDate;
}
public void setCreditDate(Date creditDate) {
this.creditDate = creditDate;
}
public Date getClsDate() {
return clsDate;
}
public void setClsDate(Date clsDate) {
this.clsDate = clsDate;
}
public String getBussinessCode() {
return bussinessCode;
}
public void setBussinessCode(String bussinessCode) {
this.bussinessCode = bussinessCode;
}
public String getTxnTypeCode() {
return txnTypeCode;
}
public void setTxnTypeCode(String txnTypeCode) {
this.txnTypeCode = txnTypeCode;
}
public Date getSettledDate() {
return settledDate;
}
public void setSettledDate(Date settledDate) {
this.settledDate = settledDate;
}
public CcyFormatAmount getSettledCcyFormatAmount() {
return settledCcyFormatAmount;
}
public void setSettledCcyFormatAmount(CcyFormatAmount settledCcyFormatAmount) {
this.settledCcyFormatAmount = settledCcyFormatAmount;
}
public CcyFormatAmount getInstructedCcyFormatAmount() {
return InstructedCcyFormatAmount;
}
public void setInstructedCcyFormatAmount(CcyFormatAmount instructedCcyFormatAmount) {
InstructedCcyFormatAmount = instructedCcyFormatAmount;
}
public BigDecimal getExchangeRate() {
return exchangeRate;
}
public void setExchangeRate(BigDecimal exchangeRate) {
this.exchangeRate = exchangeRate;
}
public ChargeForEnum getChargeFor() {
return chargeFor;
}
public void setChargeFor(ChargeForEnum chargeFor) {
this.chargeFor = chargeFor;
}
public CcyFormatAmount getChargeCcyFormatAmount() {
return chargeCcyFormatAmount;
}
public void setChargeCcyFormatAmount(CcyFormatAmount chargeCcyFormatAmount) {
this.chargeCcyFormatAmount = chargeCcyFormatAmount;
}
public List<InstructionCode> getInstructionCodeList() {
if (instructionCodes == null) {
instructionCodes = new ArrayList<>();
}
return this.instructionCodes;
}
public VoCustomerCreditTransfer addInstructionCode(InstructionCode instructionCode) {
getInstructionCodeList().add(instructionCode);
return this;
}
public List<PartyDto> getPartyDtoList() {
if (partyDtos == null) {
partyDtos = new ArrayList<>();
}
return this.partyDtos;
}
public VoCustomerCreditTransfer addPartyDto(PartyDto partyDto) {
getPartyDtoList().add(partyDto);
return this;
}
public List<String> getRemittanceInfoList() {
if (remittanceInfos == null) {
remittanceInfos = new ArrayList<>();
}
return this.remittanceInfos;
}
public VoCustomerCreditTransfer addRemittanceInfo(String remittanceInfo) {
getRemittanceInfoList().add(remittanceInfo);
return this;
}
public List<SenderToReceiverInformation> getSenderToReceiverInformationList() {
if (senderToReceiverInformations == null) {
senderToReceiverInformations = new ArrayList<>();
}
return this.senderToReceiverInformations;
}
public VoCustomerCreditTransfer addSenderToReceiverInformation(SenderToReceiverInformation senderToReceiverInformation) {
getSenderToReceiverInformationList().add(senderToReceiverInformation);
return this;
}
public List<String> getRegulatoryReportingList() {
if (regulatoryReportings == null) {
regulatoryReportings = new ArrayList<>();
}
return this.regulatoryReportings;
}
public VoCustomerCreditTransfer addRegulatoryReporting(String regulatoryReporting) {
getRegulatoryReportingList().add(regulatoryReporting);
return this;
}
@Override
public String getMessageType() {
return "pacs.008.001";
}
}
package com.brilliance.swift.vo.common;
import java.math.BigDecimal;
public class CcyFormatAmount{
private String ccy;
private BigDecimal amt = BigDecimal.ZERO;
public String getCcy() {
return ccy;
}
public void setCcy(String ccy) {
this.ccy = ccy;
}
public BigDecimal getAmt() {
return amt;
}
public void setAmt(BigDecimal amt) {
this.amt = amt;
}
}
package com.brilliance.swift.vo.common;
public enum ChargeForEnum {
/**
* All transaction charges are to be borne by the debtor.
*
*/
DEBT("OUR"),
/**
* All transaction charges are to be borne by the creditor.
*
*/
CRED("BEN"),
/**
* In a credit transfer context, means that transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor. In a direct debit context, means that transaction charges on the sender side are to be borne by the creditor, transaction charges on the receiver side are to be borne by the debtor.
*
*/
SHAR("SHA"),
/**
* Charges are to be applied following the rules agreed in the service level and/or scheme.
*
*/
SLEV("SLEV");
ChargeForEnum(String s) {
this.desc = s;
}
public String value() {
return name();
}
String desc;
public String desc() {
return desc;
}
}
package com.brilliance.swift.vo.common;
public class InstructionCode{
private String code;
private String additionalInformation;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getAdditionalInformation() {
return additionalInformation;
}
public void setAdditionalInformation(String additionalInformation) {
this.additionalInformation = additionalInformation;
}
}
package com.brilliance.swift.vo.common;
public enum MessagePriority {
/**
* Priority level is high.
*
*/
HIGH,
/**
* Priority level is normal.
*
*/
NORM;
public String value() {
return name();
}
public static MessagePriority fromValue(String v) {
return valueOf(v);
}
}
package com.brilliance.swift.vo.common;
import java.util.ArrayList;
import java.util.List;
public class PartyDto {
private PartyTypeEnum partyType;
private String partyBic;
private String partyName;
private String partyAcct;
/**
* pattern: [A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}
* International Bank Account Number (IBAN)
* - identifier used internationally by financial institutions to uniquely identify the
* account of a customer. Further specifications of the format and content of the
* IBAN can be found in the standard ISO 13616 "Banking and related financial services
* - International Bank Account Number (IBAN)" version 1997-10-01, or later revisions.
*/
private String partyIBANAcct;
private String partyId;
private String partyIdType;
private List<String> addressList;
public PartyDto(PartyTypeEnum partyType) {
this.partyType = partyType;
}
public PartyTypeEnum getPartyType() {
return partyType;
}
public void setPartyType(PartyTypeEnum partyType) {
this.partyType = partyType;
}
public String getPartyBic() {
return partyBic;
}
public void setPartyBic(String partyBic) {
this.partyBic = partyBic;
}
public String getPartyName() {
return partyName;
}
public void setPartyName(String partyName) {
this.partyName = partyName;
}
public String getPartyAcct() {
return partyAcct;
}
public void setPartyAcct(String partyAcct) {
this.partyAcct = partyAcct;
}
public String getPartyId() {
return partyId;
}
public void setPartyId(String partyId) {
this.partyId = partyId;
}
public String getPartyIdType() {
return partyIdType;
}
public void setPartyIdType(String partyIdType) {
this.partyIdType = partyIdType;
}
public List<String> getAddressList() {
if (addressList == null) {
addressList = new ArrayList<>();
}
return this.addressList;
}
public PartyDto addAddress(String address) {
getAddressList().add(address);
return this;
}
public String getPartyIBANAcct() {
return partyIBANAcct;
}
public void setPartyIBANAcct(String partyIBANAcct) {
this.partyIBANAcct = partyIBANAcct;
}
@Override
public String toString() {
return "PartyDto{" +
"partyType=" + partyType +
", partyBic='" + partyBic + '\'' +
", partyName='" + partyName + '\'' +
", partyAcct='" + partyAcct + '\'' +
", partyIBANAcct='" + partyIBANAcct + '\'' +
", partyId='" + partyId + '\'' +
", partyIdType='" + partyIdType + '\'' +
", addressList=" + addressList +
'}';
}
}
package com.brilliance.swift.vo.common;
public enum PartyTypeEnum {
OC("Ordering Customer"),
OI("Ordering Institution"),
SC("Sender’s Correspondent"),
RC("Receiver’s Correspondent"),
RI("Third Reimbursement Institution"),
II("Intermediary Institution"),
AI("Account With Institution"),
BC("Beneficiary Customer");
PartyTypeEnum(String s) {}
public String value() {
return name();
}
}
package com.brilliance.swift.vo.common;
public class SenderToReceiverInformation {
private SenderToReceiverInformationType type;
private String InstructionInformation;
public SenderToReceiverInformationType getType() {
return type;
}
public void setType(SenderToReceiverInformationType type) {
this.type = type;
}
public String getInstructionInformation() {
return InstructionInformation;
}
public void setInstructionInformation(String instructionInformation) {
InstructionInformation = instructionInformation;
}
}
package com.brilliance.swift.vo.common;
public enum SenderToReceiverInformationType {
PIA("Previous Instructing Agent"),
IFCA("Instruction For Creditor Agent"),
IFNA("Instruction For Next Agent");
SenderToReceiverInformationType(String s) {
this.desc = s;
}
public String value() {
return name();
}
String desc;
public String desc() {
return desc;
}
}
{1:F01FOOBARC0AXXX2866874081}{2:O1031010200908BANKANC0AXXX62454427571727220418N}{3:{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4:
{1:F01FOOBARC0AXXX0146815888}{2:O1031010200908BANKANC0AXXX12032828262204210951N}{3:{121:8a562c67-ca16-48ba-b074-65581be6f001}}{4:
:20:TBEXO12345
:13C:/SNDTIME/2124+0800
:13C:/RNCTIME/2330+0800
:13C:/CLSTIME/2221+0800
:13C:/SNDTIME/2124+0700
:13C:/RNCTIME/2330+0700
:13C:/CLSTIME/2221+0700
:23B:CRED
:23E:SDVA
:23E:BNKK
......@@ -19,7 +19,7 @@ GCYXXXXXX12
:55A:FOOBARC4
:56A:FOOBARC6
:57A:BANKANC7
:59://CH00013500510020179998
:59:/00013500510020179998
TEST CORP
Nellis ABC, NV
:70:gechengyang
......@@ -27,7 +27,8 @@ Nellis ABC, NV
:71G:USD12,43
:72:/INS/FOOBARC7
/ACC/789556
:77B:/WUBEISHENGWUHANSHI
:77B:/ORDERRES/BE//MEILAAN 1, 9000 GENT
//JIANGXIAQU
//WENHUADADAO
-}
\ No newline at end of file
-}
......@@ -15,7 +15,7 @@
</FinInstnId>
</FIId>
</To>
<BizMsgIdr>pacs8bizmsgidr02</BizMsgIdr>
<BizMsgIdr>TBEXO12345</BizMsgIdr>
<MsgDefIdr>pacs.008.001.09</MsgDefIdr>
<BizSvc>swift.cbprplus.02</BizSvc>
<CreDt>2020-09-08T10:10:47+08:00</CreDt>
......@@ -158,17 +158,17 @@
</Doc:PrvsInstgAgt1>
<Doc:RgltryRptg>
<Doc:Dtls>
<Doc:Inf>WUBEISHENGWUHANSHI</Doc:Inf>
<Doc:Inf>/ORDERRES/BE//MEILAAN 1, 9000 GENT</Doc:Inf>
</Doc:Dtls>
</Doc:RgltryRptg>
<Doc:RgltryRptg>
<Doc:Dtls>
<Doc:Inf>JIANGXIAQU</Doc:Inf>
<Doc:Inf>//JIANGXIAQU</Doc:Inf>
</Doc:Dtls>
</Doc:RgltryRptg>
<Doc:RgltryRptg>
<Doc:Dtls>
<Doc:Inf>WENHUADADAO</Doc:Inf>
<Doc:Inf>//WENHUADADAO</Doc:Inf>
</Doc:Dtls>
</Doc:RgltryRptg>
</Doc:CdtTrfTxInf>
......
package com.brilliance.mt2mx.camt053001;
import com.prowidesoftware.swift.model.mt1xx.MT103;
import java.io.File;
public class TestCamt053001 {
public static void main(String[] args) {
try {
MT103 mt103 = MT103.parse(new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT103.txt"));
System.out.println(mt103.getField32A().getAmount());
//System.out.println(mt103.message());
} catch (Exception e) {
}
}
}
package com.brilliance.mt2mx.pacs008001;
import com.brilliance.swift.mt2mx.Mt2MxCreateManager;
import org.apache.commons.io.FileUtils;
import java.io.File;
public class TestPacs008001 {
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftTxt\\MT103.txt");
String mtStr = FileUtils.readFileToString(file);
String xmlStr = new Mt2MxCreateManager().mt2mx(file, "d:/test/pacs008.xml", null);
System.out.println(xmlStr);
}
}
......@@ -33,7 +33,6 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
......@@ -1543,7 +1542,7 @@ public class SwiftMessage implements Serializable, JsonSerializable {
log.warning("Cannot determine the message type from application header (block 2)");
} else {
final StringBuilder className = new StringBuilder();
className.append("com.prowidesoftware.swift.model.mt.mt");
className.append("com.prowidesoftware.swift.model.mt");
className.append(type.charAt(0));
className.append("xx.MT");
className.append(type);
......
......@@ -904,6 +904,17 @@ public class MT103 extends AbstractMT implements Serializable {
return null;
}
}
public List<Field70> getField70List() {
final List<Field70> result = new ArrayList<>();
final Tag[] tags = tags("70");
if (tags != null && tags.length > 0) {
for (Tag tag : tags) {
result.add(new Field70(tag.getValue()));
}
}
return result;
}
/**
* Iterates through block4 fields and return the first one whose name matches 71A,
......
......@@ -295,12 +295,14 @@ public abstract class AbstractMX extends AbstractMessage implements JsonSerializ
if (includeXMLDeclaration) {
xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
}
final String header = header("h", false);
//final String header = header("h", false);
final String header = header(null, false);
if (header != null) {
xml.append("<" + root + ">\n");
xml.append(header + "\n");
}
xml.append(document("Doc", false) + "\n");
//xml.append(document("Doc", false) + "\n");
xml.append(document(null, false) + "\n");
if (header != null) {
xml.append("</" + root + ">");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment