Skip to content

Instantly share code, notes, and snippets.

View esaounkine's full-sized avatar

Ilya Saunkin esaounkine

View GitHub Profile
@esaounkine
esaounkine / SepaMessageProcessingService.java
Created November 5, 2013 13:49
pacs 008 001 parse and validate
FIToFICustomerCreditTransfer fiToFICustomerCreditTransfer = new FIToFICustomerCreditTransfer();
fiToFICustomerCreditTransfer.parseMessageFromXML(msgText);
List<String> validationErrors = fiToFICustomerCreditTransfer.validate();
@esaounkine
esaounkine / distance_between.sql
Created September 23, 2011 14:03
Calculate distance between two points with MySQL
CREATE FUNCTION distance_between (from_lat DECIMAL(6, 3), from_lng DECIMAL(6, 3), to_lat DECIMAL(6, 3), to_lng DECIMAL(6, 3)) RETURNS DECIMAL(11, 3)
RETURN 6371 * 2 * ATAN2(SQRT(POW(SIN(RADIANS(to_lat - from_lat)/2), 2) + POW(SIN(RADIANS(to_lng - from_lng)/2), 2) * COS(RADIANS(from_lat)) * COS(RADIANS(to_lat))), SQRT(1 - POW(SIN(RADIANS(to_lat - from_lat)/2), 2) + POW(SIN(RADIANS(to_lng - from_lng)/2), 2) * COS(RADIANS(from_lat)) * COS(RADIANS(to_lat))));
@esaounkine
esaounkine / MxMessageProcessingService.java
Created January 28, 2014 13:39
code snippet to parse XML string into a valid MX message object
public Message parseMessage(String msgText) throws Exception {
String namespace = msgText.replaceAll("(?s).*?xmlns=\"(.*?)\".*", "$1");
return CoreMessage.parseXML(msgText, namespace);
}
@esaounkine
esaounkine / SampleMessageCreation.java
Last active January 2, 2016 15:18
sample code to create SWIFT MT 205COV using the Datamation SMV (more examples at http://wiki.datamation.gr/x/OIBH)
@Test
public void testCreating205COV() {
SwiftMessage message = new SwiftMessage();
// Set Tags for block1
message.setArgApplid("F");
message.setArgServid("01");
message.setArgLTaddrBlk1("AAAABEBBAXXX");
// Set Tags for block2
@esaounkine
esaounkine / ValidateMTTest.java
Created December 9, 2013 14:54
SMV multi-error sample (more examples at http://wiki.datamation.gr/x/OIBH)
SwiftMessage message = new SwiftMsgProcessor().ParseMsgStringToObject(messageContent);
SwiftMsgValidator validator = new SwiftMsgValidator(DEFAULT_CRLF);
SwiftValidObj validation = validator.validateMsg(message);
for(ValidationError error : validation.getValidationErrorList()) {
System.out.println(error.getTagName() + " => " + error.getDescription());
}
@esaounkine
esaounkine / SepaMessageProcessingService.java
Last active December 27, 2015 11:49
pacs 008 001 auto reply with 004
//Initialize a payment return (pacs.004)
PaymentReturn paymentReturn = new PaymentReturn();
//message id is commonly auto-generated by each system
paymentReturn.set_GrpHdr_MsgId("OURMESSAGEID");
//The settlement date for our return
paymentReturn.set_GrpHdr_IntrBkSttlmDt(Calendar.getInstance());
//In most cases this is set to CLRG...
paymentReturn.set_GrpHdr_SttlmInf_SttlmMtd("CLRG");
//and Clearing system is set to ST2
paymentReturn.set_GrpHdr_SttlmInf_ClrSys_Prtry("ST2");
@esaounkine
esaounkine / SepaMessageProcessingService.java
Last active December 27, 2015 11:49
pacs 008 001 auto reply with 056
//Initialize a request for recall message (camt.056) with default values
FIToFIPaymentCancellationRequest fiToFIPaymentCancellationRequest = new FIToFIPaymentCancellationRequest(
"GENERATEDASSIGNMENTID", // the assignment id
"XXXXXBIC", // the assigner bank BIC
"YYYYYBIC" // the assignee bank BIC
);
//Construct the message reply information
//Here we are requesting a recall for a message with reason code DUPL (dulicate sending)
Vector<MsgReplyInfo> msgReplyInfo = new Vector<MsgReplyInfo>();
ReasonCode rc = new ReasonCode(ReasonCode.CD, "DUPL", null, null);
@esaounkine
esaounkine / IndexController.java
Created October 14, 2013 10:45
validate SWIFT message example
SwiftMessage parsedMessage = swiftMessageProcessingService.parseSwiftMessage(messageText);
SwiftValidObj validatedMessage = swiftMessageProcessingService.validateSwiftMessage(parsedMessage);
//validatedMessage will contain the SWIFT message object and text, as well as error message in case the message is not valid
@esaounkine
esaounkine / SwiftMessageProcessingService.java
Last active December 25, 2015 06:29
parse a text SWIFT message using the SwiftMsgProcessor
SwiftMessage parsedSwiftMsg = new SwiftMsgProcessor().ParseMsgStringToObject(msgText)
@esaounkine
esaounkine / gist:1011865
Created June 7, 2011 08:01
Offline tile layer with ArcGIS for Android - usage
map = (MapView) findViewById(R.id.map); //get the map instance
TiledLayer DAY_LAYER = new OfflineTiledLayer(this, new File(Environment.getExternalStorageDirectory(), "services"), "/RoadMapsWebMercator101010/MapServer/", "index.html", "/Day/tile/"); //create a layer
map.addLayer(DAY_LAYER); //add this layer to the map