super.casResultListener = Optional.<CASResultListener>fromNullable(this.compositeCASResultListener);
this.batchStatement = createBatchStatement(batchType, statementWrappers);
}
private BatchStatement createBatchStatement(BatchStatement.Type batchType, List<AbstractStatementWrapper> statementWrappers) {
BatchStatement batch = new BatchStatement(batchType);
boolean tracingEnabled = false;
for (AbstractStatementWrapper statementWrapper : statementWrappers) {
statementWrapper.activateQueryTracing();
tracingEnabled |= statementWrapper.isTracingEnabled();
if (statementWrapper.casResultListener.isPresent()) {
this.compositeCASResultListener.addCASResultListener(statementWrapper.casResultListener.get());
}
if (statementWrapper instanceof NativeStatementWrapper) {
batch.add(((NativeStatementWrapper) statementWrapper).buildParameterizedStatement());
} else {
batch.add(statementWrapper.getStatement());
}
}
if (tracingEnabled) {
batch.enableTracing();
}
if (consistencyLevelO.isPresent()) {
batch.setConsistencyLevel(getCQLLevel(consistencyLevelO.get()));
}
// TODO Serial Consistency not supported for batch. Wait for C* 2.1
if (serialConsistencyLevelO.isPresent()) {
// batch.setSerialConsistencyLevel(serialConsistencyLevelO.get());
}