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

	public AppRoleVo()
	{
	}
	public AppRoleVo(Integer id, int version)
	{
		super(id, version);
	}
	public AppRoleVo(ims.admin.vo.beans.AppRoleVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.isactive = bean.getIsActive();
		this.requirespds = bean.getRequiresPDS();
		this.description = bean.getDescription();
		this.navigation = bean.getNavigation() == null ? null : bean.getNavigation().buildVo();
		this.apprights = ims.admin.vo.AppRightVoCollection.buildFromBeanCollection(bean.getAppRights());
		this.topbuttonconfig = bean.getTopButtonConfig() == null ? null : bean.getTopButtonConfig().buildVo();
		this.formmenuactionsdenied = ims.admin.vo.FormMenuActionsDeniedVoCollection.buildFromBeanCollection(bean.getFormMenuActionsDenied());
		this.codemappings = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getCodeMappings());
		this.sessiontimeout = bean.getSessionTimeout();
		this.autolocktimer = bean.getAutolockTimer();
		this.alertsaccess = ims.core.vo.AlertAccessRightVoCollection.buildFromBeanCollection(bean.getAlertsAccess());
		this.spinerbac = bean.getSpineRbac() == null ? null : bean.getSpineRbac().buildVo();
		this.pdsrights = ims.admin.vo.AppRightVoCollection.buildFromBeanCollection(bean.getPdsRights());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.AppRoleVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.isactive = bean.getIsActive();
		this.requirespds = bean.getRequiresPDS();
		this.description = bean.getDescription();
		this.navigation = bean.getNavigation() == null ? null : bean.getNavigation().buildVo(map);
		this.apprights = ims.admin.vo.AppRightVoCollection.buildFromBeanCollection(bean.getAppRights());
		this.topbuttonconfig = bean.getTopButtonConfig() == null ? null : bean.getTopButtonConfig().buildVo(map);
		this.formmenuactionsdenied = ims.admin.vo.FormMenuActionsDeniedVoCollection.buildFromBeanCollection(bean.getFormMenuActionsDenied());
		this.codemappings = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getCodeMappings());
		this.sessiontimeout = bean.getSessionTimeout();
		this.autolocktimer = bean.getAutolockTimer();
		this.alertsaccess = ims.core.vo.AlertAccessRightVoCollection.buildFromBeanCollection(bean.getAlertsAccess());
		this.spinerbac = bean.getSpineRbac() == null ? null : bean.getSpineRbac().buildVo(map);
		this.pdsrights = ims.admin.vo.AppRightVoCollection.buildFromBeanCollection(bean.getPdsRights());
	}
	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.AppRoleVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.AppRoleVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.AppRoleVoBean();
			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("DESCRIPTION"))
			return getDescription();
		if(fieldName.equals("NAVIGATION"))
			return getNavigation();
		if(fieldName.equals("APPRIGHTS"))
			return getAppRights();
		if(fieldName.equals("TOPBUTTONCONFIG"))
			return getTopButtonConfig();
		if(fieldName.equals("FORMMENUACTIONSDENIED"))
			return getFormMenuActionsDenied();
		if(fieldName.equals("CODEMAPPINGS"))
			return getCodeMappings();
		if(fieldName.equals("SESSIONTIMEOUT"))
			return getSessionTimeout();
		if(fieldName.equals("AUTOLOCKTIMER"))
			return getAutolockTimer();
		if(fieldName.equals("ALERTSACCESS"))
			return getAlertsAccess();
		if(fieldName.equals("SPINERBAC"))
			return getSpineRbac();
		if(fieldName.equals("PDSRIGHTS"))
			return getPdsRights();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getDescriptionIsNotNull()
	{
		return this.description != null;
	}
	public String getDescription()
	{
		return this.description;
	}
	public static int getDescriptionMaxLength()
	{
		return 255;
	}
	public void setDescription(String value)
	{
		this.isValidated = false;
		this.description = value;
	}
	public boolean getNavigationIsNotNull()
	{
		return this.navigation != null;
	}
	public ims.admin.vo.AppNavigationVo getNavigation()
	{
		return this.navigation;
	}
	public void setNavigation(ims.admin.vo.AppNavigationVo value)
	{
		this.isValidated = false;
		this.navigation = value;
	}
	public boolean getAppRightsIsNotNull()
	{
		return this.apprights != null;
	}
	public ims.admin.vo.AppRightVoCollection getAppRights()
	{
		return this.apprights;
	}
	public void setAppRights(ims.admin.vo.AppRightVoCollection value)
	{
		this.isValidated = false;
		this.apprights = value;
	}
	public boolean getTopButtonConfigIsNotNull()
	{
		return this.topbuttonconfig != null;
	}
	public ims.admin.vo.AppTopButtonConfigVo getTopButtonConfig()
	{
		return this.topbuttonconfig;
	}
	public void setTopButtonConfig(ims.admin.vo.AppTopButtonConfigVo value)
	{
		this.isValidated = false;
		this.topbuttonconfig = value;
	}
	public boolean getFormMenuActionsDeniedIsNotNull()
	{
		return this.formmenuactionsdenied != null;
	}
	public ims.admin.vo.FormMenuActionsDeniedVoCollection getFormMenuActionsDenied()
	{
		return this.formmenuactionsdenied;
	}
	public void setFormMenuActionsDenied(ims.admin.vo.FormMenuActionsDeniedVoCollection value)
	{
		this.isValidated = false;
		this.formmenuactionsdenied = 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;
	}
	public boolean getSessionTimeoutIsNotNull()
	{
		return this.sessiontimeout != null;
	}
	public Integer getSessionTimeout()
	{
		return this.sessiontimeout;
	}
	public void setSessionTimeout(Integer value)
	{
		this.isValidated = false;
		this.sessiontimeout = value;
	}
	public boolean getAutolockTimerIsNotNull()
	{
		return this.autolocktimer != null;
	}
	public Integer getAutolockTimer()
	{
		return this.autolocktimer;
	}
	public void setAutolockTimer(Integer value)
	{
		this.isValidated = false;
		this.autolocktimer = value;
	}
	public boolean getAlertsAccessIsNotNull()
	{
		return this.alertsaccess != null;
	}
	public ims.core.vo.AlertAccessRightVoCollection getAlertsAccess()
	{
		return this.alertsaccess;
	}
	public void setAlertsAccess(ims.core.vo.AlertAccessRightVoCollection value)
	{
		this.isValidated = false;
		this.alertsaccess = value;
	}
	public boolean getSpineRbacIsNotNull()
	{
		return this.spinerbac != null;
	}
	public ims.admin.vo.RBACBaselineJobRoleLiteVo getSpineRbac()
	{
		return this.spinerbac;
	}
	public void setSpineRbac(ims.admin.vo.RBACBaselineJobRoleLiteVo value)
	{
		this.isValidated = false;
		this.spinerbac = value;
	}
	public boolean getPdsRightsIsNotNull()
	{
		return this.pdsrights != null;
	}
	public ims.admin.vo.AppRightVoCollection getPdsRights()
	{
		return this.pdsrights;
	}
	public void setPdsRights(ims.admin.vo.AppRightVoCollection value)
	{
		this.isValidated = false;
		this.pdsrights = value;
	}
	/**
	* IAppRole interface methods
	*/
		public Integer getRoleSessionTimeout()
		{
			return sessiontimeout;
		}	
		public Integer getRoleAutolockTimer()
		{
			return autolocktimer;
		}	
	
		public ims.framework.interfaces.IAppRight[] getRoleRights()
		{
			if (this.getAppRights() == null)
				return new ims.framework.interfaces.IAppRight[0];
			else
				return this.getAppRights().toArray();
		}
		public boolean hasRight(ims.framework.interfaces.IAppRight right)
		{
			for (int i = 0; i < this.getAppRights().size(); i++)
			{
				if (this.getAppRights().get(i).getName().equals(right.getName()))
					return true;
			}
			for (int i = 0; i < this.getPdsRights().size(); i++)
			{
				if (this.getPdsRights().get(i).getName().equals(right.getName()))
					return true;
			}
			return false;
		}
		public ims.framework.interfaces.INavigation getRoleNavigation()
		{
			return this.getNavigation();
		}
		public ims.framework.interfaces.ITopButtonConfig getRoleTopButtonConfig() 
		{
			return topbuttonconfig;
		}
		public boolean hasMenuActionRight(ims.framework.interfaces.IAppForm form, ims.framework.interfaces.IMenuAction menuAction) 
		{
			if(formmenuactionsdenied == null)
				return true;
			if(form == null)
				return false;
			if(menuAction == null)
				return false;
			
			for(int x = 0; x < formmenuactionsdenied.size(); x++)
			{
				ims.admin.vo.FormMenuActionsDeniedVo item = formmenuactionsdenied.get(x);
				if(item != null && 
						item.getMenuActionsIsNotNull() && 
						item.getFormIsNotNull() && 
						item.getForm().getID_AppFormIsNotNull() && 
						item.getForm().getID_AppForm().intValue() == form.getFormId())
				{
					for(int y = 0; y < item.getMenuActions().size(); y++)
					{
						ims.core.configuration.vo.MenuActionRefVo menuActionItem = item.getMenuActions().get(y);
						if(menuActionItem != null && menuActionItem.getID_MenuActionIsNotNull() && menuActionItem.getID_MenuAction() == menuAction.getMenuActionID())
							return false;
					}
				}
			}
				
			return true;
		}
		public ims.framework.interfaces.IAlertsAccess[] getAlertsAccessList()
		{
			return this.getAlertsAccess() != null ? this.getAlertsAccess().toArray() : null;
		}
	
			public  ims.framework.interfaces.IRBACBaselineJobRole getSpineRbacRole()
			{
				return this.getSpineRbac();
			}
	
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.navigation != null)
		{
			if(!this.navigation.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.apprights != null)
		{
			if(!this.apprights.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.topbuttonconfig != null)
		{
			if(!this.topbuttonconfig.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.formmenuactionsdenied != null)
		{
			if(!this.formmenuactionsdenied.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.codemappings != null)
		{
			if(!this.codemappings.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.alertsaccess != null)
		{
			if(!this.alertsaccess.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.spinerbac != null)
		{
			if(!this.spinerbac.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.pdsrights != null)
		{
			if(!this.pdsrights.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() > 30)
			listOfErrors.add("The length of the field [name] in the value object [ims.admin.vo.AppRoleVo] is too big. It should be less or equal to 30");
		if(this.isactive == null)
			listOfErrors.add("IsActive is mandatory");
		if(this.description != null)
			if(this.description.length() > 255)
				listOfErrors.add("The length of the field [description] in the value object [ims.admin.vo.AppRoleVo] is too big. It should be less or equal to 255");
		if(this.navigation == null)
			listOfErrors.add("Navigation is mandatory");
		if(this.navigation != null)
		{
			String[] listOfOtherErrors = this.navigation.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.apprights != null)
		{
			String[] listOfOtherErrors = this.apprights.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.topbuttonconfig != null)
		{
			String[] listOfOtherErrors = this.topbuttonconfig.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.formmenuactionsdenied != null)
		{
			String[] listOfOtherErrors = this.formmenuactionsdenied.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]);
				}
			}
		}
		if(this.alertsaccess != null)
		{
			String[] listOfOtherErrors = this.alertsaccess.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.spinerbac != null)
		{
			String[] listOfOtherErrors = this.spinerbac.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.pdsrights != null)
		{
			String[] listOfOtherErrors = this.pdsrights.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;
	
		AppRoleVo clone = new AppRoleVo(this.id, this.version);
		
		clone.name = this.name;
		clone.isactive = this.isactive;
		clone.requirespds = this.requirespds;
		clone.description = this.description;
		if(this.navigation == null)
			clone.navigation = null;
		else
			clone.navigation = (ims.admin.vo.AppNavigationVo)this.navigation.clone();
		if(this.apprights == null)
			clone.apprights = null;
		else
			clone.apprights = (ims.admin.vo.AppRightVoCollection)this.apprights.clone();
		if(this.topbuttonconfig == null)
			clone.topbuttonconfig = null;
		else
			clone.topbuttonconfig = (ims.admin.vo.AppTopButtonConfigVo)this.topbuttonconfig.clone();
		if(this.formmenuactionsdenied == null)
			clone.formmenuactionsdenied = null;
		else
			clone.formmenuactionsdenied = (ims.admin.vo.FormMenuActionsDeniedVoCollection)this.formmenuactionsdenied.clone();
		if(this.codemappings == null)
			clone.codemappings = null;
		else
			clone.codemappings = (ims.core.vo.TaxonomyMapCollection)this.codemappings.clone();
		clone.sessiontimeout = this.sessiontimeout;
		clone.autolocktimer = this.autolocktimer;
		if(this.alertsaccess == null)
			clone.alertsaccess = null;
		else
			clone.alertsaccess = (ims.core.vo.AlertAccessRightVoCollection)this.alertsaccess.clone();
		if(this.spinerbac == null)
			clone.spinerbac = null;
		else
			clone.spinerbac = (ims.admin.vo.RBACBaselineJobRoleLiteVo)this.spinerbac.clone();
		if(this.pdsrights == null)
			clone.pdsrights = null;
		else
			clone.pdsrights = (ims.admin.vo.AppRightVoCollection)this.pdsrights.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 (!(AppRoleVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A AppRoleVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((AppRoleVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((AppRoleVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.description != null)
			count++;
		if(this.navigation != null)
			count++;
		if(this.apprights != null)
			count++;
		if(this.topbuttonconfig != null)
			count++;
		if(this.formmenuactionsdenied != null)
			count++;
		if(this.codemappings != null)
			count++;
		if(this.sessiontimeout != null)
			count++;
		if(this.autolocktimer != null)
			count++;
		if(this.alertsaccess != null)
			count++;
		if(this.spinerbac != null)
			count++;
		if(this.pdsrights != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 11;
	}
	protected String description;
	protected ims.admin.vo.AppNavigationVo navigation;
	protected ims.admin.vo.AppRightVoCollection apprights;
	protected ims.admin.vo.AppTopButtonConfigVo topbuttonconfig;
	protected ims.admin.vo.FormMenuActionsDeniedVoCollection formmenuactionsdenied;
	protected ims.core.vo.TaxonomyMapCollection codemappings;
	protected Integer sessiontimeout;
	protected Integer autolocktimer;
	protected ims.core.vo.AlertAccessRightVoCollection alertsaccess;
	protected ims.admin.vo.RBACBaselineJobRoleLiteVo spinerbac;
	protected ims.admin.vo.AppRightVoCollection pdsrights;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
