<commit_before>/*
 * ALMA - Atacama Large Millimiter Array (c) European Southern Observatory, 2007
 * 
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This library 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 Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 */
package alma.acs.lasercore.test.stress.category;

import java.util.Date;
import java.text.SimpleDateFormat;

/**
 * The view of an alarm in the table
 * 
 * @author acaproni
 *
 */
public class AlarmView {
	
	// The format for the timestamp
	private final String TIME_FORMAT = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
	private final SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_FORMAT);
	
	public String alarmID=null; // Triplet
	public Integer priority = null; // Priority
	public Date sourceTimestamp=null; // Source timestamp
	public String description=null; // Problem description
	public String cause=null; // The cause
	public Boolean active=null; // Active
	public String hostName; // The name of the host of the source that sent the alarm
	
	/**
	 * Constructor
	 * 
	 * @param id The ID (triplet)
	 * @param pri Priority
	 * @param timestamp Timestamp
	 * @param desc Problem description
	 * @param act Active
	 */
	public AlarmView(String id, String pri, String timestamp, String desc, String cause,String act,String hostName) {
		if (id==null || id.length()==0) {
			throw new IllegalArgumentException("Invalid triplet in constructor");
		}
		alarmID=id;
		description=desc;
		this.cause=cause;
		this.hostName=hostName;
		// Get the date
		try {
			long nsec=Long.parseLong(timestamp);
			 sourceTimestamp=new Date(nsec);
		} catch (Exception e) {
			// Invalid timestamp
			sourceTimestamp=null;
			System.err.println("Invalid timestamp for "+alarmID+": "+timestamp);
		}
		// Get the status
		try {
			active=Boolean.parseBoolean(act);
		} catch (Exception e) {
			System.err.println("Invalid priority for "+alarmID+": "+pri);
			active=true;
		}
		// Get the priority
		try {
			priority=new Integer(pri);
		} catch (Exception e) {
			System.err.println("Invalid priority for "+alarmID+": "+pri);
			priority=0;
		}<commit_msg>Reviewed<commit_after>/*
 * ALMA - Atacama Large Millimiter Array (c) European Southern Observatory, 2007
 * 
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This library 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 Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 */
package alma.acs.lasercore.test.stress.category;

import java.util.Date;
import java.text.SimpleDateFormat;

/**
 * The view of an alarm in the table
 * 
 * @author acaproni
 *
 */
public class AlarmView {
	
	// The format for the timestamp
	private final String TIME_FORMAT = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
	private final SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_FORMAT);
	
	public final String alarmID; // Triplet
	public final Integer priority; // Priority
	public final Date sourceTimestamp; // Source timestamp
	public final String description; // Problem description
	public final String cause; // The cause
	public final Boolean active;// Active
	public final String hostName; // The name of the host of the source that sent the alarm
	
	/**
	 * Constructor
	 * 
	 * @param id The ID (triplet)
	 * @param pri Priority
	 * @param timestamp Timestamp
	 * @param desc Problem description
	 * @param act Active
	 */
	public AlarmView(String id, String pri, String timestamp, String desc, String cause,String act,String hostName) 
	throws Exception {
		if (id==null || id.length()==0) {
			throw new IllegalArgumentException("Invalid triplet in constructor");
		}
		alarmID=id;
		description=desc;
		this.cause=cause;
		this.hostName=hostName;
		// Get the date
		long nsec=Long.parseLong(timestamp);
		 sourceTimestamp=new Date(nsec);
		// Get the status
		active=Boolean.parseBoolean(act);
		// Get the priority
		priority=new Integer(pri);
{'fraction_non_alphanumeric': 0.0925074925074925, 'fraction_numerical': 0.008591408591408592, 'mean_word_length': 3.8554801163918526, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '4269450', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1359, 'n_words': 572}