/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.qsoft.rs.sincoar.model;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TBPMPROCESSINSTANCE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tbpmprocessinstance.findAll", query = "SELECT t FROM Tbpmprocessinstance t"),
    @NamedQuery(name = "Tbpmprocessinstance.findByJournalid", query = "SELECT t FROM Tbpmprocessinstance t WHERE t.journalid = :journalid"),
    @NamedQuery(name = "Tbpmprocessinstance.findBySessionid", query = "SELECT t FROM Tbpmprocessinstance t WHERE t.sessionid = :sessionid"),
    @NamedQuery(name = "Tbpmprocessinstance.findByProcessid", query = "SELECT t FROM Tbpmprocessinstance t WHERE t.processid = :processid"),
    @NamedQuery(name = "Tbpmprocessinstance.findByFinalized", query = "SELECT t FROM Tbpmprocessinstance t WHERE t.finalized = :finalized"),
    @NamedQuery(name = "Tbpmprocessinstance.findBySnapshot", query = "SELECT t FROM Tbpmprocessinstance t WHERE t.snapshot = :snapshot"),
    @NamedQuery(name = "Tbpmprocessinstance.findByCreationdate", query = "SELECT t FROM Tbpmprocessinstance t WHERE t.creationdate = :creationdate"),
    @NamedQuery(name = "Tbpmprocessinstance.findByEnddate", query = "SELECT t FROM Tbpmprocessinstance t WHERE t.enddate = :enddate"),
    @NamedQuery(name = "Tbpmprocessinstance.findByPackagename", query = "SELECT t FROM Tbpmprocessinstance t WHERE t.packagename = :packagename")})
public class Tbpmprocessinstance implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "JOURNALID")
    private String journalid;
    @Basic(optional = false)
    @Column(name = "SESSIONID")
    private long sessionid;
    @Column(name = "PROCESSID")
    private BigInteger processid;
    @Column(name = "FINALIZED")
    private String finalized;
    @Column(name = "SNAPSHOT")
    private String snapshot;
    @Basic(optional = false)
    @Column(name = "CREATIONDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date creationdate;
    @Column(name = "ENDDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date enddate;
    @Column(name = "PACKAGENAME")
    private String packagename;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tbpmprocessinstance")
    private Collection<Tbpmprocessvariables> tbpmprocessvariablesCollection;
    @JoinColumns({
        @JoinColumn(name = "RULECODE", referencedColumnName = "RULECODE"),
        @JoinColumn(name = "COMPANYCODE", referencedColumnName = "COMPANYCODE")})
    @ManyToOne
    private Tbpmrules tbpmrules;

    public Tbpmprocessinstance() {
    }

    public Tbpmprocessinstance(String journalid) {
        this.journalid = journalid;
    }

    public Tbpmprocessinstance(String journalid, long sessionid, Date creationdate) {
        this.journalid = journalid;
        this.sessionid = sessionid;
        this.creationdate = creationdate;
    }

    public String getJournalid() {
        return journalid;
    }

    public void setJournalid(String journalid) {
        this.journalid = journalid;
    }

    public long getSessionid() {
        return sessionid;
    }

    public void setSessionid(long sessionid) {
        this.sessionid = sessionid;
    }

    public BigInteger getProcessid() {
        return processid;
    }

    public void setProcessid(BigInteger processid) {
        this.processid = processid;
    }

    public String getFinalized() {
        return finalized;
    }

    public void setFinalized(String finalized) {
        this.finalized = finalized;
    }

    public String getSnapshot() {
        return snapshot;
    }

    public void setSnapshot(String snapshot) {
        this.snapshot = snapshot;
    }

    public Date getCreationdate() {
        return creationdate;
    }

    public void setCreationdate(Date creationdate) {
        this.creationdate = creationdate;
    }

    public Date getEnddate() {
        return enddate;
    }

    public void setEnddate(Date enddate) {
        this.enddate = enddate;
    }

    public String getPackagename() {
        return packagename;
    }

    public void setPackagename(String packagename) {
        this.packagename = packagename;
    }

    @XmlTransient
    public Collection<Tbpmprocessvariables> getTbpmprocessvariablesCollection() {
        return tbpmprocessvariablesCollection;
    }

    public void setTbpmprocessvariablesCollection(Collection<Tbpmprocessvariables> tbpmprocessvariablesCollection) {
        this.tbpmprocessvariablesCollection = tbpmprocessvariablesCollection;
    }

    public Tbpmrules getTbpmrules() {
        return tbpmrules;
    }

    public void setTbpmrules(Tbpmrules tbpmrules) {
        this.tbpmrules = tbpmrules;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (journalid != null ? journalid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tbpmprocessinstance)) {
            return false;
        }
        Tbpmprocessinstance other = (Tbpmprocessinstance) object;
        if ((this.journalid == null && other.journalid != null) || (this.journalid != null && !this.journalid.equals(other.journalid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsoft.rs.sincoar.model.Tbpmprocessinstance[ journalid=" + journalid + " ]";
    }
    
}
