<commit_before>package edu.iu.grid.oim.view.divrep;

import java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.TreeMap;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.log4j.Logger;

import com.divrep.DivRep;
import com.divrep.DivRepEvent;
import com.divrep.DivRepEventListener;
import com.divrep.common.DivRepButton;
import com.divrep.common.DivRepCheckBox;
import com.divrep.common.DivRepFormElement;
import com.divrep.common.DivRepSelectBox;
import com.divrep.common.DivRepStaticContent;
import com.divrep.common.DivRepTextArea;

import edu.iu.grid.oim.lib.Authorization;
import edu.iu.grid.oim.lib.StaticConfig;
import edu.iu.grid.oim.model.Context;
import edu.iu.grid.oim.model.ResourceDowntime;
import edu.iu.grid.oim.model.db.DowntimeClassModel;
import edu.iu.grid.oim.model.db.DowntimeSeverityModel;
import edu.iu.grid.oim.model.db.ResourceDowntimeModel;
import edu.iu.grid.oim.model.db.ResourceDowntimeServiceModel;
import edu.iu.grid.oim.model.db.ResourceServiceModel;
import edu.iu.grid.oim.model.db.ServiceModel;
import edu.iu.grid.oim.model.db.ConfigModel.Config;
import edu.iu.grid.oim.model.db.record.DowntimeClassRecord;
import edu.iu.grid.oim.model.db.record.DowntimeSeverityRecord;
import edu.iu.grid.oim.model.db.record.ResourceDowntimeRecord;
import edu.iu.grid.oim.model.db.record.ResourceDowntimeServiceRecord;
import edu.iu.grid.oim.model.db.record.ResourceServiceRecord;
import edu.iu.grid.oim.model.db.record.ServiceRecord;

public class ResourceDowntimeEditor extends DivRepFormElement {
    static Logger log = Logger.getLogger(ResourceDowntimeEditor.class); 

    private Context context;
    
	private DivRepButton add_button;
	private ArrayList<ResourceDowntimeRecord> downtime_recs;
	private Authorization auth;
	private int resource_id;
	
	public class DowntimeEditor extends DivRepFormElement
	{
		//service details
		
		private Integer downtime_id;
	
		private DurationDR duration;
		private DivRepTextArea summary;
		private DivRepSelectBox class_id;
		private DivRepSelectBox severity_id;
			
		private HashMap<Integer/*service_id*/, DivRepCheckBox> affected_services = new HashMap<Integer, DivRepCheckBox>();
		
		private DivRepButton remove_button;

		class DateDE extends DivRepFormElement<Date>
		{
			private static final String default_format = "M/d/yyyy";

			//http://docs.jquery.com/UI/Datepicker/formatDate
			private static final String default_jquery_format = "m/d/yy";
			
			String minDate = null;
			protected DateDE(DivRep parent) {
				super(parent);
				value = new Date();//today
			}

			public void setMinDate(Date d)
			{
				minDate = "new Date("+d.getTime()+")";
			}
			protected void onEvent(DivRepEvent e) {
				SimpleDateFormat format = new SimpleDateFormat(default_format);
				try {
					value = format.parse((String)e.value);
				} catch (ParseException e1) {<commit_msg>Made the resource downtime to round at minute since we don't allow user to select second and sub-second<commit_after>package edu.iu.grid.oim.view.divrep;

import java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.TreeMap;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.log4j.Logger;

import com.divrep.DivRep;
import com.divrep.DivRepEvent;
import com.divrep.DivRepEventListener;
import com.divrep.common.DivRepButton;
import com.divrep.common.DivRepCheckBox;
import com.divrep.common.DivRepFormElement;
import com.divrep.common.DivRepSelectBox;
import com.divrep.common.DivRepStaticContent;
import com.divrep.common.DivRepTextArea;

import edu.iu.grid.oim.lib.Authorization;
import edu.iu.grid.oim.lib.StaticConfig;
import edu.iu.grid.oim.model.Context;
import edu.iu.grid.oim.model.ResourceDowntime;
import edu.iu.grid.oim.model.db.DowntimeClassModel;
import edu.iu.grid.oim.model.db.DowntimeSeverityModel;
import edu.iu.grid.oim.model.db.ResourceDowntimeModel;
import edu.iu.grid.oim.model.db.ResourceDowntimeServiceModel;
import edu.iu.grid.oim.model.db.ResourceServiceModel;
import edu.iu.grid.oim.model.db.ServiceModel;
import edu.iu.grid.oim.model.db.ConfigModel.Config;
import edu.iu.grid.oim.model.db.record.DowntimeClassRecord;
import edu.iu.grid.oim.model.db.record.DowntimeSeverityRecord;
import edu.iu.grid.oim.model.db.record.ResourceDowntimeRecord;
import edu.iu.grid.oim.model.db.record.ResourceDowntimeServiceRecord;
import edu.iu.grid.oim.model.db.record.ResourceServiceRecord;
import edu.iu.grid.oim.model.db.record.ServiceRecord;

public class ResourceDowntimeEditor extends DivRepFormElement {
    static Logger log = Logger.getLogger(ResourceDowntimeEditor.class); 

    private Context context;
    
	private DivRepButton add_button;
	private ArrayList<ResourceDowntimeRecord> downtime_recs;
	private Authorization auth;
	private int resource_id;
	
	public class DowntimeEditor extends DivRepFormElement
	{
		//service details
		
		private Integer downtime_id;
	
		private DurationDR duration;
		private DivRepTextArea summary;
		private DivRepSelectBox class_id;
		private DivRepSelectBox severity_id;
			
		private HashMap<Integer/*service_id*/, DivRepCheckBox> affected_services = new HashMap<Integer, DivRepCheckBox>();
		
		private DivRepButton remove_button;

		class DateDE extends DivRepFormElement<Date>
		{
			private static final String default_format = "M/d/yyyy";

			//http://docs.jquery.com/UI/Datepicker/formatDate
			private static final String default_jquery_format = "m/d/yy";
			
			String minDate = null;
			protected DateDE(DivRep parent) {
				super(parent);
				value = new Date();//today
				value.setTime((value.getTime() / (1000L*60)) * (1000L*60)); //round to nearest minute
			}

			public void setMinDate(Date d)
			{
				minDate = "new Date("+d.getTime()+")";
			}
			protected void onEvent(DivRepEvent e) {
				SimpleDateFormat format = new SimpleDateFormat(default_format);
				try {
					value = format.parse((String)e.value);
				} catch (ParseException e1) {
{'fraction_non_alphanumeric': 0.10347526612398247, 'fraction_numerical': 0.002504696305572949, 'mean_word_length': 4.976613657623948, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2273842', 'n_tokens_mistral': 2284, 'n_tokens_neox': 2072, 'n_words': 392}