Commit ef14e210 by chengzhuoshen

commit init

parents
package com.prowidesoftware.brilliance.constants;
public class ERROR {
public static String ERROR_0001="ERROR_0001";
public static String ERROR_0001_DESC="xml转Obj失败,请联系技术人员!";
public static String ERROR_0002="ERROR_0002";
public static String ERROR_0002_DESC="swift模板转字符串失败,请检查";
public static String ERROR_0003="ERROR_0003";
public static String ERROR_0003_DESC="swift log config error";
}
package com.prowidesoftware.brilliance.constants;
public class Mx2MtConstants {
public static final String BICSUFFIX = "AXXX";
public static final String BICMIDDLE = "A";
public static final String DRCRMARK_C = "C";
public static final String DRCRMARK_D = "D";
public static final String DRCRMARK_RC = "RC";
public static final String DRCRMARK_RD = "RD";
/**
* 回车换行
*/
public static final String NEW_LINE = "\r\n";
public static final String MT_TYPE_900 = "900";
public static final String MT_TYPE_910 = "910";
public static final String MT_TYPE_940 = "940";
public static final String MT_TYPE_950 = "950";
public static final String MT_TYPE_103 = "103";
public static final String OUT_PUT_FILE_PATH = "outPutFilePath";
public static final String MX_OBJECT = "mxObj";
public static final String MT_TYPE = "mtType";
}
package com.prowidesoftware.brilliance.exception;
public class CommonRuntimeException extends RuntimeException {
static {
CommonRuntimeException.class.getName();
}
public CommonRuntimeException(String msg) {
super(msg);
}
public CommonRuntimeException(String msg, Throwable cause) {
super(msg, cause);
}
public String getMessage() {
return buildMessage(super.getMessage(), getCause());
}
public Throwable getRootCause() {
return getRootCause(this);
}
private String buildMessage(String message, Throwable cause) {
if (cause == null) {
return message;
}
StringBuilder sb = new StringBuilder(64);
if (message != null) {
sb.append(message).append("; ");
}
sb.append("nested exception is ").append(cause);
return sb.toString();
}
private Throwable getRootCause(Throwable original) {
if (original == null) {
return null;
}
Throwable rootCause = null;
Throwable cause = original.getCause();
while (cause != null && cause != rootCause) {
rootCause = cause;
cause = cause.getCause();
}
return rootCause;
}
}
package com.prowidesoftware.brilliance.exception;
public class IORuntimeException extends CommonRuntimeException {
public IORuntimeException(String msg) {
super(msg);
}
public IORuntimeException(String msg, Throwable cause) {
super(msg, cause);
}
}
\ No newline at end of file
package com.prowidesoftware.brilliance.exception;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/**
* 接口实例化异常
*/
public class InstantiateException extends CommonRuntimeException {
private final Class<?> beanClass;
private final Constructor<?> constructor;
private final Method constructingMethod;
public InstantiateException(Constructor<?> constructor, String msg, Throwable cause) {
super("Failed to instantiate [" + constructor.getDeclaringClass().getName() + "]: " + msg, cause);
this.beanClass = constructor.getDeclaringClass();
this.constructor = constructor;
this.constructingMethod = null;
}
public InstantiateException(String beanClass, String msg, Throwable cause) {
super("Failed to instantiate [" + beanClass + "]: " + msg, cause);
this.beanClass = null;
this.constructor = null;
this.constructingMethod = null;
}
public InstantiateException(Class<?> beanClass, String msg) {
super("Failed to instantiate [" + beanClass.getName() + "]: " + msg);
this.beanClass = beanClass;
this.constructor = null;
this.constructingMethod = null;
}
public InstantiateException(Class<?> beanClass, String msg, Throwable cause) {
super("Failed to instantiate [" + beanClass.getName() + "]: " + msg, cause);
this.beanClass = beanClass;
this.constructor = null;
this.constructingMethod = null;
}
public Class<?> getBeanClass() {
return this.beanClass;
}
public Constructor<?> getConstructor() {
return this.constructor;
}
public Method getConstructingMethod() {
return constructingMethod;
}
}
package com.prowidesoftware.brilliance.exception;
/**
* 接口通用异常类
*
* @author xiaoyuanzhen
*/
public class SwiftException
extends RuntimeException {
private String id;
private String message;
private Exception exception;
private static final long serialVersionUID = 1L;
public SwiftException(String id) {
super();
this.id = id;
}
public SwiftException(String id, String message) {
super();
this.id = id;
this.message = message;
}
public SwiftException(String id, Exception e) {
super();
this.id = id;
this.exception = e;
}
public SwiftException(String id, String message, Exception e) {
super();
this.id = id;
this.message = message;
this.exception = e;
}
public String getId() {
return id;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Throwable getCause() {
return exception;
}
public Exception getException() {
return exception;
}
}
package com.prowidesoftware.brilliance.mx2mt;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader42;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractMx2MtCreator implements Mx2MtCreator {
private static final Logger logger = LoggerFactory.getLogger(AbstractMx2MtCreator.class);
protected Map<String, Object> map = new HashMap<>();
protected AbstractMx2MtCreator withObj(Object obj) {
map.put(Mx2MtConstants.MX_OBJECT, obj);
return this;
}
protected AbstractMx2MtCreator withOutPutFilePath(String outPutFilePath) {
if (!StringUtil.isEmpty(outPutFilePath)) {
map.put(Mx2MtConstants.OUT_PUT_FILE_PATH, outPutFilePath);
}
return this;
}
protected AbstractMx2MtCreator withExtraMap(Map<String, Object> extraMap) {
if (extraMap != null && extraMap.size() > 0) {
logger.info("External Map...");
extraMap.forEach((key, value) -> {
logger.info(key + "-" + value);
map.put(key, value);
});
}
return this;
}
protected void generateCommonField(GroupHeader42 grpHdr) {
if (grpHdr != null) {
String createDateStr = DateUtil.format(grpHdr.getCreDtTm(), "YYMMdd");
String createTimeStr = DateUtil.format(grpHdr.getCreDtTm(), "HHmm");
map.put("createDate", createDateStr);
map.put("createTime", createTimeStr);
String outDateStr = DateUtil.formatNow( "YYMMdd");
String outTimeStr = DateUtil.formatNow("HHmm");
map.put("outDate", outDateStr);
map.put("outTime", outTimeStr);
}
}
public Map<String, Object> getMap() {
return map;
}
public void setMap(Map<String, Object> map) {
this.map = map;
}
}
package com.prowidesoftware.brilliance.mx2mt;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import java.util.Map;
public abstract class AbstractMx2MtFieldsGenerate implements Mx2MtFieldsGenerate {
protected Map<String, Object> map = null;
protected void withMap(Map<String, Object> targetMap) {
map = targetMap;
}
/**
* length == 8 append AXXX
* length == 11 substring(0,8)+A+substring(8)
* @param bicCode
* @return
*/
protected String processBicCode(String bicCode) {
String processedBicCode = "";
if (!StringUtil.isEmpty(bicCode)) {
if (bicCode.length() == 8) {
processedBicCode = bicCode + Mx2MtConstants.BICSUFFIX;
} else if (bicCode.length() == 11) {
processedBicCode = bicCode.substring(0, 8) + Mx2MtConstants.BICMIDDLE + bicCode.substring(8);
} else {
throw new SwiftException("ERROR", "BicCode length is invalid.");
}
}
return processedBicCode;
}
}
package com.prowidesoftware.brilliance.mx2mt;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.mt900910.Mx2Mt900910Creator;
import com.prowidesoftware.swift.model.mx.AbstractMX;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.List;
import java.util.Map;
public class Mx2MtCreateManager {
private static final Logger logger = LoggerFactory.getLogger(Mx2MtCreateManager.class);
private String msgType = "";
private Object mxObj = null;
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public Object getMxObj() {
return mxObj;
}
public void setMxObj(Object mxObj) {
this.mxObj = mxObj;
}
public void init(String xmlStr) {
AbstractMX abstractMX = AbstractMX.parse(xmlStr);
msgType = (abstractMX.getMxId().getBusinessProcess().name()
+ abstractMX.getMxId().getFunctionality()
+ abstractMX.getMxId().getVariant()
+ abstractMX.getMxId().getVersion())
.trim()
.replace(".", "");
mxObj = abstractMX;
}
public String mx2mt(File file, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
logger.info("invoke mx2mt(file) start...");
String xmlStr = FileUtils.readFileToString(file);
init(xmlStr);
logger.info("Xml Message Type = " + msgType);
logger.info("Xml Message Obj = " + mxObj);
return convert(outPutFilePath, extraMap);
}
public String mx2mt(File file, String outPutFilePath) throws Exception {
return mx2mt(file, outPutFilePath, null);
}
public String mx2mt(File file) throws Exception {
return mx2mt(file, null, null);
}
public String mx2mt(String xmlStr, String outPutFilePath, Map<String, Object> extraMap) throws Exception {
logger.info("invoke mx2mt(string) start...");
init(xmlStr);
logger.info("Xml Message Type = " + msgType);
logger.info("Xml Message Obj = " + mxObj);
return convert(outPutFilePath, extraMap);
}
public String mx2mt(String xmlStr, String outPutFilePath) throws Exception {
return mx2mt(xmlStr, outPutFilePath, null);
}
public String mx2mt(String xmlStr) throws Exception {
return mx2mt(xmlStr, null, null);
}
public String convert(String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
AbstractMx2MtCreator creator = getMx2MtCreator(msgType);
creator.withObj(mxObj).withOutPutFilePath(outPutFilePath).withExtraMap(extraMap);
List<Mx2MtFieldsGenerate> generateList = creator.getFieldsGenerateList();
for (int i=0; i<generateList.size(); i++) {
AbstractMx2MtFieldsGenerate fieldsGenerate = (AbstractMx2MtFieldsGenerate) generateList.get(i);
fieldsGenerate.withMap(creator.getMap());
fieldsGenerate.fieldsGenerate();
}
return creator.generateMtMsg();
}
public AbstractMx2MtCreator getMx2MtCreator(String msgType) throws SwiftException {
/*if ("pacs00800102".equals(msgType)) {
return new Mx2Mt103Creator();
} else if ("camt05300102".equals(msgType)) {
return new Mx2Mt950Creator();
} else*/ if ("camt05400102".equals(msgType)) {
return new Mx2Mt900910Creator();
} else {
throw new SwiftException("Invalid message type");
}
}
}
package com.prowidesoftware.brilliance.mx2mt;
import java.util.List;
public interface Mx2MtCreator {
public List<Mx2MtFieldsGenerate> getFieldsGenerateList();
public String generateMtMsg();
}
package com.prowidesoftware.brilliance.mx2mt;
import com.prowidesoftware.brilliance.exception.SwiftException;
public interface Mx2MtFieldsGenerate {
public void fieldsGenerate() throws SwiftException;
}
package com.prowidesoftware.brilliance.mx2mt.mt900910;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtCreator;
import com.prowidesoftware.brilliance.mx2mt.Mx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.mx2mt.mt900910.impl.*;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.brilliance.util.TemplateUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class Mx2Mt900910Creator extends AbstractMx2MtCreator {
private static final Logger logger = LoggerFactory.getLogger(Mx2Mt900910Creator.class);
@Override
public List<Mx2MtFieldsGenerate> getFieldsGenerateList() {
List<Mx2MtFieldsGenerate> fieldsGenerateList = new ArrayList<>();
fieldsGenerateList.add(new ReceiverBicFieldGenerate());
fieldsGenerateList.add(new SenderBicFieldGenerate());
fieldsGenerateList.add(new Field13DGenerate());
fieldsGenerateList.add(new Field20Generate());
fieldsGenerateList.add(new Field21Generate());
fieldsGenerateList.add(new Field25aGenerate());
fieldsGenerateList.add(new Field32AGenerate());
fieldsGenerateList.add(new Field50aGenerate());
fieldsGenerateList.add(new Field52aGenerate());
fieldsGenerateList.add(new Field56aGenerate());
fieldsGenerateList.add(new Field72Generate());
return fieldsGenerateList;
}
@Override
public String generateMtMsg() {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 != null
&& mxCamt05400102.getBkToCstmrDbtCdtNtfctn() != null
&& mxCamt05400102.getBkToCstmrDbtCdtNtfctn().getGrpHdr() != null) {
generateCommonField(mxCamt05400102.getBkToCstmrDbtCdtNtfctn().getGrpHdr());
}
validate();
map.forEach((key,value)->{
logger.info(key + "-" + value);
});
String outPutFilePath = (String)map.get(Mx2MtConstants.OUT_PUT_FILE_PATH);
String msg = TemplateUtil.makeFileByTemplate("swift_mt_900_910.vm", map, outPutFilePath, "utf-8");
return msg;
}
public void validate() {
String mtType = (String)map.get(Mx2MtConstants.MT_TYPE);
if (Mx2MtConstants.MT_TYPE_910.equals(mtType)) {
String field50a = (String)map.get("field50a");
String field52a = (String)map.get("field52a");
if (StringUtil.isEmpty(field50a) && StringUtil.isEmpty(field52a)) {
throw new SwiftException("ERROR", "Either field 50a or field 52a must be present.");
}
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Field13DGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field13DGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
//no mapping
map.put("field13D", "");
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerDebitCreditNotificationV02;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader42;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <GrpHdr><MsgId>
*/
public class Field20Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field20Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field20Generate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
GroupHeader42 grpHdr = bkToCstmrDbtCdtNtfctn.getGrpHdr();
if (grpHdr != null) {
String field20 = grpHdr.getMsgId();
map.put("field20", field20);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field20 error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* <Ntfctn><Ntry><NtryDtls><TxDtls><Refs><EndToEndId>
*/
public class Field21Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field21Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field21Generate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
TransactionReferences2 refs = txDtls.getRefs();
if (refs != null) {
map.put("field21", refs.getEndToEndId());
}
}
}
}
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field21 error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* <Ntfctn><Acct><Id><IBAN>
* <Ntfctn><Acct><Id><<Othr><Id>
*/
public class Field25aGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field25aGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field25aGenerate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
CashAccount20 acct = ntfctn.getAcct();
if (acct != null) {
AccountIdentification4Choice id = acct.getId();
if (id != null) {
if (!StringUtil.isEmpty(id.getIBAN())) {
map.put("field25a", id.getIBAN());
} else {
GenericAccountIdentification1 othr = id.getOthr();
if (othr != null) {
map.put("field25a", othr.getId());
}
}
}
}
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field25a error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* <Ntfctn><Ntry><ValDt><Dt>
* <Ntfctn><Ntry><Amt Ccy="XXX">
*/
public class Field32AGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field32AGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field32AGenerate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
String dateStr = "";
if (ntry.getValDt() != null) {
dateStr = DateUtil.format(ntry.getValDt().getDt(), "YYMMdd");
}
String ccy = "";
String amtStr = "";
ActiveOrHistoricCurrencyAndAmount amt = ntry.getAmt();
if (amt != null) {
ccy = amt.getCcy();
amtStr = NumberUtil.formatAmt(amt.getValue(), ccy);
}
map.put("field32A", dateStr+ccy+amtStr);
//judge 900 or 910
if (CreditDebitCode.DBIT.equals(ntry.getCdtDbtInd())) {
map.put(Mx2MtConstants.MT_TYPE, Mx2MtConstants.MT_TYPE_900);
} else if (CreditDebitCode.CRDT.equals(ntry.getCdtDbtInd())) {
map.put(Mx2MtConstants.MT_TYPE, Mx2MtConstants.MT_TYPE_910);
}
}
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field32A error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* 50A
* <Ntfctn><Ntry><NtryDtls><TxDtls><RltdPties><Dbtr><Pty><Id><OrgId><AnyBIC>
* <Ntfctn><Ntry><NtryDtls><TxDtls><RltdPties><DbtrAcct><Id><IBAN>
* <Ntfctn><Ntry><NtryDtls><TxDtls><RltdPties><DbtrAcct><Id><Othr><Id>
*
* 50K
* <Ntfctn><Ntry><NtryDtls><TxDtls><RltdPties><Dbtr><Pty><Nm>
* <Ntfctn><Ntry><NtryDtls><TxDtls><RltdPties><Dbtr><Pty><PstlAdr><AdrLine>
*/
public class Field50aGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field50aGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
String mtType = (String)map.get("mtType");
if (!Mx2MtConstants.MT_TYPE_910.equals(mtType)) {
return;
}
logger.info("Field50aGenerate start.");
try {
TransactionParty2 rltdPties = getTransactionParty2();
if (rltdPties == null) {
logger.info("<Ntfctn><Ntry><NtryDtls><TxDtls><RltdPties> Object is null.");
return;
}
String field50aOption = "";
String field50a = "";
PartyIdentification32 dbtr = rltdPties.getDbtr();
if (dbtr != null) {
if (dbtr.getId() != null
&& dbtr.getId().getOrgId() != null
&& !StringUtil.isEmpty(dbtr.getId().getOrgId().getBICOrBEI())) {
String bicCode = dbtr.getId().getOrgId().getBICOrBEI();
field50aOption = "A";
String iban = "";
String otherId = "";
CashAccount16 dbtrAcct = rltdPties.getDbtrAcct();
if (dbtrAcct.getId() != null) {
iban = dbtrAcct.getId().getIBAN();
if (StringUtil.isEmpty(iban)) {
GenericAccountIdentification1 othr = dbtrAcct.getId().getOthr();
if (othr != null) {
otherId = othr.getId();
}
}
}
if (!StringUtil.isEmpty(iban)) {
field50a = "/"+iban + "\r\n" + bicCode;
} else if (!StringUtil.isEmpty(otherId)) {
field50a = "//CH"+otherId + "\r\n" + bicCode;
} else {
field50a = bicCode;
}
} else if (!StringUtil.isEmpty(dbtr.getNm())) {
field50aOption = "K";
field50a = "/" + dbtr.getNm();
PostalAddress6 pstlAdr = dbtr.getPstlAdr();
if (pstlAdr != null) {
List<String> adrLineList = pstlAdr.getAdrLine();
if (adrLineList.size() > 0) {
for (int i=0; i<adrLineList.size(); i++) {
if (i == 4) {
break;
}
String adrLine = adrLineList.get(i);
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
field50a += Mx2MtConstants.NEW_LINE+adrLine;
}
}
}
}
}
if (StringUtil.isNotEmpty(field50aOption) && StringUtil.isNotEmpty(field50a)) {
map.put("field50aOption", field50aOption);
map.put("field50a", field50a);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field50a error");
}
}
private TransactionParty2 getTransactionParty2() {
try {
TransactionParty2 rltdPties = null;
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return null;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
rltdPties = txDtls.getRltdPties();
}
}
}
}
return rltdPties;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field50a error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class Field52aGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field52aGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field52aGenerate start.");
try {
BranchAndFinancialInstitutionIdentification4 crDrTrAgt = getCrDrTrAgt();
if (crDrTrAgt == null) {
logger.info("<Ntfctn><Ntry><NtryDtls><TxDtls><RltdAgts><DbtrAgt>or<CdtrAgt> Object is null.");
return;
}
String field52aOption = "";
String field52a = "";
FinancialInstitutionIdentification7 finInstnId = crDrTrAgt.getFinInstnId();
if (finInstnId != null) {
String bicCode = finInstnId.getBIC();
if (StringUtil.isNotEmpty(bicCode)) {
field52aOption = "A";
String memberId = "";
ClearingSystemMemberIdentification2 clrSysMmbId = finInstnId.getClrSysMmbId();
if (clrSysMmbId != null) {
memberId = clrSysMmbId.getMmbId();
}
if (StringUtil.isNotEmpty(memberId)) {
field52a = "/" + memberId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field52a = bicCode;
}
} else if (!StringUtil.isEmpty(finInstnId.getNm())){
field52aOption = "D";
field52a = "/" + finInstnId.getNm();
PostalAddress6 pstlAdr = finInstnId.getPstlAdr();
if (pstlAdr != null) {
List<String> adrLineList = pstlAdr.getAdrLine();
if (adrLineList.size() > 0) {
for (int i=0; i<adrLineList.size(); i++) {
if (i == 4) {
break;
}
String adrLine = adrLineList.get(i);
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
if (i==0 && StringUtil.isEmpty(field52a)) {
field52a += adrLine;
} else {
field52a += Mx2MtConstants.NEW_LINE+adrLine;
}
}
}
}
}
}
if (StringUtil.isNotEmpty(field52aOption) && StringUtil.isNotEmpty(field52a)) {
map.put("field52aOption", field52aOption);
map.put("field52a", field52a);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field52a error");
}
}
private BranchAndFinancialInstitutionIdentification4 getCrDrTrAgt() {
try {
BranchAndFinancialInstitutionIdentification4 crDrTrAgt = null;
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return null;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
TransactionAgents2 rltdAgts = txDtls.getRltdAgts();
if (rltdAgts != null) {
/*String mtType = (String)map.get("mtType");
if (Mx2MtConstants.MT_TYPE_900.equals(mtType)) {
crDrTrAgt = rltdAgts.getDbtrAgt();
} else if (Mx2MtConstants.MT_TYPE_910.equals(mtType)) {
crDrTrAgt = rltdAgts.getCdtrAgt();
}*/
crDrTrAgt = rltdAgts.getDbtrAgt();
}
}
}
}
}
return crDrTrAgt;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field52a error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class Field56aGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field56aGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException {
String mtType = (String)map.get("mtType");
if (!Mx2MtConstants.MT_TYPE_910.equals(mtType)) {
return;
}
logger.info("Field56aGenerate start.");
try {
BranchAndFinancialInstitutionIdentification4 intrmyAgt1 = getIntrmyAgt1();
if (intrmyAgt1 == null) {
logger.info("<Ntfctn><Ntry><NtryDtls><TxDtls><RltdAgts><IntrmyAgt1> Object is null.");
return;
}
String field56aOption = "";
String field56a = "";
FinancialInstitutionIdentification7 finInstnId = intrmyAgt1.getFinInstnId();
if (finInstnId != null) {
String bicCode = finInstnId.getBIC();
if (StringUtil.isNotEmpty(bicCode)) {
field56aOption = "A";
String memberId = "";
ClearingSystemMemberIdentification2 clrSysMmbId = finInstnId.getClrSysMmbId();
if (clrSysMmbId != null) {
memberId = clrSysMmbId.getMmbId();
}
if (StringUtil.isNotEmpty(memberId)) {
field56a = "/" + memberId + Mx2MtConstants.NEW_LINE + bicCode;
} else {
field56a = bicCode;
}
} else if (!StringUtil.isEmpty(finInstnId.getNm())){
field56aOption = "D";
field56a = "/" + finInstnId.getNm();
PostalAddress6 pstlAdr = finInstnId.getPstlAdr();
if (pstlAdr != null) {
List<String> adrLineList = pstlAdr.getAdrLine();
if (adrLineList.size() > 0) {
for (int i=0; i<adrLineList.size(); i++) {
if (i == 4) {
break;
}
String adrLine = adrLineList.get(i);
if (adrLine.length() > 35) {
adrLine = adrLine.substring(0, 35);
}
if (i==0 && StringUtil.isEmpty(field56a)) {
field56a += adrLine;
} else {
field56a += Mx2MtConstants.NEW_LINE+adrLine;
}
}
}
}
}
}
if (StringUtil.isNotEmpty(field56aOption) && StringUtil.isNotEmpty(field56a)) {
map.put("field56aOption", field56aOption);
map.put("field56a", field56a);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field56a error");
}
}
private BranchAndFinancialInstitutionIdentification4 getIntrmyAgt1() {
try {
BranchAndFinancialInstitutionIdentification4 intrmyAgt1 = null;
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return null;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
TransactionAgents2 rltdAgts = txDtls.getRltdAgts();
if (rltdAgts != null) {
intrmyAgt1 = rltdAgts.getIntrmyAgt1();
}
}
}
}
}
return intrmyAgt1;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field56a error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class Field72Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field72Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field72Generate start.");
try {
EntryTransaction2 txDtls = getEntryTransaction2();
if (txDtls != null) {
String addtLtxnInf = txDtls.getAddtlTxInf();
if (StringUtil.isNotEmpty(addtLtxnInf)) {
logger.info(addtLtxnInf);
String field72 = StringUtil.getStringByEnter(addtLtxnInf, 35, 6);
map.put("field72", field72);
}
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field56a error");
}
}
private EntryTransaction2 getEntryTransaction2() {
try {
EntryTransaction2 txDtls = null;
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return null;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
List<ReportEntry2> ntryList = ntfctn.getNtry();
if (ntryList != null && ntryList.size() > 0) {
ReportEntry2 ntry = ntryList.get(0);
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList != null && ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList != null && txDtlsList.size() > 0) {
return txDtlsList.get(0);
}
}
}
}
return txDtls;
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 Field72 error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.AccountNotification2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerDebitCreditNotificationV02;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class ReceiverBicFieldGenerate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(ReceiverBicFieldGenerate.class);
/**
* <Stmt><Acct><Svcr><FinInstnId><BICFI>
* @throws SwiftException
*/
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("ReceiverBicFieldGenerate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
if (ntfctn != null
&& ntfctn.getAcct() != null
&& ntfctn.getAcct().getSvcr() != null
&& ntfctn.getAcct().getSvcr().getFinInstnId() != null) {
String receiverBic = ntfctn.getAcct().getSvcr().getFinInstnId().getBIC();
String mtReceiverBic = processBicCode(receiverBic);
if (!StringUtil.isEmpty(mtReceiverBic)) {
map.put("receiverBic", mtReceiverBic);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 ReceiverBic error.");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt900910.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05400102;
import com.prowidesoftware.swift.model.mx.dic.AccountNotification2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerDebitCreditNotificationV02;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class SenderBicFieldGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(SenderBicFieldGenerate.class);
/**
* <Stmt><Acct><Ownr><Id><OrgId><AnyBIC> BICOrBEI
* @throws SwiftException
*/
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("SenderBicFieldGenerate start.");
try {
MxCamt05400102 mxCamt05400102 = (MxCamt05400102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05400102 == null || mxCamt05400102.getBkToCstmrDbtCdtNtfctn() == null) {
return;
}
BankToCustomerDebitCreditNotificationV02 bkToCstmrDbtCdtNtfctn = mxCamt05400102.getBkToCstmrDbtCdtNtfctn();
List<AccountNotification2> ntfctnList = bkToCstmrDbtCdtNtfctn.getNtfctn();
if (ntfctnList != null && ntfctnList.size() > 0) {
AccountNotification2 ntfctn = ntfctnList.get(0);
if (ntfctn != null
&& ntfctn.getAcct() != null
&& ntfctn.getAcct().getOwnr() != null
&& ntfctn.getAcct().getOwnr().getId() != null
&& ntfctn.getAcct().getOwnr().getId().getOrgId() != null) {
String senderBic = ntfctn.getAcct().getOwnr().getId().getOrgId().getBICOrBEI();
String mtSenderBic = processBicCode(senderBic);
if (!StringUtil.isEmpty(mtSenderBic)) {
map.put("senderBic", mtSenderBic);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT900/910 SenderBic error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtCreator;
import com.prowidesoftware.brilliance.mx2mt.Mx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.mx2mt.mt940950.impl.*;
import com.prowidesoftware.brilliance.util.TemplateUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class Mx2Mt950Creator extends AbstractMx2MtCreator {
private static final Logger logger = LoggerFactory.getLogger(Mx2Mt950Creator.class);
/**
* Object MxCamt05300102
* receiverBic
* senderBic
* field20
* field25a
* field28c
* field60Option
* field60F
* field60A
* field61List
* field62Option
* field62F
* field62M
* field64
*/
@Override
public List<Mx2MtFieldsGenerate> getFieldsGenerateList() {
List<Mx2MtFieldsGenerate> fieldsGenerateList = new ArrayList<>();
if (getMtMsg()){
fieldsGenerateList.add(new Field21Generate());
fieldsGenerateList.add(new Field65Generate());
fieldsGenerateList.add(new Field86Generate());
}
fieldsGenerateList.add(new ReceiverBicFieldGenerate());
fieldsGenerateList.add(new SenderBicFieldGenerate());
fieldsGenerateList.add(new Field20Generate());
fieldsGenerateList.add(new Field25aGenerate());
fieldsGenerateList.add(new Field28CGenerate());
fieldsGenerateList.add(new Field60Generate());
fieldsGenerateList.add(new Field61ListGenerate());
fieldsGenerateList.add(new Field62Generate());
fieldsGenerateList.add(new Field64Generate());
return fieldsGenerateList;
}
@Override
public String generateMtMsg() {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 != null
&& mxCamt05300102.getBkToCstmrStmt() != null
&& mxCamt05300102.getBkToCstmrStmt().getGrpHdr() != null) {
generateCommonField(mxCamt05300102.getBkToCstmrStmt().getGrpHdr());
}
map.forEach((key, value) -> {
logger.info(key + "-" + value);
});
String outPutFilePath = (String) map.get(Mx2MtConstants.OUT_PUT_FILE_PATH);
String template;
if (getMtMsg())
template = "swift_mt_940.vm";
else
template = "swift_mt_950.vm";
String msg = TemplateUtil.makeFileByTemplate(template, map, outPutFilePath, "utf-8");
return msg;
}
/**
* 符合以下其中一个条件,则为940,否则为950报文
* (1)<Stmt><Ntry>[j]数组中,节点<AddtlNtryInf>有值
* (2)<Stmt><Bal>[i]数组中,节点<Tp><CdOrPrtry><Cd>值为“FWAV”
* (3)节点<Stmt><AddtlStmtInf>有值
* @return true:940, false:950
*/
public boolean getMtMsg() {
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102) map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return false;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 stmt = stmtList.get(0);
List<ReportEntry2> ntryList = stmt.getNtry();
if (ntryList.size() > 0 && StringUtils.isNotEmpty(ntryList.get(0).getAddtlNtryInf()))
return true;
List<CashBalance3> balList = stmt.getBal();
if (balList != null && balList.size() > 0) {
for (CashBalance3 tmpBal : balList) {
if (tmpBal != null
&& tmpBal.getTp() != null
&& tmpBal.getTp().getCdOrPrtry() != null
&& BalanceType12Code.FWAV.equals(tmpBal.getTp().getCdOrPrtry().getCd())) {
return true;
}
}
}
if (StringUtils.isNotEmpty(stmt.getAddtlStmtInf()))
return true;
return false;
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Mx2Mt950Creator.getMtMsg() error");
}
return false;
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader42;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <GrpHdr><MsgId>
*/
public class Field20Generate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(Field20Generate.class);
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field20Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
GroupHeader42 grpHdr = bkToCstmrStmt.getGrpHdr();
map.put("field20", grpHdr.getMsgId());
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field20 error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
/**
* N/A
*/
public class Field21Generate extends AbstractMx2MtFieldsGenerate {
@Override
public void fieldsGenerate() throws SwiftException {
map.put("field21", "");
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.AccountIdentification4Choice;
import com.prowidesoftware.swift.model.mx.dic.AccountStatement2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02;
import com.prowidesoftware.swift.model.mx.dic.GenericAccountIdentification1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* <Stmt><Acct><Id><IBAN>
* <Stmt><Acct><Id><Othr><Id>
*/
public class Field25aGenerate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(Field25aGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field25aGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 accountStatement2 = stmtList.get(0);
if (accountStatement2.getAcct() != null
&& accountStatement2.getAcct().getId() != null) {
AccountIdentification4Choice id = accountStatement2.getAcct().getId();
if (!StringUtil.isEmpty(id.getIBAN())) {
map.put("field25a", id.getIBAN());
} else {
GenericAccountIdentification1 othr = id.getOthr();
if (othr != null) {
map.put("field25a", othr.getId());
}
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field25a error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.AccountStatement2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02;
import com.prowidesoftware.swift.model.mx.dic.GroupHeader42;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.List;
/**
* <GrpHdr><MsgPgntn><PgNb>
* <Stmt><ElctrncSeqNb>
*/
public class Field28CGenerate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(Field28CGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field28CGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
BigDecimal seqNb = null;
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 accountStatement2 = stmtList.get(0);
if (accountStatement2 != null) {
seqNb = accountStatement2.getElctrncSeqNb();
}
}
String pgNb = "";
GroupHeader42 grpHdr = bkToCstmrStmt.getGrpHdr();
if (grpHdr != null && grpHdr.getMsgPgntn() != null) {
pgNb = grpHdr.getMsgPgntn().getPgNb();
}
if (seqNb == null && StringUtil.isEmpty(pgNb)) {
throw new SwiftException("ERROR", "Convert MT950 field28C is required!");
} else {
if (seqNb == null) { //only <Stmt><ElctrncSeqNb>
map.put("field28C", pgNb);
} else if (StringUtil.isEmpty(pgNb)) { //only <GrpHdr><MsgPgntn><PgNb>
map.put("field28C", seqNb.toString());
} else { //<Stmt><ElctrncSeqNb> + "/" + GrpHdr><MsgPgntn><PgNb>
map.put("field28C", seqNb.toString() + "/" + pgNb);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 field28C error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
* <Stmt><Bal>[i]<CdtDbtInd>
* <Stmt><Bal>[i]<Dt><Dt>
* <Stmt><Bal>[i]<Amt Ccy=“XXX”>
* i = 1
*/
public class Field60Generate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(Field60Generate.class);
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field60Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 stmt = stmtList.get(0);
List<CashBalance3> balList = stmt.getBal();
if (balList != null && balList.size() > 0) {
CashBalance3 bal = balList.get(0);
String filed60Option = "";
if (bal != null && bal.getTp() != null
&& bal.getTp().getCdOrPrtry() != null) {
if (BalanceType12Code.PRCD.equals(bal.getTp().getCdOrPrtry().getCd())) {
filed60Option = "F";
} else if (BalanceType12Code.ITBD.equals(bal.getTp().getCdOrPrtry().getCd())) {
filed60Option = "M";
} else {
throw new SwiftException("ERROR", "cannot find filed60Option.");
}
map.put("filed60Option", filed60Option);
}
if (bal != null) {
String crdr = "";
if (CreditDebitCode.CRDT.equals(bal.getCdtDbtInd())) {
crdr = Mx2MtConstants.DRCRMARK_C;
} else if (CreditDebitCode.DBIT.equals(bal.getCdtDbtInd())) {
crdr = Mx2MtConstants.DRCRMARK_D;
} else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
String dateStr = "";
if (bal.getDt() != null) {
dateStr = DateUtil.format(bal.getDt().getDt(), "YYMMdd");
}
String ccy = "";
String amtStr = "";
ActiveOrHistoricCurrencyAndAmount ccyAndAmt = bal.getAmt();
if (ccyAndAmt != null) {
ccy = ccyAndAmt.getCcy();
BigDecimal amt = ccyAndAmt.getValue();
amtStr = NumberUtil.formatAmt(amt, ccy);
}
map.put("filed60", crdr+dateStr+ccy+amtStr);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field60Generate error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* <Stmt><Ntry>[j]<ValDt><Dt>
* <Stmt><Ntry>[j]<BookgDt><Dt>
* <Stmt><Ntry>[j]<CdtDbtInd>
* <Stmt><Ntry>[j]<RvslInd>
* <Stmt><Ntry>[j]<Sts>
* <Stmt><Ntry>[j]<Amt Ccy=“XXX”>
* <Stmt><Ntry>[j]<BkTxCd><Prtry><Cd>
* <Stmt><Ntry>[j]<NtryDtls><TxDtls><Refs><EndToEndId>
* <Stmt><Ntry>[j]<AcctSvcrRef>
* <Stmt><Ntry>[j]<NtryDtls><TxDtls><AddtlTxInf>
*/
public class Field61ListGenerate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(Field61ListGenerate.class);
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field61ListGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 stmt = stmtList.get(0);
List<ReportEntry2> ntryList = stmt.getNtry();
if (ntryList.size() > 0) {
List<String> filed61List = new ArrayList<>();
for (int i=0; i<ntryList.size(); i++) {
ReportEntry2 ntry = ntryList.get(i);
String valueDateStr = DateUtil.format(ntry.getValDt().getDt(), "YYMMdd");
String entryDateStr = DateUtil.format(ntry.getBookgDt().getDt(), "YYMMdd");
String drCrMark = "";
if (CreditDebitCode.CRDT.equals(ntry.getCdtDbtInd())) {
if (Boolean.TRUE.equals(ntry.isRvslInd())) {
drCrMark = Mx2MtConstants.DRCRMARK_RD;
} else {
drCrMark = Mx2MtConstants.DRCRMARK_C;
}
} else if (CreditDebitCode.DBIT.equals(ntry.getCdtDbtInd())) {
if (Boolean.TRUE.equals(ntry.isRvslInd())) {
drCrMark = Mx2MtConstants.DRCRMARK_RC;
} else {
drCrMark = Mx2MtConstants.DRCRMARK_D;
}
} else {
throw new SwiftException("ERROR", "cannot find filed61 D/C Mark.");
}
String ccy = "";
String amtStr = "";
ActiveOrHistoricCurrencyAndAmount ccyAndAmt = ntry.getAmt();
if (ccyAndAmt != null) {
ccy = ccyAndAmt.getCcy();
amtStr = NumberUtil.formatAmt(ccyAndAmt.getValue(), ccy);
}
//TODO
String txnTypeAndIdentification = "";
BankTransactionCodeStructure4 bkTxCd = ntry.getBkTxCd();
if (bkTxCd != null) {
ProprietaryBankTransactionCodeStructure1 prtry = bkTxCd.getPrtry();
if (prtry != null) {
txnTypeAndIdentification = prtry.getCd();
}
}
String referenceForTheAccountOwner = "";
String supplementDetails = "";
List<EntryDetails1> ntryDtlsList = ntry.getNtryDtls();
if (ntryDtlsList.size() > 0) {
EntryDetails1 ntryDtls = ntryDtlsList.get(0);
List<EntryTransaction2> txDtlsList = ntryDtls.getTxDtls();
if (txDtlsList.size() > 0) {
EntryTransaction2 txDtls = txDtlsList.get(0);
if (txDtls.getRefs() != null) {
referenceForTheAccountOwner = txDtls.getRefs().getEndToEndId();
}
supplementDetails = txDtls.getAddtlTxInf();
}
}
String referenceForTheAccountServInst = ntry.getAcctSvcrRef();
StringBuilder sb = new StringBuilder();
sb.append(valueDateStr)
.append(entryDateStr)
.append(drCrMark)
.append(ccy)
.append(amtStr)
.append(txnTypeAndIdentification)
.append(referenceForTheAccountOwner);
if (!StringUtil.isEmpty(referenceForTheAccountServInst)) {
sb.append("//"+referenceForTheAccountServInst);
}
if (!StringUtil.isEmpty(supplementDetails)) {
sb.append(Mx2MtConstants.NEW_LINE+supplementDetails);
}
if (StringUtils.isNotEmpty(ntry.getAddtlNtryInf()))
sb.append(Mx2MtConstants.NEW_LINE).append(":86:").append(StringUtil.getStringByEnter(ntry.getAddtlNtryInf(), 35, 6));
filed61List.add(sb.toString());
}
if (filed61List.size() > 0) {
filed61List.forEach(field61 -> logger.info(":61:"+field61));
map.put("filed61List", filed61List);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field61List error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
* <Stmt><Bal>[i]<CdtDbtInd>
* <Stmt><Bal>[i]<Dt><Dt>
* <Stmt><Bal>[i]<Amt Ccy=“XXX”
* i = 2
*/
public class Field62Generate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(Field62Generate.class);
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field62Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 stmt = stmtList.get(0);
List<CashBalance3> balList = stmt.getBal();
if (balList != null && balList.size() >= 2) {
CashBalance3 bal = balList.get(1);
String filed62Option = "";
if (bal != null && bal.getTp() != null
&& bal.getTp().getCdOrPrtry() != null) {
if (BalanceType12Code.CLBD.equals(bal.getTp().getCdOrPrtry().getCd())) {
filed62Option = "F";
} else if (BalanceType12Code.ITBD.equals(bal.getTp().getCdOrPrtry().getCd())) {
filed62Option = "M";
} else {
throw new SwiftException("ERROR", "cannot find filed62Option.");
}
map.put("filed62Option", filed62Option);
}
if (bal != null) {
String crdr = "";
if (CreditDebitCode.CRDT.equals(bal.getCdtDbtInd())) {
crdr = Mx2MtConstants.DRCRMARK_C;
} else if (CreditDebitCode.DBIT.equals(bal.getCdtDbtInd())) {
crdr = Mx2MtConstants.DRCRMARK_D;
} else {
throw new SwiftException("ERROR", "cannot find filed60 D/C Mark.");
}
String dateStr = "";
if (bal.getDt() != null) {
dateStr = DateUtil.format(bal.getDt().getDt(), "YYMMdd");
}
String ccy = "";
String amtStr = "";
ActiveOrHistoricCurrencyAndAmount ccyAndAmt = bal.getAmt();
if (ccyAndAmt != null) {
ccy = ccyAndAmt.getCcy();
BigDecimal amt = ccyAndAmt.getValue();
amtStr = NumberUtil.formatAmt(amt, ccy);
}
map.put("filed62", crdr+dateStr+ccy+amtStr);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 Field62 error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
* <Stmt><Bal>[i]<CdtDbtInd>
* <Stmt><Bal>[i]<Dt><Dt>
* <Stmt><Bal>[i]<Amt Ccy=“XXX”
* LOOP BAL
* IF CLAV == <Bal><Tp><CdOrPrtry><Cd> means exist 64
*/
public class Field64Generate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(Field64Generate.class);
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field64Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 stmt = stmtList.get(0);
List<CashBalance3> balList = stmt.getBal();
CashBalance3 bal = null;
if (balList != null && balList.size() > 0) {
for (CashBalance3 tmpBal : balList) {
if (tmpBal != null
&& tmpBal.getTp() != null
&& tmpBal.getTp().getCdOrPrtry() != null
&& BalanceType12Code.CLAV.equals(tmpBal.getTp().getCdOrPrtry().getCd())) {
bal = tmpBal;
break;
}
}
}
if (bal != null) { //exist 64
String crdr = "";
if (CreditDebitCode.CRDT.equals(bal.getCdtDbtInd())) {
crdr = Mx2MtConstants.DRCRMARK_C;
} else if (CreditDebitCode.DBIT.equals(bal.getCdtDbtInd())) {
crdr = Mx2MtConstants.DRCRMARK_D;
} else {
throw new SwiftException("ERROR", "cannot find filed64 D/C Mark.");
}
String dateStr = "";
if (bal.getDt() != null) {
dateStr = DateUtil.format(bal.getDt().getDt(), "YYMMdd");
}
String ccy = "";
String amtStr = "";
ActiveOrHistoricCurrencyAndAmount ccyAndAmt = bal.getAmt();
if (ccyAndAmt != null) {
ccy = ccyAndAmt.getCcy();
BigDecimal amt = ccyAndAmt.getValue();
amtStr = NumberUtil.formatAmt(amt, ccy);
}
String filed64 = crdr+dateStr+ccy+amtStr;
map.put("filed64", filed64);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940/MT950 filed64 error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.DateUtil;
import com.prowidesoftware.brilliance.util.NumberUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.List;
/**
* <Stmt><Bal>[i]<Tp><CdOrPrtry><Cd>
* <Stmt><Bal>[i]<CdtDbtInd>
* <Stmt><Bal>[i]<Dt><Dt>
* <Stmt><Bal>[i]<Amt Ccy=“XXX”>
* LOOP BAL
* IF CLAV == <Bal><Tp><CdOrPrtry><Cd> means exist 65
*/
public class Field65Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field65Generate.class);
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("Field65Generate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 stmt = stmtList.get(0);
List<CashBalance3> balList = stmt.getBal();
CashBalance3 bal = null;
if (balList != null && balList.size() > 0) {
for (CashBalance3 tmpBal : balList) {
if (tmpBal != null
&& tmpBal.getTp() != null
&& tmpBal.getTp().getCdOrPrtry() != null
&& BalanceType12Code.FWAV.equals(tmpBal.getTp().getCdOrPrtry().getCd())) {
bal = tmpBal;
break;
}
}
}
if (bal != null) { //exist 65
String crdr = "";
if (CreditDebitCode.CRDT.equals(bal.getCdtDbtInd())) {
crdr = Mx2MtConstants.DRCRMARK_C;
} else if (CreditDebitCode.DBIT.equals(bal.getCdtDbtInd())) {
crdr = Mx2MtConstants.DRCRMARK_D;
} else {
throw new SwiftException("ERROR", "cannot find filed65 D/C Mark.");
}
String dateStr = "";
if (bal.getDt() != null) {
dateStr = DateUtil.format(bal.getDt().getDt(), "YYMMdd");
}
String ccy = "";
String amtStr = "";
ActiveOrHistoricCurrencyAndAmount ccyAndAmt = bal.getAmt();
if (ccyAndAmt != null) {
ccy = ccyAndAmt.getCcy();
BigDecimal amt = ccyAndAmt.getValue();
amtStr = NumberUtil.formatAmt(amt, ccy);
}
String filed65 = crdr+dateStr+ccy+amtStr;
map.put("field65", filed65);
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940 filed65 error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.AccountStatement2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
*<Stmt><AddtlStmtInf>
*
*/
public class Field86Generate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(Field86Generate.class);
@Override
public void fieldsGenerate() throws SwiftException {
logger.info("Field86Generate start");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102) map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 stmt = stmtList.get(0);
if (StringUtils.isNotEmpty(stmt.getAddtlStmtInf())) {
map.put("field86", StringUtil.getStringByEnter(stmt.getAddtlStmtInf(), 35, 6));
}
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT940 filed86 error");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.AccountStatement2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class ReceiverBicFieldGenerate extends AbstractMx2MtFieldsGenerate{
private static final Logger logger = LoggerFactory.getLogger(ReceiverBicFieldGenerate.class);
/**
* <Stmt><Acct><Svcr><FinInstnId><BICFI>
* @throws SwiftException
*/
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("ReceiverBicFieldGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 accountStatement2 = stmtList.get(0);
if (accountStatement2 != null
&& accountStatement2.getAcct() != null
&& accountStatement2.getAcct().getSvcr() != null
&& accountStatement2.getAcct().getSvcr().getFinInstnId() != null) {
String receiverBic = accountStatement2.getAcct().getSvcr().getFinInstnId().getBIC();
String mtReceiverBic = processBicCode(receiverBic);
if (!StringUtil.isEmpty(mtReceiverBic)) {
map.put("receiverBic", mtReceiverBic);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT950 ReceiverBic error.");
}
}
}
package com.prowidesoftware.brilliance.mx2mt.mt940950.impl;
import com.prowidesoftware.brilliance.constants.Mx2MtConstants;
import com.prowidesoftware.brilliance.exception.SwiftException;
import com.prowidesoftware.brilliance.mx2mt.AbstractMx2MtFieldsGenerate;
import com.prowidesoftware.brilliance.util.StringUtil;
import com.prowidesoftware.swift.model.mx.MxCamt05300102;
import com.prowidesoftware.swift.model.mx.dic.AccountStatement2;
import com.prowidesoftware.swift.model.mx.dic.BankToCustomerStatementV02;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class SenderBicFieldGenerate extends AbstractMx2MtFieldsGenerate {
private static final Logger logger = LoggerFactory.getLogger(SenderBicFieldGenerate.class);
/**
* <Stmt><Acct><Ownr><Id><OrgId><AnyBIC> BICOrBEI
* @throws SwiftException
*/
@Override
public void fieldsGenerate() throws SwiftException{
logger.info("SenderBicFieldGenerate start.");
try {
MxCamt05300102 mxCamt05300102 = (MxCamt05300102)map.get(Mx2MtConstants.MX_OBJECT);
if (mxCamt05300102 == null || mxCamt05300102.getBkToCstmrStmt() == null) {
return;
}
BankToCustomerStatementV02 bkToCstmrStmt = mxCamt05300102.getBkToCstmrStmt();
List<AccountStatement2> stmtList = bkToCstmrStmt.getStmt();
if (stmtList != null && stmtList.size() > 0) {
AccountStatement2 accountStatement2 = stmtList.get(0);
if (accountStatement2 != null
&& accountStatement2.getAcct() != null
&& accountStatement2.getAcct().getOwnr() != null
&& accountStatement2.getAcct().getOwnr().getId() != null
&& accountStatement2.getAcct().getOwnr().getId().getOrgId() != null) {
String senderBic = accountStatement2.getAcct().getOwnr().getId().getOrgId().getBICOrBEI();
String mtSenderBic = processBicCode(senderBic);
if (!StringUtil.isEmpty(mtSenderBic)) {
map.put("senderBic", mtSenderBic);
}
}
}
} catch(Exception e) {
logger.error(e.getMessage());
throw new SwiftException("ERROR", "Convert MT950 SenderBic error");
}
}
}
package com.prowidesoftware.brilliance.spi;
import com.prowidesoftware.brilliance.util.ClassUtil;
import com.prowidesoftware.brilliance.util.PropertyUtil;
import com.prowidesoftware.brilliance.util.ReflectionUtil;
import com.prowidesoftware.brilliance.util.StringUtil;
import org.springframework.core.OrderComparator;
import org.springframework.util.Assert;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
/**
* spi加载类
*/
public class BeSpiLoader {
public static final String SERVICES_RESOURCE_LOCATION = "META-INF/be-esb.services";
public static final String COMMA_DELIMITED = ",";
static final com.prowidesoftware.brilliance.spi.ConcurrentReferenceMap<ClassLoader, Map<String, List<String>>> cache = new ConcurrentReferenceMap<ClassLoader, Map<String, List<String>>>();
private BeSpiLoader() {
}
public static <T> List<T> loadBeServices(Class<T> serviceType, ClassLoader classLoader) {
return loadBeServices(serviceType, classLoader, null, null);
}
public static <T> List<T> loadBeServices(Class<T> serviceType, ClassLoader classLoader, Object[] args, Class[] argsTypes) {
Assert.notNull(serviceType, "'serviceType' must not be null");
ClassLoader classLoaderToUse = classLoader;
if (classLoaderToUse == null) {
classLoaderToUse = BeSpiLoader.class.getClassLoader();
}
List<String> serviceImplementationNames = loadServiceNames(serviceType, classLoaderToUse);
List<T> result = new ArrayList<>(serviceImplementationNames.size());
for (String serviceImplementationName : serviceImplementationNames) {
result.add(instantiateService(serviceImplementationName, serviceType, classLoaderToUse, args, argsTypes));
}
OrderComparator.sort(result);
return result;
}
public static List<String> loadServiceNames(Class<?> serviceType, ClassLoader classLoader) {
ClassLoader classLoaderToUse = classLoader;
if (classLoaderToUse == null) {
classLoaderToUse = BeSpiLoader.class.getClassLoader();
}
String serviceTypeName = serviceType.getName();
return loadBeServices(classLoaderToUse).getOrDefault(serviceTypeName, Collections.emptyList());
}
private static Map<String, List<String>> loadBeServices(ClassLoader classLoader) {
Map<String, List<String>> result = cache.get(classLoader);
if (result != null) {
return result;
}
try {
Enumeration<URL> urls = classLoader.getResources(SERVICES_RESOURCE_LOCATION);
result = new HashMap<String, List<String>>();
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
Properties properties = PropertyUtil.loadProperties(url);
for (Map.Entry<?, ?> entry : properties.entrySet()) {
String serviceTypeName = ((String) entry.getKey()).trim();
String[] serviceImplementationNames = ((String) entry.getValue()).split(COMMA_DELIMITED);
for (String serviceImplementationName : serviceImplementationNames) {
if(StringUtil.isEmpty(serviceImplementationName)){
continue;
}
result.computeIfAbsent(serviceTypeName, key -> new ArrayList<>())
.add(serviceImplementationName.trim());
}
}
}
// 去重,并且转换为不能修改得list,按key为classLoader缓存到map
result.replaceAll((serviceType, implementations) -> implementations.stream().distinct()
.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)));
cache.put(classLoader, result);
} catch (IOException ex) {
throw new IllegalArgumentException("Unable to load services from location [" +
SERVICES_RESOURCE_LOCATION + "]", ex);
}
return result;
}
@SuppressWarnings("unchecked")
private static <T> T instantiateService(String serviceImplementationName, Class<T> serviceType,
ClassLoader classLoader, Object[] args, Class[] argsTypes) {
try {
Class<?> serviceImplementationClass = ClassUtil.forName(serviceImplementationName, classLoader);
if (!serviceType.isAssignableFrom(serviceImplementationClass)) {
throw new IllegalArgumentException(
"Class [" + serviceImplementationName + "] is not assignable to type [" + serviceType.getName() + "]");
}
if (args == null) {
return (T) ReflectionUtil.accessibleConstructor(serviceImplementationClass).newInstance();
} else {
try{
return (T) ReflectionUtil.accessibleConstructor(serviceImplementationClass, argsTypes).newInstance(args);
}catch (NoSuchMethodException e){
//尝试采用无参构造函数创建实例
return (T) ReflectionUtil.accessibleConstructor(serviceImplementationClass).newInstance();
}
}
} catch (Throwable ex) {
throw new IllegalArgumentException(
"Unable to instantiate class [" + serviceImplementationName + "] for type [" + serviceType.getName() + "]",
ex);
}
}
}
package com.prowidesoftware.brilliance.spi;
import com.prowidesoftware.brilliance.util.ObjectUtil;
import org.springframework.util.Assert;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.concurrent.ConcurrentHashMap;
/**
* 对ConcurrentHashMap的封装,目的是通过值的引用封装,从而在JVM内存吃紧时GC时会自动释放内存。对于用户操作键值对却是无感的。
* <p><b>注意:</b>引用的使用意味着不能保证放置到Map中的键值对随后可用。垃圾收集器可能会随时丢弃引用,因此可能会出现未知线程正在悄悄删除键值对。</p>
* <p>支持ReferenceType.SOFT或ReferenceType.WEAK类型引用,默认为SOFT。</p>
*/
public class ConcurrentReferenceMap<T, S> {
private static final ReferenceType DEFAULT_REFERENCE_TYPE = ReferenceType.SOFT;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private final ConcurrentHashMap<T, Reference<S>> cache;
private final ReferenceType referenceType;
/**
* 空构造ConcurrentReferenceMap。使用默认引用类型SOFT和默认缓存初始容量16
*/
public ConcurrentReferenceMap() {
this(DEFAULT_REFERENCE_TYPE, DEFAULT_INITIAL_CAPACITY);
}
/**
* 构造一个初始容量为initialCapacity的ConcurrentReferenceMap。使用默认引用类型SOFT
* @param initialCapacity 初始容量大小
*/
public ConcurrentReferenceMap(int initialCapacity) {
this(DEFAULT_REFERENCE_TYPE, initialCapacity);
}
/**
* 构造一个指定引用类型和初始容量的ConcurrentReferenceMap。
* @param referenceType 引用类型(ReferenceType.SOFT或ReferenceType.WEAK)
* @param initialCapacity
*/
public ConcurrentReferenceMap(ReferenceType referenceType, int initialCapacity) {
this.cache = new ConcurrentHashMap<>(initialCapacity);
this.referenceType = referenceType;
}
public S get(Object key) {
Assert.notNull(key, "key must not be null");
Reference<S> sReference = cache.get(key);
if (ObjectUtil.isNull(sReference)) {
return null;
}
return sReference.get();
}
public S getOrDefault(Object key, S defaultValue) {
S v;
return (v = get(key)) == null ? defaultValue : v;
}
public S put(T key, S value) {
Assert.notNull(key, "key must not be null");
Assert.notNull(value, "value must not be null");
Reference<S> oldref = null;
if (value instanceof Reference) {
oldref = cache.put(key, (Reference<S>) value);
} else {
oldref = cache.put(key, referenceType.generateReference(value));
}
return ObjectUtil.isNull(oldref) ? null : oldref.get();
}
public void clear(){
cache.clear();
}
/**
* 强制清理值为空的键值对
*/
public void clearUnreferencedEntries() {
cache.entrySet().removeIf(entry -> ObjectUtil.isNull(entry.getValue()));
}
public enum ReferenceType {
SOFT {
@Override
Reference generateReference(Object value) {
return new SoftReference(value);
}
}, WEAK {
@Override
Reference generateReference(Object value) {
return new WeakReference(value);
}
};
abstract Reference generateReference(Object value);
}
}
package com.prowidesoftware.brilliance.test;
import com.prowidesoftware.brilliance.mx2mt.Mx2MtCreateManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
public class ConvertMx2Mt {
public static Logger logger = LoggerFactory.getLogger(ConvertMx2Mt.class);
public static void main(String[] args) {
String xmlPath=args[0];
String outPath=args[1];
logger.info("xmlPath="+xmlPath);
Mx2MtCreateManager mx2MtCreateManager=new Mx2MtCreateManager();
try {
String str= mx2MtCreateManager.mx2mt(new File(xmlPath),outPath);
System.out.println(str);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.prowidesoftware.brilliance.util;
/**
* 数组工具
*/
public class ArrayUtil {
/**
* 数组是否为空
*
* @param array 对象数组
* @return 是否为空
*/
public static boolean isEmpty(Object[] array) {
return array == null || array.length == 0;
}
/**
* 数组是否为空
*
* @param array long成员数组
* @return 是否为空
*/
public static boolean isEmpty(long[] array) {
return array == null || array.length == 0;
}
/**
* 数组是否为空
*
* @param array int成员数组
* @return 是否为空
*/
public static boolean isEmpty(int[] array) {
return array == null || array.length == 0;
}
/**
* 数组是否为空
*
* @param array 数组
* @return 是否为空
*/
public static boolean isEmpty(short[] array) {
return array == null || array.length == 0;
}
/**
* 数组是否为空
*
* @param array char成员数组
* @return 是否为空
*/
public static boolean isEmpty(char[] array) {
return array == null || array.length == 0;
}
/**
* 数组是否为空
*
* @param array double成员数组
* @return 是否为空
*/
public static boolean isEmpty(double[] array) {
return array == null || array.length == 0;
}
/**
* 数组是否为空
*
* @param array float成员数组
* @return 是否为空
*/
public static boolean isEmpty(float[] array) {
return array == null || array.length == 0;
}
/**
* 数组是否为空
*
* @param array boolean成员数组
* @return 是否为空
*/
public static boolean isEmpty(boolean[] array) {
return array == null || array.length == 0;
}
/**
* 数组是否为空
*
* @param array byte成员数组
* @return 是否为空
*/
public static boolean isEmpty(byte[] array) {
return array == null || array.length == 0;
}
public static boolean contains(char[] array, char value) {
return indexOf(array, value) > -1;
}
public static int indexOf(char[] array, char value) {
if (null != array) {
for (int i = 0; i < array.length; ++i) {
if (value == array[i]) {
return i;
}
}
}
return -1;
}
/**
* 生成一个新的重新设置大小的数组<br>
* 调整大小后拷贝原数组到新数组下。扩大则占位前N个位置,其它位置补充0,缩小则截断
*
* @param bytes 原数组
* @param newSize 新的数组大小
* @return 调整后的新数组
*/
public static byte[] resize(byte[] bytes, int newSize) {
if (newSize < 0) {
return bytes;
}
final byte[] newArray = new byte[newSize];
if (newSize > 0 && !isEmpty(bytes)) {
System.arraycopy(bytes, 0, newArray, 0, Math.min(bytes.length, newSize));
}
return newArray;
}
/**
* 包装 {@link System#arraycopy(Object, int, Object, int, int)}<br>
* 数组复制,缘数组和目标数组都是从位置0开始复制
*
* @param src 源数组
* @param dest 目标数组
* @param length 拷贝数组长度
* @return 目标数组
*/
public static Object copy(Object src, Object dest, int length) {
System.arraycopy(src, 0, dest, 0, length);
return dest;
}
}
package com.prowidesoftware.brilliance.util;
import com.prowidesoftware.brilliance.exception.IORuntimeException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.Assert;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
public class FileUtil {
public static final String CLASSPATH_URL_PREFIX = "classpath:";
public static final String URL_PROTOCOL_FILE = "file";
public static URL getURL(String resourceLocation) {
Assert.notNull(resourceLocation, "Resource location must not be null");
if (resourceLocation.startsWith(CLASSPATH_URL_PREFIX)) {
String path = resourceLocation.substring(CLASSPATH_URL_PREFIX.length());
ClassLoader cl = ClassUtil.getDefaultClassLoader();
URL url = (cl != null ? cl.getResource(path) : ClassLoader.getSystemResource(path));
if (url == null) {
String description = "class path resource [" + path + "]";
throw new IllegalArgumentException(description +
" cannot be resolved to URL because it does not exist");
}
return url;
}
try {
if (isAbsolutePath(resourceLocation)) {
//如果是绝对路径直接返回
return new File(resourceLocation).toURI().toURL();
}
//重复:考虑有的没有加classpath:前缀
ClassLoader cl = ClassUtil.getDefaultClassLoader();
URL url = (cl != null ? cl.getResource(resourceLocation) : ClassLoader.getSystemResource(resourceLocation));
if (url == null) {
//视为url协议
return new URL(resourceLocation);
}
return url;
} catch (MalformedURLException ex) {
// 视为文件路径
try {
return new File(resourceLocation).toURI().toURL();
} catch (MalformedURLException ex2) {
throw new IllegalArgumentException("Resource location [" + resourceLocation +
"] is neither a URL not a well-formed file path");
}
}
}
public static File getFile(String path) {
Assert.notNull(path, "Resource path must not be null");
return getFile(getURL(path));
}
public static File getFile(String rootPath, String childPath) {
Assert.notNull(rootPath, "Resource rootPath must not be null");
Assert.notNull(childPath, "Resource childPath must not be null");
File rootFile = getFile(rootPath);
return new File(rootFile, childPath);
}
public static File getFile(URL resourceUrl) {
Assert.notNull(resourceUrl, "Resource URL must not be null");
if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) {
throw new IllegalArgumentException("url cannot be resolved to absolute file path " +
"because it does not reside in the file system: " + resourceUrl);
}
return new File(toURI(resourceUrl).getSchemeSpecificPart());
}
public static URI toURI(URL url) {
return toURI(url.toString());
}
public static URI toURI(String location) {
try {
return new URI(StringUtils.replace(location, " ", "%20"));
} catch (Exception e) {
throw new IllegalArgumentException("URI转换异常:" + e.getMessage(), e);
}
}
public static List<File> loopFiles(File file, FileFilter fileFilter) {
List<File> fileList = new ArrayList();
if (null != file && file.exists()) {
if (file.isDirectory()) {
File[] subFiles = file.listFiles();
if (!ObjectUtil.isEmpty(subFiles)) {
for (int i = 0; i < subFiles.length; ++i) {
File tmp = subFiles[i];
fileList.addAll(loopFiles(tmp, fileFilter));
}
}
} else if (null == fileFilter || fileFilter.accept(file)) {
fileList.add(file);
}
return fileList;
} else {
return fileList;
}
}
/**
* 获取文件或者目录名,如果是文件名则不带扩展名
*/
public static String getFileName(File file) {
if (null == file) {
return null;
} else {
return file.isDirectory() ? file.getName() : preName(file.getName());
}
}
public static String getSuffix(File file) {
if (null == file) {
return null;
} else {
return file.isDirectory() ? null : extName(file.getName());
}
}
public static String extName(String fileName) {
if (fileName == null) {
return null;
} else {
int index = fileName.lastIndexOf(".");
if (index == -1) {
return "";
} else {
String ext = fileName.substring(index + 1);
return StringUtil.containsAny(ext, new char[]{'/', '\\'}) ? "" : ext;
}
}
}
public static String preName(String fileName) {
if (fileName == null) {
return null;
} else {
int index = fileName.lastIndexOf(".");
if (index == -1) {
return "";
} else {
return fileName.substring(0, index);
}
}
}
public static File writeString(String content, String path) {
return writeString(content, path, Charset.defaultCharset());
}
public static File writeString(String content, String path, Charset charset) {
return writeString(content, touch(path), charset, false);
}
public static File writeString(String content, File file, Charset charset, boolean append) {
FileOutputStream out = null;
try {
out = openOutputStream(file, append);
IOUtils.write(content, out, charset);
out.close();
} catch (Exception e) {
throw new IORuntimeException("Write String to File exception",e);
} finally {
IOUtils.closeQuietly(out);
}
return file;
}
public static FileOutputStream openOutputStream(File file, boolean append) {
if (file.exists()) {
if (file.isDirectory()) {
throw new IORuntimeException("File '" + file + "' exists but is a directory");
}
if (!file.canWrite()) {
throw new IORuntimeException("File '" + file + "' cannot be written to");
}
} else {
File parent = file.getParentFile();
if (parent != null && !parent.mkdirs() && !parent.isDirectory()) {
throw new IORuntimeException("Directory '" + parent + "' could not be created");
}
}
try {
return new FileOutputStream(file, append);
} catch (FileNotFoundException e) {
throw new IORuntimeException("File Not Found Exception", e);
}
}
public static File touch(String fullFilePath) {
return fullFilePath == null ? null : touch(getFile(fullFilePath));
}
public static File touch(File file) throws IORuntimeException {
if (null == file) {
return null;
} else {
if (!file.exists()) {
mkParentDirs(file);
try {
file.createNewFile();
} catch (Exception ex) {
throw new IORuntimeException("create new file exception", ex);
}
}
return file;
}
}
public static File mkParentDirs(File file) {
File parentFile = file.getParentFile();
if (null != parentFile && !parentFile.exists()) {
parentFile.mkdirs();
}
return parentFile;
}
public static boolean isAbsolutePath(String path) {
if (StringUtil.isEmpty(path)) {
return false;
} else {
return '/' == path.charAt(0) || path.matches("^[a-zA-Z]:([/\\\\].*)?");
}
}
}
package com.prowidesoftware.brilliance.util;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.FieldPosition;
public class NumberUtil {
public static String decimalFormat(String decimal) {
return NumberUtil.decimalFormat(decimal, 2);
}
public static String decimalFormat(String decimal, int num) {
String string = "#0." + StringUtil.repeat("0", num);
DecimalFormat df = new DecimalFormat(string);
StringBuffer stringBuffer = new StringBuffer("");
df.format(Double.valueOf(decimal), stringBuffer, new FieldPosition(num));
decimal = stringBuffer.toString();
return decimal;
}
public static String decimalFormat(Object decimal, int num) {
String dec = decimal.toString();
return decimalFormat(dec, num);
}
public static String accurateDivide(String dividend, String divisor, int digits) {
BigDecimal decimal = BigDecimal.valueOf(Double.valueOf(dividend));
return decimal.divide(BigDecimal.valueOf(Double.valueOf(divisor)), digits, BigDecimal.ROUND_HALF_UP).toString();
}
public static double accurateDivide(double dividend, double divisor, int digits) {
BigDecimal decimal = BigDecimal.valueOf(dividend);
return decimal.divide(BigDecimal.valueOf(divisor), digits, BigDecimal.ROUND_HALF_UP).doubleValue();
}
public static double round(double v, int scale) {
if (scale < 0) {
throw new IllegalArgumentException("The scale must be a positive integer or zero");
}
BigDecimal b = new BigDecimal(Double.toString(v));
BigDecimal one = new BigDecimal("1");
return b.divide(one, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
public static int getMax(int[] values) {
if (values != null) {
int max = Integer.MIN_VALUE;
for (int i : values) {
max = max > i ? max : i;
}
return max;
} else {
return -1;
}
}
public static String formatAmt(String amt, int dot) {
String s = NumberUtil.decimalFormat(amt, dot);
return s.replace(".", "");
}
public static String formatAmt(BigDecimal amt, String ccy) {
if (amt == null) {
throw new RuntimeException("Source Amt cannot be null.");
}
int ccyDecimalNum = getCcyDecimalNum(ccy);
String s = NumberUtil.decimalFormat(amt.toString(), ccyDecimalNum);
String pointSuffiex = ".";
for (int i=0; i<ccyDecimalNum; i++) {
pointSuffiex +="0";
}
if (s.indexOf(pointSuffiex) > -1) { //like 1000.00 -> 1000,
return s.replace(pointSuffiex, ",");
} else {
return s.replace(".", ",");//like 1000.01 -> 1000,01
}
}
private static int getCcyDecimalNum(String ccy) {
int decimalNum = 2;
//TODO
return decimalNum;
}
}
package com.prowidesoftware.brilliance.util;
import com.prowidesoftware.brilliance.exception.SwiftException;
import org.apache.commons.io.IOUtils;
import java.io.*;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
* Properties文件工具
*
* @author xiaoyuanzhen
*
*/
public class PropertyUtil {
private static final String XML_FILE_EXTENSION = ".xml";
public static Properties loadProperties(String propertyFile) {
return loadProperties(propertyFile, null);
}
public static Properties loadProperties(String propertyFile, String encode) {
Properties props = new Properties();
try {
fillProperties(props, propertyFile, encode);
} catch (IOException e) {
throw new SwiftException("fill Properties occure exception,filePath=" + propertyFile + ",encode" + encode, e);
}
return props;
}
public static Properties loadProperties(URL url) throws IOException {
Properties props = new Properties();
try (InputStream is =url.openStream()){
if (url.getFile().endsWith(XML_FILE_EXTENSION)) {
props.loadFromXML(is);
} else {
props.load(is);
}
}
return props;
}
static void fillProperties(Properties props, String propertyFile, String encode)
throws IOException {
InputStream is = null;
Reader reader = null;
try {
URL url = FileUtil.getURL(propertyFile);
if (propertyFile.endsWith(XML_FILE_EXTENSION)) {
is = url.openStream();
props.loadFromXML(is);
} else if (encode != null) {
reader = new InputStreamReader(url.openStream(), encode);
props.load(reader);
} else {
is = url.openStream();
props.load(is);
}
} finally {
if (is != null) {
is.close();
}
if (reader != null) {
reader.close();
}
}
}
/**
* 从properties文件中获取指定属性名对应的值
*
* @param propertyFile
* @param propertyName
* @return
*/
private static Map<String, Properties> map = new HashMap<String, Properties>();
public static String getProperty(String propertyFile, String propertyName) {
String propertyValue = "";
InputStream is = null;
try {
Properties propertie = new Properties();
if (!map.containsKey(propertyFile)) {
is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(propertyFile);
propertie.load(is);
map.put(propertyFile, propertie);
}
propertyValue = map.get(propertyFile).getProperty(propertyName);
} catch (Exception e) {
e.printStackTrace();
propertyValue = "";
} finally {
try {
IOUtils.closeQuietly(is);
} catch (Exception e) {
e.printStackTrace();
}
}
return propertyValue;
}
/**
* 设置properties文件的某个属性值
*
* @param propertyFile
* @param propertyName
* @param propertyValue
* @return
*/
public synchronized static boolean setProperty(String propertyFile, String propertyName,
String propertyValue) {
boolean sav = false;
InputStream is = null;
OutputStream os = null;
try {
Properties propertie = new Properties();
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFile);
propertie.load(is);
propertie.setProperty(propertyName, propertyValue);
String path = Thread.currentThread().getContextClassLoader().getResource(propertyFile)
.getPath();
os = new FileOutputStream(new File(path));
propertie.store(os, "");
os.flush();
sav = true;
} catch (Exception e) {
e.printStackTrace();
sav = false;
} finally {
try {
is.close();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return sav;
}
public synchronized static boolean setPropertyValue(String propertyFile, String propertyName,
String propertyValue) {
boolean sav = false;
OutputStream os = null;
InputStream is = null;
try {
Properties propertie = new Properties();
is = new FileInputStream(new File(propertyFile));
propertie.load(is);
propertie.setProperty(propertyName, propertyValue);
os = new FileOutputStream(new File(propertyFile));
propertie.store(os, "");
os.flush();
sav = true;
} catch (Exception e) {
e.printStackTrace();
propertyValue = "";
} finally {
try {
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return sav;
}
private static Properties load(File f, String encoding) throws IOException {
Properties propertie = new Properties();
InputStreamReader is = new InputStreamReader(new FileInputStream(f), encoding);
propertie.load(is);
is.close();
return propertie;
}
private static Properties load(File f) throws IOException {
return load(f, "GBK");
}
public static Properties getProperties(String propertyFile)
throws IOException {
return getProperties(propertyFile,"GBK");
}
public static Properties getProperties(String propertyFile, String encoding)
throws IOException {
return load(new File(propertyFile), encoding);
}
public static String getPropertyValue(String propertyFile, String propertyName) {
String propertyValue = "";
// InputStream is = null;
try {
Properties propertie = load(new File(propertyFile));
propertyValue = propertie.getProperty(propertyName);
} catch (Exception e) {
e.printStackTrace();
propertyValue = "";
}
return propertyValue;
}
}
package com.prowidesoftware.brilliance.util;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.GregorianCalendar;
public class SwiftTransferUtil {
public static XMLGregorianCalendar getXMLGregorianCalendarNow() {
GregorianCalendar gregorianCalendar = new GregorianCalendar();
DatatypeFactory datatypeFactory = null;
try {
datatypeFactory = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
e.printStackTrace();
}
XMLGregorianCalendar now = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);
return now;
}
}
package com.prowidesoftware.brilliance.util;
import com.prowidesoftware.brilliance.constants.ERROR;
import com.prowidesoftware.brilliance.exception.SwiftException;
import org.apache.commons.io.FileUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 通过模型类将模板转成字符串
*
* **/
public class TemplateUtil {
/**
* 通过模型生成函数将模板转成字符串
* @Param String template 模板名称
* @Param cache 模板变量Map集合
* @Param outPut 文件输出保存路径
* @Param encode 文件生成编码
* @Return string 返回生成的文件字符串
* **/
public static String makeFileByTemplate(String template, Map<String, Object> cache, String outPut, String encode) {
String lastStr="";
ClassLoader classLoader = TemplateUtil.class.getClassLoader();
URL url = classLoader.getResource("template/");
if (url != null) {
VelocityEngine ve = new VelocityEngine();
try {
ve.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, url.toURI().getPath());
ve.setProperty(Velocity.OUTPUT_ENCODING, encode);
ve.setProperty(Velocity.INPUT_ENCODING, encode);
ve.init();
VelocityContext context = new VelocityContext();
Template vt = ve.getTemplate(template);
context.put("vm", cache);
StringWriter sw = new StringWriter();
vt.merge(context, sw);
lastStr=sw.toString();
if (!StringUtil.isEmpty(outPut)) {
FileUtils.write(new File(outPut),lastStr.replaceAll("\\\\\\\\", "\\$"), encode, false);
}
} catch (Exception e) {
throw new SwiftException(ERROR.ERROR_0002,ERROR.ERROR_0002_DESC);
}
} else {
}
return lastStr;
}
public static void makeFileByTemplate2(String template, Map<String, Object> cache, String outPut, String encode) throws IOException {
ClassLoader classLoader = TemplateUtil.class.getClassLoader();
URL url = classLoader.getResource("template/");
if (url != null) {
VelocityEngine ve = new VelocityEngine();
ve.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, url.getPath());
ve.setProperty(Velocity.OUTPUT_ENCODING, encode);
ve.setProperty(Velocity.INPUT_ENCODING, encode);
ve.init();
VelocityContext context = new VelocityContext();
Template vt = ve.getTemplate(template);
for (String key : cache.keySet()) {
context.put(key, cache.get(key));
}
StringWriter sw = new StringWriter();
vt.merge(context, sw);
FileUtils.write(new File(outPut), sw.toString().replaceAll("\\\\\\\\", "\\$"), encode, false);
} else {
throw new FileNotFoundException("没有在template目录下找到模板文件:" + template);
}
}
public static void main(String[] args) throws Exception {
Map map = new HashMap();
List<List> list = new ArrayList<List>();
List<String> subList = new ArrayList<String>();
subList.add("aaa");
subList.add("bbb");
list.add(subList);
subList = new ArrayList<String>();
subList.add("ccc");
subList.add("ddd");
subList.add("eee");
list.add(subList);
map.put("digestValue", "abc");
map.put("data", list);
makeFileByTemplate("singlewindow.vm", map, "d:/test.xml", "utf-8");
}
}
package com.prowidesoftware.brilliance.util;
import com.prowidesoftware.brilliance.constants.ERROR;
import com.prowidesoftware.brilliance.exception.SwiftException;
import java.net.URL;
public class UrlUtil {
public static URL getCommonURL(String relativePath) {
URL url = Thread.currentThread().getContextClassLoader().getResource(relativePath);
if (url == null) {
url = UrlUtil.class.getClassLoader().getResource(relativePath);
if (url == null) {
url = UrlUtil.class.getClassLoader().getResource("");
try {
return new URL(url + relativePath);
} catch (Exception e) {
throw new SwiftException(ERROR.ERROR_0003,ERROR.ERROR_0003_DESC);
}
}
}
return url;
}
}
/*
* Copyright 2006-2021 Prowide
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.prowidesoftware.deprecation;
import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Map;
import java.util.logging.Level;
/**
* Helper API to implement the http://www.prowidesoftware.com/resources/deprecation-policy
*
* @author sebastian
* @since 7.8.9
*/
public class DeprecationUtils {
/**
* Environment variable used to switch off deprecation phase implementation
*/
public static final String PW_DEPRECATED = "PW_DEPRECATED";
private static final transient java.util.logging.Logger log = java.util.logging.Logger.getLogger(DeprecationUtils.class.getName());
// Suppress default constructor for noninstantiability
private DeprecationUtils() {
throw new AssertionError();
}
/**
* According to the deprecation policy this method implements the phase 2 which
* involves logging a warning and making a small pause in the execution thread.
*
* @param message the log message
*/
@SuppressWarnings("rawtypes")
public static void phase2(final Class clazz, final String method, final String message) {
if (!isSet(EnvironmentVariableKey.NOLOG)) {
log.warning(notice(clazz, method) + message);
}
if (!isSet(EnvironmentVariableKey.NODELAY)) {
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.log(Level.WARNING, notice(clazz, method) + message, e);
}
}
}
@SuppressWarnings("rawtypes")
private static String notice(final Class clazz, final String method) {
StringBuilder note = new StringBuilder();
note.append("The API ").append(clazz.getSimpleName());
if (method != null) {
note.append("#").append(method);
}
note.append(" is deprecated. ");
return note.toString();
}
/**
* According to the deprecation policy this method implements the phase 3 which
* involves throwing a runtime exception.
*
* @param message the log message
*/
@SuppressWarnings("rawtypes")
public static void phase3(final Class clazz, final String method, final String message) {
if (!isSet(EnvironmentVariableKey.NOEXCEPTION)) {
throw new UnsupportedOperationException(notice(clazz, method) + message);
} else {
/*
* fall back to phase 2
*/
phase2(clazz, method, message);
}
}
/**
* Returns true if the environment variable {@link #PW_DEPRECATED} contains
* the given key in its value
*/
private static final boolean isSet(final EnvironmentVariableKey key) {
return StringUtils.containsIgnoreCase(System.getenv(PW_DEPRECATED), key.name());
}
/**
* Helper hack to set the environment variable from Java.
*
* <p>For example if all keys are passed as parameter, this will set
* the environment variable PW_DEPRECATED=nolog,nodelay,noexception
*
* @param keys the variables to set in the environment variable
*/
public static void setEnv(EnvironmentVariableKey... keys) {
if (keys != null && keys.length > 0) {
StringBuilder value = new StringBuilder();
for (EnvironmentVariableKey key : keys) {
if (value.length() > 0) {
value.append(",");
}
value.append(key.name().toLowerCase());
}
setEnv(PW_DEPRECATED, value.toString());
}
}
/**
* Sets the environment variable PW_DEPRECATED to an empty string, meaning
* all flags corresponding to the deprecation phase will be active by default.
*/
public static void clearEnv() {
setEnv(PW_DEPRECATED, "");
}
/**
* Helper hack to set environment variables from Java code
*/
@SuppressWarnings({"unchecked", "rawtypes"})
private static void setEnv(final String key, final String value) {
try {
Class<?> processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment");
Field theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment");
theEnvironmentField.setAccessible(true);
Map<String, String> env = (Map<String, String>) theEnvironmentField.get(null);
env.put(key, value);
Field theCaseInsensitiveEnvironmentField = processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment");
theCaseInsensitiveEnvironmentField.setAccessible(true);
Map<String, String> cienv = (Map<String, String>) theCaseInsensitiveEnvironmentField.get(null);
cienv.put(key, value);
} catch (NoSuchFieldException e) {
try {
Class[] classes = Collections.class.getDeclaredClasses();
Map<String, String> env = System.getenv();
for (Class cl : classes) {
if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) {
Field field = cl.getDeclaredField("m");
field.setAccessible(true);
Object obj = field.get(env);
Map<String, String> map = (Map<String, String>) obj;
map.clear();
map.put(key, value);
}
}
} catch (Exception e2) {
e2.printStackTrace();
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
/**
* Keywords for the environment variable {@link #PW_DEPRECATED}
*/
public enum EnvironmentVariableKey {
NOLOG,
NODELAY,
NOEXCEPTION
}
}
/*
* Copyright 2006-2021 Prowide
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.prowidesoftware.deprecation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Main annotation to track prowide deprecated items.
* <p>
* See <a href="http://www.prowidesoftware.com/resources/deprecation-policy">Deprecation Policy</a>
* for more details.
*
* <p>This annotation is intended for internal use of Prowide and
* source code administration. It may suffer incompatible changes
* without prior notice.
*
* @author miguel
* @since 7.8.1
*/
@Retention(RetentionPolicy.SOURCE)
@Documented
public @interface ProwideDeprecated {
String comment() default "";
/**
* Scheduled year for entering phase 2 of deprecation
*/
TargetYear phase2() default TargetYear.SRU2021;
/**
* Scheduled year for entering phase 3 of deprecation
*/
TargetYear phase3() default TargetYear.SRU2022;
/**
* Scheduled year for entering phase 4 of deprecation
*/
TargetYear phase4() default TargetYear.SRU2023;
}
/*
* Copyright 2006-2021 Prowide
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.prowidesoftware.deprecation;
/**
* Target year for which a deprecation operation is scheduled.
* Mainly used for tracking items in codebase.
*
* @author miguel
* @since 7.8.1
*/
public enum TargetYear {
SRU2021,
SRU2022,
SRU2023
}
/*
* Copyright 2006-2021 Prowide
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Classes to support Prowide deprecation policy: <a href="http://www.prowidesoftware.com/resources/deprecation-policy">Deprecation Policy</a>
*/
package com.prowidesoftware.deprecation;
\ No newline at end of file
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