CooperatorAttachment.java

/*
 * Copyright 2020 Global Crop Diversity Trust
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gringlobal.model;

import lombok.Getter;
import lombok.Setter;
import org.genesys.blocks.annotations.NotCopyable;
import org.genesys.filerepository.model.RepositoryFile;
import org.gringlobal.model.community.IWebVisible;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * The Class CooperatorAttachment.
 *
 * @author Matija Obreza
 */
@MappedSuperclass
@Getter
@Setter
public abstract class CooperatorAttachment extends CooperatorOwnedModel implements IWebVisible, IAttachment {
	private static final long serialVersionUID = 1L;

	@Basic
	@Size(max = 500)
	@Column(length = 500)
	protected String title;

	@Basic
	@NotNull
	@NotCopyable
	@Column(name = "virtual_path", nullable = false)
	protected String virtualPath;

	@Basic
	@NotCopyable
	@Column(name = "thumbnail_virtual_path")
	protected String thumbnailVirtualPath;

	@Basic
	@Size(max = 100)
	@Column(name = "content_type", length = 100)
	protected String contentType;

	@Basic
	@NotNull
	@Size(min = 1, max = 1)
	@Column(name = "is_web_visible", nullable = false, length = 1)
	protected String isWebVisible;

	@Basic
	@Column(name = "sort_order")
	protected Integer sortOrder;

	@Basic
	@Column
	@Lob
	protected String note;

	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "repositoryFileId", unique = false)
	protected RepositoryFile repositoryFile;

	@Override
	public void lazyLoad() {
		super.lazyLoad();
		lazyLoad(this.repositoryFile);
	}
}