IoT CAS Frameworks/IOT_Server/Report_Generator_Framework/IT/source/DashBoard-JSONgenerator/src/com/merit/dashboard/DAO/metrics/LineChartMetrics_2.java
public String generateLineChart(String resourceType, long smilli, long emilli, String customer, String metrictype) {
        log.debug("==============================Endof LineChartMetricsSummary linechart===========================================");

        Statement stat = null;
        ResultSet rs = null;
        String szLineChartJson = "[]";
        System.out.println(">>>>>>>>>>>>>>>>>>>>> metrictype ==== " + metrictype);
        String szQueryDataPointsForBattery = "";
        if (metrictype == null || metrictype.equalsIgnoreCase("")) {
            szQueryDataPointsForBattery = ""
                    + "SELECT service,resourcetype,metrictype, array_agg(metricvalue) AS metricvalue,array_agg(sla) as slavalues,array_agg(to_char(totimestamp,'yyyy/MM/dd HH24:mi:SS')) as timestamp,host from "
                    + "( select service,resourcetype,metrictype,metricvalue,sla,to_timestamp(timestamp1) as totimestamp,host "
                    + "from servicemetrics  where "
                    + "timestamp1 between 1339046856 and 1370582856 and "
                    + "metricvalue is not null and "
                    + "resourceType='server' "
                    + "GROUP BY service,resourcetype,metrictype,metricvalue,sla,timestamp1,host "
                    + "ORDER By metrictype,totimestamp) as gh "
                    + "GROUP BY service,resourcetype,host,metrictype";

        } else {
            szQueryDataPointsForBattery = ""
                    + "SELECT service,resourcetype,metrictype, array_agg(metricvalue) AS metricvalue,array_agg(sla) as slavalues,array_agg(to_char(totimestamp,'yyyy/MM/dd HH24:mi:SS')) as timestamp,host "
                    + "from "
                    + "( select service,resourcetype,metrictype,metricvalue,sla,to_timestamp(timestamp1) as totimestamp,host "
                    + "from servicemetrics  where "
                    + "timestamp1 between " + smilli + " and " + emilli + " and "
                    + "metricvalue is not null and "
                    + "resourceType='" + resourceType + "' "
                    + "and metrictype in ( " + metrictype + ")"
                    + "GROUP BY service,resourcetype,metrictype,metricvalue,sla,timestamp1,host "
                    + "ORDER By metrictype,totimestamp) as gh "
                    + "GROUP BY service,resourcetype,host,metrictype";
        }
        try {
            log.debug("linechart query: /" + resourceType + "/ \n" + szQueryDataPointsForBattery);
            szLineChartJson = executeQueryForLineChart(szQueryDataPointsForBattery, customer);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("DashBoard LineCharMetrics  generateLineChart()  :" + e.getMessage());

        } finally {

            try {
                if (rs != null) {
//                    rs.close();
                    rs = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
                log.error("DashBoard LineCharMetrics  generateLineChart()  :\n" + e.getMessage());

            }

        }
        return szLineChartJson;
    }
/**
     * ***************************************************************************************************
     * This method is Query to Generate TimeLine Chart for using user Defined
     * array_agg()function for concatenating the column of a query Result
     * array_agg function in postgresql below 8 version we have to create by
     * following command:
     *
     * create aggregate array_agg ( sfunc = array_append, basetype = anyelement,
     * stype = anyarray, initcond = '{}' );
     *
     * Then sending to executeQueryForLineChart() to execute query and generate
     * HashMap for Generating Chart.
     *
     * @param resourceType Different category as
     * Desktop,Server,DataBase,Network,JVM
     * @param smilli date in second as long Timestamp(Current Time-selected Time
     * Period)
     * @param emilli date in second as long Timestamp(Current Time)
     * @param customer Selected customerID
     * ***************************************************************************************************
     */
This method is Query to Generate TimeLine Chart for using user Defined
array_agg()function for concatenating the column of a query Result
array_agg function in postgresql below 8 version we have to create by
following command.

create aggregate array_agg ( sfunc = array_append, basetype = anyelement,
stype = anyarray, initcond = '{}' ).

Then sending to executeQueryForLineChart() to execute query and generate
HashMap for Generating Chart.

@param resourceType Different category as
Desktop,Server,DataBase,Network,JVM
@param smilli date in second as long Timestamp(Current Time-selected Time
Period)
@param emilli date in second as long Timestamp(Current Time)
@param customer Selected customerID
This method is Query to Generate TimeLine Chart for using user Defined array_agg () function for concatenating the column of a query Result array_agg function in postgresql below 8 version we have to create by following command . create aggregate array_agg ( sfunc = array_append basetype = anyelement stype = anyarray initcond = ' {} ' ) . Then sending to executeQueryForLineChart () to execute query and generate HashMap for Generating Chart . @param resourceType Different category as Desktop Server DataBase Network JVM @param smilli date in second as long Timestamp ( Current Time - selected Time Period ) @param emilli date in second as long Timestamp ( Current Time ) @param customer Selected customerID
public String generateLineChart(String resourceType, long smilli, long emilli, String customer, String metrictype) {
        log.debug("==============================Endof LineChartMetricsSummary linechart===========================================");
        Statement stat = null;
        ResultSet rs = null;
        String szLineChartJson = "[]";
        System.out.println(">>>>>>>>>>>>>>>>>>>>> metrictype ==== " + metrictype);
        String szQueryDataPointsForBattery = "";
        if (metrictype == null || metrictype.equalsIgnoreCase("")) {
            szQueryDataPointsForBattery = ""
                    + "SELECT service,resourcetype,metrictype, array_agg(metricvalue) AS metricvalue,array_agg(sla) as slavalues,array_agg(to_char(totimestamp,'yyyy/MM/dd HH24:mi:SS')) as timestamp,host from "
                    + "( select service,resourcetype,metrictype,metricvalue,sla,to_timestamp(timestamp1) as totimestamp,host "
                    + "from servicemetrics  where "
                    + "timestamp1 between 1339046856 and 1370582856 and "
                    + "metricvalue is not null and "
                    + "resourceType='server' "
                    + "GROUP BY service,resourcetype,metrictype,metricvalue,sla,timestamp1,host "
                    + "ORDER By metrictype,totimestamp) as gh "
                    + "GROUP BY service,resourcetype,host,metrictype";
        } else {
            szQueryDataPointsForBattery = ""
                    + "SELECT service,resourcetype,metrictype, array_agg(metricvalue) AS metricvalue,array_agg(sla) as slavalues,array_agg(to_char(totimestamp,'yyyy/MM/dd HH24:mi:SS')) as timestamp,host "
                    + "from "
                    + "( select service,resourcetype,metrictype,metricvalue,sla,to_timestamp(timestamp1) as totimestamp,host "
                    + "from servicemetrics  where "
                    + "timestamp1 between " + smilli + " and " + emilli + " and "
                    + "metricvalue is not null and "
                    + "resourceType='" + resourceType + "' "
                    + "and metrictype in ( " + metrictype + ")"
                    + "GROUP BY service,resourcetype,metrictype,metricvalue,sla,timestamp1,host "
                    + "ORDER By metrictype,totimestamp) as gh "
                    + "GROUP BY service,resourcetype,host,metrictype";
        }
        try {
            log.debug("linechart query: /" + resourceType + "/ \n" + szQueryDataPointsForBattery);
            szLineChartJson = executeQueryForLineChart(szQueryDataPointsForBattery, customer);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("DashBoard LineCharMetrics  generateLineChart()  :" + e.getMessage());
        } finally {
            try {
                if (rs != null) {
                    rs = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
                log.error("DashBoard LineCharMetrics  generateLineChart()  :\n" + e.getMessage());
            }
        }
        return szLineChartJson;
    }
public String generateLineChart ( String resourceType , long smilli , long emilli , String customer , String metrictype ) { log . debug ( "==============================Endof LineChartMetricsSummary linechart===========================================" ) ; Statement stat = null ; ResultSet rs = null ; String szLineChartJson = "[]" ; System . out . println ( ">>>>>>>>>>>>>>>>>>>>> metrictype ==== " + metrictype ) ; String szQueryDataPointsForBattery = "" ; if ( metrictype == null || metrictype . equalsIgnoreCase ( "" ) ) { szQueryDataPointsForBattery = "" + "SELECT service,resourcetype,metrictype, array_agg(metricvalue) AS metricvalue,array_agg(sla) as slavalues,array_agg(to_char(totimestamp,'yyyy/MM/dd HH24:mi:SS')) as timestamp,host from " + "( select service,resourcetype,metrictype,metricvalue,sla,to_timestamp(timestamp1) as totimestamp,host " + "from servicemetrics  where " + "timestamp1 between 1339046856 and 1370582856 and " + "metricvalue is not null and " + "resourceType='server' " + "GROUP BY service,resourcetype,metrictype,metricvalue,sla,timestamp1,host " + "ORDER By metrictype,totimestamp) as gh " + "GROUP BY service,resourcetype,host,metrictype" ; } else { szQueryDataPointsForBattery = "" + "SELECT service,resourcetype,metrictype, array_agg(metricvalue) AS metricvalue,array_agg(sla) as slavalues,array_agg(to_char(totimestamp,'yyyy/MM/dd HH24:mi:SS')) as timestamp,host " + "from " + "( select service,resourcetype,metrictype,metricvalue,sla,to_timestamp(timestamp1) as totimestamp,host " + "from servicemetrics  where " + "timestamp1 between " + smilli + " and " + emilli + " and " + "metricvalue is not null and " + "resourceType='" + resourceType + "' " + "and metrictype in ( " + metrictype + ")" + "GROUP BY service,resourcetype,metrictype,metricvalue,sla,timestamp1,host " + "ORDER By metrictype,totimestamp) as gh " + "GROUP BY service,resourcetype,host,metrictype" ; } try { log . debug ( "linechart query: /" + resourceType + "/ \n" + szQueryDataPointsForBattery ) ; szLineChartJson = executeQueryForLineChart ( szQueryDataPointsForBattery , customer ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; log . error ( "DashBoard LineCharMetrics  generateLineChart()  :" + e . getMessage ( ) ) ; } finally { try { if ( rs != null ) { rs = null ; } } catch ( Exception e ) { e . printStackTrace ( ) ; log . error ( "DashBoard LineCharMetrics  generateLineChart()  :\n" + e . getMessage ( ) ) ; } } return szLineChartJson ; }
This method is Query to Generate TimeLine Chart for using user Defined
 array_agg()function for concatenating the column of a query Result
 array_agg function in postgresql below 8 version we have to create by
 following command:
This method is Query to Generate TimeLine Chart for using user Defined array_agg () function for concatenating the column of a query Result array_agg function in postgresql below 8 version we have to create by following command :
//                    rs.close();