RepositoryDocument.java
/*
* Copyright 2018 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.filerepository.model;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import org.genesys.filerepository.metadata.DocumentMetadata;
import org.hibernate.annotations.Type;
/**
* An {@link RepositoryDocument} is a text document in the repository.
*
* @author mobreza
*/
@Cacheable
@Entity
@Table(name = "repository_document")
@Getter
@Setter
public class RepositoryDocument extends RepositoryFile implements DocumentMetadata {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 463013109027900550L;
/** The language. */
@Column(name = "language")
private String language;
/** The abstrct. */
@Column(name = "abstract")
@Lob
@Type(type = "org.hibernate.type.TextType")
private String abstrct;
/*
* (non-Javadoc)
* @see org.genesys.filerepository.model.RepositoryFile#prePersist()
*/
@Override
@PrePersist
@PreUpdate
protected void prePersist() {
// Don't forget the superclass!
super.prePersist();
}
/*
* (non-Javadoc)
* @see org.genesys.filerepository.metadata.DocumentMetadata#getLanguage()
*/
@Override
public String getLanguage() {
return language;
}
/**
* Sets the language.
*
* @param language the new language
*/
public void setLanguage(final String language) {
this.language = language;
}
/*
* (non-Javadoc)
* @see org.genesys.filerepository.metadata.DocumentMetadata#getAbstract()
*/
@Override
public String getAbstract() {
return abstrct;
}
/**
* Sets the abstract.
*
* @param abstrct the new abstract
*/
public void setAbstract(final String abstrct) {
this.abstrct = abstrct;
}
/**
* Apply.
*
* @param source the source
* @return the repository document
*/
public RepositoryDocument apply(final RepositoryDocument source) {
super.apply(source);
this.abstrct = source.abstrct;
this.language = source.language;
return this;
}
@Override
public boolean canEqual(Object other) {
return other instanceof RepositoryDocument;
}
}