/*
 * This file is part of NavalPlan
 *
 * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
 *                         Desenvolvemento Tecnolóxico de Galicia
 * Copyright (C) 2010-2011 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.externalcompanies.entities;

import java.util.Date;

import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;
import org.libreplan.business.common.BaseEntity;
import org.libreplan.business.orders.entities.Order;

/**
 * Entity CustomerComunication
 *
 * @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
 */
public class CustomerComunication extends BaseEntity{

    private Date deadline;

    private ComunicationType comunicationType;

    private Date comunicationDate;

    private Boolean reviewed = false;

    private Order order;

    public CustomerComunication() {
        this.setComunicationDate(new Date());
    }

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

    public CustomerComunication(Date deadline) {
        this.setDeadline(deadline);
        this.setComunicationDate(new Date());
    }

    public static CustomerComunication createToday(Date deadline) {
        return (CustomerComunication) create(new CustomerComunication(deadline));
    }

    public static CustomerComunication createTodayNewProject(Date deadline) {
        return (CustomerComunication) create(new CustomerComunication(deadline,
                new Date(), ComunicationType.NEW_PROJECT));
    }

    protected CustomerComunication(Date deadline, Date comunicationDate, ComunicationType comunicationType) {
        this.setDeadline(deadline);
        this.setComunicationDate(comunicationDate);
        this.setComunicationType(comunicationType);
    }

    protected CustomerComunication(Date deadline, Date comunicationDate, ComunicationType comunicationType, Order order) {
        this.setDeadline(deadline);
        this.setComunicationDate(comunicationDate);
        this.setComunicationType(comunicationType);
        this.setOrder(order);
    }

    public static CustomerComunication create(Date deadline, Date comunicationDate, ComunicationType comunicationType) {
        return (CustomerComunication) create(new CustomerComunication(deadline, comunicationDate, comunicationType));
    }

    public static CustomerComunication create(Date deadline, Date comunicationDate, ComunicationType comunicationType, Order order) {
        return (CustomerComunication) create(new CustomerComunication(deadline, comunicationDate, comunicationType, order));
    }

    public void setDeadline(Date deadline) {
        this.deadline = deadline;
    }

    public Date getDeadline() {
        return deadline;
    }

    public void setComunicationType(ComunicationType comunicationType) {
        this.comunicationType = comunicationType;
    }

    public ComunicationType getComunicationType() {
        return comunicationType;
    }

    public void setComunicationDate(Date comunicationDate) {
        this.comunicationDate = comunicationDate;
    }

    public Date getComunicationDate() {
        return comunicationDate;
    }

    public void setReviewed(Boolean reviewed) {
        this.reviewed = reviewed;
    }

    public Boolean getReviewed() {
        return reviewed;
    }

    public void setOrder(Order order) {
        this.order = order;
    }

    @NotNull(message = "order not specified")
    public Order getOrder() {
        return order;
    }
}

@@ -1506,38 +1506,180 @@
    p
-ublic CustomerComunication() %7B
+rotected CustomerComunication() %7B%0A        this.setComunicationDate(new Date());%0A    %7D%0A%0A    private CustomerComunication(Date deadline) %7B%0A        this.setDeadline(deadline);
 %0A   
@@ -1863,146 +1863,8 @@
  %7D%0A%0A
-    public CustomerComunication(Date deadline) %7B%0A        this.setDeadline(deadline);%0A        this.setComunicationDate(new Date());%0A    %7D%0A%0A
     

use private visibility in constructors.