klass.model.meta.domain.EnumerationAbstract 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 EnumerationAbstract 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(Enumeration.class.getName());
private static final RelationshipHashStrategy forpackageableElementSuperClass = new PackageableElementSuperClassRhs();
private static final class PackageableElementSuperClassRhs implements RelationshipHashStrategy
{
public boolean equalsForRelationship(Object _srcObject, Object _srcData, Object _targetData, Timestamp _asOfDate0, Timestamp _asOfDate1)
{
EnumerationData _castedSrcData = (EnumerationData) _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)
{
EnumerationData _castedSrcData = (EnumerationData) _srcData;
return HashUtil.hash(_castedSrcData.getName());
}
public int computeOffHeapHashCodeFromRelated(Object _srcObject, Object _srcData)
{
EnumerationData _castedSrcData = (EnumerationData) _srcData;
return HashUtil.offHeapHash(_castedSrcData.getName());
}
}
public EnumerationAbstract()
{
this.persistenceState = MEMORY_STATE;
}
public Enumeration getDetachedCopy() throws MithraBusinessException
{
return (Enumeration) super.getDetachedCopy();
}
public Enumeration getNonPersistentCopy() throws MithraBusinessException
{
Enumeration result = (Enumeration) super.getNonPersistentCopy();
result.persistenceState = MEMORY_STATE;
return result;
}
public Enumeration copyDetachedValuesToOriginalOrInsertIfNew()
{
return (Enumeration) this.zCopyDetachedValuesToOriginalOrInsertIfNew();
}
public Enumeration zFindOriginal()
{
EnumerationData data = (EnumerationData) this.currentData;
Operation op;
op = EnumerationFinder.name().eq(data.getName());
return EnumerationFinder.findOne(op);
}
public boolean isModifiedSinceDetachmentByDependentRelationships()
{
if(this.isModifiedSinceDetachment()) return true;
if(isEnumerationLiteralsModifiedSinceDetachment()) return true;
return false;
}
private Logger getLogger()
{
return logger;
}
public MithraDataObject zAllocateData()
{
return new EnumerationData();
}
protected void zSetFromEnumerationData( EnumerationData data )
{
super.zSetData(data);
this.persistenceState = PERSISTED_STATE;
}
public void setFromEnumerationData( EnumerationData data )
{
super.zSetData(data);
}
public void zWriteDataClassName(ObjectOutput out) throws IOException
{
}
public final boolean isNameNull()
{
return ((EnumerationData) this.zSynchronizedGetData()).isNameNull();
}
public final String getName()
{
EnumerationData data = (EnumerationData) 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(EnumerationFinder.name(), newValue, true, false );
if (d == null) return;
EnumerationData data = (EnumerationData) d;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
if (!_behavior.isPersisted())
{
EnumerationLiteralList enumerationLiterals =
(EnumerationLiteralList ) data.getEnumerationLiterals();
if (enumerationLiterals != null)
{
enumerationLiterals.setEnumerationName(newValue);
}
}
}
protected void issuePrimitiveNullSetters(TransactionalBehavior behavior, MithraDataObject data)
{
}
public void zPersistDetachedRelationships(MithraDataObject _data)
{
EnumerationData _newData = (EnumerationData) _data;
{
EnumerationLiteralList enumerationLiterals =
(EnumerationLiteralList) _newData.getEnumerationLiterals();
if (enumerationLiterals != null)
{
enumerationLiterals.copyDetachedValuesToOriginalOrInsertIfNewOrDeleteIfRemoved();
}
}
}
public void zSetTxDetachedDeleted()
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
if (_behavior.isDetached() && _behavior.isDeleted()) return;
EnumerationData _newData = (EnumerationData) _behavior.getCurrentDataForRead(this);
if (_newData.getEnumerationLiterals() != null && !(_newData.getEnumerationLiterals() instanceof NulledRelation))
{
((EnumerationLiteralList)_newData.getEnumerationLiterals()).zSetTxDetachedDeleted();
}
this.zSetTxPersistenceState(PersistenceState.DETACHED_DELETED);
}
public void zSetNonTxDetachedDeleted()
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
EnumerationData _newData = (EnumerationData) _behavior.getCurrentDataForRead(this);
if (_newData.getEnumerationLiterals() != null && !(_newData.getEnumerationLiterals() instanceof NulledRelation))
{
((EnumerationLiteralList)_newData.getEnumerationLiterals()).zSetNonTxDetachedDeleted();
}
this.zSetNonTxPersistenceState(PersistenceState.DETACHED_DELETED);
}
/**
* Relationship Expression:
this.name = EnumerationLiteral.enumerationName
* Order By: ordinal asc
.
* @see EnumerationLiteral#getEnumeration() reverse relationship EnumerationLiteral.getEnumeration()
* @return enumeration literals
*/
public EnumerationLiteralList getEnumerationLiterals()
{
EnumerationLiteralList _result = null;
Operation _op = null;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForRead(this);
if (_behavior.isPersisted())
{
{
{
_op = EnumerationLiteralFinder.enumerationName().eq(_data.getName());
}
}
}
else if (_behavior.isDetached())
{
_result = (EnumerationLiteralList) _data.getEnumerationLiterals();
if (_result == null)
{
{
Operation detachedOp = EnumerationLiteralFinder.enumerationName().eq(_data.getName());
_result = new EnumerationLiteralList(detachedOp);
_result.zSetForRelationship();
if(_result != null)
{
_result = _result.getDetachedCopy();
}
_result.zSetAddHandler(new EnumerationLiteralsAddHandlerInMemory());
}
_result.setOrderBy(EnumerationLiteralFinder.ordinal().ascendingOrderBy());
_behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
_data = (EnumerationData) _behavior.getCurrentDataForWrite(this);
_data.setEnumerationLiterals(_result);
if (_result != null) _result.zSetParentContainerenumeration(this);
}
}
else if (_behavior.isInMemory())
{
_result = (EnumerationLiteralList) _data.getEnumerationLiterals();
if (_result == null)
{
_result = new EnumerationLiteralList();
_result.zSetAddHandler(new EnumerationLiteralsAddHandlerInMemory());
_behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
_data = (EnumerationData) _behavior.getCurrentDataForWrite(this);
_data.setEnumerationLiterals(_result);
}
}
if (_op != null)
{
_result = new EnumerationLiteralList(_op);
_result.zSetForRelationship();
_result.zSetRemoveHandler(DeleteOnRemoveHandler.getInstance());
_result.zSetAddHandler(new EnumerationLiteralsAddHandlerPersisted());
_result.setOrderBy(EnumerationLiteralFinder.ordinal().ascendingOrderBy());
}
return _result;
}
public void setEnumerationLiterals(EnumerationLiteralList enumerationLiterals)
{
EnumerationLiteralList _enumerationLiterals = (EnumerationLiteralList) enumerationLiterals;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForWrite(this);
if (_behavior.isInMemory())
{
if (_behavior.isDetached() && _enumerationLiterals != null)
{
_enumerationLiterals.zMakeDetached(EnumerationLiteralFinder.enumerationName().eq(_data.getName()),
_data.getEnumerationLiterals());
}
_data.setEnumerationLiterals(_enumerationLiterals);
if (_enumerationLiterals != null)
{
_enumerationLiterals.setEnumerationName(_data.getName());
_enumerationLiterals.zSetParentContainerenumeration(this);
_enumerationLiterals.zSetAddHandler(new EnumerationLiteralsAddHandlerInMemory());
}
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);
_enumerationLiterals.zSetAddHandler(new EnumerationLiteralsAddHandlerPersisted());
EnumerationLiteralList enumerationLiteralsToDelete = new EnumerationLiteralList();
enumerationLiteralsToDelete.addAll(this.getEnumerationLiterals());
for(int i=0;i < _enumerationLiterals.size(); i++)
{
EnumerationLiteral item = _enumerationLiterals.getEnumerationLiteralAt(i);
if (!enumerationLiteralsToDelete.remove(item))
{
item.setEnumerationName(_data.getName());
item.cascadeInsert();
}
}
enumerationLiteralsToDelete.cascadeDeleteAll();
}
else throw new RuntimeException("not implemented");
}
public boolean isEnumerationLiteralsModifiedSinceDetachment()
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForRead(this);
EnumerationLiteralList enumerationLiterals =
(EnumerationLiteralList) _data.getEnumerationLiterals();
if( enumerationLiterals != null)
{
return enumerationLiterals.isModifiedSinceDetachment();
}
return false;
}
/**
* Relationship Expression:
EnumerationParameter.enumerationName = this.name
* @see EnumerationParameter#getEnumeration() reverse relationship EnumerationParameter.getEnumeration()
* @return enumeration parameters
*/
public EnumerationParameterList getEnumerationParameters()
{
EnumerationParameterList _result = null;
Operation _op = null;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForRead(this);
if (_behavior.isPersisted())
{
{
{
_op = EnumerationParameterFinder.enumerationName().eq(_data.getName());
}
}
}
else if (_behavior.isDetached())
{
{
{
Operation detachedOp = EnumerationParameterFinder.enumerationName().eq(_data.getName());
_result = new EnumerationParameterList(detachedOp);
_result.zSetForRelationship();
}
}
}
else if (_behavior.isInMemory())
{
_result = (EnumerationParameterList) _data.getEnumerationParameters();
if (_result == null)
{
{
_op = EnumerationParameterFinder.enumerationName().eq(_data.getName());
}
}
}
if (_op != null)
{
_result = new EnumerationParameterList(_op);
_result.zSetForRelationship();
}
return _result;
}
public void setEnumerationParameters(EnumerationParameterList enumerationParameters)
{
EnumerationParameterList _enumerationParameters = (EnumerationParameterList) enumerationParameters;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForWrite(this);
if (_behavior.isInMemory())
{
_data.setEnumerationParameters(_enumerationParameters);
}
else if (_behavior.isPersisted())
{
_behavior.clearTempTransaction(this);
}
else throw new RuntimeException("not implemented");
}
/**
* Relationship Expression:
EnumerationProperty.enumerationName = this.name
* @see EnumerationProperty#getEnumeration() reverse relationship EnumerationProperty.getEnumeration()
* @return enumeration properties
*/
public EnumerationPropertyList getEnumerationProperties()
{
EnumerationPropertyList _result = null;
Operation _op = null;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForRead(this);
if (_behavior.isPersisted())
{
{
{
_op = EnumerationPropertyFinder.enumerationName().eq(_data.getName());
}
}
}
else if (_behavior.isDetached())
{
{
{
Operation detachedOp = EnumerationPropertyFinder.enumerationName().eq(_data.getName());
_result = new EnumerationPropertyList(detachedOp);
_result.zSetForRelationship();
}
}
}
else if (_behavior.isInMemory())
{
_result = (EnumerationPropertyList) _data.getEnumerationProperties();
if (_result == null)
{
{
_op = EnumerationPropertyFinder.enumerationName().eq(_data.getName());
}
}
}
if (_op != null)
{
_result = new EnumerationPropertyList(_op);
_result.zSetForRelationship();
}
return _result;
}
public void setEnumerationProperties(EnumerationPropertyList enumerationProperties)
{
EnumerationPropertyList _enumerationProperties = (EnumerationPropertyList) enumerationProperties;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForWrite(this);
if (_behavior.isInMemory())
{
_data.setEnumerationProperties(_enumerationProperties);
}
else if (_behavior.isPersisted())
{
_behavior.clearTempTransaction(this);
}
else throw new RuntimeException("not implemented");
}
/**
* Relationship Expression:
PackageableElement.name = this.name
* @see PackageableElement#getEnumerationSubClass() reverse relationship PackageableElement.getEnumerationSubClass()
* @return The packageable element super class
*/
public PackageableElement getPackageableElementSuperClass()
{
PackageableElement _result = null;
Operation _op = null;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _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 = (EnumerationData) _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).setEnumerationSubClass((Enumeration)this);
}
public void zSetParentContainerpackageableElementSuperClass(PackageableElementAbstract parent)
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForWrite(this);
_behavior.clearTempTransaction(this);
if (_behavior.isInMemory())
{
_data.setPackageableElementSuperClass(parent);
}
}
protected void cascadeInsertImpl() throws MithraBusinessException
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForWrite(this);
EnumerationLiteralList enumerationLiterals =
(EnumerationLiteralList) _data.getEnumerationLiterals();
_behavior.insert(this);
if (enumerationLiterals != null)
{
enumerationLiterals.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)
{
EnumerationFinder.EnumerationRelatedFinder parentFinder = (EnumerationFinder.EnumerationRelatedFinder) parentFinderGeneric;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
EnumerationData _newData = (EnumerationData) _behavior.getCurrentDataForWrite(this);
{
EnumerationLiteralList enumerationLiterals =
(EnumerationLiteralList) _newData.getEnumerationLiterals();
RelatedFinder dependentFinder = parentFinder.enumerationLiterals();
DeepRelationshipUtility.zAddToNavigationStats(dependentFinder, enumerationLiterals != null, navigationStats);
if (enumerationLiterals != null)
{
enumerationLiterals.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 Enumeration zCascadeCopyThenInsert() throws MithraBusinessException
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
EnumerationData _data = (EnumerationData) _behavior.getCurrentDataForWrite(this);
EnumerationLiteralList enumerationLiterals =
(EnumerationLiteralList) _data.getEnumerationLiterals();
Enumeration original = (Enumeration) _behavior.copyThenInsert(this);
if (enumerationLiterals != null)
{
enumerationLiterals.zCascadeCopyThenInsertAll();
}
return original;
}
protected void cascadeDeleteImpl() throws MithraBusinessException
{
this.getEnumerationLiterals().cascadeDeleteAll();
this.delete();
}
public Cache zGetCache()
{
return EnumerationFinder.getMithraObjectPortal().getCache();
}
public MithraObjectPortal zGetPortal()
{
return EnumerationFinder.getMithraObjectPortal();
}
public Enumeration getOriginalPersistentObject()
{
return this.zFindOriginal();
}
protected boolean issueUpdatesForNonPrimaryKeys(TransactionalBehavior behavior, MithraDataObject data, MithraDataObject newData)
{
boolean changed = false;
return changed;
}
protected boolean issueUpdatesForPrimaryKeys(TransactionalBehavior behavior, MithraDataObject data, MithraDataObject newData)
{
boolean changed = false;
changed |= zUpdateString(behavior, data, newData, EnumerationFinder.name(), false);
return changed;
}
public Object readResolve() throws ObjectStreamException
{
EnumerationAbstract result = (EnumerationAbstract) 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 EnumerationLiteralsAddHandlerInMemory implements DependentRelationshipAddHandler
{
public void addRelatedObject(MithraTransactionalObject relatedObject)
{
EnumerationLiteral item = (EnumerationLiteral) relatedObject;
item.setEnumerationName(getName());
item.zSetParentContainerenumeration(EnumerationAbstract.this);
}
}
protected class EnumerationLiteralsAddHandlerPersisted implements DependentRelationshipAddHandler
{
public void addRelatedObject(MithraTransactionalObject relatedObject)
{
EnumerationLiteral item = (EnumerationLiteral) relatedObject;
item.setEnumerationName(getName());
item.cascadeInsert();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy