Package com.scooterframework.orm.sqldataexpress.object

Examples of com.scooterframework.orm.sqldataexpress.object.TableData


    try {
      OmniDTO returnTO = getSqlService().execute(inputs,
          DataProcessorTypes.DIRECT_SQL_STATEMENT_PROCESSOR, sql);

      if (returnTO != null) {
        TableData rt = returnTO.getTableData(sql);
        if (rt != null) {
          int records = rt.getTableSize();
          if (records > 0) {
            list = new ArrayList<ActiveRecord>();
            for (int i = 0; i < records; i++) {
              ActiveRecord newRecord = (ActiveRecord) createNewInstance();
              newRecord.populateDataFromDatabase(rt.getRow(i));
              list.add(newRecord);
            }
           
            if (modelCacheClient.useCache("findAllBySQL")) {
              modelCacheClient.getCache().put(cacheKey, list);
View Full Code Here


    try {
      OmniDTO returnTO = getSqlService().execute(inputs,
          DataProcessorTypes.NAMED_SQL_STATEMENT_PROCESSOR, sqlKey);

      if (returnTO != null) {
        TableData rt = returnTO.getTableData(sqlKey);
        if (rt != null) {
          int records = rt.getTableSize();
          if (records > 0) {
            list = new ArrayList<ActiveRecord>();
            for (int i = 0; i < records; i++) {
              ActiveRecord newRecord = (ActiveRecord) createNewInstance();
              newRecord.populateDataFromDatabase(rt.getRow(i));
              list.add(newRecord);
            }
           
            if (modelCacheClient.useCache("findAllBySQLKey")) {
              modelCacheClient.getCache().put(cacheKey, list);
View Full Code Here

        cacheKey = modelCacheClient.getCacheKey("findAll", findSQL, inputs, limit, offset);
        list = (List<ActiveRecord>) modelCacheClient.getCache().get(cacheKey);
        if (list != null) return list;
      }

      TableData td = getSqlService().retrieveRows(inputs,
          DataProcessorTypes.DIRECT_SQL_STATEMENT_PROCESSOR, findSQL,
          limit, offset);

      if (td != null) {
        int records = td.getTableSize();
        if (records > 0) {
          list = new ArrayList<ActiveRecord>();
          for (int i = 0; i < records; i++) {
            ActiveRecord newRecord = (ActiveRecord) createNewInstance();
            newRecord.populateDataFromDatabase(td.getRow(i));
            list.add(newRecord);
          }
         
          if (modelCacheClient.useCache("findAll")) {
            modelCacheClient.getCache().put(cacheKey, list);
View Full Code Here

        cacheKey = modelCacheClient.getCacheKey("findAll", findSQL, inputs, limit, offset);
        list = (List<ActiveRecord>) modelCacheClient.getCache().get(cacheKey);
        if (list != null) return list;
      }

      TableData td = getSqlService().retrieveRows(inputs,
          DataProcessorTypes.DIRECT_SQL_STATEMENT_PROCESSOR, findSQL,
          limit, offset);

      if (td != null) {
        int records = td.getTableSize();
        if (records > 0) {
          list = new ArrayList<ActiveRecord>();
          for (int i = 0; i < records; i++) {
            ActiveRecord newRecord = (ActiveRecord) createNewInstance();
            newRecord.populateDataFromDatabase(td.getRow(i));
            list.add(newRecord);
          }
         
          if (modelCacheClient.useCache("findAll")) {
            modelCacheClient.getCache().put(cacheKey, list);
View Full Code Here

        cacheKey = modelCacheClient.getCacheKey("findAll", findSQL, inputs, limit, offset);
        list = (List<ActiveRecord>) modelCacheClient.getCache().get(cacheKey);
        if (list != null) return list;
      }

      TableData td = getSqlService().retrieveRows(inputs,
          DataProcessorTypes.DIRECT_SQL_STATEMENT_PROCESSOR, findSQL,
          limit, offset);

      if (td != null) {
        list = sqlHelper.organizeData(td);
View Full Code Here

public class SqlServiceClientTest extends ScooterTestHelper {
 
  @Test
  public void test_retrieveTableDataBySQL() {
    String sql = "SELECT * FROM pets ORDER BY birth_date DESC";
    TableData td = SqlServiceClient.retrieveTableDataBySQL(sql);
    assertEquals("total vets", 13, td.getTableSize());
   
    RowData rd1 = td.getFirstRow();
    assertEquals("first row pet name", "Basil", rd1.getField("name"));
  }
View Full Code Here

  @Test
  public void test_retrieveTableDataBySQL_inputs() {
    String sql = "SELECT * FROM pets WHERE name = ?name ORDER BY birth_date DESC";
    Map<String, Object> inputs = new HashMap<String, Object>();
    inputs.put("name", "Max");
    TableData td = SqlServiceClient.retrieveTableDataBySQL(sql, inputs);
    assertEquals("total vets", 1, td.getTableSize());
   
    RowData rd1 = td.getFirstRow();
    assertEquals("first row pet id", "8", rd1.getField("id").toString());
  }
View Full Code Here

  }
 
  @Test
  public void test_retrieveTableDataBySQLKey() {
    String sql = "getAllPets";
    TableData td = SqlServiceClient.retrieveTableDataBySQLKey(sql);
    assertEquals("total vets", 13, td.getTableSize());
   
    RowData rd1 = td.getFirstRow();
    assertEquals("first row pet name", "Leo", rd1.getField("name"));
  }
View Full Code Here

  @Test
  public void test_retrieveTableDataBySQLKey_inputs() {
    String sql = "getPetByName";
    Map<String, Object> inputs = new HashMap<String, Object>();
    inputs.put("name", "Max");
    TableData td = SqlServiceClient.retrieveTableDataBySQLKey(sql, inputs);
    assertEquals("total vets", 1, td.getTableSize());
   
    RowData rd1 = td.getFirstRow();
    assertEquals("first row pet id", "8", rd1.getField("id").toString());
  }
View Full Code Here

                    ResultSet rs = (ResultSet)cstmt.getObject(p.getIndex());
                   
                    Cursor cursor = sp.getCursor(p.getName(), rs);
                    int cursorWidth = cursor.getDimension();
                   
                    TableData rt = new TableData();
                    rt.setHeader(cursor);
                    returnTO.addTableData(p.getName(), rt);
                   
                    while(rs.next()) {
                        Object[] cellValues = new Object[cursorWidth];
                        for ( int i = 0; i < cursorWidth; i++ ) {
                            cellValues[i] = dba.getObjectFromResultSetByType(rs,
                                                                         cursor.getColumnJavaClassName(i),
                                                                         cursor.getColumnSqlDataType(i),
                                                                         i+1);
                        }
                        rt.addRow(new RowData(cursor, cellValues));
                    }
                    rs.close();
                }
                else {
                    returnTO.addNamedObject(p.getName(), dba.getObjectFromStatementByType(cstmt,
View Full Code Here

TOP

Related Classes of com.scooterframework.orm.sqldataexpress.object.TableData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.