/*
 * Copyright 2004-2007 IDCA. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 * 
 *    1. Redistributions of source code must retain the above copyright notice, this list of conditions and
 *        the following disclaimer.
 *    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
 *        and the following disclaimer in the documentation and/or other materials provided with the
 *        distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are those of the authors and
 * should not be interpreted as representing official policies, either expressed or implied, of IDCA.
 */

package com.idcanet.vasc.impl;

import java.util.ArrayList;
import java.util.List;

import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.vasc.validators.VascValidator;


/**
 * 
 * @author Willem Cazander
 * @version 1.0 Mar 21, 2007
 */
public class DefaultVascEntryField implements VascEntryField {
	
	private VascEntry vascEntry = null;

	private String id = null;
	private String backendName = null;
	private String displayName = null;

	private VascEntryFieldType vascEntryFieldType = null;
	private VascEntryFieldValue vascEntryFieldValue = null;
	private List<VascValidator> vascValidators = null;
	
	private String name = null;
	private String description = null;
	private String helpId = null;
	private String image = null;
	private Integer orderIndex = null;
	private Object defaultValue = null;
	
	private Integer sizeList = null;
	private Integer sizeEdit = null;
	private String styleList = null;
	private String styleEdit = null;
	
	private String choices = null;
	private Boolean choicesAsRadio = null;
	
	/** Defines if this columns is used in interface list,create,edit **/
	private Boolean view = null;
	private Boolean optional = null;
	
	/** Defines per view state of this field **/
	private Boolean create = null;
	private Boolean edit = null;
	private Boolean editReadOnly = null;
	private Boolean editBlank = null;
	private Boolean list = null;

	/** Defines the roles stuff if all up is true **/
	private String rolesCreate = null;
	private String rolesEdit = null;
	private String rolesEditReadOnly = null;
	private String rolesList = null;
	
	private Boolean sortable = null;
	private Boolean sumable = null;
	private Boolean graphable = null;
	
	public DefaultVascEntryField() {
		vascValidators = new ArrayList<VascValidator>(5);
	}
	
	public DefaultVascEntryField(String id) {
		this();
		setId(id);
	}
	
	/**
	 * @see java.lang.Object#clone()
	 */
	@Override
	public VascEntryField clone() throws CloneNotSupportedException {
		DefaultVascEntryField result = new DefaultVascEntryField();
		result.id=id;
		result.backendName=backendName;
		result.displayName=displayName;
		result.vascEntryFieldType=vascEntryFieldType;
		result.name=name;
		result.description=description;
		result.helpId=helpId;
		result.image=image;
		result.defaultValue=defaultValue;
		result.orderIndex=orderIndex;
		result.sizeList=sizeList;
		result.sizeEdit=sizeEdit;
		result.styleList=styleList;
		result.styleEdit=styleEdit;
		result.choices=choices;
		result.choicesAsRadio=choicesAsRadio;
		result.view=view;
		result.optional=optional;
		result.create=create;
		result.edit=edit;
		result.editReadOnly=editReadOnly;
		result.editBlank=editBlank;
		result.list=list;
		
		result.rolesCreate=rolesCreate;
		result.rolesEdit=rolesEdit;
		result.rolesEditReadOnly=rolesEditReadOnly;
		result.rolesList=rolesList;
		
		result.sortable=sortable;
		result.sumable=sumable;
		result.graphable=graphable;
		
		// this polls full backend..
		//result.vascEntryFieldValue=vascEntryFieldValue;
		
		for (VascValidator val:vascValidators) {
			result.vascValidators.add(val.clone());
		}
		
		return result;
	}

	public VascEntry getVascEntry() {
		return vascEntry;
	}
	
	public void setVascEntry(VascEntry vascEntry) {
		this.vascEntry=vascEntry;
	}
	
	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}
	
	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}
	
	/**
	 * @return the vascEntryFieldType
	 */
	public VascEntryFieldType getVascEntryFieldType() {
		return vascEntryFieldType;
	}
	
	/**
	 * @param vascEntryFieldType the vascEntryFieldType to set
	 */
	public void setVascEntryFieldType(VascEntryFieldType vascEntryFieldType) {
		this.vascEntryFieldType = vascEntryFieldType;
	}
	
	/**
	 * @return the backendName
	 */
	public String getBackendName() {
		return backendName;
	}
	
	/**
	 * @param backendName the backendName to set
	 */
	public void setBackendName(String backendName) {
		this.backendName = backendName;
	}
	
	/**
	 * @return the vascEntryFieldValue
	 */
	public VascEntryFieldValue getVascEntryFieldValue() {
		return vascEntryFieldValue;
	}
	
	/**
	 * @param vascEntryFieldValue the vascEntryFieldValue to set
	 */
	public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue) {
		this.vascEntryFieldValue = vascEntryFieldValue;
	}
		
	/**
	 * @return the vascValidators
	 */
	public List<VascValidator> getVascValidators() {
		return vascValidators;
	}
	
	/**
	 * @param vascValidators the vascValidators to add
	 */
	public void addVascValidator(VascValidator vascValidator) {
		this.vascValidators.add(vascValidator);
	}

	/**
	 * @param vascValidators the vascValidators to remove
	 */
	public void removeVascValidator(VascValidator vascValidator) {
		this.vascValidators.remove(vascValidator);
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	/**
	 * @return the helpId
	 */
	public String getHelpId() {
		return helpId;
	}
	
	/**
	 * @param helpId the helpId to set
	 */
	public void setHelpId(String helpId) {
		this.helpId = helpId;
	}
	
	/**
	 * @return the image
	 */
	public String getImage() {
		return image;
	}
	
	/**
	 * @param image the image to set
	 */
	public void setImage(String image) {
		this.image = image;
	}
	
	/**
	 * @return the defaultValue
	 */
	public Object getDefaultValue() {
		return defaultValue;
	}
	
	/**
	 * @param defaultValue the defaultValue to set
	 */
	public void setDefaultValue(Object defaultValue) {
		this.defaultValue = defaultValue;
	}
	
	/**
	 * @return the sizeList
	 */
	public Integer getSizeList() {
		return sizeList;
	}
	
	/**
	 * @param sizeList the sizeList to set
	 */
	public void setSizeList(Integer sizeList) {
		this.sizeList = sizeList;
	}
	
	/**
	 * @return the sizeEdit
	 */
	public Integer getSizeEdit() {
		return sizeEdit;
	}
	
	/**
	 * @param sizeEdit the sizeEdit to set
	 */
	public void setSizeEdit(Integer sizeEdit) {
		this.sizeEdit = sizeEdit;
	}
	
	/**
	 * @return the styleList
	 */
	public String getStyleList() {
		return styleList;
	}
	
	/**
	 * @param styleList the styleList to set
	 */
	public void setStyleList(String styleList) {
		this.styleList = styleList;
	}
	
	/**
	 * @return the styleEdit
	 */
	public String getStyleEdit() {
		return styleEdit;
	}
	
	/**
	 * @param styleEdit the styleEdit to set
	 */
	public void setStyleEdit(String styleEdit) {
		this.styleEdit = styleEdit;
	}
	
	/**
	 * @return the choices
	 */
	public String getChoices() {
		return choices;
	}
	
	/**
	 * @param choices the choices to set
	 */
	public void setChoices(String choices) {
		this.choices = choices;
	}
	
	/**
	 * @return the view
	 */
	public Boolean getView() {
		return view;
	}
	
	/**
	 * @param view the view to set
	 */
	public void setView(Boolean view) {
		this.view = view;
	}
	
	/**
	 * @return the optional
	 */
	public Boolean getOptional() {
		return optional;
	}
	
	/**
	 * @param optional the optional to set
	 */
	public void setOptional(Boolean optional) {
		this.optional = optional;
	}
	
	/**
	 * @return the create
	 */
	public Boolean getCreate() {
		return create;
	}
	
	/**
	 * @param create the create to set
	 */
	public void setCreate(Boolean create) {
		this.create = create;
	}
	
	/**
	 * @return the edit
	 */
	public Boolean getEdit() {
		return edit;
	}
	
	/**
	 * @param edit the edit to set
	 */
	public void setEdit(Boolean edit) {
		this.edit = edit;
	}
	
	/**
	 * @return the editReadOnly
	 */
	public Boolean getEditReadOnly() {
		return editReadOnly;
	}
	
	/**
	 * @param editReadOnly the editReadOnly to set
	 */
	public void setEditReadOnly(Boolean editReadOnly) {
		this.editReadOnly = editReadOnly;
	}
	
	/**
	 * @return the list
	 */
	public Boolean getList() {
		return list;
	}
	
	/**
	 * @param list the list to set
	 */
	public void setList(Boolean list) {
		this.list = list;
	}
	
	/**
	 * @return the rolesCreate
	 */
	public String getRolesCreate() {
		return rolesCreate;
	}
	
	/**
	 * @param rolesCreate the rolesCreate to set
	 */
	public void setRolesCreate(String rolesCreate) {
		this.rolesCreate = rolesCreate;
	}
	
	/**
	 * @return the rolesEdit
	 */
	public String getRolesEdit() {
		return rolesEdit;
	}
	
	/**
	 * @param rolesEdit the rolesEdit to set
	 */
	public void setRolesEdit(String rolesEdit) {
		this.rolesEdit = rolesEdit;
	}
	
	/**
	 * @return the rolesEditReadOnly
	 */
	public String getRolesEditReadOnly() {
		return rolesEditReadOnly;
	}
	
	/**
	 * @param rolesEditReadOnly the rolesEditReadOnly to set
	 */
	public void setRolesEditReadOnly(String rolesEditReadOnly) {
		this.rolesEditReadOnly = rolesEditReadOnly;
	}
	
	/**
	 * @return the rolesList
	 */
	public String getRolesList() {
		return rolesList;
	}
	
	/**
	 * @param rolesList the rolesList to set
	 */
	public void setRolesList(String rolesList) {
		this.rolesList = rolesList;
	}

	/**
	 * @return the choicesAsRadio
	 */
	public Boolean getChoicesAsRadio() {
		return choicesAsRadio;
	}

	/**
	 * @param choicesAsRadio the choicesAsRadio to set
	 */
	public void setChoicesAsRadio(Boolean choicesAsRadio) {
		this.choicesAsRadio = choicesAsRadio;
	}

	/**
	 * @return the editBlank
	 */
	public Boolean getEditBlank() {
		return editBlank;
	}

	/**
	 * @param editBlank the editBlank to set
	 */
	public void setEditBlank(Boolean editBlank) {
		this.editBlank = editBlank;
	}

	/**
	 * @return the displayName
	 */
	public String getDisplayName() {
		return displayName;
	}

	/**
	 * @param displayName the displayName to set
	 */
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	/**
	 * @return the orderIndex
	 */
	public Integer getOrderIndex() {
		return orderIndex;
	}

	/**
	 * @param orderIndex the orderIndex to set
	 */
	public void setOrderIndex(Integer orderIndex) {
		this.orderIndex = orderIndex;
	}

	/**
	 * @return the sortable
	 */
	public Boolean getSortable() {
		return sortable;
	}

	/**
	 * @param sortable the sortable to set
	 */
	public void setSortable(Boolean sortable) {
		this.sortable = sortable;
	}

	/**
	 * @return the sumable
	 */
	public Boolean getSumable() {
		return sumable;
	}

	/**
	 * @param sumable the sumable to set
	 */
	public void setSumable(Boolean sumable) {
		this.sumable = sumable;
	}

	/**
	 * @return the graphable
	 */
	public Boolean getGraphable() {
		return graphable;
	}

	/**
	 * @param graphable the graphable to set
	 */
	public void setGraphable(Boolean graphable) {
		this.graphable = graphable;
	}
}