⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ksc_performancereportfactory.java

📁 opennms得相关源码 请大家看看
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * identified by working_index (this should have been set when the working     * report was loaded), then create a new blank working report     */    public void unloadWorkingReport() throws MarshalException, ValidationException {        int total_reports = m_config.getReportCount();        if ((working_index < 0) || (working_index >= total_reports)) {            // out of range... assume the new report needs to be appended to            // list            m_config.addReport(working_report);        } else {            // Replace the report in the configuration with the working report            m_config.setReport(working_index, working_report);        }        // Create a new and unique instance of a report for screwing around with        // as the working report        working_report = KSC_PerformanceReportFactory.getNewReport();        working_index = -1;    }    /** Create a new blank report & initialize it */    public static Report getNewReport() {        Report new_report = new Report();        new_report.setTitle("New Report Title");        new_report.setShow_graphtype_button(false);        new_report.setShow_timespan_button(false);        return new_report;    }    /** Returns the working report index */    public int getWorkingReportIndex() {        return working_index;    }    /** Sets the working report index */    public void setWorkingReportIndex(int v_index) {        working_index = v_index;    }    /** Returns the working graph object */    public Graph getWorkingGraph() {        return working_graph;    }    /** Returns the working graph index */    public int getWorkingGraphIndex() {        return graph_index;    }    /** Create a new blank graph & initialize it */    public static Graph getNewGraph() {        Graph new_graph = new Graph();        new_graph.setTitle("");        new_graph.setGraphtype("mib2.bits");        new_graph.setTimespan("7_day");        return new_graph;    }    /**     * Loads the indexed graph from the working report into the working graph     * object or creates a new one if the object does not exist     */    public void loadWorkingGraph(int index) throws MarshalException, ValidationException {        int total_graphs = working_report.getGraphCount();        graph_index = index;        if ((graph_index < 0) || (graph_index >= total_graphs)) {            // out of range... assume new report needs to be created            working_graph = KSC_PerformanceReportFactory.getNewGraph();            graph_index = -1;        } else {            // Create a new and unique instance of the graph for screwing around            // with            StringWriter stringWriter = new StringWriter();            Marshaller.marshal(working_report.getGraph(graph_index), stringWriter);            StringReader stringReader = new StringReader(stringWriter.toString());            working_graph = (Graph) Unmarshaller.unmarshal(Graph.class, stringReader);        }    }    /**     * Unloads the working graph into the working report list at the requested     * graph number. If the graph was modified from an existing graph, then the     * old one is replaced. A new blank working graph is then created     */    public void unloadWorkingGraph(int requested_graphnum) throws MarshalException, ValidationException {        int total_graphs = working_report.getGraphCount();        int insert_location = requested_graphnum--;        boolean replace_graph = false;        // Check range for existing graph and delete if it is in the valid range        if ((graph_index >= 0) && (graph_index < total_graphs)) {            // in range... delete existing graph.            working_report.removeGraph(working_report.getGraph(graph_index));        }        // Check range for insertion point        if ((insert_location < 0) || (insert_location >= total_graphs)) {            // out of range... assume the new graph needs to be appended to list            working_report.addGraph(working_graph);        } else {            // Insert the graph in the configuration within the working report            working_report.addGraph(insert_location, working_graph);        }        // Create a new and unique instance of a report for screwing around with        // as the working report        working_graph = KSC_PerformanceReportFactory.getNewGraph();        graph_index = -1;    }    public static synchronized void getBeginEndTime(String interval, Calendar begin_time, Calendar end_time) throws IllegalArgumentException    /**     * This method requires begin time and end time to be set to the current     * time prior to call. The start and stop times are relative to this time.     * Init values as follows: begin_time = Calendar.getInstance(); end_time =     * Calendar.getInstance();     */    {        if (interval.equals("1_hour")) {            begin_time.add(Calendar.HOUR, -1);        } else if (interval.equals("2_hour")) {            begin_time.add(Calendar.HOUR, -2);        } else if (interval.equals("4_hour")) {            begin_time.add(Calendar.HOUR, -4);        } else if (interval.equals("8_hour")) {            begin_time.add(Calendar.HOUR, -8);        } else if (interval.equals("1_day")) {            begin_time.add(Calendar.DATE, -1);        } else if (interval.equals("7_day")) {            begin_time.add(Calendar.DATE, -7);        } else if (interval.equals("1_month")) {            begin_time.add(Calendar.DATE, -30);        } else if (interval.equals("6_month")) {            begin_time.add(Calendar.DATE, -183);        } else if (interval.equals("1_year")) {            begin_time.add(Calendar.DATE, -365);        } else {            // From current time, lets zero out the small components            begin_time.set(Calendar.HOUR_OF_DAY, 0);            begin_time.set(Calendar.MINUTE, 0);            begin_time.set(Calendar.SECOND, 0);            end_time.set(Calendar.HOUR_OF_DAY, 0);            end_time.set(Calendar.MINUTE, 0);            end_time.set(Calendar.SECOND, 0);            if (interval.equals("Today")) {                end_time.add(Calendar.DATE, 1);            } else if (interval.equals("Yesterday")) {                begin_time.add(Calendar.DATE, -1);            } else if (interval.equals("This Week") || interval.equals("Last Week")) {                begin_time.set(Calendar.DAY_OF_WEEK, 1);                end_time.set(Calendar.DAY_OF_WEEK, 7);                end_time.set(Calendar.HOUR_OF_DAY, 23);                end_time.set(Calendar.MINUTE, 59);                if (interval.equals("Last Week")) {                    begin_time.add(Calendar.DATE, -7);                    end_time.add(Calendar.DATE, -7);                }            } else if (interval.equals("This Month")) {                begin_time.set(Calendar.DATE, 1);                end_time.add(Calendar.MONTH, 1);                end_time.set(Calendar.DATE, 1);            } else if (interval.equals("Last Month")) {                begin_time.add(Calendar.MONTH, -1);                begin_time.set(Calendar.DATE, 1);                end_time.set(Calendar.DATE, 1);            } else if (interval.equals("This Quarter") || interval.equals("Last Quarter")) {                begin_time.set(Calendar.DATE, 1);                end_time.set(Calendar.DATE, 1);                switch (begin_time.get(Calendar.MONTH)) {                case 0:                case 1:                case 2:                    begin_time.set(Calendar.MONTH, 0);                    end_time.set(Calendar.MONTH, 3);                    break;                case 3:                case 4:                case 5:                    begin_time.set(Calendar.MONTH, 3);                    end_time.set(Calendar.MONTH, 6);                    break;                case 6:                case 7:                case 8:                    begin_time.set(Calendar.MONTH, 6);                    end_time.set(Calendar.MONTH, 9);                    break;                case 9:                case 10:                case 11:                    begin_time.set(Calendar.MONTH, 9);                    end_time.set(Calendar.MONTH, 0);                    end_time.add(Calendar.YEAR, 1);                    break;                default:                    throw new IllegalArgumentException("Invalid Calendar Month " + begin_time.get(Calendar.MONTH));                }                if (interval.equals("Last Quarter")) {                    begin_time.add(Calendar.MONTH, -3);                    end_time.add(Calendar.MONTH, -3);                }            } else if (interval.equals("This Year")) {                begin_time.set(Calendar.MONTH, 0);                begin_time.set(Calendar.DATE, 1);                end_time.set(Calendar.MONTH, 0);                end_time.set(Calendar.DATE, 1);                end_time.add(Calendar.YEAR, 1);            } else if (interval.equals("Last Year")) {                begin_time.set(Calendar.MONTH, 0);                begin_time.set(Calendar.DATE, 1);                begin_time.add(Calendar.YEAR, -1);                end_time.set(Calendar.MONTH, 0);                end_time.set(Calendar.DATE, 1);            } else {                throw new IllegalArgumentException("Unknown graph timespan: " + interval);            }        }    } // getBeginEndTime()}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -