package com.eshore.gringotts.web.domain.resource.entity.type;

import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = Constants.TABLE_PREFIX + "resource_type_file")
@NamedEntityGraph(name = "file_resource_type.detail", attributeNodes = {
        @NamedAttributeNode(value = "file")
})
public class FileResourceType extends ResourceType {
    @OneToOne
    @JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    private DataFile file;

    @Override
    public Type getResourceType() {
        return Type.FILE;
    }
}
