/*
 * Copyright 2018 Scytl Secure Electronic Voting SA
 *
 * All rights reserved
 *
 * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
 */
package com.scytl.products.ov.channel.cc.orchestrator.choicecodes.domain.model.computedvalues;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.scytl.products.ov.commons.beans.errors.SemanticErrorGroup;
import com.scytl.products.ov.commons.beans.errors.SyntaxErrorGroup;
import com.scytl.products.ov.commons.domain.model.Constants;

/**
 * Entity that contains the information about the computed values.
 */
@Entity
@Table(name = "COMPUTED_VALUES")
public class ComputedValues {

    /**
     * The identifier of this computed value.
     */
    @Id
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "computedValuesSeq")
    @SequenceGenerator(name = "computedValuesSeq", sequenceName = "COMPUTED_VALUES_SEQ")
    @JsonIgnore
    private Integer id;

    /**
     * The identifier of the verification card set, to which this computed values
     * belong.
     */
    @Column(name = "VERIFICATION_CARD_SET_ID")
    @NotNull(groups = SyntaxErrorGroup.class)
    @Size(max = Constants.COLUMN_LENGTH_100, groups = SemanticErrorGroup.class)
    private String verificationCardSetId;

    /**
     * The identifier of the tenant, to which this computed values belong.
     */
    @Column(name = "TENANT_ID")
    @NotNull(groups = SyntaxErrorGroup.class)
    @Size(max = Constants.COLUMN_LENGTH_100, groups = SemanticErrorGroup.class)
    private String tenantId;

    /**
     * The identifier of the election event, to which this computed values belong.
     */
    @Column(name = "ELECTION_EVENT_ID")
    @NotNull(groups = SyntaxErrorGroup.class)
    @Size(max = Constants.COLUMN_LENGTH_100, groups = SemanticErrorGroup.class)
    private String electionEventId;
    
    /**
     * The identifier of the chunk.
     */
    @Column(name = "CHUNK_ID")
    @NotNull(groups = SyntaxErrorGroup.class)
    private int chunkId;
    
    /** The field containing the computation results **/
    @Column(name = "JSON")
    @Lob
    private String json;

    /**
     * Returns the current value of the field id.
     *
     * @return Returns the id.
     */
    @JsonIgnore
    public Integer getId() {
        return id;
    }

    /**
     * Sets the value of the field id.
     *
     * @param id
     *            The id to set.
     */
    @JsonIgnore
    public void setId(Integer id) {
        this.id = id;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getElectionEventId() {
        return electionEventId;
    }

    public void setElectionEventId(String electionEventId) {
        this.electionEventId = electionEventId;
    }

    public String getVerificationCardSetId() {
        return verificationCardSetId;
    }

    public void setVerificationCardSetId(String verificationCardSetId) {
        this.verificationCardSetId = verificationCardSetId;
    }
    
    public int getChunkId() {
        return chunkId;
    }

    public void setChunkId(int chunkId) {
        this.chunkId = chunkId;
    }

    public String getJson() {
        return json;
    }

    public void setJson(String json) {
        this.json = json;
    }
}
