Skip to content

Instantly share code, notes, and snippets.

@nickman
Created June 9, 2011 20:21
Show Gist options
  • Save nickman/1017634 to your computer and use it in GitHub Desktop.
Save nickman/1017634 to your computer and use it in GitHub Desktop.
import com.onexchange.org.*;
import groovy.xml.MarkupBuilder;
writer = new StringWriter()
fixml = new MarkupBuilder(writer);
reqIdCounter = 0;
transactionType = 3;
adjType = 2;
actn = 1;
bizDt = "2011-04-28";
txnTime = "2011-04-28T09:01:00";
party21 = "ICEU";
party22 = "IFEU";
paType = "PA";
Random random = new Random(System.nanoTime());
instructionCount = 2;
secType = "'FUTURE'";
TX.exec({
sqlECS.execute("BEGIN DELETE FROM PcsFile; DELETE FROM PcsFileInstruction; END;");
});
driverSql = "select DECODE(g.genre_type, 'FUTURE', 'FUT', 'OPTION', 'OOF') genre_type, asp.period_code, pa.pa_seg_type_code, g.commodity_code, pa.acct_nbr position_acct_nbr, pa.position_account_id, sub.acct_nbr subscriber_acct_nbr, long_open_qty long_qty, short_open_qty short_qty, asp.display_name specie, asp.specie_id, g.long_name genre " +
"from accountposition ap, positionaccount pa, settlementaccount sa, subscriber sub, actualspecie asp, genre g " +
"where ap.position_account_id = pa.position_account_id and " +
"pa.settlement_account_id = sa.settlement_account_id and " +
"sa.subscriber_id = sub.subscriber_id and " +
"ap.specie_id = asp.specie_id and " +
"asp.genre_id = g.genre_id and " +
"g.genre_type = ${secType} and " +
"ROWNUM <= ${instructionCount}";
fixml.FIXML {
sqlECS.eachRow(driverSql , { pos ->
reqIdCounter++;
PosMntReq(ReqId:reqIdCounter, TxnTyp:transactionType, AdjTyp:adjType, Actn:actn, BizDt:bizDt, TxnTm:txnTime) {
Pty(ID:party21, R:21){}
Pty(ID:party22, R:22){}
Pty(ID:pos.subscriber_acct_nbr, R:1){}
Pty(ID:pos.pa_seg_type_code, R:38){}
Instrmt(Exch:party22, SecTyp:pos.genre_type, ID:pos.commodity_code, MMY:pos.period_code){}
Qty(Typ:paType, Long:1, Short:0){}
}
});
}
pcsContent = '<?xml version="1.0" encoding="UTF-8"?>\n' + writer.toString().replace("'", "\"");
println pcsContent;
new File("c:/temp/pcs-file-submission-dir/PCS_CIN_TD_20110428_Hello_090100.xml.ready").setText(pcsContent);
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment