package dev.dinauer.maven.maven.core.release;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;

import java.time.ZonedDateTime;

@Entity
@Table(name = "release_pom")
public class ReleasePom
{
    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private String id;

    @JsonIgnore
    @Column(columnDefinition = "TEXT")
    @Basic(fetch = FetchType.LAZY)
    private String pom;

    private String md5;

    private String sha1;

    private String url;

    private String filename;

    @OneToOne
    @JoinColumn(name = "release_version_id")
    @JsonBackReference
    private ReleaseVersion releaseVersion;

    @Column(name = "updated_at")
    private ZonedDateTime updatedAt;

    public String getId()
    {
        return id;
    }

    public ReleasePom setId(String id)
    {
        this.id = id;
        return this;
    }

    public String getPom()
    {
        return pom;
    }

    public ReleasePom setPom(String pom)
    {
        this.pom = pom;
        return this;
    }

    public String getMd5()
    {
        return md5;
    }

    public ReleasePom setMd5(String md5)
    {
        this.md5 = md5;
        return this;
    }

    public String getSha1()
    {
        return sha1;
    }

    public ReleasePom setSha1(String sha1)
    {
        this.sha1 = sha1;
        return this;
    }

    public ReleaseVersion getReleaseVersion()
    {
        return releaseVersion;
    }

    public ReleasePom setReleaseVersion(ReleaseVersion releaseVersion)
    {
        this.releaseVersion = releaseVersion;
        return this;
    }

    public String getUrl()
    {
        return url;
    }

    public ReleasePom setUrl(String url)
    {
        this.url = url;
        return this;
    }

    public String getFilename()
    {
        return filename;
    }

    public ReleasePom setFilename(String filename)
    {
        this.filename = filename;
        return this;
    }

    public ZonedDateTime getUpdatedAt()
    {
        return updatedAt;
    }

    public ReleasePom setUpdatedAt(ZonedDateTime updatedAt)
    {
        this.updatedAt = updatedAt;
        if (this.releaseVersion != null)
        {
            this.releaseVersion.setUpdatedAt(updatedAt);
        }
        return this;
    }
}
