Here are the examples of the java api org.hibernate.Query.setInteger() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
228 Examples
19
Source : SystemService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
@Transactional(readOnly = true)
public Message getUserMessage(int userId) {
Session session = sessionFactory.getCurrentSession();
Query q = session.createQuery("FROM Message m WHERE m.userId = :id");
q.setInteger("id", userId);
@SuppressWarnings("unchecked")
List<Message> messages = q.list();
Message result;
if (!messages.isEmpty()) {
result = messages.get(0);
if (result.getAutoDeactivate() != null && result.getAutoDeactivate().before(new Date())) {
result.setActive(false);
}
} else {
return null;
}
q = session.createQuery("FROM MessageType m ORDER BY m.criticality ASC");
@SuppressWarnings("unchecked")
List<MessageType> messageTypes = q.list();
result.setTypes(messageTypes);
return result;
}
18
Source : UserDaoImpl.java
with MIT License
from zhangjikai
with MIT License
from zhangjikai
@Override
public boolean deleteUserById(int userId, int group) {
String sql = "delete from User where id=:id and group<:group";
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery(sql);
query.setInteger("id", userId);
query.setInteger("group", group);
int num = query.executeUpdate();
if (num > 0)
return true;
return false;
}
18
Source : CollectDaoImpl.java
with MIT License
from zhangjikai
with MIT License
from zhangjikai
@Override
public boolean deleteCollect(int collectId, int userId) {
String sql = "delete from Collect where id=:id and userId=:userId";
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery(sql);
query.setInteger("id", collectId);
query.setInteger("userId", userId);
int num = query.executeUpdate();
if (num > 0)
return true;
return false;
}
18
Source : CollectDaoImpl.java
with MIT License
from zhangjikai
with MIT License
from zhangjikai
@Override
public List<String> getRecommend(int userId) {
String sql = "select b.dynasty from Collect c, Book b where c.bookId = b.bookID and c.userId=:userId group by b.dynasty having" + " count(c.bookId) >= all (select count(c1.bookId) from Collect c1, Book b1 where c1.bookId = b1.bookID and c1.userId=:userId1 group by b1.dynasty)";
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery(sql);
query.setInteger("userId", userId);
query.setInteger("userId1", userId);
return query.list();
}
18
Source : MenuRolesDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* Load menu by role id.
*
* @param roleId
* the role id
*
* @return the list
*
* @throws EMFUserError
* the EMF user error
*
* @see it.eng.spagobi.wapp.dao.IMenuRolesDAO#loadMenuByRoleId(java.lang.Integer)
*/
@Override
public List loadMenuByRoleId(Integer roleId) throws EMFUserError {
logger.debug("IN");
if (roleId != null)
logger.debug("roleId=" + roleId.toString());
Session aSession = null;
Transaction tx = null;
List realResult = new ArrayList();
String hql = null;
Query hqlQuery = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
hql = " select mf.id.menuId, mf.id.extRoleId from SbiMenuRole as mf, SbiMenu m " + " where mf.id.menuId = m.menuId " + " and mf.id.extRoleId = ? " + " order by m.parentId, m.prog";
hqlQuery = aSession.createQuery(hql);
hqlQuery.setInteger(0, roleId.intValue());
List hibList = hqlQuery.list();
Iterator it = hibList.iterator();
IMenuDAO menuDAO = DAOFactory.getMenuDAO();
Menu tmpMenu = null;
while (it.hasNext()) {
Object[] tmpLst = (Object[]) it.next();
Integer menuId = (Integer) tmpLst[0];
tmpMenu = menuDAO.loadMenuByID(menuId, roleId);
if (tmpMenu != null) {
logger.debug("Add Menu:" + tmpMenu.getName());
realResult.add(tmpMenu);
}
}
tx.commit();
} catch (HibernateException he) {
logger.error("HibernateException", 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 realResult;
}
18
Source : SbiNewsReadDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public SbiNewsRead getNewsReadByIdAndUser(Integer id, String user) {
logger.debug("IN");
SbiNewsRead sbiNewsRead = null;
Session session = null;
Transaction transaction = null;
try {
session = getSession();
transaction = session.beginTransaction();
String hql = "from SbiNewsRead s WHERE s.newsId = :newsReadID and s.user = :user";
Query query = session.createQuery(hql);
query.setInteger("newsReadID", id);
query.setString("user", user);
sbiNewsRead = (SbiNewsRead) query.uniqueResult();
transaction.commit();
} catch (HibernateException e) {
logException(e);
if (transaction != null)
transaction.rollback();
throw new SpagoBIRuntimeException("Cannot get newsRead with id = " + id, e);
} finally {
if (session != null && session.isOpen())
session.close();
}
logger.debug("OUT");
return sbiNewsRead;
}
18
Source : SbiGeoLayersDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public List<SbiGeoLayersRoles> getListRolesById(Integer id) {
Session tmpSession = null;
List<SbiGeoLayersRoles> roles = new ArrayList<>();
try {
tmpSession = getSession();
String hql = " from SbiGeoLayersRoles WHERE layer.layerId =? ";
Query q = tmpSession.createQuery(hql);
q.setInteger(0, id);
roles = q.list();
if (roles.size() == 0) {
return null;
}
} catch (HibernateException he) {
logException(he);
} finally {
if (tmpSession != null && tmpSession.isOpen()) {
tmpSession.close();
}
}
return roles;
}
18
Source : SbiGeoLayersDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public List<SbiGeoLayersRoles> getListRolesById(Integer id, Session session) {
List<SbiGeoLayersRoles> roles = new ArrayList<>();
try {
String hql = " from SbiGeoLayersRoles WHERE layer.layerId =? ";
Query q = session.createQuery(hql);
q.setInteger(0, id);
roles = q.list();
if (roles.size() == 0) {
return null;
}
} catch (HibernateException he) {
logException(he);
}
return roles;
}
18
Source : CacheDaoImpl.java
with Apache License 2.0
from helicalinsight
with Apache License 2.0
from helicalinsight
@Override
public Cache findUniqueCache(Cache sampleCache) {
Cache cache = null;
Query query = session.getCurrentSession().createQuery("from Cache where query=:query " + "and" + " connectionId=:connectionId and mapId=:mapId and connectionType=:connectionType" + " order by " + "cacheExpiryTime desc");
query.setParameter("query", sampleCache.getQuery());
query.setLong("connectionId", sampleCache.getConnectionId());
query.setInteger("mapId", sampleCache.getMapId());
query.setParameter("connectionType", sampleCache.getConnectionType());
@SuppressWarnings("rawtypes")
List results = query.list();
try {
if (results != null && results.size() > 0) {
cache = (Cache) results.get(0);
}
} catch (Exception e) {
logger.error("Exception", e);
}
return cache;
}
18
Source : SystemService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
@Transactional
public void deleteMessage(int id, int userId, boolean userisadmin) {
Session session = sessionFactory.getCurrentSession();
String hql;
if (userisadmin) {
hql = "DELETE FROM Message m WHERE (m.userId = :userid OR m.userId = -1) AND m.id = :id";
} else {
hql = "DELETE FROM Message m WHERE m.userId = :userid AND m.id = :id";
}
Query q = session.createQuery(hql);
q.setInteger("userid", userId);
q.setInteger("id", id);
q.executeUpdate();
}
18
Source : SqlQueryService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
private void setParameter(Map<String, Object> parameters, String key, Query query) throws MessageException {
Object parameter = parameters.get(key);
if (parameter instanceof String) {
query.setString(key, (String) parameter);
} else if (parameter instanceof String[]) {
query.setParameterList(key, (String[]) parameter);
} else if (parameter instanceof Integer) {
query.setInteger(key, (Integer) parameter);
} else if (parameter instanceof Double) {
query.setDouble(key, (Double) parameter);
} else if (parameter instanceof Integer[]) {
query.setParameterList(key, (Integer[]) parameter);
} else if (parameter instanceof Date) {
query.setParameter(key, (Date) parameter);
} else if (parameter == null) {
query.setParameter(key, null);
} else {
// this should not happen
throw new MessageException("unknown parameter type: " + parameter);
}
}
18
Source : ExportService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
@Transactional(readOnly = true)
public List<Export> getSurveyExports(int surveyId) {
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery("FROM Export e WHERE e.survey.id = :id");
query.setInteger("id", surveyId);
@SuppressWarnings("unchecked")
List<Export> exports = query.list();
return exports;
}
18
Source : ExportService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
@Transactional(readOnly = true)
public Export getExportByResultFilterID(int id) {
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery("FROM Export e WHERE e.resultFilter.id = :id");
query.setInteger("id", id);
@SuppressWarnings("unchecked")
List<Export> exports = query.list();
if (!exports.isEmpty())
return exports.get(0);
return null;
}
17
Source : CollectDaoImpl.java
with MIT License
from zhangjikai
with MIT License
from zhangjikai
@Override
public Collect getCollectByBook$User(int bookId, int userId) {
String sql = "from Collect where bookId=:bookId and userId=:userId";
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery(sql);
query.setInteger("bookId", bookId);
query.setInteger("userId", userId);
List<Collect> collects = query.list();
if (collects.size() == 0)
return null;
return collects.get(0);
}
17
Source : BookDaoImpl.java
with MIT License
from zhangjikai
with MIT License
from zhangjikai
@Override
public void updateClickTime(int bookId, int clickTime) {
String hql = "update Book set clickTimes=:clickTimes where bookID=:bookId";
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery(hql);
query.setInteger("clickTimes", clickTime);
query.setInteger("bookId", bookId);
query.executeUpdate();
}
17
Source : LookupTableHelper.java
with Apache License 2.0
from Pardus-Engerek
with Apache License 2.0
from Pardus-Engerek
private void deleteRowById(Session session, String tableOid, Long id) {
Query query = session.getNamedQuery("delete.lookupTableDataRow");
query.setString("oid", tableOid);
query.setInteger("id", RUtil.toInteger(id));
query.executeUpdate();
}
17
Source : DashboardDAO.java
with GNU General Public License v2.0
from openkm
with GNU General Public License v2.0
from openkm
/**
* Get dashboard stats
*/
@SuppressWarnings("unchecked")
public Dashboard findByPk(int dsId) throws DatabaseException {
log.debug("findByPk({})", dsId);
String qs = "from Dashboard db where db.id=:id";
Session session = null;
try {
session = HibernateUtil.getSessionFactory().openSession();
Query q = session.createQuery(qs);
q.setInteger("id", dsId);
// uniqueResult
List<Dashboard> results = q.list();
Dashboard ret = null;
if (results.size() == 1) {
ret = results.get(0);
}
log.debug("findByPk: {}", ret);
return ret;
} catch (HibernateException e) {
throw new DatabaseException(e.getMessage(), e);
} finally {
HibernateUtil.close(session);
}
}
17
Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
private void eraseMenuSons(Integer eventualFatherId, Session tmpSession) throws EMFUserError {
String getSons = null;
Query queryD = null;
if (eventualFatherId != null) {
getSons = "from SbiMenu s where s.parentId = ?";
queryD = tmpSession.createQuery(getSons);
queryD.setInteger(0, eventualFatherId);
}
List sons = queryD.list();
if (sons != null) {
Iterator it = sons.iterator();
while (it.hasNext()) {
SbiMenu toDel = (SbiMenu) it.next();
eraseMenuSons(toDel.getMenuId(), tmpSession);
tmpSession.delete(toDel);
Integer parentId = toDel.getParentId();
String hqlUpdateProg = null;
Query query = null;
if (parentId != null) {
hqlUpdateProg = "update SbiMenu s set s.prog = (s.prog - 1) where s.prog > ?" + " and s.parentId = ? ";
query = tmpSession.createQuery(hqlUpdateProg);
query.setInteger(0, toDel.getProg().intValue());
query.setInteger(1, toDel.getParentId().intValue());
} else {
hqlUpdateProg = "update SbiMenu s set s.prog = (s.prog - 1) where s.prog > ?" + " and s.parentId = null";
query = tmpSession.createQuery(hqlUpdateProg);
query.setInteger(0, toDel.getProg().intValue());
}
query.executeUpdate();
}
}
}
17
Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
private void deleteIncongruousRoles(Session aSession, SbiMenu hibMenu) {
// delete incongruous roles children of the current menu node
Integer menuId = hibMenu.getMenuId();
String getIncongruousRolesHqlQuery = "select mr FROM SbiMenuRole mr, SbiMenu m where mr.id.menuId = m.menuId and m.parentId = :MENU_ID " + " and mr.id.extRoleId not in (select id.extRoleId from SbiMenuRole where id.menuId = :MENU_ID)";
Query getIncongruousRolesQuery = aSession.createQuery(getIncongruousRolesHqlQuery);
getIncongruousRolesQuery.setParameter("MENU_ID", menuId);
List incongruousRoles = getIncongruousRolesQuery.list();
if (incongruousRoles != null && !incongruousRoles.isEmpty()) {
Iterator it = incongruousRoles.iterator();
while (it.hasNext()) {
SbiMenuRole role = (SbiMenuRole) it.next();
aSession.delete(role);
}
}
// recursion on children
String getChildrenMenuNodesHqlQuery = " from SbiMenu s where s.id.parentId = ?";
Query getChildrenMenuNodesQuery = aSession.createQuery(getChildrenMenuNodesHqlQuery);
getChildrenMenuNodesQuery.setInteger(0, menuId.intValue());
List childrenMenuNodes = getChildrenMenuNodesQuery.list();
if (childrenMenuNodes != null && !childrenMenuNodes.isEmpty()) {
Iterator it = childrenMenuNodes.iterator();
while (it.hasNext()) {
SbiMenu menu = (SbiMenu) it.next();
deleteIncongruousRoles(aSession, menu);
}
}
}
17
Source : SbiMetaTableDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public SbiMetaTable loadTableByNameAndSource(Session session, String name, Integer sourceId) 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();
String hql = " from SbiMetaTable c where c.name = ? and c.sbiMetaSource.sourceId = ? ";
Query aQuery = tmpSession.createQuery(hql);
aQuery.setString(0, name);
aQuery.setInteger(1, sourceId);
toReturn = (SbiMetaTable) aQuery.uniqueResult();
} catch (HibernateException he) {
logException(he);
throw new HibernateException(he);
} finally {
logger.debug("OUT");
}
return toReturn;
}
17
Source : ParameterUseDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public void eraseParameterUseDetAndCkSameSession(Integer parUseId, Session sessionCurrDB) throws EMFUserError {
logger.debug("IN");
// SbiParuse hibParuse = (SbiParuse)sessionCurrDB.load(SbiParuseCk.clreplaced, parUseId);
String qCk = "from SbiParuseCk ck where ck.id.sbiParuse.useId = ?";
Query hqlQueryCk = sessionCurrDB.createQuery(qCk);
hqlQueryCk.setInteger(0, parUseId);
String qDet = "from SbiParuseDet det where det.id.sbiParuse.useId = ?";
Query hqlQueryDet = sessionCurrDB.createQuery(qDet);
hqlQueryDet.setInteger(0, parUseId);
try {
logger.debug("delete ParUSeDet for paruse ");
List hibDet = hqlQueryDet.list();
for (Iterator iterator = hibDet.iterator(); iterator.hasNext(); ) {
SbiParuseDet hibParuseDet = (SbiParuseDet) iterator.next();
sessionCurrDB.delete(hibParuseDet);
}
logger.debug("delete ParUSeCk for paruse ");
List hibCk = hqlQueryCk.list();
for (Iterator iterator = hibCk.iterator(); iterator.hasNext(); ) {
SbiParuseCk hibParuseCk = (SbiParuseCk) iterator.next();
sessionCurrDB.delete(hibParuseCk);
}
} catch (HibernateException he) {
logException(he);
logger.error("Error in deleting checks and dets replacedociated to SbiParuse with id " + parUseId, he);
throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
} finally {
}
logger.debug("OUT");
}
17
Source : ObjParuseDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
public void eraseObjParuse(ObjParuse aObjParuse, Session aSession) {
// get the existing object
/*
* String hql = "from SbiObjParuse s where s.id.sbiObjPar.objParId = " + aObjParuse.getObjParId() + " and s.id.sbiParuse.useId = " +
* aObjParuse.getUseModeId() + " and s.id.sbiObjParFather.objParId = " + aObjParuse.getParFatherId() + " and s.id.filterOperation = '" +
* aObjParuse.getFilterOperation() + "'";
*/
String hql = "from SbiObjParuse s where s.id = ? ";
Query hqlQuery = aSession.createQuery(hql);
hqlQuery.setInteger(0, aObjParuse.getId().intValue());
SbiObjParuse sbiObjParuse = (SbiObjParuse) hqlQuery.uniqueResult();
if (sbiObjParuse == null) {
SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClreplaced().getName(), "eraseObjParuse", "the ObjParuse relevant to BIObjectParameter with " + "id=" + aObjParuse.getParId() + " and ParameterUse with " + "id=" + aObjParuse.getUseModeId() + " does not exist.");
}
aSession.delete(sbiObjParuse);
}
17
Source : ObjParuseDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public void eraseObjParuseIfExists(ObjParuse aObjParuse, Session aSession) throws HibernateException {
// get the existing object
/*
* String hql = "from SbiObjParuse s where s.id.sbiObjPar.objParId = " + aObjParuse.getObjParId() + " and s.id.sbiParuse.useId = " +
* aObjParuse.getUseModeId() + " and s.id.sbiObjParFather.objParId = " + aObjParuse.getParFatherId() + " and s.id.filterOperation = '" +
* aObjParuse.getFilterOperation() + "'";
*/
String hql = "from SbiObjParuse s where s.id = ? ";
Query hqlQuery = aSession.createQuery(hql);
hqlQuery.setInteger(0, aObjParuse.getId().intValue());
SbiObjParuse sbiObjParuse = (SbiObjParuse) hqlQuery.uniqueResult();
if (sbiObjParuse == null) {
} else {
aSession.delete(sbiObjParuse);
}
}
17
Source : HibernateUserDAO.java
with Apache License 2.0
from isstac
with Apache License 2.0
from isstac
/**
* @see org.openmrs.api.UserService#hasDuplicateUsername(org.openmrs.User)
*/
@Override
public boolean hasDuplicateUsername(String username, String systemId, Integer userId) {
if (username == null || username.length() == 0) {
username = "-";
}
if (systemId == null || systemId.length() == 0) {
systemId = "-";
}
if (userId == null) {
userId = -1;
}
String usernameWithCheckDigit = username;
try {
// Hardcoding in Luhn since past user IDs used this validator.
usernameWithCheckDigit = new LuhnIdentifierValidator().getValidIdentifier(username);
} catch (Exception e) {
}
Query query = sessionFactory.getCurrentSession().createQuery("select count(*) from User u where (u.username = :uname1 or u.systemId = :uname2 or u.username = :sysid1 or u.systemId = :sysid2 or u.systemId = :uname3) and u.userId <> :uid");
query.setString("uname1", username);
query.setString("uname2", username);
query.setString("sysid1", systemId);
query.setString("sysid2", systemId);
query.setString("uname3", usernameWithCheckDigit);
query.setInteger("uid", userId);
Long count = (Long) query.uniqueResult();
log.debug("# users found: " + count);
return (count != null && count != 0);
}
17
Source : HibernatePatientDAO.java
with Apache License 2.0
from isstac
with Apache License 2.0
from isstac
/**
* This method uses a SQL query and does not load anything into the hibernate session. It exists
* because of ticket #1375.
*
* @see org.openmrs.api.db.PatientDAO#isIdentifierInUseByAnotherPatient(org.openmrs.PatientIdentifier)
*/
@Override
public boolean isIdentifierInUseByAnotherPatient(PatientIdentifier patientIdentifier) {
boolean checkPatient = patientIdentifier.getPatient() != null && patientIdentifier.getPatient().getPatientId() != null;
boolean checkLocation = patientIdentifier.getLocation() != null && patientIdentifier.getIdentifierType().getUniquenessBehavior() == UniquenessBehavior.LOCATION;
// switched this to an hql query so the hibernate cache can be considered as well as the database
String hql = "select count(*) from PatientIdentifier pi, Patient p where pi.patient.patientId = p.patient.patientId " + "and p.voided = false and pi.voided = false and pi.identifier = :identifier and pi.identifierType = :idType";
if (checkPatient) {
hql += " and p.patientId != :ptId";
}
if (checkLocation) {
hql += " and pi.location = :locationId";
}
Query query = sessionFactory.getCurrentSession().createQuery(hql);
query.setString("identifier", patientIdentifier.getIdentifier());
query.setInteger("idType", patientIdentifier.getIdentifierType().getPatientIdentifierTypeId());
if (checkPatient) {
query.setInteger("ptId", patientIdentifier.getPatient().getPatientId());
}
if (checkLocation) {
query.setInteger("locationId", patientIdentifier.getLocation().getLocationId());
}
return !"0".equals(query.uniqueResult().toString());
}
17
Source : HibernateDiagnosisDAO.java
with Apache License 2.0
from isstac
with Apache License 2.0
from isstac
/**
* Gets primary diagnoses for a given encounter
*
* @param encounter the specific encounter to get the primary diagnoses for.
* @return list of primary diagnoses for an encounter
*/
@Override
public List<Diagnosis> getPrimaryDiagnoses(Encounter encounter) {
Query query = sessionFactory.getCurrentSession().createQuery("from Diagnosis d where d.encounter.encounterId = :encounterId and d.rank = :rankId order by dateCreated desc");
query.setInteger("encounterId", encounter.getId());
query.setInteger("rankId", PRIMARY_RANK);
return query.list();
}
17
Source : HibernateDiagnosisDAO.java
with Apache License 2.0
from isstac
with Apache License 2.0
from isstac
/**
* Gets all diagnoses for a given encounter
*
* @param encounter the specific encounter to get the diagnoses for.
* @return list of diagnoses for an encounter
*/
@Override
public List<Diagnosis> getDiagnoses(Encounter encounter) {
Query query = sessionFactory.getCurrentSession().createQuery("from Diagnosis d where d.encounter.encounterId = :encounterId order by dateCreated desc");
query.setInteger("encounterId", encounter.getId());
return query.list();
}
17
Source : HibernateConditionDAO.java
with Apache License 2.0
from isstac
with Apache License 2.0
from isstac
/**
* Gets all conditions related to the specified patient.
*
* @param patient the patient whose condition history is being queried.
* @return all active and non active conditions related to the specified patient.
*/
@Override
public List<Condition> getConditionHistory(Patient patient) {
Query query = sessionFactory.getCurrentSession().createQuery("from Condition con where con.patient.patientId = :patientId and con.voided = false " + "order by con.onsetDate desc");
query.setInteger("patientId", patient.getId());
return query.list();
}
17
Source : HibernateConditionDAO.java
with Apache License 2.0
from isstac
with Apache License 2.0
from isstac
/**
* Gets all active conditions related to the specified patient.
*
* @param patient the patient whose active conditions are being queried.
* @return all active conditions replacedociated with the specified patient.
*/
@Override
public List<Condition> getActiveConditions(Patient patient) {
Query query = sessionFactory.getCurrentSession().createQuery("from Condition c where c.patient.patientId = :patientId and c.voided = false and c.endDate is null order " + "by c.onsetDate desc");
query.setInteger("patientId", patient.getId());
return query.list();
}
17
Source : ExportService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
@Transactional
public void setNotified(int id) {
Session session = sessionFactory.getCurrentSession();
try {
Query query = session.createQuery("UPDATE Export e SET e.notified = true WHERE e.id = :id");
query.setInteger("id", id);
query.executeUpdate();
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
}
}
17
Source : ExportService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
/**
* Check if user waits for some exports to finished
* @param userID id of user
* @return
* true if user has pending exports, false otherwise
*/
@Transactional(readOnly = true)
public boolean hasPendingExports(int userID) {
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery("SELECT count(*) FROM Export e WHERE e.userId = :userId and e.state = :state and e.notified is false");
query.setInteger("userId", userID);
query.setParameter("state", ExportState.Finished);
long count = (Long) query.uniqueResult();
return count > 0;
}
17
Source : ExportService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
@Transactional(readOnly = false)
public void deleteSurveyExports(int surveyId) throws IOException {
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery("SELECT e.id, e.format FROM Export e WHERE e.survey.id = :id");
query.setInteger("id", surveyId);
@SuppressWarnings("unchecked")
List<Object[]> data = query.list();
for (Object[] export : data) {
java.io.File f = new java.io.File(getTempExportFilePath(ConversionTools.getValue(export[0]), (ExportFormat) export[1]));
Files.deleteIfExists(f.toPath());
}
query = session.createQuery("DELETE FROM Export e WHERE e.survey.id = :id");
query.setInteger("id", surveyId);
query.executeUpdate();
}
17
Source : ExportService.java
with European Union Public License 1.1
from EUSurvey
with European Union Public License 1.1
from EUSurvey
@Transactional(readOnly = false)
public void deleteExport(Export export) {
try {
String filePath = getTempExportFilePath(export, null);
File file = new File(filePath);
Files.delete(file.toPath());
file = new File(filePath + ".zip");
Files.deleteIfExists(file.toPath());
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery("delete Export e where e.id = :id");
query.setInteger("id", export.getId());
int rowCount = query.executeUpdate();
if (rowCount < 1)
logger.error("Deletion of export " + export.getId() + " not possible!");
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
}
}
16
Source : ClickDaoImpl.java
with MIT License
from zhangjikai
with MIT License
from zhangjikai
@Override
public List<String> getRecommends(int userId) {
String sql = "select b.dynasty from Click c, Book b where c.book.bookID = b.bookID and c.user.id=:userId group by b.dynasty having" + " count(c.book.bookID) >= all (select count(c1.book.bookID) from Click c1, Book b1 where c1.book.bookID = b1.bookID and c1.user.id=:userId1 group by b1.dynasty)";
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery(sql);
query.setInteger("userId", userId);
query.setInteger("userId1", userId);
List<String> lists = query.list();
return lists;
}
16
Source : RegionMessageDaoImpl.java
with Apache License 2.0
from tmobile
with Apache License 2.0
from tmobile
/**
* Gets the list of messages related to a component for a particular date
*/
@Override
public List<Messages> getCompRegionMessage(final String environmentName, final String componentId, final String regionName, final String histDateString) {
if (componentId == null || environmentName == null || regionName == null || histDateString == null) {
throw new IllegalArgumentException("Request Method parameter cannot be null");
}
Calendar histDate = Calendar.getInstance();
try {
histDate.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(histDateString));
histDate.setTimeZone(TimeZone.getTimeZone("GMT"));
} catch (ParseException e) {
throw new IllegalArgumentException("History Date must be of yyyy-MM-dd format");
}
int regionId = getRegionId(regionName);
int environmentId = environmentDao.getEnironmentIdFromName(environmentName);
Long compId = Long.parseLong(componentId);
Set<Integer> childCompIdList = getAllChildWithStatusChange(compId.intValue(), regionId, environmentId, histDate);
childCompIdList.add(compId.intValue());
List<Messages> msgList = new ArrayList<Messages>();
// Getting messages till 11:59:59 pm of this day.
histDate.add(Calendar.SECOND, ((24 * 60 * 60) - 1));
Session session = sessionFactory.openSession();
Query query = session.createQuery(HQLConstants.QUERY_COMP_FAILURE_LOG_HIS);
for (Integer childCompId : childCompIdList) {
query.setInteger("envId", environmentId).setInteger("regId", regionId).setInteger("compId", childCompId).setString("hisDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(histDate.getTime()));
@SuppressWarnings("unchecked")
List<Messages> resultList = makeMessage(query.list());
List<Messages> messageList = new ArrayList<Messages>();
Messages previousDateMessage = null;
for (Messages resultMsg : resultList) {
if (resultMsg.getMessageDate().startsWith(histDateString)) {
messageList.add(resultMsg);
} else if (previousDateMessage == null) {
previousDateMessage = resultMsg;
}
}
if (messageList.size() > 0) {
msgList.addAll(messageList);
} else if (previousDateMessage != null) {
msgList.add(previousDateMessage);
}
}
query = session.createQuery(HQLConstants.QUERY_COMP_MESSAGE_HIS);
query.setInteger("envId", environmentId).setInteger("regId", regionId).setParameterList("compIds", childCompIdList).setCalendarDate("hisDate", histDate);
@SuppressWarnings("unchecked")
List<Object[]> resultList = query.list();
msgList.addAll(makeMessage(resultList));
session.close();
return msgList;
}
16
Source : RegionMessageDaoImpl.java
with Apache License 2.0
from tmobile
with Apache License 2.0
from tmobile
/**
* Get the Component message for the componentId for the given environmentName and regionName
*/
public List<Messages> getCompRegionMessage(String environmentName, String componentId, String regionName) {
if (componentId == null || environmentName == null || regionName == null) {
throw new IllegalArgumentException("Request Method parameter cannot be null");
}
int regionId = getRegionId(regionName);
int environmentId = environmentDao.getEnironmentIdFromName(environmentName);
Long compId = Long.parseLong(componentId);
Set<Integer> childCompIdList = getAllChildWithStatusChange(compId.intValue(), regionId, environmentId, null);
childCompIdList.add(compId.intValue());
List<Messages> msgList = new ArrayList<Messages>();
Session session = sessionFactory.openSession();
Query query = session.createQuery(HQLConstants.QUERY_COMP_FAILURE_LOG);
Date previousDay = getPreviousDayDate();
for (Integer childCompId : childCompIdList) {
query.setInteger("envId", environmentId).setInteger("regId", regionId).setInteger("compId", childCompId).setDate("prevoiusDay", previousDay);
@SuppressWarnings("unchecked")
List<Object[]> resultList = query.list();
msgList.addAll(makeMessage(resultList));
}
query = session.createQuery(HQLConstants.QUERY_COMP_MESSAGE);
query.setInteger("envId", environmentId).setInteger("regId", regionId).setParameterList("compIds", childCompIdList).setDate("prevoiusDay", previousDay);
@SuppressWarnings("unchecked")
List<Object[]> resultList = query.list();
msgList.addAll(makeMessage(resultList));
session.close();
return msgList;
}
16
Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* Move down the current folder
*
* @param menuID
* @throws EMFUserError
*/
@Override
public void moveDownMenu(Integer menuID) throws EMFUserError {
Session tmpSession = null;
Transaction tx = null;
try {
tmpSession = getSession();
tx = tmpSession.beginTransaction();
SbiMenu hibMenu = (SbiMenu) tmpSession.load(SbiMenu.clreplaced, menuID);
Integer oldProg = hibMenu.getProg();
Integer newProg = new Integer(oldProg.intValue() + 1);
String upperMenuHql = "";
Query query = null;
if (hibMenu.getParentId() == null || hibMenu.getParentId().intValue() == 0) {
// upperMenuHql = "from SbiMenu s where s.prog = " +
// newProg.toString() +
// " and s.parentId is null ";
upperMenuHql = "from SbiMenu s where s.prog = ? " + " and (s.parentId is null or s.parentId = 0)";
query = tmpSession.createQuery(upperMenuHql);
query.setInteger(0, newProg.intValue());
} else {
// upperMenuHql = "from SbiMenu s where s.prog = " +
// newProg.toString() +
// " and s.parentId = " + hibMenu.getParentId().toString();
upperMenuHql = "from SbiMenu s where s.prog = ? " + " and s.parentId = ? ";
query = tmpSession.createQuery(upperMenuHql);
query.setInteger(0, newProg.intValue());
query.setInteger(1, hibMenu.getParentId().intValue());
}
// Query query = tmpSession.createQuery(upperMenuHql);
SbiMenu hibUpperMenu = (SbiMenu) query.uniqueResult();
if (hibUpperMenu == null) {
logger.error("The menu with prog [" + newProg + "] does not exist.");
return;
}
hibMenu.setProg(newProg);
hibUpperMenu.setProg(oldProg);
updateSbiCommonInfo4Update(hibMenu);
updateSbiCommonInfo4Update(hibUpperMenu);
tx.commit();
} catch (HibernateException he) {
if (tx != null)
tx.rollback();
throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
} finally {
if (tmpSession != null) {
if (tmpSession.isOpen())
tmpSession.close();
}
}
}
16
Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* Move up the current folder
*
* @param menuID
* @throws EMFUserError
*/
@Override
public void moveUpMenu(Integer menuID) throws EMFUserError {
Session tmpSession = null;
Transaction tx = null;
try {
tmpSession = getSession();
tx = tmpSession.beginTransaction();
SbiMenu hibMenu = (SbiMenu) tmpSession.load(SbiMenu.clreplaced, menuID);
Integer oldProg = hibMenu.getProg();
Integer newProg = new Integer(oldProg.intValue() - 1);
String upperMenuHql = "";
Query query = null;
if (hibMenu.getParentId() == null || hibMenu.getParentId().intValue() == 0) {
// upperMenuHql = "from SbiMenu s where s.prog = " +
// newProg.toString() +
// " and s.parentId is null ";
upperMenuHql = "from SbiMenu s where s.prog = ? " + " and (s.parentId is null or s.parentId = 0)";
query = tmpSession.createQuery(upperMenuHql);
query.setInteger(0, newProg.intValue());
} else {
// upperMenuHql = "from SbiMenu s where s.prog = " +
// newProg.toString() +
// " and s.parentId = " + hibMenu.getParentId().toString();
upperMenuHql = "from SbiMenu s where s.prog = ? " + " and s.parentId = ? ";
query = tmpSession.createQuery(upperMenuHql);
query.setInteger(0, newProg.intValue());
query.setInteger(1, hibMenu.getParentId().intValue());
}
SbiMenu hibUpperMenu = (SbiMenu) query.uniqueResult();
if (hibUpperMenu == null) {
logger.error("The menu with prog [" + newProg + "] does not exist.");
return;
}
hibMenu.setProg(newProg);
hibUpperMenu.setProg(oldProg);
updateSbiCommonInfo4Update(hibMenu);
updateSbiCommonInfo4Update(hibUpperMenu);
tx.commit();
} catch (HibernateException he) {
if (tx != null)
tx.rollback();
throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
} catch (Exception e) {
logger.error("Error: " + e.getMessage());
throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
} finally {
if (tmpSession != null) {
if (tmpSession.isOpen())
tmpSession.close();
}
}
}
16
Source : MenuDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* Checks for roles replacedociated.
*
* @param menuId the menu id
*
* @return true, if checks for roles replacedociated
*
* @throws EMFUserError the EMF user error
*
* @see it.eng.spagobi.wapp.dao.IMenuDAO#hasRolesreplacedociated(java.lang.Integer)
*/
@Override
public boolean hasRolesreplacedociated(Integer menuId) throws EMFUserError {
boolean bool = false;
Session tmpSession = null;
Transaction tx = null;
try {
tmpSession = getSession();
tx = tmpSession.beginTransaction();
// String hql = " from SbiMenuRole s where s.id.menuId = "+ menuId;
String hql = " from SbiMenuRole s where s.id.menuId = ? ";
Query aQuery = tmpSession.createQuery(hql);
aQuery.setInteger(0, menuId.intValue());
List biFeaturesreplacedocitedWithMap = aQuery.list();
if (biFeaturesreplacedocitedWithMap.size() > 0)
bool = true;
else
bool = false;
// 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 bool;
}
16
Source : ObjMetadataDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* Checks for bi subobject replacedociated.
*
* @param id the metadata id
*
* @return true, if checks for bi subobjects replacedociated
*
* @throws EMFUserError the EMF user error
*
* @see it.eng.spagobi.tools.objmetadata.dao.IObjMetadataDAO#hreplacedubObjreplacedociated(java.lang.String)
*/
@Override
public boolean hreplacedubObjreplacedociated(String id) throws EMFUserError {
logger.debug("IN");
boolean bool = false;
Session aSession = null;
Transaction tx = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
Integer idInt = Integer.valueOf(id);
String hql = " from SbiObjMetacontents c where c.objmetaId = ? and c.sbiSubObjects is not null";
Query aQuery = aSession.createQuery(hql);
aQuery.setInteger(0, idInt.intValue());
List biObjectsreplacedocitedWithSubobj = aQuery.list();
if (biObjectsreplacedocitedWithSubobj.size() > 0)
bool = true;
else
bool = false;
tx.commit();
} catch (HibernateException he) {
logger.error("Error while getting the engines replacedociated with the data source with id " + id, 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 bool;
}
16
Source : ObjMetadataDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* Checks for bi obj replacedociated.
*
* @param id the metadata id
*
* @return true, if checks for bi obj replacedociated
*
* @throws EMFUserError the EMF user error
*
* @see it.eng.spagobi.tools.objmetadata.dao.IObjMetadataDAO#hasBIObjreplacedociated(java.lang.String)
*/
@Override
public boolean hasBIObjreplacedociated(String id) throws EMFUserError {
logger.debug("IN");
boolean bool = false;
Session aSession = null;
Transaction tx = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
Integer idInt = Integer.valueOf(id);
String hql = " from SbiObjMetacontents c where c.objmetaId = ? and c.sbiObjects is not null";
Query aQuery = aSession.createQuery(hql);
aQuery.setInteger(0, idInt.intValue());
List biObjectsreplacedocitedWithObj = aQuery.list();
if (biObjectsreplacedocitedWithObj.size() > 0)
bool = true;
else
bool = false;
tx.commit();
} catch (HibernateException he) {
logger.error("Error while getting the objects replacedociated with the metadata with id " + id, 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 bool;
}
16
Source : ObjMetacontentDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* Load object's metadata by objMetaId, biObjId and subobjId.
*
* @param objMetaId
* the objMetaId
* @param biObjId
* the biObjId
* @param subObjId
* the subObjId
*
* @return A list containing all metadata contents objects of a specific subObjId
*
* @throws EMFUserError
* the EMF user error
*
* @see it.eng.spagobi.tools.objmetadata.dao.IObjMetacontentDAO#loadObjMetacontentByObjId(java.lang.Integer, java.lang.Integer)
*/
@Override
public ObjMetacontent loadObjMetacontent(Integer objMetaId, Integer biObjId, Integer subObjId) throws EMFUserError {
logger.debug("IN");
ObjMetacontent realResult = null;
Session session = null;
Transaction tx = null;
try {
session = getSession();
tx = session.beginTransaction();
String hql = " from SbiObjMetacontents c where c.objmetaId = ? and c.sbiObjects.biobjId = ? ";
if (subObjId != null) {
hql += "and c.sbiSubObjects.subObjId = ? ";
} else {
hql += "and c.sbiSubObjects.subObjId IS NULL ";
}
Query aQuery = session.createQuery(hql);
aQuery.setInteger(0, objMetaId.intValue());
aQuery.setInteger(1, biObjId.intValue());
if (subObjId != null) {
aQuery.setInteger(2, subObjId.intValue());
}
SbiObjMetacontents res = (SbiObjMetacontents) aQuery.uniqueResult();
if (res != null) {
realResult = toObjMetacontent(res);
}
tx.rollback();
} catch (HibernateException he) {
logger.error("Error while loading the metadata content with metadata id = " + objMetaId + ", biobject id = " + biObjId + ", subobject id = " + subObjId, he);
if (tx != null)
tx.rollback();
throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
} finally {
if (session != null) {
if (session.isOpen())
session.close();
}
}
logger.debug("OUT");
return realResult;
}
16
Source : SbiNewsDAOImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
public SbiNews getSbiNewsById(Integer id, UserProfile profile) {
logger.debug("IN");
SbiNews sbiNews = null;
Session session = null;
Transaction transaction = null;
try {
session = getSession();
transaction = session.beginTransaction();
String hql = "from SbiNews s WHERE s.id = :id";
Query query = session.createQuery(hql);
query.setInteger("id", id);
sbiNews = (SbiNews) query.uniqueResult();
transaction.commit();
} catch (HibernateException e) {
logException(e);
if (transaction != null)
transaction.rollback();
throw new SpagoBIRuntimeException("Cannot get news with id " + id, e);
} finally {
if (session != null && session.isOpen())
session.close();
}
if (UserUtilities.isTechnicalUser(profile) || getAvailableNews(sbiNews, profile) != null) {
logger.debug("OUT");
return sbiNews;
} else {
throw new SpagoBIRuntimeException("You are not allowed to get this news");
}
}
16
Source : DistributionListDaoImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/*
* (non-Javadoc)
*
* @see it.eng.spagobi.tools.distributionlist.dao.IDistributionListDAO#hasBIObjreplacedociated(java.lang.String)
*/
@Override
public boolean hasBIObjreplacedociated(String dlId) throws EMFUserError {
logger.debug("IN");
boolean bool = false;
Session aSession = null;
Transaction tx = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
Integer dlIdInt = Integer.valueOf(dlId);
// String hql = " from SbiObjects s where s.distributionList.dlId = "+ dlIdInt;
String hql = " from SbiObjects s where s.distributionList.dlId = ?";
Query aQuery = aSession.createQuery(hql);
aQuery.setInteger(0, dlIdInt.intValue());
List biObjectsreplacedocitedWithDl = aQuery.list();
if (biObjectsreplacedocitedWithDl.size() > 0)
bool = true;
else
bool = false;
tx.commit();
} catch (HibernateException he) {
logger.error("Error while getting the objects replacedociated with the distribution list with id " + dlId, 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 bool;
}
16
Source : DistributionListDaoImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/*
* (non-Javadoc)
*
* @see
* it.eng.spagobi.tools.distributionlist.dao.IDistributionListDAO#isDocScheduleAlreadyLinkedToDL(it.eng.spagobi.tools.distributionlist.bo.DistributionList,
* int, java.lang.String)
*/
@Override
public boolean isDocScheduleAlreadyLinkedToDL(DistributionList dl, int objId, String xml) throws EMFUserError {
logger.debug("IN");
Session tmpSession = null;
Transaction tx = null;
try {
tmpSession = getSession();
tx = tmpSession.beginTransaction();
// String hql = "from SbiDistributionListsObjects sdlo where sdlo.sbiDistributionList.dlId=" +
// dl.getId()+" and sdlo.sbiObjects.biobjId="+objId+" and sdlo.xml='"+xml+"'" ;
String hql = "from SbiDistributionListsObjects sdlo where sdlo.sbiDistributionList.dlId=? and sdlo.sbiObjects.biobjId=? and sdlo.xml=?";
Query query = tmpSession.createQuery(hql);
query.setInteger(0, dl.getId());
query.setInteger(1, objId);
query.setString(2, xml);
SbiDistributionListsObjects hibDL = (SbiDistributionListsObjects) query.uniqueResult();
if (hibDL == null)
return false;
tx.commit();
} catch (HibernateException he) {
logger.error("Error while loading the distribution list doreplacedents ", he);
if (tx != null)
tx.rollback();
throw new EMFUserError(EMFErrorSeverity.ERROR, 9106);
} finally {
if (tmpSession != null) {
if (tmpSession.isOpen())
tmpSession.close();
}
}
logger.debug("OUT");
return true;
}
16
Source : DataSourceDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* Checks for bi obj replacedociated.
*
* @param dsId
* the ds id
* @return true, if checks for bi obj replacedociated
* @throws EMFUserError
* the EMF user error
* @see it.eng.spagobi.tools.datasource.dao.IDataSourceDAO#hasBIObjreplacedociated(java.lang.String)
*/
@Override
public boolean hasBIObjreplacedociated(String dsId) throws EMFUserError {
logger.debug("IN");
boolean bool = false;
Session aSession = null;
Transaction tx = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
Integer dsIdInt = Integer.valueOf(dsId);
// String hql = " from SbiObjects s where s.dataSource.dsId = "+
// dsIdInt;
String hql = " from SbiObjects s where s.dataSource.dsId = ?";
Query aQuery = aSession.createQuery(hql);
aQuery.setInteger(0, dsIdInt.intValue());
List biObjectsreplacedocitedWithDs = aQuery.list();
if (biObjectsreplacedocitedWithDs.size() > 0)
bool = true;
else
bool = false;
tx.commit();
} catch (HibernateException he) {
logger.error("Error while getting the objects replacedociated with the data source with id " + dsId, 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 bool;
}
16
Source : SbiUserDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public ArrayList<SbiExtRoles> loadSbiUserRolesById(Integer id) {
logger.debug("IN");
Session aSession = null;
Transaction tx = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
String q = "select us.sbiExtUserRoleses from SbiUser us where us.id = :id";
Query query = aSession.createQuery(q);
query.setInteger("id", id);
ArrayList<SbiExtRoles> result = (ArrayList<SbiExtRoles>) query.list();
return result;
} catch (HibernateException he) {
if (tx != null)
tx.rollback();
throw new SpagoBIDAOException("Error while loading user role with id " + id, he);
} finally {
logger.debug("OUT");
if (aSession != null) {
if (aSession.isOpen())
aSession.close();
}
}
}
16
Source : SbiUserDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public ArrayList<SbiUserAttributes> loadSbiUserAttributesById(Integer id) {
logger.debug("IN");
Session aSession = null;
Transaction tx = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
String q = "select us.sbiUserAttributeses from SbiUser us where us.id = :id";
Query query = aSession.createQuery(q);
query.setInteger("id", id);
ArrayList<SbiUserAttributes> result = (ArrayList<SbiUserAttributes>) query.list();
Hibernate.initialize(result);
for (SbiUserAttributes current : result) {
Hibernate.initialize(current.getSbiAttribute());
}
return result;
} catch (HibernateException he) {
if (tx != null)
tx.rollback();
throw new SpagoBIDAOException("Error while loading user attribute with id " + id, he);
} finally {
logger.debug("OUT");
if (aSession != null) {
if (aSession.isOpen())
aSession.close();
}
}
}
16
Source : SbiObjDsDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public List<SbiMetaObjDs> loadDsByObjId(Integer objId) throws EMFUserError {
logger.debug("IN");
Session aSession = null;
Transaction tx = null;
List<SbiMetaObjDs> toReturn = new ArrayList();
Query hqlQuery = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
hqlQuery = aSession.createQuery(" from SbiMetaObjDs as db where db.id.objId = ? ");
hqlQuery.setInteger(0, objId);
toReturn = hqlQuery.list();
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();
}
}
logger.debug("OUT");
return toReturn;
}
16
Source : SbiObjDsDAOHibImpl.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
@Override
public List<SbiMetaObjDs> loadObjByDsId(Integer dsId) throws EMFUserError {
logger.debug("IN");
Session aSession = null;
Transaction tx = null;
List<SbiMetaObjDs> toReturn = new ArrayList();
Query hqlQuery = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
hqlQuery = aSession.createQuery(" from SbiMetaObjDs as db where db.id.dsId = ? ");
hqlQuery.setInteger(0, dsId);
toReturn = hqlQuery.list();
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();
}
}
logger.debug("OUT");
return toReturn;
}
See More Examples