Commit 43ea2afb by chengzhuoshen

fix code

parent 6d855680
package com.brilliance.swift;
import com.brilliance.swift.exception.SwiftException;
import com.brilliance.swift.mt2SwiftDto.Mt2SwiftDtoCreateManager;
import com.brilliance.swift.mt2mx.Mt2MxCreatorManager;
import com.brilliance.swift.mx2map.Mx2MapCreatorManager;
import com.brilliance.swift.mx2mt.Mx2MtCreatorManager;
import com.brilliance.swift.swiftdto2mx.SwiftDto2MxCreatorManager;
import com.brilliance.swift.util.StringUtil;
import com.brilliance.swift.util.SwiftTransferUtil;
import com.brilliance.swift.util.XmlUtil;
import com.brilliance.swift.vo.SwiftDto;
import com.brilliance.swift.vo.SwiftTranslationReport;
import com.prowidesoftware.swift.model.MxId;
import com.prowidesoftware.swift.model.mx.AbstractMX;
......@@ -65,16 +63,14 @@ public class SwiftTransfer {
public static String mt2Mx(File file, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
try{
String mtStr = FileUtils.readFileToString(file);
SwiftDto swiftDto = new Mt2SwiftDtoCreateManager().convert(mtStr, outPutFilePath, extraMap);
return new SwiftDto2MxCreatorManager().swiftDto2Mx(swiftDto, outPutFilePath);
return mt2Mx(mtStr, outPutFilePath, extraMap);
} catch (IOException e) {
throw new SwiftException("ERROR", e.getMessage());
throw new SwiftException(e.getMessage());
}
}
public static String mt2Mx(String mtStr, String outPutFilePath, Map<String, Object> extraMap) throws SwiftException {
SwiftDto swiftDto = new Mt2SwiftDtoCreateManager().convert(mtStr, outPutFilePath, extraMap);
return new SwiftDto2MxCreatorManager().swiftDto2Mx(swiftDto, outPutFilePath);
return new Mt2MxCreatorManager().mt2mx(mtStr, outPutFilePath, extraMap);
}
/**
......@@ -110,6 +106,14 @@ public class SwiftTransfer {
}
public static String mx2Gson(File file) {
try{
String mtStr = FileUtils.readFileToString(file);
return mx2Gson(mtStr);
} catch (IOException e) {
throw new SwiftException(e.getMessage());
}
}
/**
* 将MX xml转换成gson 字符串
* @param xmlStr
......@@ -132,6 +136,14 @@ public class SwiftTransfer {
return new Mx2MapCreatorManager().mx2Map(xmlStr);
}
public static boolean validateMx(File file) {
try{
String mtStr = FileUtils.readFileToString(file);
return validateMx(mtStr);
} catch (IOException e) {
throw new SwiftException(e.getMessage());
}
}
/**
* 根据xml的内容获取对应的xsd文件并校验
* 失败则抛出异常
......@@ -181,11 +193,4 @@ public class SwiftTransfer {
}
return true;
}
public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05700106.xml");
String xmlStr = FileUtils.readFileToString(file);
validateMx(xmlStr);
}
}
......@@ -94,6 +94,6 @@ public class ContextImpl implements Context, Serializable {
if (null == paramMap || paramMap.isEmpty()) {
return;
}
paramMap.forEach((key, value) -> map.put(key.toString(), paramMap.get(value)));
paramMap.forEach((key, value) -> map.put(key.toString(), value));
}
}
......@@ -51,4 +51,15 @@ public class SwiftTranslationErrorInfo {
public void setOriginalValue(String originalValue) {
this.originalValue = originalValue;
}
@Override
public String toString() {
return "SwiftTranslationErrorInfo{" +
"location='" + location + '\'' +
", errorCode='" + errorCode + '\'' +
", description='" + description + '\'' +
", errorType='" + errorType + '\'' +
", originalValue='" + originalValue + '\'' +
'}';
}
}
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