CooperatorOwnedModel.java

/*
 * Copyright 2019 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.genesys.server.model.grin;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import lombok.Getter;
import lombok.Setter;
import org.genesys.blocks.model.EmptyModel;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.time.Instant;
import java.util.Date;

/**
 * The Class CooperatorOwnedModel.
 */
@MappedSuperclass
@Getter
@Setter
public abstract class CooperatorOwnedModel extends EmptyModel {

	private static final long serialVersionUID = 1L;

	@Column(name = "created_by", nullable = false)
	@JsonIgnore
	private Long createdById;

	@Column(name = "created_date", nullable = false)
	@JsonIgnore
	private Instant createdDate;
	
	@Column(name = "owned_by", nullable = false)
	@JsonIgnore
	private Long ownedById;

	@Column(name = "owned_date", nullable = false)
	@JsonIgnore
	private Instant ownedDate;

	@Column(name = "modified_by")
	@JsonIgnore
	private Long modifiedById;
	
	@Column(name = "modified_date")
	@JsonIgnore
	private Instant modifiedDate;
	
	/**
	 * @param createdDate the createdDate to set
	 */
	public void setCreatedDate(Instant createdDate) {
		this.createdDate = createdDate;
	}

	/**
	 * @param ownedDate the ownedDate to set
	 */
	public void setOwnedDate(Instant ownedDate) {
		this.ownedDate = ownedDate;
	}

	/**
	 * @param modifiedDate the modifiedDate to set
	 */
	public void setModifiedDate(Instant modifiedDate) {
		this.modifiedDate = modifiedDate;
	}

	public void setOwnedDate(Date ownedDate) {
		setOwnedDate(ownedDate == null ? null : ownedDate.toInstant());
	}

	public void setCreatedDate(Date createdDate) {
		setCreatedDate(createdDate == null ? null : createdDate.toInstant());
	}

	public void setModifiedDate(Date modifiedDate) {
		setModifiedDate(modifiedDate == null ? null : modifiedDate.toInstant());
	}
}