/**
 * 
 */
package gov.nih.nci.cagrid.portal.domain.dataservice;

import gov.nih.nci.cagrid.portal.domain.AbstractDomainObject;
import gov.nih.nci.cagrid.portal.domain.PortalUser;

import java.util.Date;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.ForceDiscriminator;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * @author <a href="mailto:joshua.phillips@semanticbits.com">Joshua Phillips</a>
 *
 */
@Entity
@Table(name = "query_instances")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = { @Parameter(name = "sequence", value = "seq_query_inst") })
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "query_inst_type", discriminatorType = DiscriminatorType.STRING)
@ForceDiscriminator
public abstract class QueryInstance extends AbstractDomainObject {

	private PortalUser portalUser;
	private Query query;
	private QueryInstanceState state = QueryInstanceState.UNSCHEDULED;
	private String result;
	private String error;
	private Date createTime = new Date();
	private Date startTime;
	private Date finishTime;
	
	/**
	 * 
	 */
	public QueryInstance() {
	}

	@ManyToOne
	@JoinColumn(name = "query_id")
	public Query getQuery() {
		return query;
	}

	public void setQuery(Query query) {
		this.query = query;
	}

	@Enumerated(EnumType.STRING)
	public QueryInstanceState getState() {
		return state;
	}

	public void setState(QueryInstanceState state) {
		this.state = state;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public Date getFinishTime() {
		return finishTime;
	}

	public void setFinishTime(Date finishTime) {
		this.finishTime = finishTime;
	}

	@Transient
	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	

	@ManyToOne
	@JoinColumn(name = "portal_user_id")
	public PortalUser getPortalUser() {
		return portalUser;
	}

	public void setPortalUser(PortalUser portalUser) {
		this.portalUser = portalUser;
	}

	
	@Transient
	public abstract String getType();
	public abstract void setType(String type);

}

@@ -228,397 +228,9 @@
 nce.
-DiscriminatorColumn;%0Aimport javax.persistence.DiscriminatorType;%0Aimport javax.persistence.Entity;%0Aimport javax.persistence.EnumType;%0Aimport javax.persistence.Enumerated;%0Aimport javax.persistence.Inheritance;%0Aimport javax.persistence.InheritanceType;%0Aimport javax.persistence.JoinColumn;%0Aimport javax.persistence.ManyToOne;%0Aimport javax.persistence.Table;%0Aimport javax.persistence.Transient
+*
 ;%0A%0Ai
@@ -1637,32 +1637,59 @@
 createTime;%0A%09%7D%0A%0A
+    @Column(length = 4000)%0A
 %09public String g

change column type