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");
}
}
}
......@@ -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
*
......
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