/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/admin/vo/AppTopButtonVo.java
//#############################################################################
//#                                                                           #
//#  Copyright (C) <2015>  <IMS MAXIMS>                                       #
//#                                                                           #
//#  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/>.    #
//#                                                                           #
//#  IMS MAXIMS provides absolutely NO GUARANTEE OF THE CLINICAL SAFTEY of    #
//#  this program.  Users of this software do so entirely at their own risk.  #
//#  IMS MAXIMS only ensures the Clinical Safety of unaltered run-time        #
//#  software that it builds, deploys and maintains.                          #
//#                                                                           #
//#############################################################################
//#EOH
// This code was generated by Barbara Worwood using IMS Development Environment (version 1.80 build 5589.25814)
// Copyright (C) 1995-2015 IMS MAXIMS. All rights reserved.
// WARNING: DO NOT MODIFY the content of this file

package ims.admin.vo;

/**
 * Linked to core.configuration.AppTopButton business object (ID: 1021100009).
 */
public class AppTopButtonVo extends ims.core.configuration.vo.AppTopButtonRefVo implements ims.vo.ImsCloneable, Comparable, ims.framework.interfaces.ITopButton
{
	private static final long serialVersionUID = 1L;

	public AppTopButtonVo()
	{
	}
	public AppTopButtonVo(Integer id, int version)
	{
		super(id, version);
	}
	public AppTopButtonVo(ims.admin.vo.beans.AppTopButtonVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.text = bean.getText();
		this.action = bean.getAction() == null ? null : ims.admin.vo.lookups.TopButtonAction.buildLookup(bean.getAction());
		this.buildin = bean.getBuildIn();
		this.form = bean.getForm() == null ? null : bean.getForm().buildFormName();
		this.url = bean.getURL();
		this.alwaysenabled = bean.getAlwaysEnabled();
		this.enabled = bean.getEnabled();
		this.contextdependent = bean.getContextDependent();
		this.patientmustbeselected = bean.getPatientMustBeSelected();
		this.displaymaximisebutton = bean.getDisplayMaximiseButton();
		this.displayclosebutton = bean.getDisplayCloseButton();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.AppTopButtonVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.text = bean.getText();
		this.action = bean.getAction() == null ? null : ims.admin.vo.lookups.TopButtonAction.buildLookup(bean.getAction());
		this.buildin = bean.getBuildIn();
		this.form = bean.getForm() == null ? null : bean.getForm().buildFormName();
		this.url = bean.getURL();
		this.alwaysenabled = bean.getAlwaysEnabled();
		this.enabled = bean.getEnabled();
		this.contextdependent = bean.getContextDependent();
		this.patientmustbeselected = bean.getPatientMustBeSelected();
		this.displaymaximisebutton = bean.getDisplayMaximiseButton();
		this.displayclosebutton = bean.getDisplayCloseButton();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.admin.vo.beans.AppTopButtonVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.AppTopButtonVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.AppTopButtonVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public Object getFieldValueByFieldName(String fieldName)
	{
		if(fieldName == null)
			throw new ims.framework.exceptions.CodingRuntimeException("Invalid field name");
		fieldName = fieldName.toUpperCase();
		if(fieldName.equals("TEXT"))
			return getText();
		if(fieldName.equals("ACTION"))
			return getAction();
		if(fieldName.equals("BUILDIN"))
			return getBuildIn();
		if(fieldName.equals("FORM"))
			return getForm();
		if(fieldName.equals("URL"))
			return getURL();
		if(fieldName.equals("ALWAYSENABLED"))
			return getAlwaysEnabled();
		if(fieldName.equals("ENABLED"))
			return getEnabled();
		if(fieldName.equals("CONTEXTDEPENDENT"))
			return getContextDependent();
		if(fieldName.equals("PATIENTMUSTBESELECTED"))
			return getPatientMustBeSelected();
		if(fieldName.equals("DISPLAYMAXIMISEBUTTON"))
			return getDisplayMaximiseButton();
		if(fieldName.equals("DISPLAYCLOSEBUTTON"))
			return getDisplayCloseButton();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getTextIsNotNull()
	{
		return this.text != null;
	}
	public String getText()
	{
		return this.text;
	}
	public static int getTextMaxLength()
	{
		return 255;
	}
	public void setText(String value)
	{
		this.isValidated = false;
		this.text = value;
	}
	public boolean getActionIsNotNull()
	{
		return this.action != null;
	}
	public ims.admin.vo.lookups.TopButtonAction getAction()
	{
		return this.action;
	}
	public void setAction(ims.admin.vo.lookups.TopButtonAction value)
	{
		this.isValidated = false;
		this.action = value;
	}
	public boolean getBuildInIsNotNull()
	{
		return this.buildin != null;
	}
	public Integer getBuildIn()
	{
		return this.buildin;
	}
	public void setBuildIn(Integer value)
	{
		this.isValidated = false;
		this.buildin = value;
	}
	public boolean getFormIsNotNull()
	{
		return this.form != null;
	}
	public ims.framework.FormName getForm()
	{
		return this.form;
	}
	public void setForm(ims.framework.FormName value)
	{
		this.isValidated = false;
		this.form = value;
	}
	public boolean getURLIsNotNull()
	{
		return this.url != null;
	}
	public String getURL()
	{
		return this.url;
	}
	public static int getURLMaxLength()
	{
		return 200;
	}
	public void setURL(String value)
	{
		this.isValidated = false;
		this.url = value;
	}
	public boolean getAlwaysEnabledIsNotNull()
	{
		return this.alwaysenabled != null;
	}
	public Boolean getAlwaysEnabled()
	{
		return this.alwaysenabled;
	}
	public void setAlwaysEnabled(Boolean value)
	{
		this.isValidated = false;
		this.alwaysenabled = value;
	}
	public boolean getEnabledIsNotNull()
	{
		return this.enabled != null;
	}
	public Boolean getEnabled()
	{
		return this.enabled;
	}
	public void setEnabled(Boolean value)
	{
		this.isValidated = false;
		this.enabled = value;
	}
	public boolean getContextDependentIsNotNull()
	{
		return this.contextdependent != null;
	}
	public Boolean getContextDependent()
	{
		return this.contextdependent;
	}
	public void setContextDependent(Boolean value)
	{
		this.isValidated = false;
		this.contextdependent = value;
	}
	public boolean getPatientMustBeSelectedIsNotNull()
	{
		return this.patientmustbeselected != null;
	}
	public Boolean getPatientMustBeSelected()
	{
		return this.patientmustbeselected;
	}
	public void setPatientMustBeSelected(Boolean value)
	{
		this.isValidated = false;
		this.patientmustbeselected = value;
	}
	public boolean getDisplayMaximiseButtonIsNotNull()
	{
		return this.displaymaximisebutton != null;
	}
	public Boolean getDisplayMaximiseButton()
	{
		return this.displaymaximisebutton;
	}
	public void setDisplayMaximiseButton(Boolean value)
	{
		this.isValidated = false;
		this.displaymaximisebutton = value;
	}
	public boolean getDisplayCloseButtonIsNotNull()
	{
		return this.displayclosebutton != null;
	}
	public Boolean getDisplayCloseButton()
	{
		return this.displayclosebutton;
	}
	public void setDisplayCloseButton(Boolean value)
	{
		this.isValidated = false;
		this.displayclosebutton = value;
	}
	/**
	* ITopButton
	*/
		public ims.framework.FormName getITopButtonForm() 
		{
			return form;
		}
		public int getITopButtonID() 
		{
			if(buildin != null)
				return buildin.intValue();
			return id == null ? 0 : id.intValue();
		}
		public String getITopButtonText() 
		{
			return text == null ? "" : text;
		}
		public String getITopButtonUrl() 
		{
			return url;
		}	
		public boolean getITopButtonIsAlwaysEnabled()
		{
			return alwaysenabled == null ? false : alwaysenabled.booleanValue();
		}	
		public boolean getITopButtonPatientMustBeSelected()
		{
			return patientmustbeselected == null ? false : patientmustbeselected.booleanValue();
		}
		public boolean getITopButtonEnabled()
		{
			return enabled == null ? false : enabled.booleanValue();
		}
		public void setITopButtonEnabled(boolean value)
		{
			this.enabled = value;
		}
		public boolean getITopButtonContextDependent()
		{
			return contextdependent== null ? false : contextdependent.booleanValue();
		}
		public void setITopButtonContextDependent(boolean value)
		{
			this.contextdependent= value;
		}
		public boolean getITopButtonDisplayMaximiseButton()
		{
			return displaymaximisebutton == null ? false : displaymaximisebutton.booleanValue();
		}
		public boolean getITopButtonDisplayCloseButton()
		{
			return displayclosebutton == null ? false : displayclosebutton.booleanValue();
		}
	
	
	
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		this.isBusy = false;
		return true;
	}
	public String[] validate()
	{
		return validate(null);
	}
	public String[] validate(String[] existingErrors)
	{
		if(this.isBusy)
			return null;
		this.isBusy = true;
	
		java.util.ArrayList<String> listOfErrors = new java.util.ArrayList<String>();
		if(existingErrors != null)
		{
			for(int x = 0; x < existingErrors.length; x++)
			{
				listOfErrors.add(existingErrors[x]);
			}
		}
		if(this.text != null)
			if(this.text.length() > 255)
				listOfErrors.add("The length of the field [text] in the value object [ims.admin.vo.AppTopButtonVo] is too big. It should be less or equal to 255");
		if(this.url != null)
			if(this.url.length() > 200)
				listOfErrors.add("The length of the field [url] in the value object [ims.admin.vo.AppTopButtonVo] is too big. It should be less or equal to 200");
		int errorCount = listOfErrors.size();
		if(errorCount == 0)
		{
			this.isBusy = false;
			this.isValidated = true;
			return null;
		}
		String[] result = new String[errorCount];
		for(int x = 0; x < errorCount; x++)
			result[x] = (String)listOfErrors.get(x);
		this.isBusy = false;
		this.isValidated = false;
		return result;
	}
	public void clearIDAndVersion()
	{
		this.id = null;
		this.version = 0;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		AppTopButtonVo clone = new AppTopButtonVo(this.id, this.version);
		
		clone.text = this.text;
		if(this.action == null)
			clone.action = null;
		else
			clone.action = (ims.admin.vo.lookups.TopButtonAction)this.action.clone();
		clone.buildin = this.buildin;
		if(this.form == null)
			clone.form = null;
		else
			clone.form = (ims.framework.FormName)this.form.clone();
		clone.url = this.url;
		clone.alwaysenabled = this.alwaysenabled;
		clone.enabled = this.enabled;
		clone.contextdependent = this.contextdependent;
		clone.patientmustbeselected = this.patientmustbeselected;
		clone.displaymaximisebutton = this.displaymaximisebutton;
		clone.displayclosebutton = this.displayclosebutton;
		clone.isValidated = this.isValidated;
		
		this.isBusy = false;
		return clone;
	}
	public int compareTo(Object obj)
	{
		return compareTo(obj, true);
	}
	public int compareTo(Object obj, boolean caseInsensitive)
	{
		if (obj == null)
		{
			return -1;
		}
		if(caseInsensitive); // this is to avoid eclipse warning only.
		if (!(AppTopButtonVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A AppTopButtonVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((AppTopButtonVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((AppTopButtonVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.text != null)
			count++;
		if(this.action != null)
			count++;
		if(this.buildin != null)
			count++;
		if(this.form != null)
			count++;
		if(this.url != null)
			count++;
		if(this.alwaysenabled != null)
			count++;
		if(this.enabled != null)
			count++;
		if(this.contextdependent != null)
			count++;
		if(this.patientmustbeselected != null)
			count++;
		if(this.displaymaximisebutton != null)
			count++;
		if(this.displayclosebutton != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 11;
	}
	protected String text;
	protected ims.admin.vo.lookups.TopButtonAction action;
	protected Integer buildin;
	protected ims.framework.FormName form;
	protected String url;
	protected Boolean alwaysenabled;
	protected Boolean enabled;
	protected Boolean contextdependent;
	protected Boolean patientmustbeselected;
	protected Boolean displaymaximisebutton;
	protected Boolean displayclosebutton;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
