no.abmu.questionnarie.domain.ReportDataOrgUnitMapping.java Source code

Java tutorial

Introduction

Here is the source code for no.abmu.questionnarie.domain.ReportDataOrgUnitMapping.java

Source

/*
 ****************************************************************************
 *                                                                          *
 *                   (c) Copyright 2006 ABM-utvikling                        *
 *                                                                          *
 * 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. http://www.gnu.org/licenses/gpl.html    *
 *                                                                          *
 ****************************************************************************
 */
package no.abmu.questionnarie.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.validator.NotNull;

/**
 * @author Erik Romson, erik@zenior.no
 * @author $Author:$
 * @version $Rev:$
 * @date $Date:$
 * @copyright ABM-Utvikling
 * @hibernate.class table="FINANCE_REPDATA_ORGUNIT_MAPPING"
 * @hibernate.cache usage="nonstrict-read-write"
 * @navassoc 1 - * no.abmu.finances.domain.ReportData
 * @navassoc 1 - 1 no.abmu.finances.domain.OrganisationUnit
 */
@javax.persistence.Entity
//@javax.persistence.Table(schema = "QUESTIONNARIE")
@javax.persistence.Table(name = "QUESTIONNARIE_RD_ORGUNIT")
public class ReportDataOrgUnitMapping implements no.abmu.common.domain.Entity {

    private static final Log logger = (Log) LogFactory.getLog(ReportDataOrgUnitMapping.class);

    private Long organisationUnitId;
    private Set<MainReportData> reportDatas = new HashSet<MainReportData>();
    private Long id;

    public ReportDataOrgUnitMapping() {
    }

    public ReportDataOrgUnitMapping(Long organisationUnit) {
        this.organisationUnitId = organisationUnit;
    }

    /**
     * @return
     * @hibernate.id generator-class="increment"
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    /**
     * unique_key="unique_orgunitid_repdata"
     *
     * @hibernate.many-to-one column="FK_ORGUNIT_ID"
     * class="no.abmu.organisationregister.domain.OrganisationUnit"
     * @hibernate.column name="FK_ORGUNIT_ID"
     * index="rdoum_FK_ORGUNIT_ID_idx"
     */
    //@OneToMany

    @Basic
    @NotNull
    public Long getOrganisationUnitId() {
        return organisationUnitId;
    }

    /**
     * unique_key="unique_orgunitid_repdata"
     *
     * @hibernate.set lazy="true"
     * cascade="save-update"
     * table="FINANCE_REPDATA_ORGUNIT_MAPPING_REPORT_DATA"
     * @hibernate.key column="FK_MAPPING_ID"
     * @hibernate.many-to-many class="no.abmu.finances.domain.MainReportData"
     * column="FK_REPORT_DATA_ID"
     * @hibernate.collection-key column="FK_MAPPING_ID"
     * @hibernate.collection-many-to-many class="no.abmu.finances.domain.MainReportData"
     * column="FK_REPORT_DATA_ID"
     */
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "ORGUNIT_MAPPING_ID")
    @NotNull
    public Set<MainReportData> getReportDatas() {
        return reportDatas;
    }

    public void addReportData(MainReportData reportData) {
        reportData.setOrgUnitMapping(this);
        reportDatas.add(reportData);
    }

    public void setOrganisationUnitId(Long organisationUnitId) {
        this.organisationUnitId = organisationUnitId;
    }

    private void setReportDatas(Set<MainReportData> reportData) {
        this.reportDatas = reportData;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        final ReportDataOrgUnitMapping mapping = (ReportDataOrgUnitMapping) o;

        if (id != null ? !id.equals(mapping.id) : mapping.id != null) {
            return false;
        }
        if (!organisationUnitId.equals(mapping.organisationUnitId)) {
            return false;
        }
        if (!reportDatas.equals(mapping.reportDatas)) {
            return false;
        }

        return true;
    }

    public int hashCode() {
        int result;
        result = organisationUnitId.hashCode();
        result = 29 * result + reportDatas.hashCode();
        return result;
    }
}