Search in sources :

Example 11 with DbSmsRoutingRule

use of org.mobicents.smsc.library.DbSmsRoutingRule 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);
    }
}
Also used : FastList(javolution.util.FastList) ResultSet(com.datastax.driver.core.ResultSet) PreparedStatement(com.datastax.driver.core.PreparedStatement) Row(com.datastax.driver.core.Row) DbSmsRoutingRule(org.mobicents.smsc.library.DbSmsRoutingRule) BoundStatement(com.datastax.driver.core.BoundStatement) XMLStreamException(javolution.xml.stream.XMLStreamException) InvalidQueryException(com.datastax.driver.core.exceptions.InvalidQueryException)

Aggregations

DbSmsRoutingRule (org.mobicents.smsc.library.DbSmsRoutingRule)11 BoundStatement (com.datastax.driver.core.BoundStatement)4 ResultSet (com.datastax.driver.core.ResultSet)4 Row (com.datastax.driver.core.Row)4 InvalidQueryException (com.datastax.driver.core.exceptions.InvalidQueryException)4 XMLStreamException (javolution.xml.stream.XMLStreamException)4 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)3 PreparedStatement (com.datastax.driver.core.PreparedStatement)2 FastList (javolution.util.FastList)2 Test (org.testng.annotations.Test)2 SmsRoutingRuleType (org.mobicents.smsc.cassandra.SmsRoutingRuleType)1