Changeset 751


Ignore:
Timestamp:
05/05/11 22:55:10 (8 years ago)
Author:
philsmart
Message:
 
Location:
raptor-mua/trunk/src/main
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • raptor-mua/trunk/src/main/config/dao-beans.xml

    r746 r751  
    2525                        <props> 
    2626                                <!-- <prop key="hibernate.dialect"> org.hibernate.dialect.PostgreSQLDialect</prop> database type --> 
    27                                 <prop key="hibernate.dialect"> org.hibernate.dialect.HSQLDialect</prop> <!-- database type --> 
    28                                 <prop key="hibernate.show_sql">false</prop>  <!-- outputs the SQL queries used to the standard logger --> 
    29                                 <prop key="hibernate.hbm2ddl.auto">update</prop> <!-- update changes the db if mapping changes, creates the db if none exists, 
    30                                         in production do not use any of these --> 
     27                                <prop key="hibernate.dialect"> org.hibernate.dialect.HSQLDialect</prop> 
     28                                <prop key="hibernate.show_sql">false</prop>  
     29                                <prop key="hibernate.hbm2ddl.auto">update</prop> 
     30                                         
    3131                        </props> 
    3232                </property> 
     
    7878        </property> 
    7979        <property name="jdbcUrl"> 
    80             <value>jdbc:hsqldb:file:/tmp/muatt;cached=true</value> 
     80            <value>jdbc:hsqldb:file:/tmp/mua;hsqldb.default_table_type=cached</value> 
    8181        </property> 
    8282        <property name="user"> 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/CountEntry.java

    r697 r751  
    9494                long testCount = 0; 
    9595                for (Bucket bucket : buckets) { 
    96                         // SQL between is >= start && <= end. We want, >= start && < end, so 
    97                         // must exclude equals end 
    98                         Integer count = (Integer) this.getEntryHandler().queryUnique( 
    99                                         "select count(*) from "+statisticParameters.getEventType().getHibernateSimpleClassName()+" where (eventTime between '" + bucket.getStart() + "' and '" 
    100                                                         + bucket.getEnd() + "') and (eventTime !='" + bucket.getEnd() + "')");// new 
    101                         // Object[]{start,end}); 
     96                        /* SQL between is >= start && <= end. We want, >= start && < end, so 
     97                        * must exclude equals end 
     98                        */ 
     99                        String tableName = statisticParameters.getEventType().getHibernateSimpleClassName(); 
     100                        String query=""; 
     101                        if (sqlWhere.equals("")) 
     102                                query ="select count(*) from "+tableName+" where (eventTime between ? and ?) and (eventTime !=?)"; 
     103                        else 
     104                                query ="select count(*) from "+tableName+" where (eventTime between ? and ?) and (eventTime !=?) and "+sqlWhere; 
     105                         
     106                        Object[] params = new Object[]{bucket.getStart().toDate(),bucket.getEnd().toDate(),bucket.getEnd().toDate()}; 
     107                        Integer count = (Integer) this.getEntryHandler().queryUnique(query,params); 
    102108                        bucket.setValue(count); 
    103109                        testCount += bucket.getValue(); 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/CountEntryPerInterval.java

    r697 r751  
    110110                String tableName= statisticParameters.getEventType().getHibernateSimpleClassName(); 
    111111                for (Bucket bucket : buckets) { 
    112                         // SQL between is >= start && <= end. We want, >= start && < end, so 
    113                         // must exclude equals end 
     112                        /*SQL between is >= start && <= end. We want, >= start && < end, so 
     113                        * must exclude equals end 
     114                        */ 
    114115                        String query=null; 
    115116                        if (sqlWhere.equals("")) 
    116                                 query = "select count(*) from "+tableName+" where (eventTime between '" + bucket.getStart() + "' and '" 
    117                                                         + bucket.getEnd() + "') and (eventTime !='" + bucket.getEnd() + "')"; 
     117                                query ="select count(*) from "+tableName+" where (eventTime between ? and ?) and (eventTime !=?)"; 
    118118                        else 
    119                                 query = "select count(*) from "+tableName+" where (eventTime between '" + bucket.getStart() + "' and '" 
    120                                 + bucket.getEnd() + "') and (eventTime !='" + bucket.getEnd() + "') and "+sqlWhere; 
    121                         Integer count = (Integer) this.getEntryHandler().queryUnique(query);// new 
     119                                query ="select count(*) from "+tableName+" where (eventTime between ? and ?) and (eventTime !=?) and "+sqlWhere; 
     120                         
     121                        Object[] params = new Object[]{bucket.getStart().toDate(),bucket.getEnd().toDate(),bucket.getEnd().toDate()}; 
     122                         
     123                        Integer count = (Integer) this.getEntryHandler().queryUnique(query,params);// new 
    122124                        // Object[]{start,end}); 
    123125                        bucket.setValue(count); 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/GroupBy.java

    r697 r751  
    5353                log.debug("Select {}, tableName {}", groupByField, tableName); 
    5454                 
    55                 String query="select " + groupByField + " from "+tableName+" where (eventTime between '" + start + "' and '" 
    56                 + end + "') group by (" + groupByField + ")"; 
     55                String query=""; 
    5756                 
    58                 List results = getEntryHandler().query(query); 
     57                if (sqlWhere.equals("")) { 
     58                        query = "select "+groupByField+" from "+tableName+" where (eventTime between ? and ?) group by ("+groupByField+")"; 
     59                } else { 
     60                        query = "select "+groupByField+" from "+tableName+" where (eventTime between ? and ?) and "+sqlWhere+" group by ("+groupByField+")"; 
     61                }        
     62                 
     63                Object[] params = new Object[]{start.toDate(),end.toDate()}; 
     64                 
     65                List results = getEntryHandler().query(query,params); 
    5966 
    6067                ArrayList<Group> groups = new ArrayList(); 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/GroupByCountDistinct.java

    r697 r751  
    3131                String countDistinctField = methodParams.get(1).getValue(); 
    3232 
    33                 log.debug("Performing groupByFrequency Statistical Operation"); 
     33                log.debug("Performing GroupByCountDistinct Statistical Operation"); 
    3434                log.debug("Params for method:  {},{}", this.getClass().getSimpleName(), statisticParameters.getUnitName()); 
    3535                log.debug("Grouping field: {}, count By distinct field {}", groupByField, countDistinctField); 
     
    4242 
    4343                log.debug("Select {}, tableName {}", groupByField, tableName); 
     44                 
     45                String query=""; 
     46                 
     47                if (sqlWhere.equals("")) { 
     48                        query = "select " + groupByField + ",count(distinct " + countDistinctField + ") from " + tableName + " where (eventTime between ?" + 
     49                        " and ?) group by (" + groupByField + ")"; 
     50                } else { 
     51                        query = "select " + groupByField + ",count(distinct " + countDistinctField + ") from " + tableName + " where (eventTime between ?" + 
     52                        " and ?) and "+sqlWhere+" group by (" + groupByField + ")"; 
     53                }        
     54                 
     55                Object[] params = new Object[]{start.toDate(),end.toDate()}; 
    4456 
    45                 // String query ="select " + groupByField + ",count(distinct " + 
    46                 // countDistinctField + ") from " + tableName + 
    47                 // " where (eventTime between '" + start 
    48                 // + "' and '" + end + "') group by (" + groupByField + ")"; 
    49  
    50                 String query = "select " + groupByField + ",count(distinct " + countDistinctField + ") from " + tableName + " where (eventTime between '" + start 
    51                                 + "' and '" + end + "') group by (" + groupByField + ")"; 
    52  
    53                 List results = getEntryHandler().query(query); 
     57                List results = getEntryHandler().query(query,params); 
    5458 
    5559                ArrayList<Group> groups = new ArrayList<Group>(); 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/GroupByFrequency.java

    r742 r751  
    5555                String query = ""; 
    5656                if (sqlWhere.equals("")) { 
    57                         query = "select " + groupByField + ", count(*) from " + tableName + " where (eventTime between '" + start + "' and '" + end + "') group by (" 
    58                                         + groupByField + ")"; 
     57                        query = "select "+groupByField+", count(*) from "+tableName+" where (eventTime between ? and ?) group by ("+groupByField+")"; 
    5958                } else { 
    60                         query = "select " + groupByField + ", count(*) from " + tableName + " where (eventTime between '" + start + "' and '" + end + "') and " + sqlWhere 
    61                                         + " group by (" + groupByField + ")"; 
    62                 } 
     59                        query = "select "+groupByField+", count(*) from "+tableName+" where (eventTime between ? and ?) and "+sqlWhere+" group by ("+groupByField+")"; 
     60                }                
     61                 
     62                Object[] params = new Object[]{start.toDate(),end.toDate()}; 
    6363 
    64                 List results = getEntryHandler().query(query); 
     64                List results = getEntryHandler().query(query,params); 
    6565 
    6666                ArrayList<Group> groups = new ArrayList<Group>(); 
Note: See TracChangeset for help on using the changeset viewer.