org.libreplan.business.users.entities.UserCoach.java Source code

Java tutorial

Introduction

Here is the source code for org.libreplan.business.users.entities.UserCoach.java

Source

/*
 * This file is part of LibrePlan
 *
 * Copyright (C) 2009-2010 Fundacin para o Fomento da Calidade Industrial e
 *                         Desenvolvemento Tecnolxico de Galicia
 * Copyright (C) 2010-2013 Igalia, S.L.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.libreplan.business.users.entities;

import java.util.Date;

import org.joda.time.LocalDate;
import org.libreplan.business.common.BaseEntity;
import org.libreplan.business.common.IHumanIdentifiable;

/**
 * Entity for modeling UserCoach.
 *
 * @author Dergen Lee
 */

public class UserCoach extends BaseEntity implements IHumanIdentifiable {
    private User user;
    private User coach;
    private LocalDate fromDate;
    private LocalDate toDate;

    /**
     * Necessary for Hibernate. Please, do not call it.
     */
    public UserCoach() {
    }

    public static UserCoach create() {
        return create(new UserCoach());
    }

    public static UserCoach create(User user, User coach) {
        UserCoach sup = create(new UserCoach());
        sup.setUser(user);
        sup.setCoach(coach);
        return sup;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public User getCoach() {
        return coach;
    }

    public void setCoach(User coach) {
        this.coach = coach;
    }

    public LocalDate getFromDate() {
        return fromDate;
    }

    public void setFromDate(LocalDate fromDate) {
        this.fromDate = fromDate;
    }

    public LocalDate getToDate() {
        return toDate;
    }

    public void setToDate(LocalDate toDate) {
        this.toDate = toDate;
    }

    @Override
    public String getHumanId() {
        return (user == null) ? "" : user.getHumanId();
    }

    public Date getFromDate_() {
        if (this.fromDate != null)
            return this.fromDate.toDate();
        else
            return null;
    }

    public void setFromDate_(Date from) {
        this.fromDate = LocalDate.fromDateFields(from);
    }

    public Date getToDate_() {
        if (this.toDate != null)
            return this.toDate.toDate();
        else
            return null;
    }

    public void setToDate_(Date to) {
        this.toDate = LocalDate.fromDateFields(to);
    }
}