use of com.datastax.driver.core.PreparedStatement in project smscgateway by RestComm.
the class DBOperations method c2_updateAlertingSupport.
public void c2_updateAlertingSupport(long dueSlot, String targetId, UUID dbId) throws PersistenceException {
PreparedStatementCollection psc = this.getStatementCollection(dueSlot);
try {
PreparedStatement ps = psc.updateAlertingSupport;
BoundStatement boundStatement = new BoundStatement(ps);
boundStatement.bind(true, dueSlot, targetId, dbId);
ResultSet res = session.execute(boundStatement);
} catch (Exception e1) {
String msg = "Failed to execute c2_updateAlertingSupport() !";
throw new PersistenceException(msg, e1);
}
}
use of com.datastax.driver.core.PreparedStatement in project smscgateway by RestComm.
the class DBOperations method c2_createRecordArchive.
public void c2_createRecordArchive(Sms sms, String dlvMessageId, String dlvDestId, boolean deliveryReceipts, boolean incomingDeliveryReceipts) throws PersistenceException {
if (!this.databaseAvailable)
return;
Date deliveryDate = sms.getDeliverDate();
if (deliveryDate == null)
deliveryDate = new Date();
long dueSlot = this.c2_getDueSlotForTime(deliveryDate);
PreparedStatementCollection psc = getStatementCollection(deliveryDate);
try {
// we are storing data into MESSAGES_YYYY_MM_DD table
PreparedStatement ps = psc.createRecordArchive;
BoundStatement boundStatement = new BoundStatement(ps);
setSmsFields(sms, dueSlot, boundStatement, true, psc.getShortMessageNewStringFormat(), psc.getAddedCorrId(), psc.getAddedNetworkId(), psc.getAddedOrigNetworkId(), psc.getAddedPacket1());
ResultSet res = session.execute(boundStatement);
} catch (Exception e1) {
String msg = "Failed createRecordArchive - 1 !" + e1.getMessage();
throw new PersistenceException(msg, e1);
}
if ((deliveryReceipts || incomingDeliveryReceipts) && !MessageUtil.isDeliveryReceipt(sms)) {
try {
// and created a record in MES_ID_YYYY_MM_DD table
SmsSetCache.getInstance().putDeliveredMsgValue(sms, 30);
PreparedStatement ps = psc.createRecordArchiveMesId;
BoundStatement boundStatement = new BoundStatement(ps);
boundStatement.setLong(Schema.COLUMN_MESSAGE_ID, sms.getMessageId());
boundStatement.setString(Schema.COLUMN_ADDR_DST_DIGITS, sms.getSmsSet().getDestAddr());
boundStatement.setUUID(Schema.COLUMN_ID, sms.getDbId());
ResultSet res = session.execute(boundStatement);
} catch (Exception e1) {
String msg = "Failed createRecordArchive - 2 !" + e1.getMessage();
throw new PersistenceException(msg, e1);
}
}
if (incomingDeliveryReceipts && !MessageUtil.isDeliveryReceipt(sms) && dlvMessageId != null && dlvMessageId.length() > 0 && dlvDestId != null) {
try {
// and created a record in DLV_MES_ID_YYYY_MM_DD table
SmsSetCache.getInstance().putDeliveredRemoteMsgIdValue(dlvMessageId, dlvDestId, sms.getMessageId(), 30);
PreparedStatement ps = psc.createRecordArchiveDlvMesId;
BoundStatement boundStatement = new BoundStatement(ps);
boundStatement.setString(Schema.COLUMN_REMOTE_MESSAGE_ID, dlvMessageId);
boundStatement.setString(Schema.COLUMN_DEST_ID, dlvDestId);
boundStatement.setLong(Schema.COLUMN_MESSAGE_ID, sms.getMessageId());
ResultSet res = session.execute(boundStatement);
} catch (Exception e1) {
String msg = "Failed createRecordArchive - 3 !, dlvMessageId=" + dlvMessageId + ", dlvDestId=" + dlvDestId + ", messageId=" + sms.getMessageId() + " - " + e1.getMessage();
throw new PersistenceException(msg, e1);
}
}
}
use of com.datastax.driver.core.PreparedStatement in project smscgateway by RestComm.
the class DBOperations method c2_getSmppSmsRoutingRulesRange.
/**
* Returns 100 rows of SMPP_SMS_ROUTING_RULE starting from passed lastAdress. If lastAdress, first 100 rows are returned
*
* @param lastAdress
* @return
* @throws PersistenceException
*/
public List<DbSmsRoutingRule> c2_getSmppSmsRoutingRulesRange(String lastAdress) throws PersistenceException {
List<DbSmsRoutingRule> ress = new FastList<DbSmsRoutingRule>();
try {
PreparedStatement ps = lastAdress != null ? getSmppSmsRoutingRulesRange : getSmppSmsRoutingRulesRange2;
BoundStatement boundStatement = new BoundStatement(ps);
if (lastAdress != null) {
boundStatement.bind(lastAdress);
}
ResultSet result = session.execute(boundStatement);
int i1 = 0;
for (Row row : result) {
String address = row.getString(Schema.COLUMN_ADDRESS);
String name = row.getString(Schema.COLUMN_CLUSTER_NAME);
int networkId = row.getInt(Schema.COLUMN_NETWORK_ID);
DbSmsRoutingRule res = new DbSmsRoutingRule(SmsRoutingRuleType.SMPP, address, networkId, name);
if (i1 == 0) {
i1 = 1;
if (lastAdress == null)
ress.add(res);
} else {
ress.add(res);
}
}
return ress;
} catch (Exception e) {
String msg = "Failed to getSmsRoutingRule DbSmsRoutingRule for all records: " + e;
throw new PersistenceException(msg, e);
}
}
use of com.datastax.driver.core.PreparedStatement in project smscgateway by RestComm.
the class DBOperations method c2_updateDueSlotForTargetId.
public void c2_updateDueSlotForTargetId(String targetId, long newDueSlot) throws PersistenceException {
PreparedStatementCollection psc = this.getStatementCollection(newDueSlot);
try {
PreparedStatement ps = psc.createDueSlotForTargetId;
BoundStatement boundStatement = new BoundStatement(ps);
boundStatement.bind(targetId, newDueSlot);
ResultSet res = session.execute(boundStatement);
} catch (Exception e1) {
String msg = "Failed to execute createDueSlotForTargetId() !";
throw new PersistenceException(msg, e1);
}
}
use of com.datastax.driver.core.PreparedStatement in project smscgateway by RestComm.
the class DBOperations method c2_setCurrentSlotTable.
private void c2_setCurrentSlotTable(int key, long newVal) throws PersistenceException {
try {
PreparedStatement ps = updateCurrentSlotTable;
BoundStatement boundStatement = new BoundStatement(ps);
boundStatement.bind(key, newVal);
ResultSet res = session.execute(boundStatement);
} catch (Exception e1) {
String msg = "Failed writing a c2_setCurrenrSlotTable !";
throw new PersistenceException(msg, e1);
}
}
Aggregations