IoT CAS Frameworks/IOT_Server/Report_Generator_Framework/IT/source/DashBoard-JSONgenerator/src/com/merit/dashboard/bizlogic/BizLogic.java
@SuppressWarnings("rawtypes")
    private String combineTwoMapForBusinessSLA(LinkedHashMap<String, String> serviceMetricInfo, LinkedHashMap<String, String> ticketInfo) {
        try {
            String szMetricTypeValueJson = "";
            String createJsonWithMap = "";
            String combinedCritical = "";
            String combinedJsonOK = "";
            String combinedJsonWithoutOK = "";
            String combined_BothCritical = "";
            Iterator<?> it = serviceMetricInfo.entrySet().iterator();
            boolean flag = false;
            while (it.hasNext()) {
                Map.Entry pairs = (Map.Entry) it.next();
                String szTicket = "";

                if (ticketInfo.get("DefaultMapValue") != null) {
                    szTicket = "\"hstdwnstatus\":[\"OK\"]";
                } else if (ticketInfo.get(pairs.getKey()) == null) {
                    szTicket = "\"hstdwnstatus\":[\"OK\"]";
                } else {
                    szTicket = ticketInfo.get(pairs.getKey());
                }
                createJsonWithMap = ",{" + pairs.getValue() + "," + szTicket + "}";
                JSONObject mTempJObj = new JSONObject("{" + pairs.getValue() + "}");
                if (pairs.getValue().toString().contains("CRITICAL") && szTicket.contains("CRITICAL")) {
                    if (mTempJObj.get("Health").toString().endsWith("CRITICAL\"]")) {
                        combined_BothCritical += createJsonWithMap;
                    } else {
                        combined_BothCritical += createJsonWithMap;
                    }
                } else if (createJsonWithMap.contains("CRITICAL")) {
                    if (mTempJObj.get("Health").toString().endsWith("CRITICAL\"]")) {
                        combinedCritical += createJsonWithMap;
                    } else {
                        combinedCritical += createJsonWithMap;
                    }
                }/* else if (!createJsonWithMap.contains("CRITICAL") && !createJsonWithMap.contains("OK")) {
                 combinedCritical += createJsonWithMap;
                 } */ else if (mTempJObj.get("Health").toString().contains("OK")) {
                    combinedJsonOK += createJsonWithMap;
                } else {
                    combinedJsonWithoutOK += createJsonWithMap;
                }
            }
            System.out.println(
                    "\n---------------\ncombinedCritical.substring(1) = " + combinedCritical + " "
                    + "\ncombinedJsonOK = " + combinedJsonOK
                    + "\ncombinedJsonWithoutOK = " + combinedJsonWithoutOK + "\n------------------\n");
            if (!combinedCritical.isEmpty()) {
                flag = true;
                createJsonWithMap = combinedCritical.substring(1) + combinedJsonOK + combinedJsonWithoutOK;
            } else if (!combinedJsonOK.isEmpty()) {
                flag = true;
                createJsonWithMap = combinedJsonOK.substring(1) + combinedJsonWithoutOK;
            } else if (!combinedJsonWithoutOK.isEmpty()) {
                flag = true;
                createJsonWithMap = combinedJsonWithoutOK.substring(1);
            }

            if (!combined_BothCritical.isEmpty() && flag) {
                createJsonWithMap = combined_BothCritical.substring(1) + "," + createJsonWithMap;
            } else if (!combined_BothCritical.isEmpty()) {
                createJsonWithMap = combined_BothCritical.substring(1);
            }

            if (!createJsonWithMap.isEmpty()) {
                szMetricTypeValueJson = "[" + createJsonWithMap + "]";
            } else {
                szMetricTypeValueJson = "[]";
            }

            return szMetricTypeValueJson;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("DashBoard combineTwoMap Metric and Ticket to generate Json \n" + e.getMessage());
        }
        return "[]";
    }
/**
     * **************************************************************************************************
     * This method is returning the JSON and sending this json to Generate Chart
     * after Combining Metric information and Ticket information by using
     * LinkedHashMap
     *
     * @param serviceMetricInfo LinkedHashMap having metric Health information
     * and Availability info
     * @param ticketInfo LinkedHashMap having Ticket Alert information
     * @return szMetricTypeValueJson Combined Result of
     * Metric,Ticket,Availability as JSON
     * **************************************************************************************************
     */
This method is returning the JSON and sending this json to Generate Chart
after Combining Metric information and Ticket information by using
LinkedHashMap

@param serviceMetricInfo LinkedHashMap having metric Health information
and Availability info
@param ticketInfo LinkedHashMap having Ticket Alert information
@return szMetricTypeValueJson Combined Result of
Metric,Ticket,Availability as JSON
This method is returning the JSON and sending this json to Generate Chart after Combining Metric information and Ticket information by using LinkedHashMap @param serviceMetricInfo LinkedHashMap having metric Health information and Availability info @param ticketInfo LinkedHashMap having Ticket Alert information @return szMetricTypeValueJson Combined Result of Metric Ticket Availability as JSON
@SuppressWarnings("rawtypes")
    private String combineTwoMapForBusinessSLA(LinkedHashMap<String, String> serviceMetricInfo, LinkedHashMap<String, String> ticketInfo) {
        try {
            String szMetricTypeValueJson = "";
            String createJsonWithMap = "";
            String combinedCritical = "";
            String combinedJsonOK = "";
            String combinedJsonWithoutOK = "";
            String combined_BothCritical = "";
            Iterator<?> it = serviceMetricInfo.entrySet().iterator();
            boolean flag = false;
            while (it.hasNext()) {
                Map.Entry pairs = (Map.Entry) it.next();
                String szTicket = "";
                if (ticketInfo.get("DefaultMapValue") != null) {
                    szTicket = "\"hstdwnstatus\":[\"OK\"]";
                } else if (ticketInfo.get(pairs.getKey()) == null) {
                    szTicket = "\"hstdwnstatus\":[\"OK\"]";
                } else {
                    szTicket = ticketInfo.get(pairs.getKey());
                }
                createJsonWithMap = ",{" + pairs.getValue() + "," + szTicket + "}";
                JSONObject mTempJObj = new JSONObject("{" + pairs.getValue() + "}");
                if (pairs.getValue().toString().contains("CRITICAL") && szTicket.contains("CRITICAL")) {
                    if (mTempJObj.get("Health").toString().endsWith("CRITICAL\"]")) {
                        combined_BothCritical += createJsonWithMap;
                    } else {
                        combined_BothCritical += createJsonWithMap;
                    }
                } else if (createJsonWithMap.contains("CRITICAL")) {
                    if (mTempJObj.get("Health").toString().endsWith("CRITICAL\"]")) {
                        combinedCritical += createJsonWithMap;
                    } else {
                        combinedCritical += createJsonWithMap;
                    }
                }/* else if (!createJsonWithMap.contains("CRITICAL") && !createJsonWithMap.contains("OK")) {
                 combinedCritical += createJsonWithMap;
                 } */ else if (mTempJObj.get("Health").toString().contains("OK")) {
                    combinedJsonOK += createJsonWithMap;
                } else {
                    combinedJsonWithoutOK += createJsonWithMap;
                }
            }
            System.out.println(
                    "\n---------------\ncombinedCritical.substring(1) = " + combinedCritical + " "
                    + "\ncombinedJsonOK = " + combinedJsonOK
                    + "\ncombinedJsonWithoutOK = " + combinedJsonWithoutOK + "\n------------------\n");
            if (!combinedCritical.isEmpty()) {
                flag = true;
                createJsonWithMap = combinedCritical.substring(1) + combinedJsonOK + combinedJsonWithoutOK;
            } else if (!combinedJsonOK.isEmpty()) {
                flag = true;
                createJsonWithMap = combinedJsonOK.substring(1) + combinedJsonWithoutOK;
            } else if (!combinedJsonWithoutOK.isEmpty()) {
                flag = true;
                createJsonWithMap = combinedJsonWithoutOK.substring(1);
            }
            if (!combined_BothCritical.isEmpty() && flag) {
                createJsonWithMap = combined_BothCritical.substring(1) + "," + createJsonWithMap;
            } else if (!combined_BothCritical.isEmpty()) {
                createJsonWithMap = combined_BothCritical.substring(1);
            }
            if (!createJsonWithMap.isEmpty()) {
                szMetricTypeValueJson = "[" + createJsonWithMap + "]";
            } else {
                szMetricTypeValueJson = "[]";
            }
            return szMetricTypeValueJson;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("DashBoard combineTwoMap Metric and Ticket to generate Json \n" + e.getMessage());
        }
        return "[]";
    }
@ SuppressWarnings ( "rawtypes" ) private String combineTwoMapForBusinessSLA ( LinkedHashMap < String , String > serviceMetricInfo , LinkedHashMap < String , String > ticketInfo ) { try { String szMetricTypeValueJson = "" ; String createJsonWithMap = "" ; String combinedCritical = "" ; String combinedJsonOK = "" ; String combinedJsonWithoutOK = "" ; String combined_BothCritical = "" ; Iterator < ? > it = serviceMetricInfo . entrySet ( ) . iterator ( ) ; boolean flag = false ; while ( it . hasNext ( ) ) { Map . Entry pairs = ( Map . Entry ) it . next ( ) ; String szTicket = "" ; if ( ticketInfo . get ( "DefaultMapValue" ) != null ) { szTicket = "\"hstdwnstatus\":[\"OK\"]" ; } else if ( ticketInfo . get ( pairs . getKey ( ) ) == null ) { szTicket = "\"hstdwnstatus\":[\"OK\"]" ; } else { szTicket = ticketInfo . get ( pairs . getKey ( ) ) ; } createJsonWithMap = ",{" + pairs . getValue ( ) + "," + szTicket + "}" ; JSONObject mTempJObj = new JSONObject ( "{" + pairs . getValue ( ) + "}" ) ; if ( pairs . getValue ( ) . toString ( ) . contains ( "CRITICAL" ) && szTicket . contains ( "CRITICAL" ) ) { if ( mTempJObj . get ( "Health" ) . toString ( ) . endsWith ( "CRITICAL\"]" ) ) { combined_BothCritical += createJsonWithMap ; } else { combined_BothCritical += createJsonWithMap ; } } else if ( createJsonWithMap . contains ( "CRITICAL" ) ) { if ( mTempJObj . get ( "Health" ) . toString ( ) . endsWith ( "CRITICAL\"]" ) ) { combinedCritical += createJsonWithMap ; } else { combinedCritical += createJsonWithMap ; } } /* else if (!createJsonWithMap.contains("CRITICAL") && !createJsonWithMap.contains("OK")) {
                 combinedCritical += createJsonWithMap;
                 } */ else if ( mTempJObj . get ( "Health" ) . toString ( ) . contains ( "OK" ) ) { combinedJsonOK += createJsonWithMap ; } else { combinedJsonWithoutOK += createJsonWithMap ; } } System . out . println ( "\n---------------\ncombinedCritical.substring(1) = " + combinedCritical + " " + "\ncombinedJsonOK = " + combinedJsonOK + "\ncombinedJsonWithoutOK = " + combinedJsonWithoutOK + "\n------------------\n" ) ; if ( ! combinedCritical . isEmpty ( ) ) { flag = true ; createJsonWithMap = combinedCritical . substring ( 1 ) + combinedJsonOK + combinedJsonWithoutOK ; } else if ( ! combinedJsonOK . isEmpty ( ) ) { flag = true ; createJsonWithMap = combinedJsonOK . substring ( 1 ) + combinedJsonWithoutOK ; } else if ( ! combinedJsonWithoutOK . isEmpty ( ) ) { flag = true ; createJsonWithMap = combinedJsonWithoutOK . substring ( 1 ) ; } if ( ! combined_BothCritical . isEmpty ( ) && flag ) { createJsonWithMap = combined_BothCritical . substring ( 1 ) + "," + createJsonWithMap ; } else if ( ! combined_BothCritical . isEmpty ( ) ) { createJsonWithMap = combined_BothCritical . substring ( 1 ) ; } if ( ! createJsonWithMap . isEmpty ( ) ) { szMetricTypeValueJson = "[" + createJsonWithMap + "]" ; } else { szMetricTypeValueJson = "[]" ; } return szMetricTypeValueJson ; } catch ( Exception e ) { e . printStackTrace ( ) ; log . error ( "DashBoard combineTwoMap Metric and Ticket to generate Json \n" + e . getMessage ( ) ) ; } return "[]" ; }
This method is returning the JSON and sending this json to Generate Chart
 after Combining Metric information and Ticket information by using
 LinkedHashMap
This method is returning the JSON and sending this json to Generate Chart after Combining Metric information and Ticket information by using LinkedHashMap