/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/admin/vo/AppFormListVo.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.AppForm business object (ID: 1021100001).
 */
public class AppFormListVo extends ims.admin.vo.AppFormVo implements ims.vo.ImsCloneable, Comparable, ims.framework.interfaces.IAppForm
{
	private static final long serialVersionUID = 1L;

	public AppFormListVo()
	{
	}
	public AppFormListVo(Integer id, int version)
	{
		super(id, version);
	}
	public AppFormListVo(ims.admin.vo.beans.AppFormListVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.aliasname = bean.getAliasName();
		this.caption = bean.getCaption();
		this.isdialog = bean.getIsDialog();
		this.isalias = bean.getIsAlias();
		this.iscomponent = bean.getIsComponent();
		this.description = bean.getDescription();
		this.canbeinnavigation = bean.getCanBeInNavigation();
		this.canbeintopbuttons = bean.getCanBeInTopButtons();
		this.logicclass = bean.getLogicClass();
		this.accessclass = bean.getAccessClass();
		this.domainimpl = bean.getDomainImpl();
		this.helplink = bean.getHelpLink();
		this.rieboclassname = bean.getRieBoClassName();
		this.namespace = bean.getNamespace() == null ? null : bean.getNamespace().buildVo();
		this.issystem = bean.getIsSystem();
		this.informationbarvisible = bean.getInformationBarVisible();
		this.image = bean.getImage() == null ? null : bean.getImage().buildVo();
		this.lookups = ims.admin.vo.FormLookupVoCollection.buildFromBeanCollection(bean.getLookups());
		this.codemappings = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getCodeMappings());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.AppFormListVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.aliasname = bean.getAliasName();
		this.caption = bean.getCaption();
		this.isdialog = bean.getIsDialog();
		this.isalias = bean.getIsAlias();
		this.iscomponent = bean.getIsComponent();
		this.description = bean.getDescription();
		this.canbeinnavigation = bean.getCanBeInNavigation();
		this.canbeintopbuttons = bean.getCanBeInTopButtons();
		this.logicclass = bean.getLogicClass();
		this.accessclass = bean.getAccessClass();
		this.domainimpl = bean.getDomainImpl();
		this.helplink = bean.getHelpLink();
		this.rieboclassname = bean.getRieBoClassName();
		this.namespace = bean.getNamespace() == null ? null : bean.getNamespace().buildVo(map);
		this.issystem = bean.getIsSystem();
		this.informationbarvisible = bean.getInformationBarVisible();
		this.image = bean.getImage() == null ? null : bean.getImage().buildVo(map);
		this.lookups = ims.admin.vo.FormLookupVoCollection.buildFromBeanCollection(bean.getLookups());
		this.codemappings = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getCodeMappings());
	}
	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.AppFormListVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.AppFormListVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.AppFormListVoBean();
			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("LOOKUPS"))
			return getLookups();
		if(fieldName.equals("CODEMAPPINGS"))
			return getCodeMappings();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getLookupsIsNotNull()
	{
		return this.lookups != null;
	}
	public ims.admin.vo.FormLookupVoCollection getLookups()
	{
		return this.lookups;
	}
	public void setLookups(ims.admin.vo.FormLookupVoCollection value)
	{
		this.isValidated = false;
		this.lookups = value;
	}
	public boolean getCodeMappingsIsNotNull()
	{
		return this.codemappings != null;
	}
	public ims.core.vo.TaxonomyMapCollection getCodeMappings()
	{
		return this.codemappings;
	}
	public void setCodeMappings(ims.core.vo.TaxonomyMapCollection value)
	{
		this.isValidated = false;
		this.codemappings = value;
	}
	/**
	* IAppForm interface methods
	*/
	public int getFormId()
	{
		if (this.getID_AppForm() == null)
			return 0;
		else
			return this.getID_AppForm().intValue();
	}
	public boolean isDialog()
	{
		if (this.getIsDialog() == null)
			return false;
		else 
			return this.getIsDialog().booleanValue();
	}
	public boolean canBeInNavigation()
	{
		if (this.getCanBeInNavigation() == null)
			return false;
		else 
			return this.getCanBeInNavigation().booleanValue();
	}
	public boolean canBeInTopButtons()
	{
		if (this.getCanBeInTopButtons() == null)
			return false;
		else 
			return this.getCanBeInTopButtons().booleanValue();		
	}
	
	public boolean isComponent()
	{
		if (this.getIsComponent() == null)
			return false;
		else 
			return this.getIsComponent().booleanValue();
	}
	public boolean isAlias()
	{
		if (this.getIsAlias() == null)
			return false;
		else 
			return this.getIsAlias().booleanValue();
	}
	public String getGenFormPackageName()
	{
		String formsPackage = "ims." + namespace.getName().toLowerCase() + ".forms." +  name.toLowerCase(); 
		return formsPackage;
	}
	public String getModule()
	{
		StringBuffer sb = new StringBuffer(this.namespace.getName().length() + 1 + this.name.length());
		sb.append(this.namespace.getName());
		sb.append('.');
		sb.append(this.name);
		return sb.toString();
	}
	public boolean isSystem()
	{
		if (this.getIsSystem() == null)
			return false;
		else 
			return this.getIsSystem().booleanValue();
	}
	public boolean isInformationBarVisible()
	{
		if(this.getInformationBarVisible() == null)
			return false;
		else
			return this.getInformationBarVisible().booleanValue();
	}
	
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.namespace != null)
		{
			if(!this.namespace.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.lookups != null)
		{
			if(!this.lookups.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.codemappings != null)
		{
			if(!this.codemappings.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.name == null || this.name.length() == 0)
			listOfErrors.add("Name is mandatory");
		else if(this.name.length() > 100)
			listOfErrors.add("The length of the field [name] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 100");
		if(this.aliasname != null)
			if(this.aliasname.length() > 100)
				listOfErrors.add("The length of the field [aliasname] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 100");
		if(this.caption == null || this.caption.length() == 0)
			listOfErrors.add("Caption is mandatory");
		else if(this.caption.length() > 100)
			listOfErrors.add("The length of the field [caption] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 100");
		if(this.isdialog == null)
			listOfErrors.add("IsDialog is mandatory");
		if(this.isalias == null)
			listOfErrors.add("IsAlias is mandatory");
		if(this.iscomponent == null)
			listOfErrors.add("IsComponent is mandatory");
		if(this.description == null || this.description.length() == 0)
			listOfErrors.add("Description is mandatory");
		else if(this.description.length() > 255)
			listOfErrors.add("The length of the field [description] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 255");
		if(this.canbeinnavigation == null)
			listOfErrors.add("CanBeInNavigation is mandatory");
		if(this.canbeintopbuttons == null)
			listOfErrors.add("CanBeInTopButtons is mandatory");
		if(this.logicclass != null)
			if(this.logicclass.length() > 200)
				listOfErrors.add("The length of the field [logicclass] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 200");
		if(this.accessclass != null)
			if(this.accessclass.length() > 200)
				listOfErrors.add("The length of the field [accessclass] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 200");
		if(this.domainimpl != null)
			if(this.domainimpl.length() > 200)
				listOfErrors.add("The length of the field [domainimpl] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 200");
		if(this.helplink != null)
			if(this.helplink.length() > 200)
				listOfErrors.add("The length of the field [helplink] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 200");
		if(this.rieboclassname != null)
			if(this.rieboclassname.length() > 500)
				listOfErrors.add("The length of the field [rieboclassname] in the value object [ims.admin.vo.AppFormListVo] is too big. It should be less or equal to 500");
		if(this.namespace != null)
		{
			String[] listOfOtherErrors = this.namespace.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.issystem == null)
			listOfErrors.add("IsSystem is mandatory");
		if(this.lookups != null)
		{
			String[] listOfOtherErrors = this.lookups.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.codemappings != null)
		{
			String[] listOfOtherErrors = this.codemappings.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		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;
	
		AppFormListVo clone = new AppFormListVo(this.id, this.version);
		
		clone.name = this.name;
		clone.aliasname = this.aliasname;
		clone.caption = this.caption;
		clone.isdialog = this.isdialog;
		clone.isalias = this.isalias;
		clone.iscomponent = this.iscomponent;
		clone.description = this.description;
		clone.canbeinnavigation = this.canbeinnavigation;
		clone.canbeintopbuttons = this.canbeintopbuttons;
		clone.logicclass = this.logicclass;
		clone.accessclass = this.accessclass;
		clone.domainimpl = this.domainimpl;
		clone.helplink = this.helplink;
		clone.rieboclassname = this.rieboclassname;
		if(this.namespace == null)
			clone.namespace = null;
		else
			clone.namespace = (ims.admin.vo.AppNamespace)this.namespace.clone();
		clone.issystem = this.issystem;
		clone.informationbarvisible = this.informationbarvisible;
		if(this.image == null)
			clone.image = null;
		else
			clone.image = (ims.admin.vo.AppImageVo)this.image.clone();
		if(this.lookups == null)
			clone.lookups = null;
		else
			clone.lookups = (ims.admin.vo.FormLookupVoCollection)this.lookups.clone();
		if(this.codemappings == null)
			clone.codemappings = null;
		else
			clone.codemappings = (ims.core.vo.TaxonomyMapCollection)this.codemappings.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 (!(AppFormListVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A AppFormListVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((AppFormListVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((AppFormListVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.lookups != null)
			count++;
		if(this.codemappings != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 2;
	}
	protected ims.admin.vo.FormLookupVoCollection lookups;
	protected ims.core.vo.TaxonomyMapCollection codemappings;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
