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

klass.model.meta.domain.AssociationAbstract 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 AssociationAbstract extends com.gs.fw.common.mithra.superclassimpl.MithraTransactionalObjectImpl
{
	private static byte MEMORY_STATE = PersistenceState.IN_MEMORY;
	private static byte PERSISTED_STATE = PersistenceState.PERSISTED;
	private static final Logger logger = LoggerFactory.getLogger(Association.class.getName());
	private static final RelationshipHashStrategy forcriteria = new CriteriaRhs();
	private static final RelationshipHashStrategy forpackageableElementSuperClass = new PackageableElementSuperClassRhs();
	private static final class CriteriaRhs implements RelationshipHashStrategy
	{
		public boolean equalsForRelationship(Object _srcObject, Object _srcData, Object _targetData, Timestamp _asOfDate0, Timestamp _asOfDate1)
		{
			AssociationData _castedSrcData = (AssociationData) _srcData;
			CriteriaData _castedTargetData = (CriteriaData) _targetData;
			if (_castedSrcData.getCriteriaId() == _castedTargetData.getId())
			{
				return true;
			}

			return false;
		}

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

		public int computeOffHeapHashCodeFromRelated(Object _srcObject, Object _srcData)
		{
			return computeHashCodeFromRelated(_srcObject, _srcData);
		}
	}

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

			return false;
		}

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

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

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

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

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

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

	public Association zFindOriginal()
	{
		AssociationData data = (AssociationData) this.currentData;
		Operation op;
		op = AssociationFinder.name().eq(data.getName());
		return AssociationFinder.findOne(op);
	}

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

	private Logger getLogger()
	{
		return logger;
	}

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

	protected void zSetFromAssociationData( AssociationData data )
	{
		super.zSetData(data);
		this.persistenceState = PERSISTED_STATE;
	}

	public void setFromAssociationData( AssociationData data )
	{
		super.zSetData(data);
	}

	public void zWriteDataClassName(ObjectOutput out) throws IOException
	{
	}

	public boolean isCriteriaIdNull()
	{
		return ((AssociationData) this.zSynchronizedGetData()).isCriteriaIdNull();
	}

	public long getCriteriaId()
	{
		AssociationData data = (AssociationData) this.zSynchronizedGetData();
		return data.getCriteriaId();
	}

	public void setCriteriaId(long newValue)
	{
		zSetLong(AssociationFinder.criteriaId(), newValue, false, false ,false);
	}

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

	public final String getName()
	{
		AssociationData data = (AssociationData) 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(AssociationFinder.name(), newValue, true, false );
		if (d == null) return;
		AssociationData data = (AssociationData) d;
		TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
		if (!_behavior.isPersisted())
		{
			AssociationEndList associationEnds =
			(AssociationEndList ) data.getAssociationEnds();
			if (associationEnds != null)
			{
				associationEnds.setAssociationName(newValue);
			}
		}
	}

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

	public void zPersistDetachedRelationships(MithraDataObject _data)
	{
		AssociationData _newData = (AssociationData) _data;
		{
			AssociationEndList associationEnds =
			(AssociationEndList) _newData.getAssociationEnds();
			if (associationEnds != null)
			{
				associationEnds.copyDetachedValuesToOriginalOrInsertIfNewOrDeleteIfRemoved();
			}
		}
	}

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

		this.zSetTxPersistenceState(PersistenceState.DETACHED_DELETED);
	}

	public void zSetNonTxDetachedDeleted()
	{
		TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
		AssociationData _newData = (AssociationData) _behavior.getCurrentDataForRead(this);
		if (_newData.getAssociationEnds() != null && !(_newData.getAssociationEnds() instanceof NulledRelation))
		{
			((AssociationEndList)_newData.getAssociationEnds()).zSetNonTxDetachedDeleted();
		}

		this.zSetNonTxPersistenceState(PersistenceState.DETACHED_DELETED);
	}

	/**
	* Relationship Expression:
	this.name = AssociationEnd.associationName
* Order By: direction asc. * @see AssociationEnd#getOwningAssociation() reverse relationship AssociationEnd.getOwningAssociation() * @return association ends */ public AssociationEndList getAssociationEnds() { AssociationEndList _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForRead(this); if (_behavior.isPersisted()) { { { _op = AssociationEndFinder.associationName().eq(_data.getName()); } } } else if (_behavior.isDetached()) { _result = (AssociationEndList) _data.getAssociationEnds(); if (_result == null) { { Operation detachedOp = AssociationEndFinder.associationName().eq(_data.getName()); _result = new AssociationEndList(detachedOp); _result.zSetForRelationship(); if(_result != null) { _result = _result.getDetachedCopy(); } _result.zSetAddHandler(new AssociationEndsAddHandlerInMemory()); } _result.setOrderBy(AssociationEndFinder.direction().ascendingOrderBy()); _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); _data = (AssociationData) _behavior.getCurrentDataForWrite(this); _data.setAssociationEnds(_result); if (_result != null) _result.zSetParentContainerowningAssociation(this); } } else if (_behavior.isInMemory()) { _result = (AssociationEndList) _data.getAssociationEnds(); if (_result == null) { _result = new AssociationEndList(); _result.zSetAddHandler(new AssociationEndsAddHandlerInMemory()); _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); _data = (AssociationData) _behavior.getCurrentDataForWrite(this); _data.setAssociationEnds(_result); } } if (_op != null) { _result = new AssociationEndList(_op); _result.zSetForRelationship(); _result.zSetRemoveHandler(DeleteOnRemoveHandler.getInstance()); _result.zSetAddHandler(new AssociationEndsAddHandlerPersisted()); _result.setOrderBy(AssociationEndFinder.direction().ascendingOrderBy()); } return _result; } public void setAssociationEnds(AssociationEndList associationEnds) { AssociationEndList _associationEnds = (AssociationEndList) associationEnds; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { if (_behavior.isDetached() && _associationEnds != null) { _associationEnds.zMakeDetached(AssociationEndFinder.associationName().eq(_data.getName()), _data.getAssociationEnds()); } _data.setAssociationEnds(_associationEnds); if (_associationEnds != null) { _associationEnds.setAssociationName(_data.getName()); _associationEnds.zSetParentContainerowningAssociation(this); _associationEnds.zSetAddHandler(new AssociationEndsAddHandlerInMemory()); } 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); _associationEnds.zSetAddHandler(new AssociationEndsAddHandlerPersisted()); AssociationEndList associationEndsToDelete = new AssociationEndList(); associationEndsToDelete.addAll(this.getAssociationEnds()); for(int i=0;i < _associationEnds.size(); i++) { AssociationEnd item = _associationEnds.getAssociationEndAt(i); if (!associationEndsToDelete.remove(item)) { item.setAssociationName(_data.getName()); item.cascadeInsert(); } } associationEndsToDelete.cascadeDeleteAll(); } else throw new RuntimeException("not implemented"); } public boolean isAssociationEndsModifiedSinceDetachment() { TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForRead(this); AssociationEndList associationEnds = (AssociationEndList) _data.getAssociationEnds(); if( associationEnds != null) { return associationEnds.isModifiedSinceDetachment(); } return false; } /** * Relationship Expression:
	this.criteriaId = Criteria.id
* @see Criteria#getAssociation() reverse relationship Criteria.getAssociation() * @return The criteria */ public Criteria getCriteria() { Criteria _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForRead(this); MithraObjectPortal _portal = null; if (_behavior.isPersisted()) { { _portal = CriteriaFinder.getMithraObjectPortal(); Object _related = _portal.getAsOneFromCache(this, _data, forcriteria, null, null); if (!(_related instanceof NulledRelation)) _result = (Criteria) _related; if (_related == null) { _op = CriteriaFinder.id().eq(_data.getCriteriaId()); } } } else if (_behavior.isDetached()) { { { Operation detachedOp = CriteriaFinder.id().eq(_data.getCriteriaId()); _result = CriteriaFinder.zFindOneForRelationship(detachedOp); } } } else if (_behavior.isInMemory()) { _result = (Criteria) _data.getCriteria(); if (_result == null) { { _op = CriteriaFinder.id().eq(_data.getCriteriaId()); } } } if (_op != null) { _result = CriteriaFinder.zFindOneForRelationship(_op); } return _result; } public void setCriteria(Criteria criteria) { Criteria _criteria = (Criteria) criteria; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForWrite(this); if (_behavior.isInMemory()) { _data.setCriteria(_criteria); if (_criteria == null) { this.setCriteriaId(0); } else { this.setCriteriaId(_criteria.getId()); } } else if (_behavior.isPersisted()) { _behavior.clearTempTransaction(this); if (_criteria == null) { this.setCriteriaId(0); } else { this.setCriteriaId( _criteria.getId()); } } else throw new RuntimeException("not implemented"); } /** * Relationship Expression:
	PackageableElement.name = this.name
* @see PackageableElement#getAssociationSubClass() reverse relationship PackageableElement.getAssociationSubClass() * @return The packageable element super class */ public PackageableElement getPackageableElementSuperClass() { PackageableElement _result = null; Operation _op = null; TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForRead(this); MithraObjectPortal _portal = null; if (_behavior.isPersisted()) { { _portal = PackageableElementFinder.getMithraObjectPortal(); Object _related = _portal.getAsOneFromCache(this, _data, forpackageableElementSuperClass, null, null); if (!(_related instanceof NulledRelation)) _result = (PackageableElement) _related; if (_related == null) { _op = PackageableElementFinder.name().eq(_data.getName()); } } } else if (_behavior.isDetached()) { if (_data.getPackageableElementSuperClass() instanceof NulledRelation) { return null; } _result = (PackageableElement) _data.getPackageableElementSuperClass(); if (_result == null) { { Operation detachedOp = PackageableElementFinder.name().eq(_data.getName()); _result = PackageableElementFinder.zFindOneForRelationship(detachedOp); if(_result != null) { _result = _result.getDetachedCopy(); } } _data = (AssociationData) _behavior.getCurrentDataForWrite(this); _data.setPackageableElementSuperClass(_result); } } else if (_behavior.isInMemory()) { _result = (PackageableElement) _data.getPackageableElementSuperClass(); if (_result == null) { { _op = PackageableElementFinder.name().eq(_data.getName()); } } } if (_op != null) { _result = PackageableElementFinder.zFindOneForRelationship(_op); } return _result; } public void setPackageableElementSuperClass(PackageableElement packageableElementSuperClass) { ((PackageableElement)packageableElementSuperClass).setAssociationSubClass((Association)this); } public void zSetParentContainerpackageableElementSuperClass(PackageableElementAbstract parent) { TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForWrite(this); _behavior.clearTempTransaction(this); if (_behavior.isInMemory()) { _data.setPackageableElementSuperClass(parent); } } protected void cascadeInsertImpl() throws MithraBusinessException { TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForWrite(this); AssociationEndList associationEnds = (AssociationEndList) _data.getAssociationEnds(); _behavior.insert(this); if (associationEnds != null) { associationEnds.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) { AssociationFinder.AssociationRelatedFinder parentFinder = (AssociationFinder.AssociationRelatedFinder) parentFinderGeneric; TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationData _newData = (AssociationData) _behavior.getCurrentDataForWrite(this); { AssociationEndList associationEnds = (AssociationEndList) _newData.getAssociationEnds(); RelatedFinder dependentFinder = parentFinder.associationEnds(); DeepRelationshipUtility.zAddToNavigationStats(dependentFinder, associationEnds != null, navigationStats); if (associationEnds != null) { associationEnds.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 Association zCascadeCopyThenInsert() throws MithraBusinessException { TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary(); AssociationData _data = (AssociationData) _behavior.getCurrentDataForWrite(this); AssociationEndList associationEnds = (AssociationEndList) _data.getAssociationEnds(); Association original = (Association) _behavior.copyThenInsert(this); if (associationEnds != null) { associationEnds.zCascadeCopyThenInsertAll(); } return original; } protected void cascadeDeleteImpl() throws MithraBusinessException { this.getAssociationEnds().cascadeDeleteAll(); this.delete(); } public Cache zGetCache() { return AssociationFinder.getMithraObjectPortal().getCache(); } public MithraObjectPortal zGetPortal() { return AssociationFinder.getMithraObjectPortal(); } public Association getOriginalPersistentObject() { return this.zFindOriginal(); } protected boolean issueUpdatesForNonPrimaryKeys(TransactionalBehavior behavior, MithraDataObject data, MithraDataObject newData) { boolean changed = false; changed |= zUpdateLong(behavior, data, newData, AssociationFinder.criteriaId(), false); return changed; } protected boolean issueUpdatesForPrimaryKeys(TransactionalBehavior behavior, MithraDataObject data, MithraDataObject newData) { boolean changed = false; changed |= zUpdateString(behavior, data, newData, AssociationFinder.name(), false); return changed; } public Object readResolve() throws ObjectStreamException { AssociationAbstract result = (AssociationAbstract) 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 AssociationEndsAddHandlerInMemory implements DependentRelationshipAddHandler { public void addRelatedObject(MithraTransactionalObject relatedObject) { AssociationEnd item = (AssociationEnd) relatedObject; item.setAssociationName(getName()); item.zSetParentContainerowningAssociation(AssociationAbstract.this); } } protected class AssociationEndsAddHandlerPersisted implements DependentRelationshipAddHandler { public void addRelatedObject(MithraTransactionalObject relatedObject) { AssociationEnd item = (AssociationEnd) relatedObject; item.setAssociationName(getName()); item.cascadeInsert(); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy