AbstractBookkeepingTerm.java from Texai at Krugle
Show AbstractBookkeepingTerm.java syntax highlighted
/*
* Bookkeeping.java
*
* Created on April 17, 2007, 10:09 PM
*
* Description: Provides a bookkeeping record of creator, creation purpose and creation date.
*
* Copyright (C) 2007 Stephen L. Reed.
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.texai.kb.entity;
import java.util.Date;
import org.texai.kb.ejb.session.shared.KBPartitionFacadeLocal;
import org.texai.util.ByteUtils;
import org.texai.util.TexaiException;
/**
*
* @author reed
*/
public abstract class AbstractBookkeepingTerm extends AbstractTerm {
/** the term type of creator term of this atomic term */
private byte creatorTermType;
/** the term id of creator term of this atomic term */
private int creatorTermId;
/** the term type of the creation purpose of this atomic term */
private byte creationPurposeTermType;
/** the term id of the creation purpose of this atomic term */
private int creationPurposeTermId;
/** the creation date */
private Date creationDate;
/** Creates a new instance of AbstractBookkeepingTerm.
*
* @param termId the database term ID
* @param creator the creator of this atomic term
* @param creationPurpose the creation purpose of this atomic term
* @param creationDate the creation date
*/
public AbstractBookkeepingTerm(
final int termId,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose,
final Date creationDate) {
super(termId);
//Preconditions
assert creator != null : "creator must not be null";
assert creationPurpose != null : "creationPurpose must not be null";
assert creationDate != null : "creationDate must not be null";
creatorTermType = creator.getTermType();
creatorTermId = creator.getTermId();
creationPurposeTermType = creationPurpose.getTermType();
creationPurposeTermId = creationPurpose.getTermId();
this.creationDate = creationDate;
}
/** Creates a new instance of AbstractBookkeepingTerm. */
public AbstractBookkeepingTerm() {
super();
}
/** Creates a new instance of AbstractBookkeepingTerm.
*
* @param termId the database term ID
* @param creatorTermType the term type of creator term of this atomic term
* @param creatorTermId the term id of creator term of this atomic term
* @param creationPurposeTermType the term type of the creation purpose of this atomic term
* @param creationPurposeTermId the term id of the creation time point of this atomic term
* @param creationDate the creation date
*/
public AbstractBookkeepingTerm(
final int termId,
final byte creatorTermType,
final int creatorTermId,
final byte creationPurposeTermType,
final int creationPurposeTermId,
final Date creationDate) {
super(termId);
//Preconditions
assert creationDate != null : "creationDate must not be null";
this.creatorTermType = creatorTermType;
this.creatorTermId = creatorTermId;
this.creationPurposeTermType = creationPurposeTermType;
this.creationPurposeTermId = creationPurposeTermId;
this.creationDate = creationDate;
}
/** Gets the creator term type.
*
* @return the creator term type
*/
public byte getCreatorTermType() {
return creatorTermType;
}
/** Sets the creator term type.
*
* @param creatorTermType the creator term type
*/
public void setCreatorTermType(final byte creatorTermType) {
this.creatorTermType = creatorTermType;
}
/** Gets the creator term id.
*
* @return the creator term id
*/
public int getCreatorTermId() {
return creatorTermId;
}
/** Sets the creator term id
*
* @param creatorTermId the creator term id.
*/
public void setCreatorTermId(final int creatorTermId) {
//Preconditions
assert creatorTermId != 0 : "creatorTermId must not be zero";
this.creatorTermId = creatorTermId;
}
/** Gets the creator.
*
* @param kbPartitionFacade the KB partition facade
* @return the creator
*/
public AbstractReifiedTerm getCreator(final KBPartitionFacadeLocal kbPartitionFacade) {
if (kbPartitionFacade == null) {
throw new TexaiException("kbPartitionFacade must not be null");
}
return (AbstractReifiedTerm) kbPartitionFacade.findTermByTermTypeAndId(creatorTermType, creatorTermId);
}
/** Sets the creator.
*
* @param creator the creator
*/
public void setCreator(final AbstractReifiedTerm creator) {
//Preconditions
assert creator != null : "creator must not be null";
creatorTermType = creator.getTermType();
creatorTermId = creator.getTermId();
}
/** Gets the creation purpose term type.
*
* @return the creation purpose term type
*/
public byte getCreationPurposeTermType() {
return creationPurposeTermType;
}
/** Sets the creation purpose term type.
*
* @param creationPurposeTermType the creation purpose term type
*/
public void setCreationPurposeTermType(final byte creationPurposeTermType) {
this.creationPurposeTermType = creationPurposeTermType;
}
/** Gets the creation purpose term id.
*
* @return the creation purpose term id
*/
public int getCreationPurposeTermId() {
return creationPurposeTermId;
}
/** Sets the creation purpose term id.
*
* @param creationPurposeTermId the creation purpose term id
*/
public void setCreationPurposeTermId(final int creationPurposeTermId) {
//Preconditions
assert creationPurposeTermId != 0 : "creationPurposeTermId must not be zero";
this.creationPurposeTermId = creationPurposeTermId;
}
/** Gets the creation purpose.
*
* @param kbPartitionFacade the KB partition facade
* @return the creation purpose
*/
public AbstractReifiedTerm getCreationPurpose(final KBPartitionFacadeLocal kbPartitionFacade) {
if (kbPartitionFacade == null) {
throw new TexaiException("kbPartitionFacade must not be null");
}
return (AbstractReifiedTerm) kbPartitionFacade.findTermByTermTypeAndId(creationPurposeTermType, creationPurposeTermId);
}
/** Sets the creation purpose.
*
* @param creationPurpose the creation purpose
*/
public void setCreationPurpose(final AbstractReifiedTerm creationPurpose) {
//Preconditions
assert creationPurpose != null : "creationPurpose must not be null";
creationPurposeTermType = creationPurpose.getTermType();
creationPurposeTermId = creationPurpose.getTermId();
}
/** Gets the creation date.
*
* @return the creation date
*/
public Date getCreationDate() {
return creationDate;
}
/** Sets the creation date.
*
* @param creationTime the creation date
*/
public void setCreationDate(final Date creationDate) {
//Preconditions
assert creationDate != null : "creationDate must not be null";
this.creationDate = creationDate;
}
}
See more files for this project here