edu.ku.brc.specify.datamodel.AgentGeography.java Source code

Java tutorial

Introduction

Here is the source code for edu.ku.brc.specify.datamodel.AgentGeography.java

Source

/* Copyright (C) 2015, University of Kansas Center for Research
 * 
 * Specify Software Project, specify@ku.edu, Biodiversity Institute,
 * 1345 Jayhawk Boulevard, Lawrence, Kansas, 66045, USA
 * 
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
package edu.ku.brc.specify.datamodel;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.StringUtils;

/**
 * @author mkelly
 * 
 * @code_status Alpha
 * 
 * Created Date: Aug 14, 2008
 */

@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@org.hibernate.annotations.Proxy(lazy = false)
@Table(name = "agentgeography")
public class AgentGeography extends DataModelObjBase implements Serializable, Cloneable {

    protected Integer agentGeographyId;
    protected String role;
    protected String remarks;

    protected Agent agent;
    protected Geography geography;

    public AgentGeography() {
        super();
    }

    public AgentGeography(Integer agentGeographyId) {
        super();
        this.agentGeographyId = agentGeographyId;
    }

    /* (non-Javadoc)
     * @see edu.ku.brc.specify.datamodel.DataModelObjBase#initialize()
     */
    @Override
    public void initialize() {
        super.init();
        agentGeographyId = null;
        role = null;
        remarks = null;
        agent = null;
        geography = null;
    }

    @Id
    @GeneratedValue
    @Column(name = "AgentGeographyID", unique = false, nullable = false, insertable = true, updatable = true)
    public Integer getAgentGeographyId() {
        return agentGeographyId;
    }

    /*
     * (non-Javadoc)
     * 
     * @see edu.ku.brc.specify.datamodel.DataModelObjBase#getId()
     */
    @Override
    @Transient
    public Integer getId() {
        return this.agentGeographyId;
    }

    /* (non-Javadoc)
     * @see edu.ku.brc.ui.forms.FormDataObjIFace#getDataClass()
     */
    @Transient
    @Override
    public Class<?> getDataClass() {
        return AgentGeography.class;
    }

    public void setAgentGeographyId(Integer agentGeographyId) {
        this.agentGeographyId = agentGeographyId;
    }

    @Column(name = "Role", unique = false, nullable = true, insertable = true, updatable = true, length = 64)
    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    @Lob
    @Column(name = "Remarks", length = 4096)
    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    /**
     * @return the agent
     */
    @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
    @JoinColumn(name = "AgentID", unique = false, nullable = false, insertable = true, updatable = true)
    public Agent getAgent() {
        return agent;
    }

    /**
     * @param agent the agent to set
     */
    public void setAgent(Agent agent) {
        this.agent = agent;
    }

    /**
     * @return the geography
     */
    @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
    @JoinColumn(name = "GeographyID", unique = false, nullable = false, insertable = true, updatable = true)
    public Geography getGeography() {
        return geography;
    }

    /**
     * @param geography the geography to set
     */
    public void setGeography(Geography geography) {
        this.geography = geography;
    }

    /* (non-Javadoc)
     * @see edu.ku.brc.specify.datamodel.DataModelObjBase#getParentTableId()
     */
    @Override
    @Transient
    public Integer getParentTableId() {
        return Agent.getClassTableId();
    }

    /* (non-Javadoc)
     * @see edu.ku.brc.specify.datamodel.DataModelObjBase#getParentId()
     */
    @Override
    @Transient
    public Integer getParentId() {
        return agent != null ? agent.getId() : null;
    }

    /* (non-Javadoc)
     * @see edu.ku.brc.ui.forms.FormDataObjIFace#getTableId()
     */
    @Override
    @Transient
    public int getTableId() {
        return getClassTableId();
    }

    /**
     * @return the Table ID for the class.
     */
    public static int getClassTableId() {
        return 78;
    }

    /* (non-Javadoc)
     * @see edu.ku.brc.specify.datamodel.DataModelObjBase#getIdentityTitle()
     */
    @Override
    @Transient
    public String getIdentityTitle() {
        String name = "";
        if (agent != null) {
            name = agent.getIdentityTitle();
        }

        if (StringUtils.isNotEmpty(name)) {
            return name;
        }

        return super.getIdentityTitle();
    }

    /* (non-Javadoc)
     * @see edu.ku.brc.specify.datamodel.DataModelObjBase#clone()
     */
    @Override
    public Object clone() throws CloneNotSupportedException {
        AgentGeography obj = (AgentGeography) super.clone();
        obj.setAgentGeographyId(null);
        return obj;
    }
}