klass.model.meta.domain.ServiceGroupAbstract 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 ServiceGroupAbstract 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(ServiceGroup.class.getName());
private static final RelationshipHashStrategy forowningClass = new OwningClassRhs();
private static final RelationshipHashStrategy forpackageableElementSuperClass = new PackageableElementSuperClassRhs();
private static final class OwningClassRhs implements RelationshipHashStrategy
{
public boolean equalsForRelationship(Object _srcObject, Object _srcData, Object _targetData, Timestamp _asOfDate0, Timestamp _asOfDate1)
{
ServiceGroupData _castedSrcData = (ServiceGroupData) _srcData;
KlassData _castedTargetData = (KlassData) _targetData;
if (_castedSrcData.getClassName()!= null && _castedSrcData.getClassName().equals(_castedTargetData.getName()))
{
return true;
}
return false;
}
public int computeHashCodeFromRelated(Object _srcObject, Object _srcData)
{
ServiceGroupData _castedSrcData = (ServiceGroupData) _srcData;
return HashUtil.hash(_castedSrcData.getClassName());
}
public int computeOffHeapHashCodeFromRelated(Object _srcObject, Object _srcData)
{
ServiceGroupData _castedSrcData = (ServiceGroupData) _srcData;
return HashUtil.offHeapHash(_castedSrcData.getClassName());
}
}
private static final class PackageableElementSuperClassRhs implements RelationshipHashStrategy
{
public boolean equalsForRelationship(Object _srcObject, Object _srcData, Object _targetData, Timestamp _asOfDate0, Timestamp _asOfDate1)
{
ServiceGroupData _castedSrcData = (ServiceGroupData) _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)
{
ServiceGroupData _castedSrcData = (ServiceGroupData) _srcData;
return HashUtil.hash(_castedSrcData.getName());
}
public int computeOffHeapHashCodeFromRelated(Object _srcObject, Object _srcData)
{
ServiceGroupData _castedSrcData = (ServiceGroupData) _srcData;
return HashUtil.offHeapHash(_castedSrcData.getName());
}
}
public ServiceGroupAbstract()
{
this.persistenceState = MEMORY_STATE;
}
public ServiceGroup getDetachedCopy() throws MithraBusinessException
{
return (ServiceGroup) super.getDetachedCopy();
}
public ServiceGroup getNonPersistentCopy() throws MithraBusinessException
{
ServiceGroup result = (ServiceGroup) super.getNonPersistentCopy();
result.persistenceState = MEMORY_STATE;
return result;
}
public ServiceGroup copyDetachedValuesToOriginalOrInsertIfNew()
{
return (ServiceGroup) this.zCopyDetachedValuesToOriginalOrInsertIfNew();
}
public ServiceGroup zFindOriginal()
{
ServiceGroupData data = (ServiceGroupData) this.currentData;
Operation op;
op = ServiceGroupFinder.name().eq(data.getName());
return ServiceGroupFinder.findOne(op);
}
public boolean isModifiedSinceDetachmentByDependentRelationships()
{
if(this.isModifiedSinceDetachment()) return true;
if(isUrlsModifiedSinceDetachment()) return true;
return false;
}
private Logger getLogger()
{
return logger;
}
public MithraDataObject zAllocateData()
{
return new ServiceGroupData();
}
protected void zSetFromServiceGroupData( ServiceGroupData data )
{
super.zSetData(data);
this.persistenceState = PERSISTED_STATE;
}
public void setFromServiceGroupData( ServiceGroupData data )
{
super.zSetData(data);
}
public void zWriteDataClassName(ObjectOutput out) throws IOException
{
}
public boolean isClassNameNull()
{
return ((ServiceGroupData) this.zSynchronizedGetData()).isClassNameNull();
}
public String getClassName()
{
ServiceGroupData data = (ServiceGroupData) this.zSynchronizedGetData();
return data.getClassName();
}
public void setClassName(String newValue)
{
if (newValue != null && newValue.length() > 256)
throw new MithraBusinessException("Attribute 'className' cannot exceed maximum length of 256: " + newValue);
zSetString(ServiceGroupFinder.className(), newValue, false, false );
}
public final boolean isNameNull()
{
return ((ServiceGroupData) this.zSynchronizedGetData()).isNameNull();
}
public final String getName()
{
ServiceGroupData data = (ServiceGroupData) 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(ServiceGroupFinder.name(), newValue, true, false );
if (d == null) return;
ServiceGroupData data = (ServiceGroupData) d;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
if (!_behavior.isPersisted())
{
UrlList urls =
(UrlList ) data.getUrls();
if (urls != null)
{
urls.setServiceGroupName(newValue);
}
}
}
protected void issuePrimitiveNullSetters(TransactionalBehavior behavior, MithraDataObject data)
{
}
public void zPersistDetachedRelationships(MithraDataObject _data)
{
ServiceGroupData _newData = (ServiceGroupData) _data;
{
UrlList urls =
(UrlList) _newData.getUrls();
if (urls != null)
{
urls.copyDetachedValuesToOriginalOrInsertIfNewOrDeleteIfRemoved();
}
}
}
public void zSetTxDetachedDeleted()
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
if (_behavior.isDetached() && _behavior.isDeleted()) return;
ServiceGroupData _newData = (ServiceGroupData) _behavior.getCurrentDataForRead(this);
if (_newData.getUrls() != null && !(_newData.getUrls() instanceof NulledRelation))
{
((UrlList)_newData.getUrls()).zSetTxDetachedDeleted();
}
this.zSetTxPersistenceState(PersistenceState.DETACHED_DELETED);
}
public void zSetNonTxDetachedDeleted()
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
ServiceGroupData _newData = (ServiceGroupData) _behavior.getCurrentDataForRead(this);
if (_newData.getUrls() != null && !(_newData.getUrls() instanceof NulledRelation))
{
((UrlList)_newData.getUrls()).zSetNonTxDetachedDeleted();
}
this.zSetNonTxPersistenceState(PersistenceState.DETACHED_DELETED);
}
/**
* Relationship Expression:
this.className = Klass.name
* @see Klass#getServiceGroups() reverse relationship Klass.getServiceGroups()
* @return The owning class
*/
public Klass getOwningClass()
{
Klass _result = null;
Operation _op = null;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _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.getClassName());
}
}
}
else if (_behavior.isDetached())
{
{
{
Operation detachedOp = KlassFinder.name().eq(_data.getClassName());
_result = KlassFinder.zFindOneForRelationship(detachedOp);
}
}
}
else if (_behavior.isInMemory())
{
_result = (Klass) _data.getOwningClass();
if (_result == null)
{
{
_op = KlassFinder.name().eq(_data.getClassName());
}
}
}
if (_op != null)
{
_result = KlassFinder.zFindOneForRelationship(_op);
}
return _result;
}
public void setOwningClass(Klass owningClass)
{
Klass _owningClass = (Klass) owningClass;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _behavior.getCurrentDataForWrite(this);
if (_behavior.isInMemory())
{
_data.setOwningClass(_owningClass);
if (_owningClass == null)
{
this.setClassName(null);
}
else
{
this.setClassName(_owningClass.getName());
}
}
else if (_behavior.isPersisted())
{
_behavior.clearTempTransaction(this);
if (_owningClass == null)
{
this.setClassName(null);
}
else
{
this.setClassName(
_owningClass.getName());
}
}
else throw new RuntimeException("not implemented");
}
/**
* Relationship Expression:
this.name = Url.serviceGroupName
* Order By: ordinal asc
.
* @see Url#getServiceGroup() reverse relationship Url.getServiceGroup()
* @return urls
*/
public UrlList getUrls()
{
UrlList _result = null;
Operation _op = null;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _behavior.getCurrentDataForRead(this);
if (_behavior.isPersisted())
{
{
{
_op = UrlFinder.serviceGroupName().eq(_data.getName());
}
}
}
else if (_behavior.isDetached())
{
_result = (UrlList) _data.getUrls();
if (_result == null)
{
{
Operation detachedOp = UrlFinder.serviceGroupName().eq(_data.getName());
_result = new UrlList(detachedOp);
_result.zSetForRelationship();
if(_result != null)
{
_result = _result.getDetachedCopy();
}
_result.zSetAddHandler(new UrlsAddHandlerInMemory());
}
_result.setOrderBy(UrlFinder.ordinal().ascendingOrderBy());
_behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
_data = (ServiceGroupData) _behavior.getCurrentDataForWrite(this);
_data.setUrls(_result);
if (_result != null) _result.zSetParentContainerserviceGroup(this);
}
}
else if (_behavior.isInMemory())
{
_result = (UrlList) _data.getUrls();
if (_result == null)
{
_result = new UrlList();
_result.zSetAddHandler(new UrlsAddHandlerInMemory());
_behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
_data = (ServiceGroupData) _behavior.getCurrentDataForWrite(this);
_data.setUrls(_result);
}
}
if (_op != null)
{
_result = new UrlList(_op);
_result.zSetForRelationship();
_result.zSetRemoveHandler(DeleteOnRemoveHandler.getInstance());
_result.zSetAddHandler(new UrlsAddHandlerPersisted());
_result.setOrderBy(UrlFinder.ordinal().ascendingOrderBy());
}
return _result;
}
public void setUrls(UrlList urls)
{
UrlList _urls = (UrlList) urls;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _behavior.getCurrentDataForWrite(this);
if (_behavior.isInMemory())
{
if (_behavior.isDetached() && _urls != null)
{
_urls.zMakeDetached(UrlFinder.serviceGroupName().eq(_data.getName()),
_data.getUrls());
}
_data.setUrls(_urls);
if (_urls != null)
{
_urls.setServiceGroupName(_data.getName());
_urls.zSetParentContainerserviceGroup(this);
_urls.zSetAddHandler(new UrlsAddHandlerInMemory());
}
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);
_urls.zSetAddHandler(new UrlsAddHandlerPersisted());
UrlList urlsToDelete = new UrlList();
urlsToDelete.addAll(this.getUrls());
for(int i=0;i < _urls.size(); i++)
{
Url item = _urls.getUrlAt(i);
if (!urlsToDelete.remove(item))
{
item.setServiceGroupName(_data.getName());
item.cascadeInsert();
}
}
urlsToDelete.cascadeDeleteAll();
}
else throw new RuntimeException("not implemented");
}
public boolean isUrlsModifiedSinceDetachment()
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _behavior.getCurrentDataForRead(this);
UrlList urls =
(UrlList) _data.getUrls();
if( urls != null)
{
return urls.isModifiedSinceDetachment();
}
return false;
}
/**
* Relationship Expression:
PackageableElement.name = this.name
* @see PackageableElement#getServiceGroupSubClass() reverse relationship PackageableElement.getServiceGroupSubClass()
* @return The packageable element super class
*/
public PackageableElement getPackageableElementSuperClass()
{
PackageableElement _result = null;
Operation _op = null;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForReadWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _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 = (ServiceGroupData) _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).setServiceGroupSubClass((ServiceGroup)this);
}
public void zSetParentContainerpackageableElementSuperClass(PackageableElementAbstract parent)
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _behavior.getCurrentDataForWrite(this);
_behavior.clearTempTransaction(this);
if (_behavior.isInMemory())
{
_data.setPackageableElementSuperClass(parent);
}
}
protected void cascadeInsertImpl() throws MithraBusinessException
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _behavior.getCurrentDataForWrite(this);
UrlList urls =
(UrlList) _data.getUrls();
_behavior.insert(this);
if (urls != null)
{
urls.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)
{
ServiceGroupFinder.ServiceGroupRelatedFinder parentFinder = (ServiceGroupFinder.ServiceGroupRelatedFinder) parentFinderGeneric;
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
ServiceGroupData _newData = (ServiceGroupData) _behavior.getCurrentDataForWrite(this);
{
UrlList urls =
(UrlList) _newData.getUrls();
RelatedFinder dependentFinder = parentFinder.urls();
DeepRelationshipUtility.zAddToNavigationStats(dependentFinder, urls != null, navigationStats);
if (urls != null)
{
urls.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 ServiceGroup zCascadeCopyThenInsert() throws MithraBusinessException
{
TransactionalBehavior _behavior = zGetTransactionalBehaviorForWriteWithWaitIfNecessary();
ServiceGroupData _data = (ServiceGroupData) _behavior.getCurrentDataForWrite(this);
UrlList urls =
(UrlList) _data.getUrls();
ServiceGroup original = (ServiceGroup) _behavior.copyThenInsert(this);
if (urls != null)
{
urls.zCascadeCopyThenInsertAll();
}
return original;
}
protected void cascadeDeleteImpl() throws MithraBusinessException
{
this.getUrls().cascadeDeleteAll();
this.delete();
}
public Cache zGetCache()
{
return ServiceGroupFinder.getMithraObjectPortal().getCache();
}
public MithraObjectPortal zGetPortal()
{
return ServiceGroupFinder.getMithraObjectPortal();
}
public ServiceGroup getOriginalPersistentObject()
{
return this.zFindOriginal();
}
protected boolean issueUpdatesForNonPrimaryKeys(TransactionalBehavior behavior, MithraDataObject data, MithraDataObject newData)
{
boolean changed = false;
changed |= zUpdateString(behavior, data, newData, ServiceGroupFinder.className(), false);
return changed;
}
protected boolean issueUpdatesForPrimaryKeys(TransactionalBehavior behavior, MithraDataObject data, MithraDataObject newData)
{
boolean changed = false;
changed |= zUpdateString(behavior, data, newData, ServiceGroupFinder.name(), false);
return changed;
}
public Object readResolve() throws ObjectStreamException
{
ServiceGroupAbstract result = (ServiceGroupAbstract) 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 UrlsAddHandlerInMemory implements DependentRelationshipAddHandler
{
public void addRelatedObject(MithraTransactionalObject relatedObject)
{
Url item = (Url) relatedObject;
item.setServiceGroupName(getName());
item.zSetParentContainerserviceGroup(ServiceGroupAbstract.this);
}
}
protected class UrlsAddHandlerPersisted implements DependentRelationshipAddHandler
{
public void addRelatedObject(MithraTransactionalObject relatedObject)
{
Url item = (Url) relatedObject;
item.setServiceGroupName(getName());
item.cascadeInsert();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy