/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/admin/vo/ElectronicPrescribingConfigVo.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.admin.ElectronicPrescribingConfig business object (ID: 1004100055).
 */
public class ElectronicPrescribingConfigVo extends ims.core.admin.vo.ElectronicPrescribingConfigRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ElectronicPrescribingConfigVo()
	{
	}
	public ElectronicPrescribingConfigVo(Integer id, int version)
	{
		super(id, version);
	}
	public ElectronicPrescribingConfigVo(ims.admin.vo.beans.ElectronicPrescribingConfigVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.button = bean.getButton() == null ? null : ims.core.vo.lookups.ElectronicPrescribingButton.buildLookup(bean.getButton());
		this.buttontext = bean.getButtonText();
		this.labeltext = bean.getLabelText();
		this.buttonexecutablepath = bean.getButtonExecutablePath();
		this.buttonparameter = bean.getButtonParameter();
		this.buttondeniedroleaccess = ims.admin.vo.AppRoleShortVoCollection.buildFromBeanCollection(bean.getButtonDeniedRoleAccess());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.ElectronicPrescribingConfigVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.button = bean.getButton() == null ? null : ims.core.vo.lookups.ElectronicPrescribingButton.buildLookup(bean.getButton());
		this.buttontext = bean.getButtonText();
		this.labeltext = bean.getLabelText();
		this.buttonexecutablepath = bean.getButtonExecutablePath();
		this.buttonparameter = bean.getButtonParameter();
		this.buttondeniedroleaccess = ims.admin.vo.AppRoleShortVoCollection.buildFromBeanCollection(bean.getButtonDeniedRoleAccess());
	}
	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.ElectronicPrescribingConfigVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.ElectronicPrescribingConfigVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.ElectronicPrescribingConfigVoBean();
			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("BUTTON"))
			return getButton();
		if(fieldName.equals("BUTTONTEXT"))
			return getButtonText();
		if(fieldName.equals("LABELTEXT"))
			return getLabelText();
		if(fieldName.equals("BUTTONEXECUTABLEPATH"))
			return getButtonExecutablePath();
		if(fieldName.equals("BUTTONPARAMETER"))
			return getButtonParameter();
		if(fieldName.equals("BUTTONDENIEDROLEACCESS"))
			return getButtonDeniedRoleAccess();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getButtonIsNotNull()
	{
		return this.button != null;
	}
	public ims.core.vo.lookups.ElectronicPrescribingButton getButton()
	{
		return this.button;
	}
	public void setButton(ims.core.vo.lookups.ElectronicPrescribingButton value)
	{
		this.isValidated = false;
		this.button = value;
	}
	public boolean getButtonTextIsNotNull()
	{
		return this.buttontext != null;
	}
	public String getButtonText()
	{
		return this.buttontext;
	}
	public static int getButtonTextMaxLength()
	{
		return 25;
	}
	public void setButtonText(String value)
	{
		this.isValidated = false;
		this.buttontext = value;
	}
	public boolean getLabelTextIsNotNull()
	{
		return this.labeltext != null;
	}
	public String getLabelText()
	{
		return this.labeltext;
	}
	public static int getLabelTextMaxLength()
	{
		return 125;
	}
	public void setLabelText(String value)
	{
		this.isValidated = false;
		this.labeltext = value;
	}
	public boolean getButtonExecutablePathIsNotNull()
	{
		return this.buttonexecutablepath != null;
	}
	public String getButtonExecutablePath()
	{
		return this.buttonexecutablepath;
	}
	public static int getButtonExecutablePathMaxLength()
	{
		return 175;
	}
	public void setButtonExecutablePath(String value)
	{
		this.isValidated = false;
		this.buttonexecutablepath = value;
	}
	public boolean getButtonParameterIsNotNull()
	{
		return this.buttonparameter != null;
	}
	public String getButtonParameter()
	{
		return this.buttonparameter;
	}
	public static int getButtonParameterMaxLength()
	{
		return 15;
	}
	public void setButtonParameter(String value)
	{
		this.isValidated = false;
		this.buttonparameter = value;
	}
	public boolean getButtonDeniedRoleAccessIsNotNull()
	{
		return this.buttondeniedroleaccess != null;
	}
	public ims.admin.vo.AppRoleShortVoCollection getButtonDeniedRoleAccess()
	{
		return this.buttondeniedroleaccess;
	}
	public void setButtonDeniedRoleAccess(ims.admin.vo.AppRoleShortVoCollection value)
	{
		this.isValidated = false;
		this.buttondeniedroleaccess = value;
	}
	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.button == null)
			listOfErrors.add("Button is mandatory");
		if(this.buttontext == null || this.buttontext.length() == 0)
			listOfErrors.add("ButtonText is mandatory");
		else if(this.buttontext.length() > 25)
			listOfErrors.add("The length of the field [buttontext] in the value object [ims.admin.vo.ElectronicPrescribingConfigVo] is too big. It should be less or equal to 25");
		if(this.labeltext != null)
			if(this.labeltext.length() > 125)
				listOfErrors.add("The length of the field [labeltext] in the value object [ims.admin.vo.ElectronicPrescribingConfigVo] is too big. It should be less or equal to 125");
		if(this.buttonexecutablepath == null || this.buttonexecutablepath.length() == 0)
			listOfErrors.add("ButtonExecutablePath is mandatory");
		else if(this.buttonexecutablepath.length() > 175)
			listOfErrors.add("The length of the field [buttonexecutablepath] in the value object [ims.admin.vo.ElectronicPrescribingConfigVo] is too big. It should be less or equal to 175");
		if(this.buttonparameter == null || this.buttonparameter.length() == 0)
			listOfErrors.add("ButtonParameter is mandatory");
		else if(this.buttonparameter.length() > 15)
			listOfErrors.add("The length of the field [buttonparameter] in the value object [ims.admin.vo.ElectronicPrescribingConfigVo] is too big. It should be less or equal to 15");
		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;
	
		ElectronicPrescribingConfigVo clone = new ElectronicPrescribingConfigVo(this.id, this.version);
		
		if(this.button == null)
			clone.button = null;
		else
			clone.button = (ims.core.vo.lookups.ElectronicPrescribingButton)this.button.clone();
		clone.buttontext = this.buttontext;
		clone.labeltext = this.labeltext;
		clone.buttonexecutablepath = this.buttonexecutablepath;
		clone.buttonparameter = this.buttonparameter;
		if(this.buttondeniedroleaccess == null)
			clone.buttondeniedroleaccess = null;
		else
			clone.buttondeniedroleaccess = (ims.admin.vo.AppRoleShortVoCollection)this.buttondeniedroleaccess.clone();
		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 (!(ElectronicPrescribingConfigVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ElectronicPrescribingConfigVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((ElectronicPrescribingConfigVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((ElectronicPrescribingConfigVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.button != null)
			count++;
		if(this.buttontext != null)
			count++;
		if(this.labeltext != null)
			count++;
		if(this.buttonexecutablepath != null)
			count++;
		if(this.buttonparameter != null)
			count++;
		if(this.buttondeniedroleaccess != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected ims.core.vo.lookups.ElectronicPrescribingButton button;
	protected String buttontext;
	protected String labeltext;
	protected String buttonexecutablepath;
	protected String buttonparameter;
	protected ims.admin.vo.AppRoleShortVoCollection buttondeniedroleaccess;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
