/*
 *  The MIT License (MIT)
 *
 *  View the full license at:
 *  https://github.com/hendrixjoseph/FamilyTree/blob/master/LICENSE.md
 *
 *  Copyright (c) 2015 Joseph Hendrix
 *
 *  Hosted on GitHub at https://github.com/hendrixjoseph/FamilyTree
 *
 */

package edu.wright.hendrix11.familyTree.entity.event;

import edu.wright.hendrix11.familyTree.entity.place.Place;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

import java.time.Month;
import java.time.format.TextStyle;
import java.util.Date;
import java.util.Locale;

import static javax.persistence.CascadeType.ALL;

/**
 * @author Joe Hendrix <hendrix.11@wright.edu>
 */
@MappedSuperclass
public abstract class Event
{
    private boolean about = false;
    private Integer day;
    @Enumerated(EnumType.STRING)
    private Month month;
    @ManyToOne(cascade = ALL)
    @JoinColumn(name = "PLACE_ID")
    private Place place;
    private Integer year;

    /**
     * Returns the date the event happened. Keep in mind this might be and approximate date, or not all fields may
     * actually be known. Also, it is recommended to get the formatted date string from {@link #getDateString()} rather
     * than just formatting the date this method returns.
     *
     * @return the date the event happened
     *
     * @see #getDateString()
     * @see #isAbout
     */
    public Date getDate()
    {
        return null;
    }

    /**
     * Returns the place this event happened. This event also happened in all regions of this place.
     *
     * @return the place this event happened
     *
     * @see Place#getRegion()
     * @see Place#iterator()
     */
    public Place getPlace()
    {
        return place;
    }

    /**
     * Sets the place this event happened. This event also happened in all regions of this place.
     *
     * @param place the place this event happened
     */
    public void setPlace(Place place)
    {
        this.place = place;
    }

    /**
     * Returns {@code true} if the date is just an approximate.
     *
     * @return {@code true} if the date is just an approximate
     */
    public boolean isAbout()
    {
        return about;
    }

    /**
     * Set if the date is an approximate date.
     *
     * @param about if the date is an approximate date
     */
    public void setAbout(boolean about)
    {
        this.about = about;
    }

    /**
     * @return
     */
    public Integer getDay()
    {
        return day;
    }

    /**
     * @param day
     */
    public void setDay(Integer day)
    {
        this.day = day;
    }

    /**
     * @return
     */
    public Month getMonth()
    {
        return month;
    }

    /**
     * @param month
     */
    public void setMonth(Month month)
    {
        this.month = month;
    }

    /**
     * @return
     */
    public Integer getYear()
    {
        return year;
    }

    /**
     * @param year
     */
    public void setYear(Integer year)
    {
        this.year = year;
    }

    /**
     * Constructs and returns the date string.
     *
     * @return the formatted date string
     */
    public String getDateString()
    {
        StringBuilder sb = new StringBuilder();

        if ( month != null )
            sb.append(month.getDisplayName(TextStyle.SHORT, Locale.US));

        if ( month != null && day != null )
            sb.append(" ");

        if ( day != null )
            sb.append(day);

        if ( day != null && year != null )
            sb.append(", ");

        if ( year != null )
            sb.append(year);

        return sb.toString();
    }
}

@@ -1147,18 +1147,19 @@
 e date, 
-or
+and
  not all
@@ -1427,26 +1427,24 @@
 etDateString
-()
 %0A     * @see
@@ -2496,39 +2496,159 @@
 %0A    /**%0A     * 
-@return
+Returns the day of the month. If the day is not known, it will return %7B@code null%7D.%0A     * %0A     * @return the day of the month
 %0A     */%0A    pub
@@ -2720,18 +2720,81 @@
   * 
-@param day
+Sets the day of the month.%0A     * %0A     * @param day the day of the month
 %0A   
@@ -2878,39 +2878,163 @@
 %0A    /**%0A     * 
-@return
+Returns the month of the year. If the month is not known, it will return %7B@code null%7D.%0A     * %0A     * @return the month of the year
 %0A     */%0A    pub
@@ -3108,20 +3108,85 @@
   * 
-@param month
+Sets the month of the year.%0A     * %0A     * @param month the month of the year
 %0A   
@@ -3284,23 +3284,120 @@
 %0A     * 
-@return
+Returns the year. If the year is not known, it will return %7B@code null%7D.%0A     * %0A     * @return the year
 %0A     */
@@ -3475,22 +3475,61 @@
 %0A     * 
-@param
+Sets the year.%0A     * %0A     * @param year the
  year%0A  

Update Event.java