// Path: components/jta/common/src/main/java/com/kumuluz/ee/jta/common/utils/TxUtils.java
// public class TxUtils {
// 
//     public static Boolean isActive(TransactionManager transactionManager) {
// 
//         try {
//             Transaction tx = transactionManager.getTransaction();
// 
//             return tx != null && JtaProvider.TRANSACTION_ACTIVE_STATUS.contains(tx.getStatus());
//         } catch (SystemException e) {
//             throw new CannotRetrieveTxException(e);
//         }
//     }
// }


import java.util.List;
import java.util.Map;
import com.kumuluz.ee.jta.common.utils.TxUtils;
import javax.persistence.*;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaDelete;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.CriteriaUpdate;
import javax.persistence.metamodel.Metamodel;
import javax.transaction.TransactionManager;
import javax.transaction.TransactionSynchronizationRegistry;
    @Override
    public <T> EntityGraph<T> createEntityGraph(Class<T> rootType) {

        return getEntityManager().createEntityGraph(rootType);
    }

    @Override
    public EntityGraph<?> createEntityGraph(String graphName) {

        return getEntityManager().createEntityGraph(graphName);
    }

    @Override
    public EntityGraph<?> getEntityGraph(String graphName) {

        return getEntityManager().getEntityGraph(graphName);
    }

    @Override
    public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {

        return getEntityManager().getEntityGraphs(entityClass);
    }

    //// Private logic methods

    private EntityManager getEntityManager() {

        EntityManager em;

// Path: components/jta/common/src/main/java/com/kumuluz/ee/jta/common/utils/TxUtils.java
// public class TxUtils {
// 
//     public static Boolean isActive(TransactionManager transactionManager) {
// 
//         try {
//             Transaction tx = transactionManager.getTransaction();
// 
//             return tx != null && JtaProvider.TRANSACTION_ACTIVE_STATUS.contains(tx.getStatus());
//         } catch (SystemException e) {
//             throw new CannotRetrieveTxException(e);
//         }
//     }
// }


// Path: components/jpa/common/src/main/java/com/kumuluz/ee/jpa/common/jta/TxScopedEntityManager.java
import java.util.List;
import java.util.Map;
import com.kumuluz.ee.jta.common.utils.TxUtils;
import javax.persistence.*;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaDelete;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.CriteriaUpdate;
import javax.persistence.metamodel.Metamodel;
import javax.transaction.TransactionManager;
import javax.transaction.TransactionSynchronizationRegistry;

    @Override
    public <T> EntityGraph<T> createEntityGraph(Class<T> rootType) {

        return getEntityManager().createEntityGraph(rootType);
    }

    @Override
    public EntityGraph<?> createEntityGraph(String graphName) {

        return getEntityManager().createEntityGraph(graphName);
    }

    @Override
    public EntityGraph<?> getEntityGraph(String graphName) {

        return getEntityManager().getEntityGraph(graphName);
    }

    @Override
    public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {

        return getEntityManager().getEntityGraphs(entityClass);
    }

    //// Private logic methods

    private EntityManager getEntityManager() {

        EntityManager em;

        if (TxUtils.isActive(transactionManager)) {