package com.tootsville.tootsbook.client.util;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.google.gwt.user.client.ui.Panel;
import com.tootsville.tootsbook.client.panel.wallobjects.PostPanel;
import com.tootsville.tootsbook.client.panel.wallobjects.WallObject;

/**
 * WRITEME: Document this type. twheys@gmail.com Jan 19, 2010
 * 
 * @author <a href="mailto:twheys@gmail.com@resinteractive.com">Tim
 *         Heys</a>
 */
public class Post implements IsSerializable {

	/**
	 * WRITEME: Document this type. twheys@gmail.com Feb 10, 2010
	 * 
	 * @author <a href="mailto:twheys@gmail.com@resinteractive.com">Tim
	 *         Heys</a>
	 */
	public enum PostPanelTypes {
		/**
		 * WRITEME: Document this field. twheys@gmail.com Feb 10, 2010
		 */
		EVENT_PANEL, /**
		 * WRITEME: Document this field. twheys@gmail.com
		 * Feb 10, 2010
		 */
		POST_PANEL
	}

	/**
    *
    */
	private String attachmentURL = null;

	/**
	 *
	 */
	private ShadowUser author = null;

	/**
	 *
	 */
	private transient Panel containingPanel;

	/**
	 *
	 */
	private int id = 0;

	/**
	 *
	 */
	private String message = "";

	/**
	 *
	 */
	private Post parent = null;

	/**
	 *
	 */
	private int parentID = 0;

	/**
	 *
	 */
	private long stampMillis = 0;

	/**
	 *
	 */
	private PostPanelTypes type = PostPanelTypes.POST_PANEL;

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * A Post WRITEME...
	 */
	public Post () {
		// do nothing, empty object
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 4, 2010
	 * </pre>
	 * 
	 * A Post WRITEME...
	 * 
	 * @param newAuthor WRITEME twheys@gmail.com
	 * @param newMessage WRITEME twheys@gmail.com
	 */
	public Post (final ShadowUser newAuthor, final String newMessage) {
		this (newAuthor, newMessage, System.currentTimeMillis ());
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 4, 2010
	 * </pre>
	 * 
	 * A Post WRITEME...
	 * 
	 * @param newAuthor WRITEME twheys@gmail.com
	 * @param newMessage WRITEME twheys@gmail.com
	 * @param newStamp WRITEME twheys@gmail.com
	 */
	public Post (final ShadowUser newAuthor, final String newMessage,
			final long newStamp) {
		author = newAuthor;
		message = newMessage;
		stampMillis = newStamp;
		parent = null;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 4, 2010
	 * </pre>
	 * 
	 * A Post WRITEME...
	 * 
	 * @param newAuthor WRITEME twheys@gmail.com
	 * @param newMessage WRITEME twheys@gmail.com
	 * @param newStamp WRITEME twheys@gmail.com
	 * @param newParent WRITEME twheys@gmail.com
	 */
	public Post (final ShadowUser newAuthor, final String newMessage,
			final long newStamp, final Post newParent) {
		author = newAuthor;
		message = newMessage;
		stampMillis = newStamp;
		parent = newParent;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 4, 2010
	 * </pre>
	 * 
	 * A Post WRITEME...
	 * 
	 * @param newAuthor WRITEME twheys@gmail.com
	 * @param newMessage WRITEME twheys@gmail.com
	 * @param newParent WRITEME twheys@gmail.com
	 */
	public Post (final ShadowUser newAuthor, final String newMessage,
			final Post newParent) {
		this (newAuthor, newMessage, System.currentTimeMillis (),
				newParent);
	}

	/**
	 * @return the attachmentURL
	 */
	public String getAttachmentURL () {
		return attachmentURL;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * TO getAuthor WRITEME...
	 * 
	 * @return WRITEME twheys@gmail.com
	 */
	public ShadowUser getAuthor () {
		// default getter (twheys@gmail.com, Oct 22, 2009)
		return author;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * TO getContainingPanel WRITEME...
	 * 
	 * @return WRITEME twheys@gmail.com
	 */
	public Panel getContainingPanel () {
		return containingPanel;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 4, 2010
	 * </pre>
	 * 
	 * TO getId WRITEME...
	 * 
	 * @return WRITEME twheys@gmail.com
	 */
	public int getId () {
		return id;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * TO getMessage WRITEME...
	 * 
	 * @return WRITEME twheys@gmail.com
	 */
	public String getMessage () {
		// default getter (twheys@gmail.com, Oct 19, 2009)
		return message;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 10, 2010
	 * </pre>
	 * 
	 * TO getPanel WRITEME...
	 * 
	 * @return WRITEME twheys@gmail.com
	 */
	public WallObject getPanel () {
		switch (type) {
			case EVENT_PANEL:
				break;
			case POST_PANEL:
				return new PostPanel (this);
		}
		return null;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * TO getParent WRITEME...
	 * 
	 * @return WRITEME twheys@gmail.com
	 */
	public Post getParent () {
		return parent;
	}

	/**
	 * @return the parentID
	 */
	public int getParentID () {
		return parentID;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Feb 4, 2010
	 * </pre>
	 * 
	 * TO getTimeStamp WRITEME...
	 * 
	 * @return WRITEME twheys@gmail.com
	 */
	public long getTimeStamp () {
		return stampMillis;
	}

	/**
	 * @return the attachmentURL
	 */
	public boolean hasAttachment () {
		return null != attachmentURL;
	}

	/**
	 * @param newAttachmentURL the attachmentURL to set
	 */
	public void setAttachmentURL (final String newAttachmentURL) {
		attachmentURL = newAttachmentURL;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * TO setAuthor WRITEME...
	 * 
	 * @param newAuthor WRITEME twheys@gmail.com
	 */
	public void setAuthor (final ShadowUser newAuthor) {
		author = newAuthor;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * TO setContainingPanel WRITEME...
	 * 
	 * @param newContainingPanel WRITEME twheys@gmail.com
	 */
	public void setContainingPanel (final Panel newContainingPanel) {
		containingPanel = newContainingPanel;
	}

	/**
	 * WRITEME: Document this field. twheys@gmail.com Dec 11, 2009
	 * 
	 * @param newId WRITEME twheys@gmail.com
	 */
	public void setId (final int newId) {
		id = newId;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * TO setMessage WRITEME...
	 * 
	 * @param newMessage WRITEME twheys@gmail.com
	 */
	public void setMessage (final String newMessage) {
		// default setter (twheys@gmail.com, Oct 19, 2009)
		message = newMessage;
	}

	/**
	 * <pre>
	 * twheys@gmail.com Jan 19, 2010
	 * </pre>
	 * 
	 * TO setParent WRITEME...
	 * 
	 * @param newParent WRITEME twheys@gmail.com
	 */
	public void setParent (final Post newParent) {
		// default setter (twheys@gmail.com, Oct 19, 2009)
		parent = newParent;
	}

	/**
	 * @param newParentID the parentID to set
	 */
	public void setParentID (final int newParentID) {
		parentID = newParentID;
	}

	/**
	 * @param newStamp the stamp to set
	 */
	public void setTimeStamp (final long newStamp) {
		stampMillis = newStamp;
	}

	/**
	 * @param newType the type to set
	 */
	public void setType (final PostPanelTypes newType) {
		type = newType;
	}
}
