package <%=packageName%>.domain;

<%_ if(ormTool === 'mybatis') { _%>
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
<%_ } else { _%>
import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.*;
<%_ } _%>

import java.io.Serializable;

import <%=packageName%>.domain.enumeration.ProcessEntityStatus;

/**
 * 流程与实体关联
 */
<%_ if(ormTool === 'mybatis') { _%>
@TableName(value = "process_entity_relation")
<%_ } else { _%>
@Entity
@Table(name = "process_entity_relation")
@DynamicUpdate
<%_ } _%>
<%_ if (searchEngine === 'elasticsearch') { _%>
@org.springframework.data.elasticsearch.annotations.Document(indexName = "processentityrelation")
<%_ } _%>
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ProcessEntityRelation implements Serializable {

    private static final long serialVersionUID = 1L;

    <%_ if(ormTool === 'mybatis') { _%>
    @TableId(type = IdType.AUTO)
    <%_ } else { _%>
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    <%_ } _%>
    private Long id;

    /**
     * 宿主实体名称
     */
    <%_ if(ormTool === 'mybatis') { _%>
    @TableField(value = "entity_type")
    <%_ } else { _%>
    @Column(name = "entity_type", insertable = false, updatable = false)
    <%_ } _%>
    private String entityType;

    /**
     * 宿主实体Id
     */
    <%_ if(ormTool === 'mybatis') { _%>
    @TableField(value = "entity_id")
    <%_ } else { _%>
    @Column(name = "entity_id", insertable = false, updatable = false)
    <%_ } _%>
    private Long entityId;

    <%_ if(ormTool !== 'mybatis') { _%>
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    @Cascade({org.hibernate.annotations.CascadeType.ALL})
    @Any(metaDef = "OwnerMetaDef",metaColumn = @Column(name = "owner_type"), fetch = FetchType.EAGER)
    @JoinColumn(name = "owner_id")
    private Owner entity;
    <%_ } _%>

    /**
     * 流程实例Id
     */
    <%_ if(ormTool === 'mybatis') { _%>
    @TableField(value = "process_instance_id")
    <%_ } else { _%>
    @Column(name = "process_instance_id")
    <%_ } _%>
    private String processInstanceId;

    /**
     * 状态
     */
    <%_ if(ormTool === 'mybatis') { _%>
    @TableField(value = "status")
    <%_ } else { _%>
    @Enumerated(EnumType.STRING)
    @Column(name = "status")
    <%_ } _%>
    private ProcessEntityStatus status;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getEntityType() {
        return entityType;
    }

    public ProcessEntityRelation entityType(String entityType) {
        this.entityType = entityType;
        return this;
    }

    public void setEntityType(String entityType) {
        this.entityType = entityType;
    }

    public Long getEntityId() {
        return entityId;
    }

    public ProcessEntityRelation entityId(Long entityId) {
        this.entityId = entityId;
        return this;
    }

    public void setEntityId(Long entityId) {
        this.entityId = entityId;
    }

    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public ProcessEntityRelation processInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
        return this;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    public ProcessEntityStatus getStatus() {
        return status;
    }

    public ProcessEntityRelation status(ProcessEntityStatus status) {
        this.status = status;
        return this;
    }
    <%_ if(ormTool !== 'mybatis') { _%>

    public Owner getEntity() {
        return entity;
    }

    public void setEntity(Owner entity) {
        this.entity = entity;
    }

    public ProcessEntityRelation entity(Owner entity) {
        this.entity = entity;
        return this;
    }
    <%_ } _%>

    public void setStatus(ProcessEntityStatus status) {
        this.status = status;
    }

    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof ProcessEntityRelation)) {
            return false;
        }
        return id != null && id.equals(((ProcessEntityRelation) o).id);
    }

    @Override
    public int hashCode() {
        return 31;
    }

    @Override
    public String toString() {
        return "ProcessEntityRelation{" +
            "id=" + getId() +
            ", entityType='" + getEntityType() + "'" +
            ", entityId=" + getEntityId() +
            ", processInstanceId='" + getProcessInstanceId() + "'" +
            ", status='" + getStatus() + "'" +
            "}";
    }
}
