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

com.landawn.abacus.core.AbstractEntityManager Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2015, Haiyang Li.
 * 
 * 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.landawn.abacus.core;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import com.landawn.abacus.DataSet;
import com.landawn.abacus.EntityId;
import com.landawn.abacus.IsolationLevel;
import com.landawn.abacus.LockMode;
import com.landawn.abacus.Transaction.Action;
import com.landawn.abacus.condition.Condition;
import com.landawn.abacus.core.AbacusConfiguration.EntityManagerConfiguration;
import com.landawn.abacus.handler.Handler;
import com.landawn.abacus.handler.HandlerFactory;
import com.landawn.abacus.metadata.EntityDefinition;
import com.landawn.abacus.metadata.EntityDefinitionFactory;
import com.landawn.abacus.util.N;
import com.landawn.abacus.util.u.Holder;
import com.landawn.abacus.util.u.Optional;

// TODO: Auto-generated Javadoc
/**
 *
 * @author Haiyang Li
 * @param 
 * @since 0.8
 */
abstract class AbstractEntityManager implements com.landawn.abacus.EntityManager {

    protected final String domainName;

    protected final EntityManagerConfiguration entityManagerConfig;

    private final List> handlerList;

    protected AbstractEntityManager(final String domainName, final EntityManagerConfiguration entityManagerConfig) {
        this.domainName = domainName;
        this.entityManagerConfig = entityManagerConfig;

        handlerList = new ArrayList<>();

        for (String attr : entityManagerConfig.getHandlerList()) {
            Handler handler = HandlerFactory.create(this, attr);
            handlerList.add(handler);
        }
    }

    /**
     *
     * @param 
     * @param entityId
     * @return
     */
    @Override
    public  Optional get(EntityId entityId) {
        return Optional.ofNullable((T) gett(entityId));
    }

    /**
     *
     * @param 
     * @param entityId
     * @param selectPropNames
     * @return
     */
    @Override
    public  Optional get(EntityId entityId, Collection selectPropNames) {
        return Optional.ofNullable((T) gett(entityId, selectPropNames));
    }

    /**
     *
     * @param 
     * @param entityId
     * @param selectPropNames
     * @param options
     * @return
     */
    @Override
    public  Optional get(EntityId entityId, Collection selectPropNames, Map options) {
        return Optional.ofNullable((T) gett(entityId, selectPropNames, options));
    }

    /**
     * Gets the t.
     *
     * @param 
     * @param entityId
     * @return
     */
    @SuppressWarnings("unchecked")
    @Override
    public  T gett(final EntityId entityId) {
        return (T) gett(entityId, null, null);
    }

    /**
     * Gets the t.
     *
     * @param 
     * @param entityId
     * @param selectPropNames
     * @return
     */
    @SuppressWarnings("unchecked")
    @Override
    public  T gett(final EntityId entityId, final Collection selectPropNames) {
        return (T) gett(entityId, selectPropNames, null);
    }

    /**
     * Gets the t.
     *
     * @param 
     * @param entityId
     * @param selectPropNames
     * @param options
     * @return
     */
    @SuppressWarnings("unchecked")
    @Override
    public  T gett(final EntityId entityId, final Collection selectPropNames, final Map options) {
        EntityManagerUtil.checkArgNotNullOrEmpty(entityId, "EntityId");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preGet(entityId, selectPropNames, options);
        }

        T entity = null;

        try {
            entity = (T) internalGet(null, entityId, selectPropNames, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postGet((E) entity, entityId, selectPropNames, options);
            }
        }

        return entity;
    }

    //    @SuppressWarnings("unchecked")
    //    @Override
    //    public  List getAll(final List entityIds) {
    //        return getAll(entityIds, null);
    //    }
    //
    //    @SuppressWarnings("unchecked")
    //    @Override
    //    public  List getAll(final List entityIds, final Collection selectPropNames) {
    //        return getAll(entityIds, selectPropNames, null);
    //    }
    //
    //    @SuppressWarnings("unchecked")
    //    @Override
    //    public  List getAll(final List entityIds, final Collection selectPropNames, final Map options) {
    //        EntityManagerUtil.checkArgNotNullOrEmpty(entityIds, "EntityIds");
    //        EntityManagerUtil.checkArgNotNullOrEmpty(entityIds.get(0), "EntityIds");
    //
    //        for (int index = 0, size = handlerList.size(); index < size; index++) {
    //            handlerList.get(index).preGet(entityIds, selectPropNames, options);
    //        }
    //
    //        List entities = null;
    //
    //        try {
    //            entities = internalGet(null, entityIds, selectPropNames, options);
    //        } finally {
    //            for (int index = 0, size = handlerList.size(); index < size; index++) {
    //                handlerList.get(index).postGet((List) entities, entityIds, selectPropNames, options);
    //            }
    //        }
    //
    //        return entities;
    //    }

    /**
     *
     * @param 
     * @param entityName
     * @param selectPropNames
     * @param condition
     * @return
     */
    @Override
    public  List list(final String entityName, final Collection selectPropNames, final Condition condition) {
        return list(entityName, selectPropNames, condition, null);
    }

    /**
     *
     * @param 
     * @param entityName
     * @param selectPropNames
     * @param condition
     * @param options
     * @return
     */
    @SuppressWarnings("unchecked")
    @Override
    public  List list(final String entityName, final Collection selectPropNames, final Condition condition, final Map options) {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preList(entityName, selectPropNames, condition, options);
        }

        List entities = null;

        try {
            entities = internalList(null, entityName, selectPropNames, condition, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postList((List) entities, entityName, selectPropNames, condition, options);
            }
        }

        return entities;
    }

    /**
     *
     * @param entity
     * @return
     */
    @Override
    public EntityId add(final E entity) {
        return add(entity, null);
    }

    /**
     *
     * @param entity
     * @param options
     * @return
     */
    @Override
    public EntityId add(final E entity, final Map options) {
        if (entity == null) {
            throw new IllegalArgumentException("Entity can't be null");
        }

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preAdd(entity, options);
        }

        EntityId entityId = null;

        try {
            entityId = internalAdd(entity, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postAdd(entityId, entity, options);
            }
        }

        return entityId;
    }

    /**
     * Adds the all.
     *
     * @param entities
     * @return
     */
    @Override
    public List addAll(final Collection entities) {
        return addAll(entities, null);
    }

    /**
     * Adds the all.
     *
     * @param entities
     * @param options
     * @return
     */
    @Override
    public List addAll(final Collection entities, final Map options) {
        N.checkArgNotNullOrEmpty(entities, "Entities");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preAdd(entities, options);
        }

        List entityIds = null;

        try {
            entityIds = internalAdd(entities, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postAdd(entityIds, entities, options);
            }
        }

        return entityIds;
    }

    /**
     *
     * @param entityName
     * @param props
     * @param options
     * @return
     */
    @Override
    public EntityId add(final String entityName, final Map props, final Map options) {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preAdd(entityName, props, options);
        }

        EntityId entityId = null;

        try {
            entityId = internalAdd(entityName, props, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postAdd(entityId, entityName, props, options);
            }
        }

        return entityId;
    }

    /**
     * Adds the all.
     *
     * @param entityName
     * @param propsList
     * @param options
     * @return
     */
    @Override
    public List addAll(final String entityName, final List> propsList, final Map options) {
        N.checkArgNotNullOrEmpty(propsList, "PropsList");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preAdd(entityName, propsList, options);
        }

        List entityIds = null;

        try {
            entityIds = internalAdd(entityName, propsList, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postAdd(entityIds, entityName, propsList, options);
            }
        }

        return entityIds;
    }

    /**
     *
     * @param entity
     * @return
     */
    @Override
    public int update(final E entity) {
        return update(entity, null);
    }

    /**
     *
     * @param entity
     * @param options
     * @return
     */
    @Override
    public int update(final E entity, final Map options) {
        if (entity == null) {
            throw new IllegalArgumentException("Entity can't be null");
        }

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preUpdate(entity, options);
        }

        int result = -1;

        try {
            // [TODO]
            // if (entity instanceof ActiveRecord) {
            // ((ActiveRecord) entity).update(options);
            // } else {
            result = internalUpdate(entity, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postUpdate(result, entity, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entities
     * @return
     */
    @Override
    public int updateAll(final Collection entities) {
        return updateAll(entities, null);
    }

    /**
     *
     * @param entities
     * @param options
     * @return
     */
    @Override
    public int updateAll(final Collection entities, final Map options) {
        N.checkArgNotNullOrEmpty(entities, "Entities");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preUpdate(entities, options);
        }

        int result = -1;

        try {
            result = internalUpdate(entities, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postUpdate(result, entities, options);
            }
        }

        return result;
    }

    /**
     * Update.
     * @param props
     * @param entityId
     * @return
     */
    @Override
    public int update(final Map props, final EntityId entityId) {
        return update(props, entityId, null);
    }

    /**
     * Update.
     * @param props
     * @param entityId
     * @param options
     * @return
     */
    @Override
    public int update(final Map props, final EntityId entityId, final Map options) {
        EntityManagerUtil.checkArgNotNullOrEmpty(entityId, "EntityId");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preUpdate(props, entityId, options);
        }

        int result = -1;

        try {
            result = internalUpdate(entityId, props, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postUpdate(result, props, entityId, options);
            }
        }

        return result;
    }

    /**
     * Update all.
     * @param props
     * @param entityIds
     * @return
     */
    @Override
    public int updateAll(final Map props, final List entityIds) {
        return updateAll(props, entityIds, null);
    }

    /**
     * Update all.
     * @param props
     * @param entityIds
     * @param options
     * @return
     */
    @Override
    public int updateAll(final Map props, final List entityIds, final Map options) {
        N.checkArgNotNullOrEmpty(entityIds, "EntityIds");
        EntityManagerUtil.checkArgNotNullOrEmpty(entityIds.get(0), "EntityIds");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preUpdate(props, entityIds, options);
        }

        int result = -1;

        try {
            result = internalUpdate(entityIds, props, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postUpdate(result, props, entityIds, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entityName
     * @param props
     * @param condition
     * @param options
     * @return
     */
    @Override
    public int update(final String entityName, final Map props, final Condition condition, final Map options) {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preUpdate(entityName, props, condition, options);
        }

        int result = -1;

        try {
            result = internalUpdate(entityName, props, condition, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postUpdate(result, entityName, props, condition, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entityId
     * @return
     */
    @Override
    public int delete(final EntityId entityId) {
        return delete(entityId, null);
    }

    /**
     *
     * @param entityId
     * @param options
     * @return
     */
    @Override
    public int delete(final EntityId entityId, final Map options) {
        EntityManagerUtil.checkArgNotNullOrEmpty(entityId, "EntityId");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preDelete(entityId, options);
        }

        int result = -1;

        try {
            result = internalDelete(entityId, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postDelete(result, entityId, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entityIds
     * @return
     */
    @Override
    public int deleteAll(final List entityIds) {
        return deleteAll(entityIds, null);
    }

    /**
     *
     * @param entityIds
     * @param options
     * @return
     */
    @Override
    public int deleteAll(final List entityIds, final Map options) {
        N.checkArgNotNullOrEmpty(entityIds, "EntityIds");
        EntityManagerUtil.checkArgNotNullOrEmpty(entityIds.get(0), "EntityIds");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preDelete(entityIds, options);
        }

        int result = -1;

        try {
            result = internalDelete(entityIds, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postDelete(result, entityIds, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entity
     * @return
     */
    @Override
    public int delete(final E entity) {
        return delete(entity, null);
    }

    /**
     *
     * @param entity
     * @param options
     * @return
     */
    @Override
    public int delete(final E entity, final Map options) {
        if (entity == null) {
            throw new IllegalArgumentException("Entity can't be null");
        }

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preDelete(entity, options);
        }

        int result = -1;

        try {
            result = internalDelete(entity, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postDelete(result, entity, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entities
     * @return
     */
    @Override
    public int deleteAll(final Collection entities) {
        return deleteAll(entities, null);
    }

    /**
     *
     * @param entities
     * @param options
     * @return
     */
    @Override
    public int deleteAll(final Collection entities, final Map options) {
        N.checkArgNotNullOrEmpty(entities, "Entities");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preDelete(entities, options);
        }

        int result = -1;

        try {
            result = internalDelete(entities, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postDelete(result, entities, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entityName
     * @param condition
     * @param options
     * @return
     */
    @Override
    public int delete(final String entityName, final Condition condition, final Map options) {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preDelete(entityName, condition, options);
        }

        int result = -1;

        try {
            result = internalDelete(entityName, condition, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postDelete(result, entityName, condition, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entityName
     * @param selectPropNames
     * @param condition
     * @return
     */
    @Override
    public DataSet query(final String entityName, final Collection selectPropNames, final Condition condition) {
        return query(entityName, selectPropNames, condition, null, null);
    }

    /**
     *
     * @param entityName
     * @param selectPropNames
     * @param condition
     * @param resultHandle
     * @param options
     * @return
     */
    @Override
    public DataSet query(final String entityName, final Collection selectPropNames, final Condition condition, final Holder resultHandle,
            final Map options) {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preQuery(entityName, selectPropNames, condition, resultHandle, options);
        }

        DataSet result = null;

        try {
            result = internalQuery(entityName, selectPropNames, condition, resultHandle, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postQuery(result, entityName, selectPropNames, condition, resultHandle, options);
            }
        }

        return result;
    }

    /**
     * Gets the result by handle.
     *
     * @param resultHandle
     * @param selectPropNames
     * @param options
     * @return
     */
    @Override
    public DataSet getResultByHandle(final String resultHandle, final Collection selectPropNames, final Map options) {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preGetResultByHandle(resultHandle, selectPropNames, options);
        }

        DataSet result = null;

        try {
            result = internalGetResultByHandle(resultHandle, selectPropNames, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postGetResultByHandle(result, resultHandle, selectPropNames, options);
            }
        }

        return result;
    }

    /**
     * Release result handle.
     *
     * @param resultHandle
     */
    @Override
    public void releaseResultHandle(String resultHandle)

    {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preReleaseResultHandle(resultHandle);
        }

        try {
            internalReleaseResultHandle(resultHandle);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postReleaseResultHandle(resultHandle);
            }
        }
    }

    /**
     *
     * @param isolationLevel
     * @param options
     * @return
     */
    @Override
    public String beginTransaction(final IsolationLevel isolationLevel, final Map options) {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preBeginTransaction(isolationLevel, options);
        }

        String result = null;

        try {
            result = internalBeginTransaction(isolationLevel, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postBeginTransaction(result, isolationLevel, options);
            }
        }

        return result;
    }

    /**
     *
     * @param transactionId
     * @param transactionAction
     * @param options
     */
    @Override
    public void endTransaction(final String transactionId, final Action transactionAction, final Map options) {
        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preEndTransaction(transactionId, transactionAction, options);
        }

        try {
            internalEndTransaction(transactionId, transactionAction, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postEndTransaction(transactionId, transactionAction, options);
            }
        }
    }

    /**
     * Gets the record version.
     *
     * @param entityId
     * @param options
     * @return
     */
    @Override
    @SuppressWarnings("deprecation")
    public long getRecordVersion(final EntityId entityId, final Map options) {
        EntityManagerUtil.checkArgNotNullOrEmpty(entityId, "EntityId");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preGetRecordVersion(entityId, options);
        }

        long result = -1;

        try {
            result = internalGetRecordVersion(entityId, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postGetRecordVersion(result, entityId, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entityId
     * @param lockMode
     * @param options
     * @return
     */
    @Override
    @SuppressWarnings("deprecation")
    public String lockRecord(final EntityId entityId, final LockMode lockMode, final Map options) {
        EntityManagerUtil.checkArgNotNullOrEmpty(entityId, "EntityId");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preLockRecord(entityId, lockMode, options);
        }

        String result = null;

        try {
            result = internalLockRecord(entityId, lockMode, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postLockRecord(result, entityId, lockMode, options);
            }
        }

        return result;
    }

    /**
     *
     * @param entityId
     * @param lockCode
     * @param options
     * @return true, if successful
     */
    @Override
    @SuppressWarnings("deprecation")
    public boolean unlockRecord(final EntityId entityId, final String lockCode, final Map options) {
        EntityManagerUtil.checkArgNotNullOrEmpty(entityId, "EntityId");

        for (int index = 0, size = handlerList.size(); index < size; index++) {
            handlerList.get(index).preUnlockRecord(entityId, lockCode, options);
        }

        boolean result = false;

        try {
            result = internalUnlockRecord(entityId, lockCode, options);
        } finally {
            for (int index = 0, size = handlerList.size(); index < size; index++) {
                handlerList.get(index).postUnlockRecord(result, entityId, lockCode, options);
            }
        }

        return result;
    }

    /**
     * Gets the entity definition factory.
     *
     * @return
     */
    @Override
    public EntityDefinitionFactory getEntityDefinitionFactory() {
        return internalGetEntityDefinitionFactory();
    }

    /**
     *
     * @param 
     * @param targetClass
     * @param entityId
     * @param selectPropNames
     * @param options
     * @return
     */
    protected abstract  T internalGet(Class targetClass, EntityId entityId, Collection selectPropNames, Map options);

    /**
     *
     * @param 
     * @param targetClass
     * @param entityIds
     * @param selectPropNames
     * @param options
     * @return
     */
    protected abstract  List internalGet(Class targetClass, List entityIds, Collection selectPropNames,
            Map options);

    /**
     *
     * @param 
     * @param targetClass
     * @param entityName
     * @param selectPropNames
     * @param condition
     * @param options
     * @return
     */
    protected abstract  List internalList(Class targetClass, String entityName, Collection selectPropNames, Condition condition,
            Map options);

    /**
     *
     * @param entity
     * @param options
     * @return
     */
    protected abstract EntityId internalAdd(E entity, Map options);

    /**
     *
     * @param entities
     * @param options
     * @return
     */
    protected abstract List internalAdd(Collection entities, Map options);

    /**
     *
     * @param entityName
     * @param props
     * @param options
     * @return
     */
    protected abstract EntityId internalAdd(String entityName, Map props, Map options);

    /**
     *
     * @param entityName
     * @param propsList
     * @param options
     * @return
     */
    protected abstract List internalAdd(String entityName, List> propsList, Map options);

    /**
     *
     * @param entity
     * @param options
     * @return
     */
    protected abstract int internalUpdate(E entity, Map options);

    /**
     *
     * @param entities
     * @param options
     * @return
     */
    protected abstract int internalUpdate(Collection entities, Map options);

    /**
     *
     * @param entityId
     * @param props
     * @param options
     * @return
     */
    protected abstract int internalUpdate(EntityId entityId, Map props, Map options);

    /**
     *
     * @param entityIds
     * @param props
     * @param options
     * @return
     */
    protected abstract int internalUpdate(List entityIds, Map props, Map options);

    /**
     *
     * @param entityName
     * @param props
     * @param condition
     * @param options
     * @return
     */
    protected abstract int internalUpdate(String entityName, Map props, Condition condition, Map options);

    /**
     *
     * @param entityId
     * @param options
     * @return
     */
    protected abstract int internalDelete(EntityId entityId, Map options);

    /**
     *
     * @param entityIds
     * @param options
     * @return
     */
    protected abstract int internalDelete(List entityIds, Map options);

    /**
     *
     * @param entity
     * @param options
     * @return
     */
    protected abstract int internalDelete(E entity, Map options);

    /**
     *
     * @param entities
     * @param options
     * @return
     */
    protected abstract int internalDelete(Collection entities, Map options);

    /**
     *
     * @param entityName
     * @param condition
     * @param options
     * @return
     */
    protected abstract int internalDelete(String entityName, Condition condition, Map options);

    /**
     *
     * @param entityName
     * @param selectPropNames
     * @param condition
     * @param resultHandle
     * @param options
     * @return
     */
    protected abstract DataSet internalQuery(String entityName, Collection selectPropNames, Condition condition, Holder resultHandle,
            Map options);

    /**
     * Internal get result by handle.
     *
     * @param resultHandle
     * @param selectPropNames
     * @param options
     * @return
     */
    protected abstract DataSet internalGetResultByHandle(String resultHandle, Collection selectPropNames, Map options);

    /**
     * Internal release result handle.
     *
     * @param resultHandle
     */
    protected abstract void internalReleaseResultHandle(String resultHandle);

    /**
     * Internal begin transaction.
     *
     * @param isolationLevel
     * @param options
     * @return
     */
    protected abstract String internalBeginTransaction(IsolationLevel isolationLevel, Map options);

    /**
     * Internal end transaction.
     *
     * @param transactionId
     * @param transactionAction
     * @param options
     */
    protected abstract void internalEndTransaction(String transactionId, Action transactionAction, Map options);

    /**
     * Internal get record version.
     *
     * @param entityId
     * @param options
     * @return
     */
    protected abstract long internalGetRecordVersion(EntityId entityId, Map options);

    /**
     * Internal lock record.
     *
     * @param entityId
     * @param lockMode
     * @param options
     * @return
     */
    protected abstract String internalLockRecord(EntityId entityId, LockMode lockMode, Map options);

    /**
     * Internal unlock record.
     *
     * @param entityId
     * @param lockCode
     * @param options
     * @return true, if successful
     */
    protected abstract boolean internalUnlockRecord(EntityId entityId, String lockCode, Map options);

    /**
     * Internal get entity definition factory.
     *
     * @return
     */
    protected abstract EntityDefinitionFactory internalGetEntityDefinitionFactory();

    /**
     * Check entity name.
     *
     * @param entityName
     * @return
     */
    protected EntityDefinition checkEntityName(final String entityName) {
        return EntityManagerUtil.checkEntityName(getEntityDefinitionFactory(), entityName);
    }

    /**
     * Check entity id.
     *
     * @param entityId
     * @return
     */
    protected EntityDefinition checkEntityId(final EntityId entityId) {
        return EntityManagerUtil.checkEntityId(getEntityDefinitionFactory(), entityId);
    }

    /**
     *
     * @param entity
     * @return
     */
    protected EntityDefinition checkEntity(final E entity) {
        return EntityManagerUtil.checkEntity(getEntityDefinitionFactory(), entity);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy