com.gs.fw.common.mithra.transaction.InTransactionDatedTransactionalObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reladomo Show documentation
Show all versions of reladomo Show documentation
Reladomo is an object-relational mapping framework.
/*
Copyright 2016 Goldman Sachs.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package com.gs.fw.common.mithra.transaction;
import com.gs.fw.common.mithra.DatedTransactionalState;
import com.gs.fw.common.mithra.MithraDataObject;
import com.gs.fw.common.mithra.MithraDatedTransactionalObject;
import com.gs.fw.common.mithra.MithraObjectPortal;
import com.gs.fw.common.mithra.MithraTransaction;
import com.gs.fw.common.mithra.MithraTransactionalDatabaseObject;
import com.gs.fw.common.mithra.MithraTransactionalObject;
import com.gs.fw.common.mithra.TransactionalState;
import com.gs.fw.common.mithra.UpdateInfo;
import com.gs.fw.common.mithra.attribute.update.AttributeUpdateWrapper;
import com.gs.fw.common.mithra.behavior.TemporalContainer;
import com.gs.fw.common.mithra.behavior.TemporalDirector;
import com.gs.fw.common.mithra.behavior.TransactionalBehavior;
import com.gs.fw.common.mithra.cache.Cache;
import com.gs.fw.common.mithra.extractor.Extractor;
import com.gs.fw.common.mithra.finder.RelatedFinder;
import com.gs.fw.common.mithra.util.StatisticCounter;
import java.io.IOException;
import java.io.ObjectOutput;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
public class InTransactionDatedTransactionalObject implements MithraDatedTransactionalObject
{
public static final byte COMMITTED_STATE = 1;
public static final byte TO_BE_UPDATED_STATE = 2;
public static final byte UPDATED_STATE = 3;
public static final byte DEACTIVATED_STATE = 4;
public static final byte DELETED_STATE = 5;
public static final byte TO_BE_INSERTED_STATE = 6;
public static final byte INSERTED_STATE = 7;
private MithraObjectPortal mithraObjectPortal;
private MithraDataObject committedData;
private MithraDataObject txData;
private byte txState;
public InTransactionDatedTransactionalObject(MithraObjectPortal mithraObjectPortal,
MithraDataObject committedData, MithraDataObject txData, byte txState)
{
this.mithraObjectPortal = mithraObjectPortal;
this.committedData = committedData;
this.txData = txData;
this.txState = txState;
}
public boolean isCommitted()
{
return this.txState == COMMITTED_STATE;
}
public void zEnrollInTransactionForWrite(TemporalContainer container, MithraDataObject data, MithraTransaction threadTx)
{
throw new RuntimeException("not implemented");
}
public boolean zEnrollInTransactionForWrite(DatedTransactionalState prevState, TemporalContainer container, MithraDataObject data, MithraTransaction threadTx)
{
throw new RuntimeException("not implemented");
}
public MithraDataObject zRefreshWithLock(boolean lock)
{
throw new RuntimeException("not implemented");
}
public TemporalDirector zGetTemporalDirector()
{
throw new RuntimeException("not implemented");
}
public void zSetCurrentData(MithraDataObject data)
{
this.committedData = data;
}
public MithraDataObject zGetCurrentData()
{
return this.committedData;
}
public MithraDataObject zGetCurrentDataWithCheck()
{
return this.committedData;
}
public void zReindexAndSetDataIfChanged(MithraDataObject data, Cache cache)
{
throw new RuntimeException("not implemented");
}
public void zSerializeFullData(ObjectOutput out) throws IOException
{
throw new RuntimeException("not implemented");
}
public void zSerializeFullTxData(ObjectOutput out) throws IOException
{
throw new RuntimeException("not implemented");
}
/* the optional object is the TransactionalBehavior in case of transactional objects */
public void zSetData(MithraDataObject data, Object optional)
{
// todo: rezaem: implement not implemented method
throw new RuntimeException("not implemented");
}
public MithraDataObject zUnsynchronizedGetData()
{
// todo: rezaem: implement not implemented method
throw new RuntimeException("not implemented");
}
public void makeInMemoryNonTransactional()
{
throw new RuntimeException("not implemented");
}
public boolean isInMemoryNonTransactional()
{
return false;
}
public MithraDataObject zSynchronizedGetData()
{
// todo: rezaem: implement not implemented method
throw new RuntimeException("not implemented");
}
public MithraDataObject zGetNonTxData()
{
return this.committedData;
}
public MithraDataObject zGetTxDataForRead()
{
if (this.txData == null)
{
return this.committedData;
}
return this.txData;
}
public boolean isNewInThisTransaction()
{
return this.txState == INSERTED_STATE || this.txState == TO_BE_INSERTED_STATE;
}
public MithraDataObject zGetTxDataForWrite()
{
if (txData == null)
{
txData = this.committedData.copy();
}
return this.txData;
}
public void zSetTxData(MithraDataObject newData)
{
this.txData = newData;
}
public void zSetNonTxData(MithraDataObject newData)
{
this.committedData = newData;
}
public void zEnrollInTransaction()
{
throw new RuntimeException("not implemented");
}
public void zRefreshWithLock(TransactionalBehavior behavior)
{
throw new RuntimeException("not implemented");
}
public void zRefreshWithLockForRead(TransactionalBehavior persistedTxEnrollBehavior)
{
throw new RuntimeException("not implemented");
}
public void zRefreshWithLockForWrite(TransactionalBehavior persistedTxEnrollBehavior)
{
throw new RuntimeException("not implemented");
}
public void zHandleCommit()
{
if (this.txState == DELETED_STATE)
{
this.zGetCache().commitRemovedObject(this.committedData);
}
else
{
MithraDataObject oldData = this.committedData;
this.committedData = txData;
if (this.txState == INSERTED_STATE || this.txState == UPDATED_STATE)
{
this.zGetCache().commitObject(this, oldData);
}
}
}
public void zHandleRollback(MithraTransaction tx)
{
// nothing to do
}
public MithraDataObject zAllocateData()
{
throw new RuntimeException("not implemented");
}
public MithraTransactionalDatabaseObject zGetDatabaseObject()
{
return (MithraTransactionalDatabaseObject) this.mithraObjectPortal.getDatabaseObject();
}
public Cache zGetCache()
{
return this.mithraObjectPortal.getCache();
}
public MithraObjectPortal zGetPortal()
{
return this.mithraObjectPortal;
}
public boolean zIsParticipatingInTransaction(MithraTransaction tx)
{
// todo: rezaem: implement not implemented method
throw new RuntimeException("not implemented");
}
public MithraTransaction zGetCurrentTransaction()
{
// todo: rezaem: implement not implemented method
throw new RuntimeException("not implemented");
}
public void zSetNonTxPersistenceState(int state)
{
}
public void zSetTxPersistenceState(int state)
{
throw new RuntimeException("not implemented");
}
public void zLockForTransaction()
{
throw new RuntimeException("not implemented");
}
public MithraDatedTransactionalObject zFindOriginal()
{
throw new RuntimeException("not implemented");
}
@Override
public MithraDatedTransactionalObject getOriginalPersistentObject()
{
throw new RuntimeException("not implemented");
}
public void zCopyAttributesFrom(MithraDataObject data)
{
throw new RuntimeException("not implemented");
}
public void zPersistDetachedChildDelete(MithraDataObject currentDataForRead)
{
throw new RuntimeException("not implemented");
}
public MithraDatedTransactionalObject copyDetachedValuesToOriginalOrInsertIfNew()
{
throw new RuntimeException("not implemented");
}
public boolean zIsDataChanged(MithraDataObject data)
{
throw new RuntimeException("not implemented");
}
public boolean nonPrimaryKeyAttributesChanged(MithraTransactionalObject other)
{
throw new RuntimeException("not implemented");
}
public boolean nonPrimaryKeyAttributesChanged(MithraTransactionalObject other, double toleranceForFloatingPointFields)
{
throw new RuntimeException("not implemented");
}
public void insert()
{
throw new RuntimeException("not implemented");
}
public void delete()
{
throw new RuntimeException("not implemented");
}
public boolean zIsDetached()
{
return false;
}
public InTransactionDatedTransactionalObject copyForInsert()
{
MithraDataObject txData = null;
if (this.txData != null) txData = this.txData.copy();
InTransactionDatedTransactionalObject result = new InTransactionDatedTransactionalObject(this.mithraObjectPortal, this.committedData, txData, TO_BE_INSERTED_STATE);
return result;
}
public boolean isInPlaceUpdated()
{
return this.txState == TO_BE_UPDATED_STATE || this.txState == UPDATED_STATE;
}
public void setToBeUpdated()
{
if (this.txState != TO_BE_INSERTED_STATE || this.txState != INSERTED_STATE)
{
this.txState = TO_BE_UPDATED_STATE;
}
}
public void zClearTxData()
{
this.txData = null;
}
public void zSetInserted()
{
if (this.txState != DELETED_STATE)
{
this.txState = INSERTED_STATE;
}
if (committedData == null || committedData.zAsOfAttributesChanged(this.txData))
{
this.committedData = this.txData.copy();
}
}
public void zSetUpdated(List updates)
{
if (this.txState != INSERTED_STATE && this.txState != DELETED_STATE)
{
this.txState = UPDATED_STATE;
}
if (committedData == null)
{
this.committedData = this.txData.copy();
}
else if (committedData.zAsOfAttributesChanged(this.txData))
{
MithraDataObject newCommitted = this.committedData.copy();
for(int i=0;i zAddNavigatedRelationshipsStats(RelatedFinder finder, Map navigationStats)
{
throw new RuntimeException("not implemented");
}
@Override
public Map zAddNavigatedRelationshipsStatsForUpdate(RelatedFinder parentFinder, Map navigationStats)
{
throw new RuntimeException("not implemented");
}
@Override
public Map zAddNavigatedRelationshipsStatsForDelete(RelatedFinder parentFinder, Map navigationStats)
{
throw new RuntimeException("not implemented");
}
}