org.hibernate.criterion.Expression.eq()

Here are the examples of the java api org.hibernate.criterion.Expression.eq() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

59 Examples 7

12 Source : DataSourceDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

private SbiDataSource loadSbiDataSourceWriteDefault(Session aSession) {
    Criterion labelCriterrion = Expression.eq("writeDefault", true);
    Criteria criteria = aSession.createCriteria(SbiDataSource.clreplaced);
    criteria.add(labelCriterrion);
    SbiDataSource hibDataSource = (SbiDataSource) criteria.uniqueResult();
    logger.debug("Hibernate datasource write default found in session: " + hibDataSource);
    return hibDataSource;
}

12 Source : SbiMetaTableColumnDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public SbiMetaTableColumn loadTableColumnByName(Session session, String name) throws EMFUserError {
    logger.debug("IN");
    SbiMetaTableColumn toReturn = null;
    Session tmpSession = session;
    try {
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiMetaTableColumn.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = (SbiMetaTableColumn) criteria.uniqueResult();
        if (toReturn == null)
            return null;
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return toReturn;
}

12 Source : SbiMetaTableColumnDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load all tablecolumn column linked to a table.
 *
 * @param session
 *            the session
 *
 * @return List of meta tables
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaTableColumnDAOHibImpl#loadTableColumnsFromTable(session, tableId)
 */
@Override
public List<SbiMetaTableColumn> loadTableColumnsFromTable(Session session, int tableId) throws EMFUserError {
    logger.debug("IN");
    List<SbiMetaTableColumn> toReturn = null;
    try {
        Criterion labelCriterrion = Expression.eq("sbiMetaTable.tableId", tableId);
        Criteria criteria = session.createCriteria(SbiMetaTableColumn.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = criteria.list();
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return toReturn;
}

11 Source : SbiMetaTableDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public SbiMetaTable loadTableByName(Session session, String name) throws EMFUserError {
    logger.debug("IN");
    SbiMetaTable toReturn = null;
    Session tmpSession = session;
    try {
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiMetaTable.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = (SbiMetaTable) criteria.uniqueResult();
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return toReturn;
}

11 Source : SbiMetaSourceDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public SbiMetaSource loadSourceByName(Session session, String name) throws EMFUserError {
    logger.debug("IN");
    SbiMetaSource toReturn = null;
    Session tmpSession = session;
    try {
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiMetaSource.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = (SbiMetaSource) criteria.uniqueResult();
        if (toReturn == null)
            return null;
    } catch (HibernateException he) {
        logException(he);
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        logger.debug("OUT");
    }
    return toReturn;
}

11 Source : SbiMetaJobDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public SbiMetaJob loadJobByName(Session session, String name) throws EMFUserError {
    logger.debug("IN");
    SbiMetaJob toReturn = null;
    Session tmpSession = session;
    try {
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiMetaJob.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = (SbiMetaJob) criteria.uniqueResult();
        if (toReturn == null)
            return null;
    } catch (HibernateException he) {
        logException(he);
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        logger.debug("OUT");
    }
    return toReturn;
}

11 Source : SbiMetaBcDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load source by name.
 *
 * @param session
 *            the session
 *
 * @param name
 *            the source name
 *
 * @return the meta source
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaBcDAOHibImpl#loadBcByName(session, string)
 */
@Override
public SbiMetaBc loadBcByName(Session session, String name) throws EMFUserError {
    logger.debug("IN");
    SbiMetaBc toReturn = null;
    try {
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = session.createCriteria(SbiMetaBc.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = (SbiMetaBc) criteria.uniqueResult();
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return toReturn;
}

11 Source : SbiMetaBcDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load source by the unique name.
 *
 * @param session
 *            the session
 *
 * @param name
 *            the unique name
 *
 * @return the meta bc
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaBcDAOHibImpl#loadBcByUniqueName(session, string)
 */
@Override
public SbiMetaBc loadBcByUniqueName(Session session, String uniqueName) throws EMFUserError {
    logger.debug("IN");
    SbiMetaBc toReturn = null;
    try {
        Criterion labelCriterrion = Expression.eq("uniqueName", uniqueName);
        Criteria criteria = session.createCriteria(SbiMetaBc.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = (SbiMetaBc) criteria.uniqueResult();
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return toReturn;
}

11 Source : DomainDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Same as loadDomainByCodeAndValue but with (optional) external session
 *
 * @param codeDomain
 * @param codeValue
 * @param aSession
 * @return
 * @throws EMFUserError
 */
@Override
public Domain loadDomainByCodeAndValue(String codeDomain, String codeValue, Session aSession) throws EMFUserError {
    if (aSession == null) {
        return loadDomainByCodeAndValue(codeDomain, codeValue);
    } else {
        Criterion aCriterion = Expression.and(Expression.eq("domainCd", codeDomain), Expression.eq("valueCd", codeValue));
        Criteria criteria = aSession.createCriteria(SbiDomains.clreplaced);
        criteria.add(aCriterion);
        SbiDomains aSbiDomains = (SbiDomains) criteria.uniqueResult();
        if (aSbiDomains == null)
            return null;
        return toDomain(aSbiDomains);
    }
}

10 Source : SbiGeoFeaturesDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load feature by name.
 *
 * @param name the name
 *
 * @return the geo feature
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.mapcatalogue.dao.geo.bo.dao.ISbiGeoFeaturesDAO#loadFeatureByName(string)
 */
public GeoFeature loadFeatureByName(String name) throws EMFUserError {
    GeoFeature biFeature = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiGeoFeatures.clreplaced);
        criteria.add(labelCriterrion);
        // List tmpLst = criteria.list();
        // return first feature (unique)
        // if (tmpLst != null && tmpLst.size()>0 ) biFeature = (SbiGeoFeatures)tmpLst.get(0);
        SbiGeoFeatures hibFeature = (SbiGeoFeatures) criteria.uniqueResult();
        if (hibFeature == null)
            return null;
        biFeature = hibFeature.toGeoFeature();
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    return biFeature;
}

9 Source : SbiMetaTableColumnDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public void modifyTableColumn(Session session, SbiMetaTableColumn aMetaTableColumn) throws EMFUserError {
    logger.debug("IN");
    Session tmpSession = session;
    try {
        SbiMetaTableColumn hibMeta = (SbiMetaTableColumn) tmpSession.load(SbiMetaTableColumn.clreplaced, aMetaTableColumn.getColumnId());
        hibMeta.setName(aMetaTableColumn.getName());
        hibMeta.setType(aMetaTableColumn.getType());
        hibMeta.setDeleted(aMetaTableColumn.isDeleted());
        SbiMetaTable metaTable = null;
        if (aMetaTableColumn.getSbiMetaTable().getTableId() < 0) {
            Criterion aCriterion = Expression.eq("valueId", aMetaTableColumn.getSbiMetaTable().getTableId());
            Criteria criteria = tmpSession.createCriteria(SbiMetaSource.clreplaced);
            criteria.add(aCriterion);
            metaTable = (SbiMetaTable) criteria.uniqueResult();
            if (metaTable == null) {
                throw new SpagoBIDAOException("The SbiMetaTable with id= " + aMetaTableColumn.getSbiMetaTable().getTableId() + " does not exist");
            }
            hibMeta.setSbiMetaTable(metaTable);
        }
        updateSbiCommonInfo4Update(hibMeta);
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
}

9 Source : SbiMetaTableColumnDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public Integer insertTableColumn(Session session, SbiMetaTableColumn aMetaTableColumn) throws EMFUserError {
    logger.debug("IN");
    Session tmpSession = session;
    Integer idToReturn = null;
    try {
        SbiMetaTableColumn hibMeta = new SbiMetaTableColumn();
        hibMeta.setName(aMetaTableColumn.getName());
        hibMeta.setType(aMetaTableColumn.getType());
        hibMeta.setDeleted(aMetaTableColumn.isDeleted());
        SbiMetaTable metaTable = null;
        if (aMetaTableColumn.getSbiMetaTable() != null) {
            Criterion aCriterion = Expression.eq("tableId", aMetaTableColumn.getSbiMetaTable().getTableId());
            Criteria criteria = tmpSession.createCriteria(SbiMetaTable.clreplaced);
            criteria.add(aCriterion);
            metaTable = (SbiMetaTable) criteria.uniqueResult();
            if (metaTable == null) {
                throw new SpagoBIDAOException("The SbiMetaTable with id= " + aMetaTableColumn.getSbiMetaTable().getTableId() + " does not exist");
            }
            hibMeta.setSbiMetaTable(metaTable);
        }
        updateSbiCommonInfo4Insert(hibMeta);
        idToReturn = (Integer) tmpSession.save(hibMeta);
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return idToReturn;
}

9 Source : SbiMetaDsTabRelDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public List<SbiMetaDsTabRel> loadByDatasetId(Integer datasetId) throws EMFUserError {
    logger.debug("IN");
    List<SbiMetaDsTabRel> toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("datasetId", datasetId);
        Criteria criteria = tmpSession.createCriteria(SbiMetaDsTabRel.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = criteria.list();
        if (toReturn == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return toReturn;
}

9 Source : SbiMetaDocTabRelDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public List<SbiMetaDocTabRel> loadByDoreplacedentId(Integer doreplacedentId) throws EMFUserError {
    logger.debug("IN");
    List<SbiMetaDocTabRel> toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("doreplacedentId", doreplacedentId);
        Criteria criteria = tmpSession.createCriteria(SbiMetaDocTabRel.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = criteria.list();
        if (toReturn == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return toReturn;
}

9 Source : SbiMetaBcAttributeDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public List<SbiMetaBcAttribute> loadAllBCAttributeFromBC(int bcId) throws EMFUserError {
    logger.debug("IN");
    List toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("bcId", bcId);
        Criteria criteria = tmpSession.createCriteria(SbiMetaBcAttribute.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = criteria.list();
        if (toReturn == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return toReturn;
}

9 Source : SbiMetaBcAttributeDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public List<SbiMetaBcAttribute> loadAllBCAttributeFromTableColumn(int columnId) throws EMFUserError {
    logger.debug("IN");
    List toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("columnId", columnId);
        Criteria criteria = tmpSession.createCriteria(SbiMetaTableColumn.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = criteria.list();
        if (toReturn == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return toReturn;
}

8 Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load sbiMenu by id.
 *
 * @param menuID the menu id
 *
 * @return the sbiMenu
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.wapp.dao.IMenuDAO#loadMenuByID(integer)
 */
@Override
public SbiMenu loadSbiMenuByID(Integer menuID) throws EMFUserError {
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion domainCdCriterrion = Expression.eq("menuId", menuID);
        Criteria criteria = tmpSession.createCriteria(SbiMenu.clreplaced);
        criteria.add(domainCdCriterrion);
        SbiMenu hibMenu = (SbiMenu) criteria.uniqueResult();
        return hibMenu;
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
}

8 Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public SbiMenu loadSbiMenubyName(String name) {
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion domainCdCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiMenu.clreplaced);
        criteria.add(domainCdCriterrion);
        SbiMenu hibMenu = (SbiMenu) criteria.uniqueResult();
        return hibMenu;
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    return null;
}

8 Source : SbiMetaBcAttributeDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load BCAttribute by name.
 *
 * @param name
 *            the BCAttribute name
 *
 * @return the meta BCAttribute
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaBcAttributeDAOHibImpl#loadBcAttributeByName(string)
 */
@Override
public SbiMetaBcAttribute loadBcAttributeByName(String name) throws EMFUserError {
    logger.debug("IN");
    SbiMetaBcAttribute toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiMetaBcAttribute.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = (SbiMetaBcAttribute) criteria.uniqueResult();
        if (toReturn == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return toReturn;
}

8 Source : SbiGeoMapsDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load map by name.
 *
 * @param name
 *            the name
 *
 * @return the geo map
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.mapcatalogue.dao.geo.bo.dao.ISbiGeoMapsDAO#loadMapByName(string)
 */
@Override
public GeoMap loadMapByName(String name) throws EMFUserError {
    GeoMap biMap = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiGeoMaps.clreplaced);
        criteria.add(labelCriterrion);
        // List tmpLst = criteria.list();
        // return first map (unique)
        // if (tmpLst != null && tmpLst.size()>0) biMap = (SbiGeoMaps)tmpLst.get(0);
        // if (tmpLst != null && tmpLst.size()>0) biMap = (SbiGeoMaps)tmpLst.get(0);
        SbiGeoMaps hibMap = (SbiGeoMaps) criteria.uniqueResult();
        if (hibMap == null)
            return null;
        biMap = hibMap.toGeoMap();
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    return biMap;
}

8 Source : SbiDossierActivityDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public DossierActivity loadActivity(Integer activityId) {
    logger.debug("IN");
    Session aSession = null;
    DossierActivity da = null;
    try {
        aSession = getSession();
        Criterion aCriterion = Expression.eq("id", activityId);
        Criteria criteria = aSession.createCriteria(SbiDossierActivity.clreplaced);
        criteria.add(aCriterion);
        SbiDossierActivity hibDa = (SbiDossierActivity) criteria.uniqueResult();
        if (hibDa == null)
            return null;
        da = toDossierActivity(hibDa);
        logger.debug("Loaded activity with id: " + activityId);
    } catch (HibernateException he) {
        logger.error("Exception while loading dossier activity with id: " + activityId, he);
        throw new SpagoBIRuntimeException("Exception while loading dossier activity with id: " + activityId, he);
    } finally {
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
    }
    return da;
}

8 Source : SbiDossierActivityDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public DossierActivity loadActivityByProgressThreadId(Integer progressthreadId) {
    logger.debug("IN");
    Session aSession = null;
    DossierActivity da = null;
    try {
        aSession = getSession();
        Criterion aCriterion = Expression.eq("progress.progressThreadId", progressthreadId);
        Criteria criteria = aSession.createCriteria(SbiDossierActivity.clreplaced);
        criteria.add(aCriterion);
        SbiDossierActivity hibDa = (SbiDossierActivity) criteria.uniqueResult();
        if (hibDa == null)
            return null;
        da = toDossierActivity(hibDa);
        logger.debug("Loaded activity with progressthreadId: " + progressthreadId);
    } catch (HibernateException he) {
        logger.error("Exception while loading dossier activity with id: " + progressthreadId, he);
        throw new SpagoBIRuntimeException("Exception while loading dossier activity with id: " + progressthreadId, he);
    } finally {
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
    }
    return da;
}

7 Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load menu by id.
 *
 * @param menuID the menu id
 *
 * @return the menu
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.wapp.dao.IMenuDAO#loadMenuByID(integer)
 */
@Override
public Menu loadMenuByID(Integer menuID) throws EMFUserError {
    Menu toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion domainCdCriterrion = Expression.eq("menuId", menuID);
        Criteria criteria = tmpSession.createCriteria(SbiMenu.clreplaced);
        criteria.add(domainCdCriterrion);
        SbiMenu hibMenu = (SbiMenu) criteria.uniqueResult();
        if (hibMenu == null)
            return null;
        // SbiMenu hibMenu = (SbiMenu)tmpSession.load(SbiMenu.clreplaced,
        // menuID);
        toReturn = toMenu(hibMenu, null);
    // toReturn = toMenu(loadSbiMenuByID(menuID), null);
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    return toReturn;
}

7 Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load menu by name.
 *
 * @param name the name
 *
 * @return the menu
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.wapp.dao.IMenuDAO#loadMenuByName(string)
 */
@Override
public Menu loadMenuByName(String name) throws EMFUserError {
    Menu biMenu = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiMenu.clreplaced);
        criteria.add(labelCriterrion);
        SbiMenu hibMenu = (SbiMenu) criteria.uniqueResult();
        if (hibMenu == null)
            return null;
        biMenu = toMenu(hibMenu, null);
    // tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    return biMenu;
}

7 Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load menu by id.
 *
 * @param menuID the menu id
 * @param roleId the user's role id
 *
 * @return the menu
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.wapp.dao.IMenuDAO#loadMenuByID(integer)
 */
@Override
public Menu loadMenuByID(Integer menuID, Integer roleID) throws EMFUserError {
    Menu toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion domainCdCriterrion = Expression.eq("menuId", menuID);
        Criteria criteria = tmpSession.createCriteria(SbiMenu.clreplaced);
        criteria.add(domainCdCriterrion);
        SbiMenu hibMenu = (SbiMenu) criteria.uniqueResult();
        if (hibMenu == null)
            return null;
        // SbiMenu hibMenu = (SbiMenu)tmpSession.load(SbiMenu.clreplaced,
        // menuID);
        toReturn = toMenu(hibMenu, roleID);
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    return toReturn;
}

7 Source : SbiMetaTableDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public List<SbiMetaTable> loadTablesFromSource(int sourceId) throws EMFUserError {
    logger.debug("IN");
    List toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("sourceid", sourceId);
        Criteria criteria = tmpSession.createCriteria(SbiMetaTable.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = criteria.list();
        if (toReturn == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return toReturn;
}

7 Source : SbiMetaTableDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load table by name.
 *
 * @param name
 *            the table name
 *
 * @return the meta table
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaTableDAOHibImpl#loadTableByName(string)
 */
@Override
public SbiMetaTable loadTableByName(String name) throws EMFUserError {
    logger.debug("IN");
    SbiMetaTable toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiMetaTable.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = (SbiMetaTable) criteria.uniqueResult();
        if (toReturn == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return toReturn;
}

7 Source : SbiMetaBcDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public List<SbiMetaBc> loadAllBCFromTable(int tableId) throws EMFUserError {
    logger.debug("IN");
    List toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("tableId", tableId);
        Criteria criteria = tmpSession.createCriteria(SbiMetaTable.clreplaced);
        criteria.add(labelCriterrion);
        toReturn = criteria.list();
        if (toReturn == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return toReturn;
}

7 Source : SbiGeoLayersDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load layer by name.
 *
 * @param name
 *            the name
 *
 * @return the geo layer
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.mapcatalogue.dao.geo.bo.dao.ISbiGeoLayersDAO#loadLayerByName(string)
 */
@Override
public GeoLayer loadLayerByLabel(String label) throws EMFUserError {
    GeoLayer biLayer = null;
    Session tmpSession = null;
    // Transaction tx = null;
    try {
        tmpSession = getSession();
        // tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("label", label);
        Criteria criteria = tmpSession.createCriteria(SbiGeoLayers.clreplaced);
        criteria.add(labelCriterrion);
        SbiGeoLayers hibLayer = (SbiGeoLayers) criteria.uniqueResult();
        if (hibLayer == null)
            return null;
        biLayer = hibLayer.toGeoLayer();
        String resourcePath = SpagoBIUtilities.getResourcePath();
        if (biLayer.getPathFile() != null) {
            if (biLayer.getPathFile().startsWith(resourcePath)) {
            // biLayer.setPathFile(biLayer.getPathFile());
            } else {
                biLayer.setPathFile(resourcePath + File.separator + biLayer.getPathFile());
            }
        }
    // tx.commit();
    } catch (HibernateException he) {
        logException(he);
        // if (tx != null)
        // tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    return biLayer;
}

7 Source : DomainDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load domain by code and value.
 *
 * @param codeDomain
 *            the code domain
 * @param codeValue
 *            the code value
 *
 * @return the domain
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.commons.dao.IDomainDAO#loadDomainByCodeAndValue(java.lang.String, java.lang.String)
 */
@Override
public SbiDomains loadSbiDomainByCodeAndValue(String codeDomain, String codeValue) throws EMFUserError {
    /*
		 * <STATEMENT name="SELECT_DOMAIN_FROM_CODE_VALUE" query="SELECT D.VALUE_NM AS VALUE_NAME, D.VALUE_ID AS VALUE_ID, D.VALUE_CD AS VALUE_CD FROM
		 * SBI_DOMAINS D WHERE DOMAIN_CD = ? AND VALUE_CD = ? "/>
		 */
    SbiDomains aSbiDomains = null;
    Session aSession = null;
    Transaction tx = null;
    try {
        aSession = getSession();
        tx = aSession.beginTransaction();
        Criterion aCriterion = Expression.and(Expression.eq("domainCd", codeDomain), Expression.eq("valueCd", codeValue));
        Criteria criteria = aSession.createCriteria(SbiDomains.clreplaced);
        criteria.add(aCriterion);
        aSbiDomains = (SbiDomains) criteria.uniqueResult();
        if (aSbiDomains == null)
            return null;
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
    }
    return aSbiDomains;
}

7 Source : ConfigDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Load configuration by complete label.
 *
 * @param label the configuration label
 *
 * @return the config object
 *
 * @throws EMFUserError the EMF user error
 *
 * @see it.eng.spagobi.common.bo.dao.ISbiConfigDAO#loadConfigParametersById(string)
 */
@Override
public Config loadConfigParametersByLabel(String label) throws Exception {
    logger.debug("IN");
    Config toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("label", label);
        Criteria criteria = tmpSession.createCriteria(SbiConfig.clreplaced);
        criteria.add(labelCriterrion);
        SbiConfig hibConfig = (SbiConfig) criteria.uniqueResult();
        if (hibConfig == null)
            return null;
        toReturn = hibConfig.toConfig();
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
        logger.debug("OUT");
    }
    return toReturn;
}

7 Source : BIObjectParameterDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public BIObjectParameter loadBiObjParameterByObjIdAndLabel(Integer objId, String label) throws EMFUserError {
    BIObjectParameter objPar = null;
    Session aSession = null;
    Transaction tx = null;
    try {
        aSession = getSession();
        tx = aSession.beginTransaction();
        Criterion idCriterrion = Expression.eq("sbiObject.biobjId", objId);
        Criterion labelCriterrion = Expression.eq("label", label);
        Criteria criteria = aSession.createCriteria(SbiObjPar.clreplaced);
        criteria.add(idCriterrion);
        criteria.add(labelCriterrion);
        SbiObjPar hibObjPar = (SbiObjPar) criteria.uniqueResult();
        if (hibObjPar != null)
            objPar = toBIObjectParameter(hibObjPar);
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
    }
    return objPar;
}

6 Source : UdpDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 *  Load a Udp by Label
 * @throws EMFUserError
 */
public Udp loadByLabel(String label) throws EMFUserError {
    logger.debug("IN");
    Udp udp = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("label", label);
        Criteria criteria = tmpSession.createCriteria(SbiUdp.clreplaced);
        criteria.add(labelCriterrion);
        SbiUdp hibUDP = (SbiUdp) criteria.uniqueResult();
        if (hibUDP == null)
            return null;
        udp = toUdp(hibUDP);
        tx.commit();
    } catch (HibernateException he) {
        logger.error("Error while loading the udp with label " + label, he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return udp;
}

6 Source : SbiDossierActivityDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public List<DossierActivity> loadAllActivities(Integer doreplacedentId) {
    logger.debug("IN");
    Session aSession = null;
    List<DossierActivity> listOfDossierActivities = new ArrayList<DossierActivity>();
    try {
        aSession = getSession();
        List<SbiDossierActivity> listSDA = new ArrayList<SbiDossierActivity>();
        Criterion aCriterion = Expression.eq("doreplacedentId", doreplacedentId);
        Criteria criteria = aSession.createCriteria(SbiDossierActivity.clreplaced);
        criteria.add(aCriterion);
        listSDA = criteria.list();
        for (int i = 0; i < listSDA.size(); i++) {
            listOfDossierActivities.add(toDossierActivity(listSDA.get(i)));
        }
    } catch (HibernateException he) {
        logger.error("Exception while laoding all dossier activities", he);
        throw new SpagoBIRuntimeException("Exception while laoding all dossier activities", he);
    } finally {
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
    }
    return listOfDossierActivities;
}

6 Source : DomainDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Delete domain by id.
 *
 * @param id
 *            the id
 *
 * @return void
 *
 * @throws EMFUserError
 *             the EMF user error
 */
@Override
public void delete(Integer idDomain) throws EMFUserError {
    logger.debug("IN");
    Session sess = null;
    Transaction tx = null;
    try {
        sess = getSession();
        tx = sess.beginTransaction();
        Criterion aCriterion = Expression.eq("valueId", idDomain);
        Criteria criteria = sess.createCriteria(SbiDomains.clreplaced);
        criteria.add(aCriterion);
        SbiDomains aSbiDomains = (SbiDomains) criteria.uniqueResult();
        if (aSbiDomains != null)
            sess.delete(aSbiDomains);
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new RuntimeException("Impossible to delete domain [" + idDomain + "]", he);
    } finally {
        if (sess != null) {
            if (sess.isOpen())
                sess.close();
        }
    }
}

5 Source : DistributionListDaoImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/*
	 * (non-Javadoc)
	 * 
	 * @see it.eng.spagobi.tools.distributionlist.dao.IDistributionListDAO#loadDistributionListByName(java.lang.String)
	 */
@Override
public DistributionList loadDistributionListByName(String name) throws EMFUserError {
    logger.debug("IN");
    DistributionList biDL = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion nameCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiDistributionList.clreplaced);
        criteria.add(nameCriterrion);
        SbiDistributionList hibDL = (SbiDistributionList) criteria.uniqueResult();
        if (hibDL == null)
            return null;
        biDL = toDistributionList(hibDL);
        tx.commit();
    } catch (HibernateException he) {
        logger.error("Error while loading the Distribution List with name " + name, he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 9104);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return biDL;
}

5 Source : SbiMetaBcAttributeDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Modify a metaBCAttribute.
 *
 * * @param aSession the hibernate session
 *
 * @param aMetaBC
 *            the sbimetaBCAttribute changed
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaBcAttributeDAOHibImpl#modifyBcAttribute(Session, SbiMetaTable)
 */
@Override
public void modifyBcAttribute(Session session, SbiMetaBcAttribute aMetaBcAttribute) throws EMFUserError {
    logger.debug("IN");
    Session tmpSession = session;
    try {
        SbiMetaBcAttribute hibMeta = (SbiMetaBcAttribute) tmpSession.load(SbiMetaBcAttribute.clreplaced, aMetaBcAttribute.getAttributeId());
        hibMeta.setName(aMetaBcAttribute.getName());
        hibMeta.setType(aMetaBcAttribute.getType());
        hibMeta.setDeleted(aMetaBcAttribute.isDeleted());
        SbiMetaBc metaBc = null;
        if (aMetaBcAttribute.getSbiMetaBc() != null) {
            Criterion aCriterion = Expression.eq("bcId", aMetaBcAttribute.getSbiMetaBc().getBcId());
            Criteria criteria = tmpSession.createCriteria(SbiMetaBc.clreplaced);
            criteria.add(aCriterion);
            metaBc = (SbiMetaBc) criteria.uniqueResult();
            if (metaBc == null) {
                throw new SpagoBIDAOException("The sbiMetaBc with id= " + aMetaBcAttribute.getSbiMetaBc().getBcId() + " does not exist");
            }
            hibMeta.setSbiMetaBc(metaBc);
        }
        SbiMetaTableColumn metaTableColumn = null;
        if (aMetaBcAttribute.getSbiMetaTableColumn() != null) {
            Criterion aCriterion = Expression.eq("columnId", aMetaBcAttribute.getSbiMetaTableColumn().getColumnId());
            Criteria criteria = tmpSession.createCriteria(SbiMetaTableColumn.clreplaced);
            criteria.add(aCriterion);
            metaTableColumn = (SbiMetaTableColumn) criteria.uniqueResult();
            if (metaTableColumn == null) {
                throw new SpagoBIDAOException("The SbiMetaTableColumn with id= " + aMetaBcAttribute.getSbiMetaTableColumn().getColumnId() + " does not exist");
            }
            hibMeta.setSbiMetaTableColumn(metaTableColumn);
        }
        updateSbiCommonInfo4Update(hibMeta);
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
}

5 Source : SbiMetaBcAttributeDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Insert a metaBCAttribute.
 *
 * * @param aSession the hibernate session
 *
 * @param aMetaBCAttribute
 *            the sbimetaBCAttribute to insert
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaBcAttributeDAOHibImpl#insertBcAttribute(Session, SbiMetaTable)
 */
@Override
public Integer insertBcAttribute(Session session, SbiMetaBcAttribute aMetaBcAttribute) throws EMFUserError {
    logger.debug("IN");
    Session tmpSession = session;
    Integer idToReturn = null;
    try {
        SbiMetaBcAttribute hibMeta = new SbiMetaBcAttribute();
        hibMeta.setName(aMetaBcAttribute.getName());
        hibMeta.setType(aMetaBcAttribute.getType());
        hibMeta.setDeleted(aMetaBcAttribute.isDeleted());
        SbiMetaBc metaBc = null;
        if (aMetaBcAttribute.getSbiMetaBc() != null) {
            Criterion aCriterion = Expression.eq("bcId", aMetaBcAttribute.getSbiMetaBc().getBcId());
            Criteria criteria = tmpSession.createCriteria(SbiMetaBc.clreplaced);
            criteria.add(aCriterion);
            metaBc = (SbiMetaBc) criteria.uniqueResult();
            if (metaBc == null) {
                throw new SpagoBIDAOException("The sbiMetaBc with id= " + aMetaBcAttribute.getSbiMetaBc().getBcId() + " does not exist");
            }
            hibMeta.setSbiMetaBc(metaBc);
        }
        SbiMetaTableColumn metaTableColumn = null;
        if (aMetaBcAttribute.getSbiMetaTableColumn() != null) {
            Criterion aCriterion = Expression.eq("columnId", aMetaBcAttribute.getSbiMetaTableColumn().getColumnId());
            Criteria criteria = tmpSession.createCriteria(SbiMetaTableColumn.clreplaced);
            criteria.add(aCriterion);
            metaTableColumn = (SbiMetaTableColumn) criteria.uniqueResult();
            if (metaTableColumn == null) {
                throw new SpagoBIDAOException("The SbiMetaTableColumn with id= " + aMetaBcAttribute.getSbiMetaTableColumn().getColumnId() + " does not exist");
            }
            hibMeta.setSbiMetaTableColumn(metaTableColumn);
        }
        updateSbiCommonInfo4Insert(hibMeta);
        idToReturn = (Integer) tmpSession.save(hibMeta);
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return idToReturn;
}

5 Source : TenantsDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public SbiTenant loadTenantById(Integer id) throws EMFUserError {
    logger.debug("IN");
    SbiTenant tenant = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("id", id);
        Criteria criteria = tmpSession.createCriteria(SbiTenant.clreplaced);
        criteria.add(labelCriterrion);
        tenant = (SbiTenant) criteria.uniqueResult();
        tx.commit();
    } catch (HibernateException he) {
        logger.error("Error while loading the tenant with id " + id, he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return tenant;
}

5 Source : TenantsDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public SbiTenant loadTenantByName(String name) throws EMFUserError {
    logger.debug("IN");
    SbiTenant tenant = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("name", name);
        Criteria criteria = tmpSession.createCriteria(SbiTenant.clreplaced);
        criteria.add(labelCriterrion);
        tenant = (SbiTenant) criteria.uniqueResult();
        tx.commit();
    } catch (HibernateException he) {
        logger.error("Error while loading the tenant with name " + name, he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return tenant;
}

5 Source : ConfigDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Delete config by id.
 *
 * @param id the id
 *
 * @return void
 *
 * @throws EMFUserError the EMF user error
 */
@Override
public void delete(Integer idConfig) throws EMFUserError {
    logger.debug("IN");
    Session sess = null;
    Transaction tx = null;
    try {
        sess = getSession();
        tx = sess.beginTransaction();
        Criterion aCriterion = Expression.eq("id", idConfig);
        Criteria criteria = sess.createCriteria(SbiConfig.clreplaced);
        criteria.add(aCriterion);
        SbiConfig aSbiConfig = (SbiConfig) criteria.uniqueResult();
        if (aSbiConfig != null)
            sess.delete(aSbiConfig);
        tx.commit();
    } catch (HibernateException he) {
        logger.error("HibernateException", he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (sess != null) {
            if (sess.isOpen())
                sess.close();
        }
    }
    logger.debug("OUT");
}

4 Source : SbiMetaTableDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public void modifyTable(Session session, SbiMetaTable aMetaTable) throws EMFUserError {
    logger.debug("IN");
    Session tmpSession = session;
    try {
        SbiMetaTable hibMeta = (SbiMetaTable) tmpSession.load(SbiMetaTable.clreplaced, aMetaTable.getTableId());
        hibMeta.setName(aMetaTable.getName());
        hibMeta.setDeleted(aMetaTable.isDeleted());
        SbiMetaSource metaSource = null;
        if (aMetaTable.getSbiMetaSource().getSourceId() < 0) {
            Criterion aCriterion = Expression.eq("valueId", aMetaTable.getSbiMetaSource().getSourceId());
            Criteria criteria = tmpSession.createCriteria(SbiMetaSource.clreplaced);
            criteria.add(aCriterion);
            metaSource = (SbiMetaSource) criteria.uniqueResult();
            if (metaSource == null) {
                throw new SpagoBIDAOException("The Domain with value_id= " + aMetaTable.getSbiMetaSource().getSourceId() + " does not exist");
            }
            hibMeta.setSbiMetaSource(metaSource);
        }
        updateSbiCommonInfo4Update(hibMeta);
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
}

4 Source : SbiMetaTableDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public Integer insertTable(Session session, SbiMetaTable aMetaTable) throws EMFUserError {
    logger.debug("IN");
    Session tmpSession = session;
    Integer idToReturn = null;
    try {
        SbiMetaTable hibMeta = new SbiMetaTable();
        hibMeta.setName(aMetaTable.getName());
        hibMeta.setDeleted(aMetaTable.isDeleted());
        SbiMetaSource metaSource = null;
        if (aMetaTable.getSbiMetaSource() != null) {
            Criterion aCriterion = Expression.eq("sourceId", aMetaTable.getSbiMetaSource().getSourceId());
            Criteria criteria = tmpSession.createCriteria(SbiMetaSource.clreplaced);
            criteria.add(aCriterion);
            metaSource = (SbiMetaSource) criteria.uniqueResult();
            if (metaSource == null) {
                throw new SpagoBIDAOException("The Domain with value_id= " + aMetaTable.getSbiMetaSource().getSourceId() + " does not exist");
            }
            hibMeta.setSbiMetaSource(metaSource);
        }
        updateSbiCommonInfo4Insert(hibMeta);
        idToReturn = (Integer) tmpSession.save(hibMeta);
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return idToReturn;
}

4 Source : SbiMetaBcDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Insert a metaBC.
 *
 * * @param aSession the hibernate session
 *
 * @param aMetaBC
 *            the sbimetaBC to insert
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaBcDAOHibImpl#insertBc(Session, SbiMetaTable)
 */
@Override
public Integer insertBc(Session session, SbiMetaBc aMetaBc) throws EMFUserError {
    logger.debug("IN");
    Integer idToReturn = null;
    try {
        SbiMetaBc hibMeta = new SbiMetaBc();
        hibMeta.setName(aMetaBc.getName());
        hibMeta.setDeleted(aMetaBc.isDeleted());
        SbiMetaModel metaModel = null;
        if (aMetaBc.getSbiMetaModel() != null) {
            Criterion aCriterion = Expression.eq("id", aMetaBc.getSbiMetaModel().getId());
            Criteria criteria = session.createCriteria(SbiMetaModel.clreplaced);
            criteria.add(aCriterion);
            metaModel = (SbiMetaModel) criteria.uniqueResult();
            if (metaModel == null) {
                throw new SpagoBIDAOException("The sbiMetaModel with id= " + aMetaBc.getSbiMetaModel().getId() + " does not exist");
            }
            hibMeta.setSbiMetaModel(metaModel);
        }
        updateSbiCommonInfo4Insert(hibMeta);
        idToReturn = (Integer) session.save(hibMeta);
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
    return idToReturn;
}

4 Source : RememberMeDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

public RememberMe getRememberMe(Integer rememberMeId) throws EMFInternalError {
    logger.debug("IN");
    Session aSession = null;
    Transaction tx = null;
    RememberMe toReturn = null;
    try {
        aSession = getSession();
        tx = aSession.beginTransaction();
        Criterion userIdCriterion = Expression.eq("id", rememberMeId);
        Criteria criteria = aSession.createCriteria(SbiRememberMe.clreplaced);
        criteria.add(userIdCriterion);
        // criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENreplacedY);
        List list = criteria.list();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            SbiRememberMe hibObj = (SbiRememberMe) it.next();
            toReturn = toRememberMe(hibObj);
        }
        return toReturn;
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFInternalError(EMFErrorSeverity.ERROR, "100");
    } finally {
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
        logger.debug("OUT");
    }
}

4 Source : ParameterDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public Parameter loadForDetailByParameterLabel(String label) throws EMFUserError {
    logger.debug("IN");
    Parameter parameter = null;
    Session aSession = null;
    Transaction tx = null;
    try {
        aSession = getSession();
        tx = aSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("label", label);
        Criteria criteria = aSession.createCriteria(SbiParameters.clreplaced);
        criteria.add(labelCriterrion);
        SbiParameters hibPar = (SbiParameters) criteria.uniqueResult();
        if (hibPar == null)
            return null;
        parameter = toParameter(hibPar);
        tx.commit();
    } catch (HibernateException he) {
        logger.error(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
    }
    logger.debug("OUT");
    return parameter;
}

3 Source : SbiMetaBcDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 * Modify a metaBC.
 *
 * * @param aSession the hibernate session
 *
 * @param aMetaBC
 *            the sbimetaBC changed
 *
 * @throws EMFUserError
 *             the EMF user error
 *
 * @see it.eng.spagobi.metadata.dao.ISbiMetaBcDAOHibImpl#modifyBc(Session, SbiMetaTable)
 */
@Override
public void modifyBc(Session aSession, SbiMetaBc aMetaBc) throws EMFUserError {
    logger.debug("IN");
    try {
        SbiMetaBc hibMeta = (SbiMetaBc) aSession.load(SbiMetaBc.clreplaced, aMetaBc.getBcId());
        hibMeta.setName(aMetaBc.getName());
        hibMeta.setUniqueName(aMetaBc.getUniqueName());
        hibMeta.setDeleted(aMetaBc.isDeleted());
        SbiMetaModel metaModel = null;
        if (aMetaBc.getSbiMetaModel() != null) {
            Criterion aCriterion = Expression.eq("id", aMetaBc.getSbiMetaModel().getId());
            Criteria criteria = aSession.createCriteria(SbiMetaModel.clreplaced);
            criteria.add(aCriterion);
            metaModel = (SbiMetaModel) criteria.uniqueResult();
            if (metaModel == null) {
                throw new SpagoBIDAOException("The sbiMetaModel with id= " + aMetaBc.getSbiMetaModel().getId() + " does not exist");
            }
            hibMeta.setSbiMetaModel(metaModel);
        }
        updateSbiCommonInfo4Update(hibMeta);
    } catch (HibernateException he) {
        logException(he);
        throw new HibernateException(he);
    } finally {
        logger.debug("OUT");
    }
}

3 Source : RememberMeDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/* (non-Javadoc)
	 * @see it.eng.spagobi.hotlink.rememberme.dao.IRememberMeDAO#getMyRememberMe(java.lang.String)
	 */
public List<RememberMe> getMyRememberMe(String userId) throws EMFInternalError {
    logger.debug("IN");
    logger.debug("*** RememberMe - userId: " + userId);
    Session aSession = null;
    Transaction tx = null;
    List toReturn = new ArrayList();
    try {
        aSession = getSession();
        tx = aSession.beginTransaction();
        Criterion userIdCriterion = Expression.eq("userName", userId);
        Criteria criteria = aSession.createCriteria(SbiRememberMe.clreplaced);
        criteria.add(userIdCriterion);
        // criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENreplacedY);
        List list = criteria.list();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            SbiRememberMe hibObj = (SbiRememberMe) it.next();
            toReturn.add(toRememberMe(hibObj));
        }
        return toReturn;
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFInternalError(EMFErrorSeverity.ERROR, "100");
    } finally {
        if (aSession != null) {
            if (aSession.isOpen())
                aSession.close();
        }
        logger.debug("OUT");
    }
}

3 Source : ConfigDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

@Override
public List<Config> loadConfigParametersByCategory(String category) throws Exception {
    logger.debug("IN");
    if (StringUtils.isEmpty(category)) {
        throw new IllegalArgumentException("Category cannot be null");
    }
    List<Config> ret = new ArrayList<Config>();
    Config toReturn = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        Criterion labelCriterrion = Expression.eq("category", category);
        Criteria criteria = tmpSession.createCriteria(SbiConfig.clreplaced);
        criteria.add(labelCriterrion);
        List<SbiConfig> matchinConfigs = criteria.list();
        for (SbiConfig currConf : matchinConfigs) {
            ret.add(currConf.toConfig());
        }
        tx.commit();
    } catch (HibernateException he) {
        logException(he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
        logger.debug("OUT");
    }
    return ret;
}

1 Source : UdpDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs

/**
 *  Load a Udp by Label and Family code
 * @throws EMFUserError
 */
public Udp loadByLabelAndFamily(String label, String family) throws EMFUserError {
    logger.debug("IN");
    Udp udp = null;
    Session tmpSession = null;
    Transaction tx = null;
    try {
        tmpSession = getSession();
        tx = tmpSession.beginTransaction();
        // get familyId
        String hql = "from SbiDomains s " + "	where lower(s.valueCd) = lower(?) AND " + "         s.domainCd = ?";
        Query hqlQuery = tmpSession.createQuery(hql);
        hqlQuery.setString(0, family);
        hqlQuery.setString(1, "UDP_FAMILY");
        SbiDomains famiDom = (SbiDomains) hqlQuery.uniqueResult();
        if (famiDom == null)
            return null;
        Criterion labelCriterrion = Expression.eq("label", label);
        Criteria criteria2 = tmpSession.createCriteria(SbiUdp.clreplaced);
        criteria2.add(labelCriterrion);
        Criterion famCriterrion = Expression.eq("familyId", famiDom.getValueId());
        criteria2.add(famCriterrion);
        SbiUdp hibUDP = (SbiUdp) criteria2.uniqueResult();
        if (hibUDP == null)
            return null;
        udp = toUdp(hibUDP);
        tx.commit();
    } catch (HibernateException he) {
        logger.error("Error while loading the udp with label " + label, he);
        if (tx != null)
            tx.rollback();
        throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
    } finally {
        if (tmpSession != null) {
            if (tmpSession.isOpen())
                tmpSession.close();
        }
    }
    logger.debug("OUT");
    return udp;
}

See More Examples