// Path: src/main/java/org/centralperf/model/SampleDataBackendTypeEnum.java
// public enum SampleDataBackendTypeEnum {
// 	/**
// 	 * Central Perf database
// 	 */
// 	DEFAULT,
// 	/**
// 	 * Elastic Search cluster
// 	 */
// 	ES
// }


import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.centralperf.model.SampleDataBackendTypeEnum;
import org.hibernate.annotations.Type;
/*
 * Copyright (C) 2014  The Central Perf authors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.centralperf.model.dao;





/**
 * A run is based on a script (specific version) associated with custom variable values (number of users, duration....)
 * A run may ready to be launched, running or achieved. An already launched run cannot be launched again (in fact you can, but a new run is then created)  
 * This is an Entity bean to persist Run info into the persistence layer.
 * 
 * @since 1.0
 */
@Entity
public class Run {

	@Id
	@GeneratedValue
	private Long id;

	@NotNull
	@Size(min = 1, max = 33)
	private String label;

	@ManyToOne
	private ScriptVersion scriptVersion;
	
	private boolean launched = false;
	
	private boolean running = false;
	
	private Date startDate;
	
	private Date endDate;
	
	private String comment;
	
	@OneToMany(cascade=CascadeType.ALL)
	private List<ScriptVariable> customScriptVariables = new ArrayList<ScriptVariable>();

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "projectId")
    private Project project;
	
	@Lob
	@Column( length = 1000000 )
	@Type(type="text")
	private String processOutput;
	
	@OneToMany(mappedBy="run", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Sample> samples;
	
// Path: src/main/java/org/centralperf/model/SampleDataBackendTypeEnum.java
// public enum SampleDataBackendTypeEnum {
// 	/**
// 	 * Central Perf database
// 	 */
// 	DEFAULT,
// 	/**
// 	 * Elastic Search cluster
// 	 */
// 	ES
// }


// Path: src/main/java/org/centralperf/model/dao/Run.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.centralperf.model.SampleDataBackendTypeEnum;
import org.hibernate.annotations.Type;

/*
 * Copyright (C) 2014  The Central Perf authors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.centralperf.model.dao;





/**
 * A run is based on a script (specific version) associated with custom variable values (number of users, duration....)
 * A run may ready to be launched, running or achieved. An already launched run cannot be launched again (in fact you can, but a new run is then created)  
 * This is an Entity bean to persist Run info into the persistence layer.
 * 
 * @since 1.0
 */
@Entity
public class Run {

	@Id
	@GeneratedValue
	private Long id;

	@NotNull
	@Size(min = 1, max = 33)
	private String label;

	@ManyToOne
	private ScriptVersion scriptVersion;
	
	private boolean launched = false;
	
	private boolean running = false;
	
	private Date startDate;
	
	private Date endDate;
	
	private String comment;
	
	@OneToMany(cascade=CascadeType.ALL)
	private List<ScriptVariable> customScriptVariables = new ArrayList<ScriptVariable>();

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "projectId")
    private Project project;
	
	@Lob
	@Column( length = 1000000 )
	@Type(type="text")
	private String processOutput;
	
	@OneToMany(mappedBy="run", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Sample> samples;
	
	private SampleDataBackendTypeEnum sampleDataBackendType = SampleDataBackendTypeEnum.DEFAULT;