All Downloads are FREE. Search and download functionalities are using the official Maven repository.

klass.model.meta.domain.AssociationEndAbstract Maven / Gradle / Ivy

The newest version!
package klass.model.meta.domain;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;
import java.io.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gs.fw.common.mithra.*;
import com.gs.fw.common.mithra.attribute.*;
import com.gs.fw.common.mithra.util.*;
import com.gs.fw.common.mithra.notification.*;
import com.gs.fw.common.mithra.notification.listener.*;
import com.gs.fw.common.mithra.list.cursor.Cursor;
import com.gs.fw.common.mithra.bulkloader.*;
import com.gs.fw.common.mithra.*;
import com.gs.fw.common.mithra.behavior.*;
import com.gs.fw.common.mithra.cache.Cache;
import com.gs.fw.common.mithra.extractor.*;
import com.gs.fw.common.mithra.finder.*;
import com.gs.fw.common.mithra.list.*;
import com.gs.fw.common.mithra.behavior.state.PersistenceState;
import com.gs.fw.common.mithra.attribute.update.*;
import com.gs.fw.common.mithra.transaction.MithraObjectPersister;
import java.util.Arrays;
import java.util.HashSet;
/**
* This file was automatically generated using Mithra 18.0.0. Please do not modify it.
* Add custom logic to its subclass instead.
*/
// Generated from templates/transactional/Abstract.jsp
public abstract class AssociationEndAbstract extends com.gs.fw.common.mithra.superclassimpl.MithraTransactionalObjectImpl
implements
NamedElement
{
	private static byte MEMORY_STATE = PersistenceState.IN_MEMORY;
	private static byte PERSISTED_STATE = PersistenceState.PERSISTED;
	private static final Logger logger = LoggerFactory.getLogger(AssociationEnd.class.getName());
	private static final RelationshipHashStrategy forresultType = new ResultTypeRhs();
	private static final RelationshipHashStrategy forowningAssociation = new OwningAssociationRhs();
	private static final RelationshipHashStrategy forowningClass = new OwningClassRhs();
	private static final class ResultTypeRhs implements RelationshipHashStrategy
	{
		public boolean equalsForRelationship(Object _srcObject, Object _srcData, Object _targetData, Timestamp _asOfDate0, Timestamp _asOfDate1)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			KlassData _castedTargetData = (KlassData) _targetData;
			if (_castedSrcData.getResultTypeName()!= null && _castedSrcData.getResultTypeName().equals(_castedTargetData.getName()))
			{
				return true;
			}

			return false;
		}

		public int computeHashCodeFromRelated(Object _srcObject, Object _srcData)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			return HashUtil.hash(_castedSrcData.getResultTypeName());
		}

		public int computeOffHeapHashCodeFromRelated(Object _srcObject, Object _srcData)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			return HashUtil.offHeapHash(_castedSrcData.getResultTypeName());
		}
	}

	private static final class OwningAssociationRhs implements RelationshipHashStrategy
	{
		public boolean equalsForRelationship(Object _srcObject, Object _srcData, Object _targetData, Timestamp _asOfDate0, Timestamp _asOfDate1)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			AssociationData _castedTargetData = (AssociationData) _targetData;
			if (_castedSrcData.getAssociationName()!= null && _castedSrcData.getAssociationName().equals(_castedTargetData.getName()))
			{
				return true;
			}

			return false;
		}

		public int computeHashCodeFromRelated(Object _srcObject, Object _srcData)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			return HashUtil.hash(_castedSrcData.getAssociationName());
		}

		public int computeOffHeapHashCodeFromRelated(Object _srcObject, Object _srcData)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			return HashUtil.offHeapHash(_castedSrcData.getAssociationName());
		}
	}

	private static final class OwningClassRhs implements RelationshipHashStrategy
	{
		public boolean equalsForRelationship(Object _srcObject, Object _srcData, Object _targetData, Timestamp _asOfDate0, Timestamp _asOfDate1)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			KlassData _castedTargetData = (KlassData) _targetData;
			if (_castedSrcData.getOwningClassName()!= null && _castedSrcData.getOwningClassName().equals(_castedTargetData.getName()))
			{
				return true;
			}

			return false;
		}

		public int computeHashCodeFromRelated(Object _srcObject, Object _srcData)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			return HashUtil.hash(_castedSrcData.getOwningClassName());
		}

		public int computeOffHeapHashCodeFromRelated(Object _srcObject, Object _srcData)
		{
			AssociationEndData _castedSrcData = (AssociationEndData) _srcData;
			return HashUtil.offHeapHash(_castedSrcData.getOwningClassName());
		}
	}

	public AssociationEndAbstract()
	{
		this.persistenceState = MEMORY_STATE;
	}

	public AssociationEnd getDetachedCopy() throws MithraBusinessException
	{
		return (AssociationEnd) super.getDetachedCopy();
	}

	public AssociationEnd getNonPersistentCopy() throws MithraBusinessException
	{
		AssociationEnd result = (AssociationEnd) super.getNonPersistentCopy();
		result.persistenceState = MEMORY_STATE;
		return result;
	}

	public AssociationEnd copyDetachedValuesToOriginalOrInsertIfNew()
	{
		return (AssociationEnd) this.zCopyDetachedValuesToOriginalOrInsertIfNew();
	}

	public AssociationEnd zFindOriginal()
	{
		AssociationEndData data = (AssociationEndData) this.currentData;
		Operation op;
		op = AssociationEndFinder.owningClassName().eq(data.getOwningClassName());
		op = op.and(AssociationEndFinder.name().eq(data.getName()));
		return AssociationEndFinder.findOne(op);
	}

	public boolean isModifiedSinceDetachmentByDependentRelationships()
	{
		if(this.isModifiedSinceDetachment()) return true;
		if(isAssociationEndModifiersModifiedSinceDetachment()) return true;
		if(isOrderBysModifiedSinceDetachment()) return true;
		return false;
	}

	private Logger getLogger()
	{
		return logger;
	}

	public MithraDataObject zAllocateData()
	{
		return new AssociationEndData();
	}

	protected void zSetFromAssociationEndData( AssociationEndData data )
	{
		super.zSetData(data);
		this.persistenceState = PERSISTED_STATE;
	}

	public void setFromAssociationEndData( AssociationEndData data )
	{
		super.zSetData(data);
	}

	public void zWriteDataClassName(ObjectOutput out) throws IOException
	{
	}

	public boolean isAssociationNameNull()
	{
		return ((AssociationEndData) this.zSynchronizedGetData()).isAssociationNameNull();
	}

	public String getAssociationName()
	{
		AssociationEndData data = (AssociationEndData) this.zSynchronizedGetData();
		return data.getAssociationName();
	}

	public void setAssociationName(String newValue)
	{
		if (newValue != null && newValue.length() > 256)
		throw new MithraBusinessException("Attribute 'associationName' cannot exceed maximum length of 256: " + newValue);
		zSetString(AssociationEndFinder.associationName(), newValue, false, false );
	}

	public boolean isDirectionNull()
	{
		return ((AssociationEndData) this.zSynchronizedGetData()).isDirectionNull();
	}

	public String getDirection()
	{
		AssociationEndData data = (AssociationEndData) this.zSynchronizedGetData();
		return data.getDirection();
	}

	public void setDirection(String newValue)
	{
		if (newValue != null && newValue.length() > 256)
		throw new MithraBusinessException("Attribute 'direction' cannot exceed maximum length of 256: " + newValue);
		zSetString(AssociationEndFinder.direction(), newValue, false, false );
	}

	public boolean isMultiplicityNull()
	{
		return ((AssociationEndData) this.zSynchronizedGetData()).isMultiplicityNull();
	}

	public String getMultiplicity()
	{
		AssociationEndData data = (AssociationEndData) this.zSynchronizedGetData();
		return data.getMultiplicity();
	}

	public void setMultiplicity(String newValue)
	{
		if (newValue != null && newValue.length() > 256)
		throw new MithraBusinessException("Attribute 'multiplicity' cannot exceed maximum length of 256: " + newValue);
		zSetString(AssociationEndFinder.multiplicity(), newValue, false, false );
	}

	public final boolean isNameNull()
	{
		return ((AssociationEndData) this.zSynchronizedGetData()).isNameNull();
	}

	public final String getName()
	{
		AssociationEndData data = (AssociationEndData) this.zSynchronizedGetData();
		return data.getName();
	}

	public void setName(String newValue)
	{
		if (newValue != null && newValue.length() > 256)
		throw new MithraBusinessException("Attribute 'name' cannot exceed maximum length of 256: " + newValue);
		MithraDataObject d = zSetString(AssociationEndFinder.name(), newValue, true, false );
		if (d == null) return;
		AssociationEndData data = (AssociationEndData) d;
		TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
		if (!_behavior.isPersisted())
		{
			AssociationEndModifierList associationEndModifiers =
			(AssociationEndModifierList ) data.getAssociationEndModifiers();
			if (associationEndModifiers != null)
			{
				associationEndModifiers.setAssociationEndName(newValue);
			}

			AssociationEndOrderByList orderBys =
			(AssociationEndOrderByList ) data.getOrderBys();
			if (orderBys != null)
			{
				orderBys.setAssociationEndName(newValue);
			}
		}
	}

	public boolean isOrdinalNull()
	{
		return ((AssociationEndData) this.zSynchronizedGetData()).isOrdinalNull();
	}

	public int getOrdinal()
	{
		AssociationEndData data = (AssociationEndData) this.zSynchronizedGetData();
		return data.getOrdinal();
	}

	public void setOrdinal(int newValue)
	{
		zSetInteger(AssociationEndFinder.ordinal(), newValue, false, false ,false);
	}

	public final boolean isOwningClassNameNull()
	{
		return ((AssociationEndData) this.zSynchronizedGetData()).isOwningClassNameNull();
	}

	public final String getOwningClassName()
	{
		AssociationEndData data = (AssociationEndData) this.zSynchronizedGetData();
		return data.getOwningClassName();
	}

	public void setOwningClassName(String newValue)
	{
		if (newValue != null && newValue.length() > 256)
		throw new MithraBusinessException("Attribute 'owningClassName' cannot exceed maximum length of 256: " + newValue);
		MithraDataObject d = zSetString(AssociationEndFinder.owningClassName(), newValue, true, false );
		if (d == null) return;
		AssociationEndData data = (AssociationEndData) d;
		TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
		if (!_behavior.isPersisted())
		{
			AssociationEndModifierList associationEndModifiers =
			(AssociationEndModifierList ) data.getAssociationEndModifiers();
			if (associationEndModifiers != null)
			{
				associationEndModifiers.setOwningClassName(newValue);
			}

			AssociationEndOrderByList orderBys =
			(AssociationEndOrderByList ) data.getOrderBys();
			if (orderBys != null)
			{
				orderBys.setAssociationEndClassName(newValue);
			}
		}
	}

	public boolean isResultTypeNameNull()
	{
		return ((AssociationEndData) this.zSynchronizedGetData()).isResultTypeNameNull();
	}

	public String getResultTypeName()
	{
		AssociationEndData data = (AssociationEndData) this.zSynchronizedGetData();
		return data.getResultTypeName();
	}

	public void setResultTypeName(String newValue)
	{
		if (newValue != null && newValue.length() > 256)
		throw new MithraBusinessException("Attribute 'resultTypeName' cannot exceed maximum length of 256: " + newValue);
		zSetString(AssociationEndFinder.resultTypeName(), newValue, false, false );
	}

	protected void issuePrimitiveNullSetters(TransactionalBehavior behavior, MithraDataObject data)
	{
	}

	public void zPersistDetachedRelationships(MithraDataObject _data)
	{
		AssociationEndData _newData = (AssociationEndData) _data;
		{
			AssociationEndModifierList associationEndModifiers =
			(AssociationEndModifierList) _newData.getAssociationEndModifiers();
			if (associationEndModifiers != null)
			{
				associationEndModifiers.copyDetachedValuesToOriginalOrInsertIfNewOrDeleteIfRemoved();
			}
		}

		{
			AssociationEndOrderByList orderBys =
			(AssociationEndOrderByList) _newData.getOrderBys();
			if (orderBys != null)
			{
				orderBys.copyDetachedValuesToOriginalOrInsertIfNewOrDeleteIfRemoved();
			}
		}
	}

	public void zSetTxDetachedDeleted()
	{
		TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
		if (_behavior.isDetached() && _behavior.isDeleted()) return;
		AssociationEndData _newData = (AssociationEndData) _behavior.getCurrentDataForRead(this);
		if (_newData.getAssociationEndModifiers() != null && !(_newData.getAssociationEndModifiers() instanceof NulledRelation))
		{
			((AssociationEndModifierList)_newData.getAssociationEndModifiers()).zSetTxDetachedDeleted();
		}

		if (_newData.getOrderBys() != null && !(_newData.getOrderBys() instanceof NulledRelation))
		{
			((AssociationEndOrderByList)_newData.getOrderBys()).zSetTxDetachedDeleted();
		}

		this.zSetTxPersistenceState(PersistenceState.DETACHED_DELETED);
	}

	public void zSetNonTxDetachedDeleted()
	{
		TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
		AssociationEndData _newData = (AssociationEndData) _behavior.getCurrentDataForRead(this);
		if (_newData.getAssociationEndModifiers() != null && !(_newData.getAssociationEndModifiers() instanceof NulledRelation))
		{
			((AssociationEndModifierList)_newData.getAssociationEndModifiers()).zSetNonTxDetachedDeleted();
		}

		if (_newData.getOrderBys() != null && !(_newData.getOrderBys() instanceof NulledRelation))
		{
			((AssociationEndOrderByList)_newData.getOrderBys()).zSetNonTxDetachedDeleted();
		}

		this.zSetNonTxPersistenceState(PersistenceState.DETACHED_DELETED);
	}

	/**
	* Relationship Expression:
	this.resultTypeName = Klass.name
* @see Klass#getAssociationEndsResultTypeOf() reverse relationship Klass.getAssociationEndsResultTypeOf() * @return The result type */ public Klass getResultType() { Klass _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); MithraObjectPortal _portal = null; if (_behavior.isPersisted()) { { _portal = KlassFinder.getMithraObjectPortal(); Object _related = _portal.getAsOneFromCache(this, _data, forresultType, null, null); if (!(_related instanceof NulledRelation)) _result = (Klass) _related; if (_related == null) { _op = KlassFinder.name().eq(_data.getResultTypeName()); } } } else if (_behavior.isDetached()) { { { Operation detachedOp = KlassFinder.name().eq(_data.getResultTypeName()); _result = KlassFinder.zFindOneForRelationship(detachedOp); } } } else if (_behavior.isInMemory()) { _result = (Klass) _data.getResultType(); if (_result == null) { { _op = KlassFinder.name().eq(_data.getResultTypeName()); } } } if (_op != null) { _result = KlassFinder.zFindOneForRelationship(_op); } return _result; } public void setResultType(Klass resultType) { Klass _resultType = (Klass) resultType; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { _data.setResultType(_resultType); if (_resultType == null) { this.setResultTypeName(null); } else { this.setResultTypeName(_resultType.getName()); } } else if (_behavior.isPersisted()) { _behavior.clearTempTransaction(this); if (_resultType == null) { this.setResultTypeName(null); } else { this.setResultTypeName( _resultType.getName()); } } else throw new RuntimeException("not implemented"); } /** * Relationship Expression:
	this.owningClassName = AssociationEndModifier.owningClassName and this.name = AssociationEndModifier.associationEndName
* Order By: ordinal asc. * @see AssociationEndModifier#getAssociationEnd() reverse relationship AssociationEndModifier.getAssociationEnd() * @return association end modifiers */ public AssociationEndModifierList getAssociationEndModifiers() { AssociationEndModifierList _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); if (_behavior.isPersisted()) { { { _op = new RelationshipMultiEqualityOperation(AssociationEndFinder.associationEndModifiers().zGetRelationshipMultiExtractor(), this); } } } else if (_behavior.isDetached()) { _result = (AssociationEndModifierList) _data.getAssociationEndModifiers(); if (_result == null) { { Operation detachedOp = new RelationshipMultiEqualityOperation(AssociationEndFinder.associationEndModifiers().zGetRelationshipMultiExtractor(), this); _result = new AssociationEndModifierList(detachedOp); _result.zSetForRelationship(); if(_result != null) { _result = _result.getDetachedCopy(); } _result.zSetAddHandler(new AssociationEndModifiersAddHandlerInMemory()); } _result.setOrderBy(AssociationEndModifierFinder.ordinal().ascendingOrderBy()); _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); _data.setAssociationEndModifiers(_result); if (_result != null) _result.zSetParentContainerassociationEnd(this); } } else if (_behavior.isInMemory()) { _result = (AssociationEndModifierList) _data.getAssociationEndModifiers(); if (_result == null) { _result = new AssociationEndModifierList(); _result.zSetAddHandler(new AssociationEndModifiersAddHandlerInMemory()); _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); _data.setAssociationEndModifiers(_result); } } if (_op != null) { _result = new AssociationEndModifierList(_op); _result.zSetForRelationship(); _result.zSetRemoveHandler(DeleteOnRemoveHandler.getInstance()); _result.zSetAddHandler(new AssociationEndModifiersAddHandlerPersisted()); _result.setOrderBy(AssociationEndModifierFinder.ordinal().ascendingOrderBy()); } return _result; } public void setAssociationEndModifiers(AssociationEndModifierList associationEndModifiers) { AssociationEndModifierList _associationEndModifiers = (AssociationEndModifierList) associationEndModifiers; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { if (_behavior.isDetached() && _associationEndModifiers != null) { _associationEndModifiers.zMakeDetached(new RelationshipMultiEqualityOperation(AssociationEndFinder.associationEndModifiers().zGetRelationshipMultiExtractor(), this), _data.getAssociationEndModifiers()); } _data.setAssociationEndModifiers(_associationEndModifiers); if (_associationEndModifiers != null) { _associationEndModifiers.setOwningClassName(_data.getOwningClassName()); _associationEndModifiers.setAssociationEndName(_data.getName()); _associationEndModifiers.zSetParentContainerassociationEnd(this); _associationEndModifiers.zSetAddHandler(new AssociationEndModifiersAddHandlerInMemory()); } else if (_behavior.isDetached()) { throw new MithraBusinessException("to-many relationships cannot be set to null. Use the clear() method on the list instead."); } } else if (_behavior.isPersisted()) { _behavior.clearTempTransaction(this); _associationEndModifiers.zSetAddHandler(new AssociationEndModifiersAddHandlerPersisted()); AssociationEndModifierList associationEndModifiersToDelete = new AssociationEndModifierList(); associationEndModifiersToDelete.addAll(this.getAssociationEndModifiers()); for(int i=0;i < _associationEndModifiers.size(); i++) { AssociationEndModifier item = _associationEndModifiers.getAssociationEndModifierAt(i); if (!associationEndModifiersToDelete.remove(item)) { item.setOwningClassName(_data.getOwningClassName()); item.setAssociationEndName(_data.getName()); item.cascadeInsert(); } } associationEndModifiersToDelete.cascadeDeleteAll(); } else throw new RuntimeException("not implemented"); } public boolean isAssociationEndModifiersModifiedSinceDetachment() { TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); AssociationEndModifierList associationEndModifiers = (AssociationEndModifierList) _data.getAssociationEndModifiers(); if( associationEndModifiers != null) { return associationEndModifiers.isModifiedSinceDetachment(); } return false; } /** * Relationship Expression:
	this.owningClassName = AssociationEndOrderBy.associationEndClassName and this.name = AssociationEndOrderBy.associationEndName
* Order By: ordinal asc. * @see AssociationEndOrderBy#getAssociationEnd() reverse relationship AssociationEndOrderBy.getAssociationEnd() * @return order bys */ public AssociationEndOrderByList getOrderBys() { AssociationEndOrderByList _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); if (_behavior.isPersisted()) { { { _op = new RelationshipMultiEqualityOperation(AssociationEndFinder.orderBys().zGetRelationshipMultiExtractor(), this); } } } else if (_behavior.isDetached()) { _result = (AssociationEndOrderByList) _data.getOrderBys(); if (_result == null) { { Operation detachedOp = new RelationshipMultiEqualityOperation(AssociationEndFinder.orderBys().zGetRelationshipMultiExtractor(), this); _result = new AssociationEndOrderByList(detachedOp); _result.zSetForRelationship(); if(_result != null) { _result = _result.getDetachedCopy(); } _result.zSetAddHandler(new OrderBysAddHandlerInMemory()); } _result.setOrderBy(AssociationEndOrderByFinder.ordinal().ascendingOrderBy()); _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); _data.setOrderBys(_result); if (_result != null) _result.zSetParentContainerassociationEnd(this); } } else if (_behavior.isInMemory()) { _result = (AssociationEndOrderByList) _data.getOrderBys(); if (_result == null) { _result = new AssociationEndOrderByList(); _result.zSetAddHandler(new OrderBysAddHandlerInMemory()); _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); _data.setOrderBys(_result); } } if (_op != null) { _result = new AssociationEndOrderByList(_op); _result.zSetForRelationship(); _result.zSetRemoveHandler(DeleteOnRemoveHandler.getInstance()); _result.zSetAddHandler(new OrderBysAddHandlerPersisted()); _result.setOrderBy(AssociationEndOrderByFinder.ordinal().ascendingOrderBy()); } return _result; } public void setOrderBys(AssociationEndOrderByList orderBys) { AssociationEndOrderByList _orderBys = (AssociationEndOrderByList) orderBys; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { if (_behavior.isDetached() && _orderBys != null) { _orderBys.zMakeDetached(new RelationshipMultiEqualityOperation(AssociationEndFinder.orderBys().zGetRelationshipMultiExtractor(), this), _data.getOrderBys()); } _data.setOrderBys(_orderBys); if (_orderBys != null) { _orderBys.setAssociationEndClassName(_data.getOwningClassName()); _orderBys.setAssociationEndName(_data.getName()); _orderBys.zSetParentContainerassociationEnd(this); _orderBys.zSetAddHandler(new OrderBysAddHandlerInMemory()); } else if (_behavior.isDetached()) { throw new MithraBusinessException("to-many relationships cannot be set to null. Use the clear() method on the list instead."); } } else if (_behavior.isPersisted()) { _behavior.clearTempTransaction(this); _orderBys.zSetAddHandler(new OrderBysAddHandlerPersisted()); AssociationEndOrderByList orderBysToDelete = new AssociationEndOrderByList(); orderBysToDelete.addAll(this.getOrderBys()); for(int i=0;i < _orderBys.size(); i++) { AssociationEndOrderBy item = _orderBys.getAssociationEndOrderByAt(i); if (!orderBysToDelete.remove(item)) { item.setAssociationEndClassName(_data.getOwningClassName()); item.setAssociationEndName(_data.getName()); item.cascadeInsert(); } } orderBysToDelete.cascadeDeleteAll(); } else throw new RuntimeException("not implemented"); } public boolean isOrderBysModifiedSinceDetachment() { TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); AssociationEndOrderByList orderBys = (AssociationEndOrderByList) _data.getOrderBys(); if( orderBys != null) { return orderBys.isModifiedSinceDetachment(); } return false; } /** * Relationship Expression:
	Association.name = this.associationName
* @see Association#getAssociationEnds() reverse relationship Association.getAssociationEnds() * @return The owning association */ public Association getOwningAssociation() { Association _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); MithraObjectPortal _portal = null; if (_behavior.isPersisted()) { { _portal = AssociationFinder.getMithraObjectPortal(); Object _related = _portal.getAsOneFromCache(this, _data, forowningAssociation, null, null); if (!(_related instanceof NulledRelation)) _result = (Association) _related; if (_related == null) { _op = AssociationFinder.name().eq(_data.getAssociationName()); } } } else if (_behavior.isDetached()) { if (_data.getOwningAssociation() instanceof NulledRelation) { return null; } _result = (Association) _data.getOwningAssociation(); if (_result == null) { { Operation detachedOp = AssociationFinder.name().eq(_data.getAssociationName()); _result = AssociationFinder.zFindOneForRelationship(detachedOp); if(_result != null) { _result = _result.getDetachedCopy(); } } _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); _data.setOwningAssociation(_result); } } else if (_behavior.isInMemory()) { _result = (Association) _data.getOwningAssociation(); if (_result == null) { { _op = AssociationFinder.name().eq(_data.getAssociationName()); } } } if (_op != null) { _result = AssociationFinder.zFindOneForRelationship(_op); } return _result; } public void setOwningAssociation(Association owningAssociation) { Association _owningAssociation = (Association) owningAssociation; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { Object _prev = _data.getOwningAssociation(); if (_behavior.isDetached() && _prev != null) { ((DelegatingList)((Association)_prev).getAssociationEnds()).zMarkMoved( (AssociationEnd) this); } _data.setOwningAssociation(_owningAssociation); _owningAssociation.getAssociationEnds().add( (AssociationEnd) this); } else if (_behavior.isPersisted()) { _behavior.clearTempTransaction(this); if (_owningAssociation == null) { this.setAssociationName(null); } else { this.setAssociationName( _owningAssociation.getName()); } } else throw new RuntimeException("not implemented"); } public void zSetParentContainerowningAssociation(AssociationAbstract parent) { TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); _behavior.clearTempTransaction(this); if (_behavior.isInMemory()) { _data.setOwningAssociation(parent); } } /** * Relationship Expression:
	Klass.name = this.owningClassName
* @see Klass#getAssociationEnds() reverse relationship Klass.getAssociationEnds() * @return The owning class */ public Klass getOwningClass() { Klass _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); MithraObjectPortal _portal = null; if (_behavior.isPersisted()) { { _portal = KlassFinder.getMithraObjectPortal(); Object _related = _portal.getAsOneFromCache(this, _data, forowningClass, null, null); if (!(_related instanceof NulledRelation)) _result = (Klass) _related; if (_related == null) { _op = KlassFinder.name().eq(_data.getOwningClassName()); } } } else if (_behavior.isDetached()) { { { Operation detachedOp = KlassFinder.name().eq(_data.getOwningClassName()); _result = KlassFinder.zFindOneForRelationship(detachedOp); } } } else if (_behavior.isInMemory()) { _result = (Klass) _data.getOwningClass(); if (_result == null) { { _op = KlassFinder.name().eq(_data.getOwningClassName()); } } } if (_op != null) { _result = KlassFinder.zFindOneForRelationship(_op); } return _result; } public void setOwningClass(Klass owningClass) { Klass _owningClass = (Klass) owningClass; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { _data.setOwningClass(_owningClass); if (_owningClass == null) { this.setOwningClassName(null); } else { this.setOwningClassName(_owningClass.getName()); } } else if (_behavior.isPersisted()) { _behavior.clearTempTransaction(this); if (_owningClass == null) { this.setOwningClassName(null); } else { this.setOwningClassName( _owningClass.getName()); } } else throw new RuntimeException("not implemented"); } /** * Relationship Expression:
	(MemberReferencePathAssociationEndMapping.associationOwningClassName = this.owningClassName and MemberReferencePathAssociationEndMapping.associationEndName = this.name )
* @see MemberReferencePathAssociationEndMapping#getAssociationEnd() reverse relationship MemberReferencePathAssociationEndMapping.getAssociationEnd() * @return member reference paths */ public MemberReferencePathAssociationEndMappingList getMemberReferencePaths() { MemberReferencePathAssociationEndMappingList _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); if (_behavior.isPersisted()) { { { _op = new RelationshipMultiEqualityOperation(AssociationEndFinder.memberReferencePaths().zGetRelationshipMultiExtractor(), this); } } } else if (_behavior.isDetached()) { { { Operation detachedOp = new RelationshipMultiEqualityOperation(AssociationEndFinder.memberReferencePaths().zGetRelationshipMultiExtractor(), this); _result = new MemberReferencePathAssociationEndMappingList(detachedOp); _result.zSetForRelationship(); } } } else if (_behavior.isInMemory()) { _result = (MemberReferencePathAssociationEndMappingList) _data.getMemberReferencePaths(); if (_result == null) { { _op = new RelationshipMultiEqualityOperation(AssociationEndFinder.memberReferencePaths().zGetRelationshipMultiExtractor(), this); } } } if (_op != null) { _result = new MemberReferencePathAssociationEndMappingList(_op); _result.zSetForRelationship(); } return _result; } public void setMemberReferencePaths(MemberReferencePathAssociationEndMappingList memberReferencePaths) { MemberReferencePathAssociationEndMappingList _memberReferencePaths = (MemberReferencePathAssociationEndMappingList) memberReferencePaths; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { _data.setMemberReferencePaths(_memberReferencePaths); } else if (_behavior.isPersisted()) { _behavior.clearTempTransaction(this); } else throw new RuntimeException("not implemented"); } /** * Relationship Expression:
	(ProjectionWithAssociationEnd.associationEndClass = this.owningClassName and ProjectionWithAssociationEnd.associationEndName = this.name )
* @see ProjectionWithAssociationEnd#getAssociationEnd() reverse relationship ProjectionWithAssociationEnd.getAssociationEnd() * @return projections with association end */ public ProjectionWithAssociationEndList getProjectionsWithAssociationEnd() { ProjectionWithAssociationEndList _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForRead(this); if (_behavior.isPersisted()) { { { _op = new RelationshipMultiEqualityOperation(AssociationEndFinder.projectionsWithAssociationEnd().zGetRelationshipMultiExtractor(), this); } } } else if (_behavior.isDetached()) { { { Operation detachedOp = new RelationshipMultiEqualityOperation(AssociationEndFinder.projectionsWithAssociationEnd().zGetRelationshipMultiExtractor(), this); _result = new ProjectionWithAssociationEndList(detachedOp); _result.zSetForRelationship(); } } } else if (_behavior.isInMemory()) { _result = (ProjectionWithAssociationEndList) _data.getProjectionsWithAssociationEnd(); if (_result == null) { { _op = new RelationshipMultiEqualityOperation(AssociationEndFinder.projectionsWithAssociationEnd().zGetRelationshipMultiExtractor(), this); } } } if (_op != null) { _result = new ProjectionWithAssociationEndList(_op); _result.zSetForRelationship(); } return _result; } public void setProjectionsWithAssociationEnd(ProjectionWithAssociationEndList projectionsWithAssociationEnd) { ProjectionWithAssociationEndList _projectionsWithAssociationEnd = (ProjectionWithAssociationEndList) projectionsWithAssociationEnd; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { _data.setProjectionsWithAssociationEnd(_projectionsWithAssociationEnd); } else if (_behavior.isPersisted()) { _behavior.clearTempTransaction(this); } else throw new RuntimeException("not implemented"); } protected void cascadeInsertImpl() throws MithraBusinessException { TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); AssociationEndModifierList associationEndModifiers = (AssociationEndModifierList) _data.getAssociationEndModifiers(); AssociationEndOrderByList orderBys = (AssociationEndOrderByList) _data.getOrderBys(); _behavior.insert(this); if (associationEndModifiers != null) { associationEndModifiers.cascadeInsertAll(); } if (orderBys != null) { orderBys.cascadeInsertAll(); } } @Override public Map< RelatedFinder, StatisticCounter > zAddNavigatedRelationshipsStats(RelatedFinder finder, Map< RelatedFinder, StatisticCounter > navigationStats) { TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); _behavior.addNavigatedRelationshipsStats(this, finder, navigationStats); return navigationStats; } @Override public Map< RelatedFinder, StatisticCounter > zAddNavigatedRelationshipsStatsForUpdate(RelatedFinder parentFinderGeneric, Map< RelatedFinder, StatisticCounter > navigationStats) { AssociationEndFinder.AssociationEndRelatedFinder parentFinder = (AssociationEndFinder.AssociationEndRelatedFinder) parentFinderGeneric; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _newData = (AssociationEndData) _behavior.getCurrentDataForWrite(this); { AssociationEndModifierList associationEndModifiers = (AssociationEndModifierList) _newData.getAssociationEndModifiers(); RelatedFinder dependentFinder = parentFinder.associationEndModifiers(); DeepRelationshipUtility.zAddToNavigationStats(dependentFinder, associationEndModifiers != null, navigationStats); if (associationEndModifiers != null) { associationEndModifiers.zCascadeAddNavigatedRelationshipsStats(dependentFinder, navigationStats); } } { AssociationEndOrderByList orderBys = (AssociationEndOrderByList) _newData.getOrderBys(); RelatedFinder dependentFinder = parentFinder.orderBys(); DeepRelationshipUtility.zAddToNavigationStats(dependentFinder, orderBys != null, navigationStats); if (orderBys != null) { orderBys.zCascadeAddNavigatedRelationshipsStats(dependentFinder, navigationStats); } } return navigationStats; } @Override public Map< RelatedFinder, StatisticCounter > zAddNavigatedRelationshipsStatsForDelete(RelatedFinder parentFinder, Map< RelatedFinder, StatisticCounter > navigationStats) { DeepRelationshipUtility.zAddAllDependentNavigationsStatsForDelete(parentFinder, navigationStats); return navigationStats; } @Override public AssociationEnd zCascadeCopyThenInsert() throws MithraBusinessException { TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationEndData _data = (AssociationEndData) _behavior.getCurrentDataForWrite(this); AssociationEndModifierList associationEndModifiers = (AssociationEndModifierList) _data.getAssociationEndModifiers(); AssociationEndOrderByList orderBys = (AssociationEndOrderByList) _data.getOrderBys(); AssociationEnd original = (AssociationEnd) _behavior.copyThenInsert(this); if (associationEndModifiers != null) { associationEndModifiers.zCascadeCopyThenInsertAll(); } if (orderBys != null) { orderBys.zCascadeCopyThenInsertAll(); } return original; } protected void cascadeDeleteImpl() throws MithraBusinessException { this.getAssociationEndModifiers().cascadeDeleteAll(); this.getOrderBys().cascadeDeleteAll(); this.delete(); } public Cache zGetCache() { return AssociationEndFinder.getMithraObjectPortal().getCache(); } public MithraObjectPortal zGetPortal() { return AssociationEndFinder.getMithraObjectPortal(); } public AssociationEnd getOriginalPersistentObject() { return this.zFindOriginal(); } protected boolean issueUpdatesForNonPrimaryKeys(TransactionalBehavior behavior, MithraDataObject data, MithraDataObject newData) { boolean changed = false; changed |= zUpdateString(behavior, data, newData, AssociationEndFinder.associationName(), false); changed |= zUpdateString(behavior, data, newData, AssociationEndFinder.direction(), false); changed |= zUpdateString(behavior, data, newData, AssociationEndFinder.multiplicity(), false); changed |= zUpdateInteger(behavior, data, newData, AssociationEndFinder.ordinal(), false); changed |= zUpdateString(behavior, data, newData, AssociationEndFinder.resultTypeName(), false); return changed; } protected boolean issueUpdatesForPrimaryKeys(TransactionalBehavior behavior, MithraDataObject data, MithraDataObject newData) { boolean changed = false; changed |= zUpdateString(behavior, data, newData, AssociationEndFinder.name(), false); changed |= zUpdateString(behavior, data, newData, AssociationEndFinder.owningClassName(), false); return changed; } public Object readResolve() throws ObjectStreamException { AssociationEndAbstract result = (AssociationEndAbstract) super.readResolve(); if (result.persistenceState == PersistenceState.PERSISTED) { result.persistenceState = PERSISTED_STATE; } else if (result.persistenceState == PersistenceState.IN_MEMORY) { result.persistenceState = MEMORY_STATE; } return result; } protected static void zConfigNonTx() { MEMORY_STATE = PersistenceState.IN_MEMORY_NON_TRANSACTIONAL; PERSISTED_STATE = PersistenceState.PERSISTED_NON_TRANSACTIONAL; } protected static void zConfigFullTx() { MEMORY_STATE = PersistenceState.IN_MEMORY; PERSISTED_STATE = PersistenceState.PERSISTED; } protected class AssociationEndModifiersAddHandlerInMemory implements DependentRelationshipAddHandler { public void addRelatedObject(MithraTransactionalObject relatedObject) { AssociationEndModifier item = (AssociationEndModifier) relatedObject; item.setOwningClassName(getOwningClassName()); item.setAssociationEndName(getName()); item.zSetParentContainerassociationEnd(AssociationEndAbstract.this); } } protected class AssociationEndModifiersAddHandlerPersisted implements DependentRelationshipAddHandler { public void addRelatedObject(MithraTransactionalObject relatedObject) { AssociationEndModifier item = (AssociationEndModifier) relatedObject; item.setOwningClassName(getOwningClassName()); item.setAssociationEndName(getName()); item.cascadeInsert(); } } protected class OrderBysAddHandlerInMemory implements DependentRelationshipAddHandler { public void addRelatedObject(MithraTransactionalObject relatedObject) { AssociationEndOrderBy item = (AssociationEndOrderBy) relatedObject; item.setAssociationEndClassName(getOwningClassName()); item.setAssociationEndName(getName()); item.zSetParentContainerassociationEnd(AssociationEndAbstract.this); } } protected class OrderBysAddHandlerPersisted implements DependentRelationshipAddHandler { public void addRelatedObject(MithraTransactionalObject relatedObject) { AssociationEndOrderBy item = (AssociationEndOrderBy) relatedObject; item.setAssociationEndClassName(getOwningClassName()); item.setAssociationEndName(getName()); item.cascadeInsert(); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy