Search in sources :

Example 1 with EntityOperation

use of com.hedera.mirror.common.domain.entity.EntityOperation in project hedera-mirror-node by hashgraph.

the class AbstractTransactionHandlerTest method getExpectedEntityWithTimestamp.

protected AbstractEntity getExpectedEntityWithTimestamp() {
    AbstractEntity entity = getEntity();
    EntityOperation entityOperation = transactionHandler.getType().getEntityOperation();
    if (entityOperation == EntityOperation.CREATE) {
        entity.setCreatedTimestamp(CREATED_TIMESTAMP_NS);
        entity.setDeleted(false);
        entity.setTimestampLower(CREATED_TIMESTAMP_NS);
    } else if (entityOperation == EntityOperation.UPDATE) {
        entity.setDeleted(false);
        entity.setTimestampLower(MODIFIED_TIMESTAMP_NS);
    } else {
        entity.setTimestampLower(MODIFIED_TIMESTAMP_NS);
    }
    return entity;
}
Also used : EntityOperation(com.hedera.mirror.common.domain.entity.EntityOperation) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity)

Example 2 with EntityOperation

use of com.hedera.mirror.common.domain.entity.EntityOperation in project hedera-mirror-node by hashgraph.

the class AbstractEntityCrudTransactionHandler method updateEntity.

protected final void updateEntity(EntityId entityId, RecordItem recordItem) {
    long consensusTimestamp = recordItem.getConsensusTimestamp();
    T entity = entityId.toEntity();
    EntityOperation entityOperation = type.getEntityOperation();
    if (entityOperation == EntityOperation.CREATE) {
        entity.setCreatedTimestamp(consensusTimestamp);
        entity.setDeleted(false);
    } else if (entityOperation == EntityOperation.UPDATE) {
        entity.setDeleted(false);
    } else if (entityOperation == EntityOperation.DELETE) {
        entity.setDeleted(true);
    }
    entity.setTimestampLower(consensusTimestamp);
    doUpdateEntity(entity, recordItem);
}
Also used : EntityOperation(com.hedera.mirror.common.domain.entity.EntityOperation)

Example 3 with EntityOperation

use of com.hedera.mirror.common.domain.entity.EntityOperation in project hedera-mirror-node by hashgraph.

the class AbstractEntityCrudTransactionHandler method updateTransaction.

@Override
public final void updateTransaction(Transaction transaction, RecordItem recordItem) {
    doUpdateTransaction(transaction, recordItem);
    EntityId entityId = transaction.getEntityId();
    EntityOperation entityOperation = type.getEntityOperation();
    if (entityOperation != EntityOperation.NONE && !EntityId.isEmpty(entityId) && recordItem.isSuccessful()) {
        updateEntity(entityId, recordItem);
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) EntityOperation(com.hedera.mirror.common.domain.entity.EntityOperation)

Aggregations

EntityOperation (com.hedera.mirror.common.domain.entity.EntityOperation)3 AbstractEntity (com.hedera.mirror.common.domain.entity.AbstractEntity)1 EntityId (com.hedera.mirror.common.domain.entity.EntityId)1