gt: 			else if (i != domIdx && i < list.size())
context: //#############################################################################
  //#                                                                           #
  //#  Copyright (C) <2014>  <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/>.    #
  //#                                                                           #
  //#############################################################################
  //#EOH
  /*
   * This code was generated
   * Copyright (C) 1995-2004 IMS MAXIMS plc. All rights reserved.
   * IMS Development Environment (version 1.80 build 5007.25751)
   * WARNING: DO NOT MODIFY the content of this file
   * Generated: 16/04/2014, 12:34
   *
   */
  package ims.edischarge.domain.objects;
  
  /**
   * 
   * @author Neil McAnaspie
   * Generated.
   */
  
  
  public class TTAStatus extends ims.domain.DomainObject implements ims.domain.SystemInformationRetainer, java.io.Serializable {
  	public static final int CLASSID = 1099100017;
  	private static final long serialVersionUID = 1099100017L;
  	public static final String CLASSVERSION = "${ClassVersion}";
  
  	@Override
  	public boolean shouldCapQuery()
  	{
  		return true;
  	}
  
  	/** Status */
  	private ims.domain.lookups.LookupInstance status;
  	/** User */
  	private ims.core.resource.people.domain.objects.MemberOfStaff authoringUser;
  	/** Status Date Time */
  	private java.util.Date statusDateTime;
  	/** Reason For Rejection */
  	private String reasonForRejection;
  	/** Reason For Suspension */
  	private String reasonForSuspension;
  	/** SystemInformation */
  	private ims.domain.SystemInformation systemInformation = new ims.domain.SystemInformation();
      public TTAStatus (Integer id, int ver)
      {
      	super(id, ver);
      }
      public TTAStatus ()
      {
      	super();
      }
      public TTAStatus (Integer id, int ver, Boolean includeRecord)
      {
      	super(id, ver, includeRecord);
      }
  	public Class getRealDomainClass()
  	{
  		return ims.edischarge.domain.objects.TTAStatus.class;
  	}
  
  
  	public ims.domain.lookups.LookupInstance getStatus() {
  		return status;
  	}
  	public void setStatus(ims.domain.lookups.LookupInstance status) {
  		this.status = status;
  	}
  
  	public ims.core.resource.people.domain.objects.MemberOfStaff getAuthoringUser() {
  		return authoringUser;
  	}
  	public void setAuthoringUser(ims.core.resource.people.domain.objects.MemberOfStaff authoringUser) {
  		this.authoringUser = authoringUser;
  	}
  
  	public java.util.Date getStatusDateTime() {
  		return statusDateTime;
  	}
  	public void setStatusDateTime(java.util.Date statusDateTime) {
  		this.statusDateTime = statusDateTime;
  	}
  
  	public String getReasonForRejection() {
  		return reasonForRejection;
  	}
  	public void setReasonForRejection(String reasonForRejection) {
  		if ( null != reasonForRejection && reasonForRejection.length() > 1500 ) {
  			throw new ims.domain.exceptions.DomainRuntimeException("MaxLength ($MaxLength) exceeded for reasonForRejection. Tried to set value: "+
  				reasonForRejection);
  		}
  		this.reasonForRejection = reasonForRejection;
  	}
  
  	public String getReasonForSuspension() {
  		return reasonForSuspension;
  	}
  	public void setReasonForSuspension(String reasonForSuspension) {
  		if ( null != reasonForSuspension && reasonForSuspension.length() > 1500 ) {
  			throw new ims.domain.exceptions.DomainRuntimeException("MaxLength ($MaxLength) exceeded for reasonForSuspension. Tried to set value: "+
  				reasonForSuspension);
  		}
  		this.reasonForSuspension = reasonForSuspension;
  	}
  
  	public ims.domain.SystemInformation getSystemInformation() {
  		if (systemInformation == null) systemInformation = new ims.domain.SystemInformation();
  		return systemInformation;
  	}
  
  
  	/**
  	 * isConfigurationObject
  	 * Taken from the Usage property of the business object, this method will return
  	 * a boolean indicating whether this is a configuration object or not
  	 * Configuration = true, Instantiation = false
  	 */
  	public static boolean isConfigurationObject()
  	{
  		if ( "Instantiation".equals("Configuration") )
  			return true;
  		else
  			return false;
  	}
  
  
  
  
  
  	public int getClassId() {
  		return CLASSID;
  	}
  
  	public String getClassVersion()
  	{
  		return CLASSVERSION;
  	}
  
  	public String toAuditString()
  	{
  		StringBuffer auditStr = new StringBuffer();
  		
  		auditStr.append("\r\n*status* :");
  		if (status != null)
  			auditStr.append(status.getText());
  	    auditStr.append("; ");
  		auditStr.append("\r\n*authoringUser* :");
  		if (authoringUser != null)
  		{
  			auditStr.append(toShortClassName(authoringUser));
  				
  		    auditStr.append(authoringUser.getId());
  		}
  	    auditStr.append("; ");
  		auditStr.append("\r\n*statusDateTime* :");
  		auditStr.append(statusDateTime);
  	    auditStr.append("; ");
  		auditStr.append("\r\n*reasonForRejection* :");
  		auditStr.append(reasonForRejection);
  	    auditStr.append("; ");
  		auditStr.append("\r\n*reasonForSuspension* :");
  		auditStr.append(reasonForSuspension);
  	    auditStr.append("; ");
  		return auditStr.toString();
  	}
  	
  	public String toXMLString()
  	{
  		return toXMLString(new java.util.HashMap());
  	}
  	
  	public String toXMLString(java.util.HashMap domMap)
  	{
  		StringBuffer sb = new StringBuffer();
  		sb.append("<class type=\"" + this.getClass().getName() + "\" ");		
  		sb.append(" id=\"" + this.getId() + "\""); 
  		sb.append(" source=\"" + ims.configuration.EnvironmentConfig.getImportExportSourceName() + "\" ");
  		sb.append(" classVersion=\"" + this.getClassVersion() + "\" ");
  		sb.append(" component=\"" + this.getIsComponentClass() + "\" >");
  		
  		if (domMap.get(this) == null)
  		{
  			domMap.put(this, this);
  			sb.append(this.fieldsToXMLString(domMap));
  		}
  		sb.append("</class>");
  		
  		String keyClassName = "TTAStatus";
  		String externalSource = ims.configuration.EnvironmentConfig.getImportExportSourceName();
  		ims.configuration.ImportedObject impObj = (ims.configuration.ImportedObject)domMap.get(keyClassName + "_" + externalSource + "_" + this.getId());
  		if (impObj == null)
  		{
      		impObj = new ims.configuration.ImportedObject();
      		impObj.setExternalId(this.getId());
      		impObj.setExternalSource(externalSource);
      		impObj.setDomainObject(this);
  			impObj.setLocalId(this.getId()); 
      		impObj.setClassName(keyClassName); 
  			domMap.put(keyClassName + "_" + externalSource + "_" + this.getId(), impObj);
  		}
  		
  		return sb.toString();
  	}
  
  	public String fieldsToXMLString(java.util.HashMap domMap)
  	{
  		StringBuffer sb = new StringBuffer();
  		if (this.getStatus() != null)
  		{
  			sb.append("<status>");
  			sb.append(this.getStatus().toXMLString()); 
  			sb.append("</status>");		
  		}
  		if (this.getAuthoringUser() != null)
  		{
  			sb.append("<authoringUser>");
  			sb.append(this.getAuthoringUser().toXMLString(domMap)); 	
  			sb.append("</authoringUser>");		
  		}
  		if (this.getStatusDateTime() != null)
  		{
  			sb.append("<statusDateTime>");
  			sb.append(new ims.framework.utils.DateTime(this.getStatusDateTime()).toString(ims.framework.utils.DateTimeFormat.MILLI));
  			sb.append("</statusDateTime>");		
  		}
  		if (this.getReasonForRejection() != null)
  		{
  			sb.append("<reasonForRejection>");
  			sb.append(ims.framework.utils.StringUtils.encodeXML(this.getReasonForRejection().toString()));
  			sb.append("</reasonForRejection>");		
  		}
  		if (this.getReasonForSuspension() != null)
  		{
  			sb.append("<reasonForSuspension>");
  			sb.append(ims.framework.utils.StringUtils.encodeXML(this.getReasonForSuspension().toString()));
  			sb.append("</reasonForSuspension>");		
  		}
  		return sb.toString();
  	}
  		
  	public static java.util.List fromListXMLString(org.dom4j.Element el, ims.domain.DomainFactory factory, java.util.List list, java.util.HashMap domMap) throws Exception
  	{
  		if (list == null)
  		 list = new java.util.ArrayList();
  		fillListFromXMLString(list, el, factory, domMap);
  		return list;
  	}
  	
  	public static java.util.Set fromSetXMLString(org.dom4j.Element el, ims.domain.DomainFactory factory, java.util.Set set, java.util.HashMap domMap) throws Exception
  	{
  		if (set == null)
  			 set = new java.util.HashSet();
  		fillSetFromXMLString(set, el, factory, domMap);
  		return set;
  	}
  	
  	private static void fillSetFromXMLString(java.util.Set set, org.dom4j.Element el, ims.domain.DomainFactory factory, java.util.HashMap domMap) throws Exception
  	{
  		if (el == null)
  			return;
  		
  		java.util.List cl = el.elements("class");
  		int size = cl.size();
  		
  		java.util.Set newSet = new java.util.HashSet();
  		for(int i=0; i<size; i++) 
  		{
  			org.dom4j.Element itemEl = (org.dom4j.Element)cl.get(i);
  			TTAStatus domainObject = getTTAStatusfromXML(itemEl, factory, domMap);
  
  			if (domainObject == null)
  			{
  				continue;
  			}
  			
  			//Trying to avoid the hibernate collection being marked as dirty via its public interface methods. (like add)
  			if (!set.contains(domainObject)) 
  				set.add(domainObject);
  			newSet.add(domainObject);			
  		}
  		
  		java.util.Set removedSet = new java.util.HashSet();
  		java.util.Iterator iter = set.iterator();
  		//Find out which objects need to be removed
  		while (iter.hasNext())
  		{
  			ims.domain.DomainObject o = (ims.domain.DomainObject)iter.next();			
  			if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue()) && !newSet.contains(o))
  			{
  				removedSet.add(o);
  			}
  		}
  		iter = removedSet.iterator();
  		//Remove the unwanted objects
  		while (iter.hasNext())
  		{
  			set.remove(iter.next());
  		}		
  	}
  	
  	private static void fillListFromXMLString(java.util.List list, org.dom4j.Element el, ims.domain.DomainFactory factory, java.util.HashMap domMap) throws Exception
  	{
  		if (el == null)
  			return;
  		
  		java.util.List cl = el.elements("class");
  		int size = cl.size();
  		
  		for(int i=0; i<size; i++) 
  		{
  			org.dom4j.Element itemEl = (org.dom4j.Element)cl.get(i);
  			TTAStatus domainObject = getTTAStatusfromXML(itemEl, factory, domMap);
  
  			if (domainObject == null)
  			{
  				continue;
  			}
  
  			int domIdx = list.indexOf(domainObject);
  			if (domIdx == -1)
  			{
  				list.add(i, domainObject);
  			}
  