<commit_before><%--
/*******************************************************************************
 * This file is part of OpenNMS(R).
 *
 * Copyright (C) 2006-2012 The OpenNMS Group, Inc.
 * OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * OpenNMS(R) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenNMS(R).  If not, see:
 *      http://www.gnu.org/licenses/
 *
 * For more information contact:
 *     OpenNMS(R) Licensing <<EMAIL>>
 *     http://www.opennms.org/
 *     http://www.opennms.com/
 *******************************************************************************/

--%>

<%@page language="java"
        contentType="text/html"
        session="true"
        import="java.util.*,
        org.opennms.netmgt.config.*,
        org.opennms.netmgt.config.poller.*,
        org.opennms.core.utils.WebSecurityUtils,
        org.opennms.core.resource.Vault,
        org.opennms.web.element.*,
        org.opennms.web.pathOutage.*,
        org.opennms.netmgt.model.OnmsNode,
        org.opennms.netmgt.EventConstants,
        org.opennms.netmgt.xml.event.Event,
        org.opennms.core.utils.*,
        org.opennms.netmgt.utils.*,
        org.opennms.web.api.Util,
        org.exolab.castor.xml.ValidationException,
        java.net.*,
        java.io.*,
        java.sql.*,
        java.text.NumberFormat,
        java.text.SimpleDateFormat
        "
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%!//A singleton instance of a "Match-any" interface, which can be used for generic tests/removals etc.
	private static org.opennms.netmgt.config.poller.Interface matchAnyInterface;
	{
		matchAnyInterface = new org.opennms.netmgt.config.poller.Interface();
		matchAnyInterface.setAddress("match-any");
	}

	private static void addNode(Outage theOutage, int newNodeId) throws ValidationException {
		try {
			org.opennms.netmgt.config.poller.Node newNode = new org.opennms.netmgt.config.poller.Node();
			newNode.setId(newNodeId);
			if (!theOutage.getNodeCollection().contains(newNode)) {
				newNode.validate();
				theOutage.addNode(newNode);
				theOutage.removeInterface(matchAnyInterface); //Just arbitrarily try and remove it.  If it's not there, this will do nothing
			}
		} catch (NumberFormatException e) {
			//Just ignore it - we can't add the node, why should we care?
		} catch (IndexOutOfBoundsException ioob) {
			// same here
		}
	}
	
	private static void addInterface(Outage theOutage, org.opennms.netmgt.config.poller.Interface newInterface) throws ValidationException {
		if (!theOutage.getInterfaceCollection().contains(newInterface)) {
			newInterface.validate();
			theOutage.addInterface(newInterface);
			try {
				theOutage.removeInterface(matchAnyInterface); //Just arbitrarily try and remove it.  If it's not there, this will do nothing
			} catch (IndexOutOfBoundsException ioob) {
				// ok if it fails
			}
		}
	}

	private static String getNumberSelectField(String name, int start, int end, int selected, int padding) {
		NumberFormat nf = NumberFormat.getInstance();
		nf.setMinimumIntegerDigits(padding);
		nf.setGroupingUsed(false);
		StringBuffer sb = new StringBuffer();
		sb.append("<select name=\"").append(name).append("\">");
		for (int i = start; i <= end; i++) {
			sb.append("<option value=\"").append(nf.format(i)).append("\"");
			if (i == selected) {
				sb.append(" selected");
			}
			sb.append(">").append(nf.format(i)).append("</option>");
		}
		sb.append("</select>");

		return sb.toString();
	}
	
	private static String getMonthSelectField(String name, int month) {
		StringBuffer sb = new StringBuffer();
		sb.append("<select name=\"").append(name).append("\">");
		SimpleDateFormat shortDF = new SimpleDateFormat("MMM", Locale.US);
		SimpleDateFormat longDF  = new SimpleDateFormat("MMMM");
		for (int mon = 0; mon < 12; mon++) {
			Date tempDate = new GregorianCalendar(0, mon, 1).getTime();
			sb.append("<option value=\"").append(shortDF.format(tempDate)).append("\" ");
			sb.append((month==(mon+1))?"selected":"");
			sb.append(">").append(longDF.format(tempDate)).append("</option>");
		}
		sb.append("</select>");
		
		return sb.toString();
	}
	
	private static final String GET_DEPENDENCY_NODES_BY_NODEID="select po.nodeid from pathoutage po left join ipinterface intf on po.criticalpathip=intf.ipaddr where intf.nodeid=?";

    private static final String GET_NODES_IN_PATH = "SELECT DISTINCT pathoutage.nodeid FROM pathoutage, ipinterface WHERE pathoutage.criticalpathip=? AND pathoutage.nodeid=ipinterface.nodeid AND ipinterface.ismanaged!='D' ORDER BY nodeid";

    private static Set<Integer> getAllDependencyNodesByCriticalPath(String criticalpathip) throws SQLException {
	    Set<Integer> allPathNodes = getDependencyNodesByCriticalPath(criticalpathip);
	    Set<Integer> currentNodes=allPathNodes;
	    while (currentNodes.size() > 0) {
	        Set<Integer> nextIterationNodes=new TreeSet<Integer>();
	        for (Integer pathnodeid : currentNodes ) {
	            nextIterationNodes.addAll(getDependencyNodesByNodeid(pathnodeid));<commit_msg>Fixed an exception when compiling jsp<commit_after><%--
/*******************************************************************************
 * This file is part of OpenNMS(R).
 *
 * Copyright (C) 2006-2012 The OpenNMS Group, Inc.
 * OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * OpenNMS(R) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenNMS(R).  If not, see:
 *      http://www.gnu.org/licenses/
 *
 * For more information contact:
 *     OpenNMS(R) Licensing <<EMAIL>>
 *     http://www.opennms.org/
 *     http://www.opennms.com/
 *******************************************************************************/

--%>

<%@page language="java"
        contentType="text/html"
        session="true"
        import="java.util.*,
        org.opennms.netmgt.config.*,
        org.opennms.netmgt.config.poller.*,
        org.opennms.core.utils.WebSecurityUtils,
        org.opennms.core.resource.Vault,
        org.opennms.web.element.*,
        org.opennms.web.pathOutage.*,
        org.opennms.netmgt.model.OnmsNode,
        org.opennms.netmgt.EventConstants,
        org.opennms.netmgt.xml.event.Event,
        org.opennms.core.utils.*,
        org.opennms.netmgt.utils.*,
        org.opennms.web.api.Util,
        org.exolab.castor.xml.ValidationException,
        java.net.*,
        java.io.*,
        java.sql.*,
        java.text.NumberFormat,
        java.text.SimpleDateFormat
        "
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%!//A singleton instance of a "Match-any" interface, which can be used for generic tests/removals etc.
	private static org.opennms.netmgt.config.poller.Interface matchAnyInterface;
	{
		matchAnyInterface = new org.opennms.netmgt.config.poller.Interface();
		matchAnyInterface.setAddress("match-any");
	}

	private static void addNode(Outage theOutage, int newNodeId) throws ValidationException {
		try {
			org.opennms.netmgt.config.poller.Node newNode = new org.opennms.netmgt.config.poller.Node();
			newNode.setId(newNodeId);
			if (!theOutage.getNodeCollection().contains(newNode)) {
				newNode.validate();
				theOutage.addNode(newNode);
				theOutage.removeInterface(matchAnyInterface); //Just arbitrarily try and remove it.  If it's not there, this will do nothing
			}
		} catch (NumberFormatException e) {
			//Just ignore it - we can't add the node, why should we care?
		} catch (IndexOutOfBoundsException ioob) {
			// same here
		}
	}
	
	private static void addInterface(Outage theOutage, org.opennms.netmgt.config.poller.Interface newInterface) throws ValidationException {
		if (!theOutage.getInterfaceCollection().contains(newInterface)) {
			newInterface.validate();
			theOutage.addInterface(newInterface);
			try {
				theOutage.removeInterface(matchAnyInterface); //Just arbitrarily try and remove it.  If it's not there, this will do nothing
			} catch (IndexOutOfBoundsException ioob) {
				// ok if it fails
			}
		}
	}

	private static String getNumberSelectField(String name, int start, int end, int selected, int padding) {
		NumberFormat nf = NumberFormat.getInstance();
		nf.setMinimumIntegerDigits(padding);
		nf.setGroupingUsed(false);
		StringBuffer sb = new StringBuffer();
		sb.append("<select name=\"").append(name).append("\">");
		for (int i = start; i <= end; i++) {
			sb.append("<option value=\"").append(nf.format(i)).append("\"");
			if (i == selected) {
				sb.append(" selected");
			}
			sb.append(">").append(nf.format(i)).append("</option>");
		}
		sb.append("</select>");

		return sb.toString();
	}
	
	private static String getMonthSelectField(String name, int month) {
		StringBuffer sb = new StringBuffer();
		sb.append("<select name=\"").append(name).append("\">");
		SimpleDateFormat shortDF = new SimpleDateFormat("MMM", Locale.US);
		SimpleDateFormat longDF  = new SimpleDateFormat("MMMM");
		for (int mon = 0; mon < 12; mon++) {
			java.util.Date tempDate = new GregorianCalendar(0, mon, 1).getTime();
			sb.append("<option value=\"").append(shortDF.format(tempDate)).append("\" ");
			sb.append((month==(mon+1))?"selected":"");
			sb.append(">").append(longDF.format(tempDate)).append("</option>");
		}
		sb.append("</select>");
		
		return sb.toString();
	}
	
	private static final String GET_DEPENDENCY_NODES_BY_NODEID="select po.nodeid from pathoutage po left join ipinterface intf on po.criticalpathip=intf.ipaddr where intf.nodeid=?";

    private static final String GET_NODES_IN_PATH = "SELECT DISTINCT pathoutage.nodeid FROM pathoutage, ipinterface WHERE pathoutage.criticalpathip=? AND pathoutage.nodeid=ipinterface.nodeid AND ipinterface.ismanaged!='D' ORDER BY nodeid";

    private static Set<Integer> getAllDependencyNodesByCriticalPath(String criticalpathip) throws SQLException {
	    Set<Integer> allPathNodes = getDependencyNodesByCriticalPath(criticalpathip);
	    Set<Integer> currentNodes=allPathNodes;
	    while (currentNodes.size() > 0) {
	        Set<Integer> nextIterationNodes=new TreeSet<Integer>();
	        for (Integer pathnodeid : currentNodes ) {
	            nextIterationNodes.addAll(getDependencyNodesByNodeid(pathnodeid));
{'fraction_non_alphanumeric': 0.15537362828775475, 'fraction_numerical': 0.004180456366486675, 'mean_word_length': 3.8780798640611724, 'pattern_counts': {'":': 2, '<': 47, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5563304', 'n_tokens_mistral': 3816, 'n_tokens_neox': 3482, 'n_words': 852}