package com.imcode.imcms.mapping.jpa.doc.content;

import com.imcode.imcms.mapping.jpa.doc.Version;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@MappedSuperclass
public abstract class VersionedContent {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "doc_id", unique = true, nullable = false, insertable = false, updatable = false)
    private Integer documentId;

    @NotNull
    @ManyToOne
    @JoinColumns({
            @JoinColumn(name = "doc_id", referencedColumnName = "doc_id"),
            @JoinColumn(name = "doc_version_no", referencedColumnName = "no")
    })
    private Version version;

    public Integer getId() {
        return id;
    }

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

    public Version getVersion() {
        return version;
    }

    public void setVersion(Version contentVersion) {
        this.version = contentVersion;
        this.documentId = contentVersion.getDocId();
        this.id = contentVersion.getId();
    }

    public Integer getDocumentId() {
        return documentId;
    }
}

package com.imcode.imcms.mapping.jpa.doc.content;

import com.imcode.imcms.mapping.jpa.doc.Version;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@MappedSuperclass
public abstract class VersionedContent {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "doc_id", unique = true, nullable = false, insertable = false, updatable = false)
    private Integer documentId;

    @NotNull
    @ManyToOne
    @JoinColumns({
            @JoinColumn(name = "doc_id", referencedColumnName = "doc_id"),
            @JoinColumn(name = "doc_version_no", referencedColumnName = "no")
    })
    private Version version;

    public Integer getId() {
        return id;
    }

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

    public Version getVersion() {
        return version;
    }

    public void setVersion(Version contentVersion) {
        this.version = contentVersion;
        this.documentId = contentVersion.getDocId();
    }

    public Integer getDocumentId() {
        return documentId;
    }
}

Apply new UI to the admin panel and editors: - Versioned content no more stealing it's version's id.
IMCMS-233: Apply new UI to the admin panel and editors:
- Versioned content no more stealing it's version's id.
