Package com.bleujin.dbfs.common

Examples of com.bleujin.dbfs.common.JSONParser


    "             param:{no1:10}," + // no2 not use param
    "             page:{listnum:10, pageno:1} }}";
   
    JSONObject jo = JSONObject.fromObject(form.getQuery());
   
    QueryObj query = new JSONParser(getDBController()).parseToQueryable(jo);
    JSONObject result = query.execute() ;
   
    request.setAttribute("result", result) ;
  }
View Full Code Here


 
  public void testParseSelectCommand() throws Exception {
    String json = "{query:{type:'usercommand', ctype:'select', command:\"select * from copy_tblc where no1 < :no1\", param:{no1:10}, page:{listnum:10, pageno:2} }}";
    JSONObject jo = JSONObject.fromObject(json);

    QueryObj cmd = new JSONParser(dc).parseToQueryable(jo);
   
    // querytype
    assertEquals(QueryType.USER_COMMAND, cmd.getQueryType());
   
    // command type
View Full Code Here

 
  public void testDefaultValue2() throws Exception {
    String json = "{query:{type:'usercommand', ctype:'select', command:\"select * from copy_tblc where no1 < '10'\"}}";

    JSONObject jo = JSONObject.fromObject(json);
    QueryObj cmd = new JSONParser(dc).parseToQueryable(jo);
   
    assertEquals(dc.getLimitedRows(), cmd.getPage().getListNum()) ;
    assertEquals(1, cmd.getPage().getPageNo()) ;
   
    assertEquals(0, cmd.getParams().size()) ;
View Full Code Here

 
  public void testDefaultValue3() throws Exception {
    String json = "{query:{command:\"select * from copy_tblc where no1 < '10'\"}}";

    JSONObject jo = JSONObject.fromObject(json);
    QueryObj cmd = new JSONParser(dc).parseToQueryable(jo);
   
    assertEquals(dc.getLimitedRows(), cmd.getPage().getListNum()) ;
    assertEquals(1, cmd.getPage().getPageNo()) ;
   
    assertEquals(0, cmd.getParams().size()) ;
View Full Code Here

  public void testDefaultValue1() throws Exception {
    String json = "{query:{type:'usercommand', ctype:'select', command:\"select * from copy_tblc where no1 < 3\", param:{}, page:{} }}";

    JSONObject jo = JSONObject.fromObject(json);
    QueryObj cmd = new JSONParser(dc).parseToQueryable(jo);
   
    assertEquals(dc.getLimitedRows(), cmd.getPage().getListNum()) ;
    assertEquals(1, cmd.getPage().getPageNo()) ;
   
    assertEquals(0, cmd.getParams().size()) ;
View Full Code Here

  public void testSelectProcedure() throws Exception {
    String json = "{query:{type:'userprocedure', ctype:'select', command=\"sample@selectEmpBy()\", page:{listnum:5, pageno:1} }}";
   
    JSONObject jo = JSONObject.fromObject(json);
    QueryObj cmd = new JSONParser(dc).parseToQueryable(jo);
   
    // querytype
    assertEquals(QueryType.USER_PROCEDURE, cmd.getQueryType());
   
    // command type
View Full Code Here

  public void testInsert() throws Exception {
    dc.execUpdate("delete from update_sample") ;
    String json = "{query:{ctype:'dml', command:\"insert into update_sample values(:a, :b)\", param:{a:1, b:'abc'} }}" ;
   
    JSONObject jo = JSONObject.fromObject(json);
    QueryObj query = new JSONParser(dc).parseToQueryable(jo);
   
    assertEquals(QueryType.USER_COMMAND, query.getQueryType());
    assertEquals(IQueryable.UPDATE_COMMAND, query.getCommandType());
   
    JSONObject result = query.execute() ;
View Full Code Here

    String json = "{query:{name:'upts', type:'userprocedures', ctype:'select', " +
              "        command:[{query:{command:'select count(*) cnt from copy_tblc'}}, " +
              "                 {query:{command:'select * from copy_tblc', page:{listnum:5, pageno:1}}}]" +
              "}}" ;
    JSONObject jo = JSONObject.fromObject(json);
    QueryObj query = new JSONParser(dc).parseToQueryable(jo);
   
    assertEquals("upts", query.getProcSQL()) ;
    assertEquals("select count(*) cnt from copy_tblc", query.getQueryObj(0).getProcSQL()) ;
    assertEquals("select * from copy_tblc", query.getQueryObj(1).getProcSQL()) ;
   
View Full Code Here

    String json = "{query:{  name:'upts', type:'userprocedures', ctype:'dml', " +
        "                command:[{query:{command:\"insert into update_sample values(1, '2')\"}}, " +
        "                        {query:{command:\"update update_sample set b = '3' where a = 1\"}}]" +
        "}}" ;
    JSONObject jo = JSONObject.fromObject(json);
    QueryObj query = new JSONParser(dc).parseToQueryable(jo);
   
    JSONObject result = query.execute() ;
    assertEquals(2, result.getJSONObject("RESULT").getInt("ROWCOUNT")) ;
 
View Full Code Here

TOP

Related Classes of com.bleujin.dbfs.common.JSONParser

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.