Publisher.java 2.15 KB
package org.legrog.entities;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Set;

/*
    Entité persistante correspondant à un éditeur.
    Pointe vers la version valide si elle existe, ainsi que son validateur et la date de validation.
    Pointe vers l'ensemble de ses versions.
 */
@Entity
//@Table(name = "editeur")
public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
// TODO L'éventuel usage de Linkable reste à confirmer https://tree.taiga.io/project/jr-utily-grog-v3/us/48
// TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué
    @Id
    @Column(name = "PUBLISHER_ID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int publisherId;

    @OneToOne
    private PublisherVersion validatedVersion;

    @OneToOne
    private User validator;

    private Timestamp validationDateTime;

    @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER)
    private Set<PublisherVersion> versions;

    public int getPublisherId() {
        return publisherId;
    }

    public void setPublisherId(int publisherId) {
        this.publisherId = publisherId;
    }

    public PublisherVersion getValidatedVersion() {
        return validatedVersion;
    }

    public void setValidatedVersion(PublisherVersion activeVersion) {
        this.validatedVersion = activeVersion;
    }

    public Set<PublisherVersion> getVersions() {
        return versions;
    }

    public void setVersions(Set<PublisherVersion> versions) {
        this.versions = versions;
    }

    public User getValidator() {
        return validator;
    }

    public void setValidator(User activeValidator) {
        this.validator = activeValidator;
    }

    public Timestamp getValidationDateTime() {
        return validationDateTime;
    }

    public void setValidationDateTime(Timestamp validationDateTime) {
        this.validationDateTime = validationDateTime;
    }

    @Override
    public String toString() {
        return "PUBLISHER_ID = " + publisherId + ", Validated Version = " + validatedVersion + ", Validator = " + validator + ", Validation DateTime = " + validationDateTime;
    }
}