List of usage examples for com.liferay.portal.kernel.dao.orm SQLQuery setInteger
public Query setInteger(int pos, int value);
From source file:com.vportal.portlet.vdoc.service.persistence.vdocDocumentFinderImpl.java
License:Open Source License
public List findDocumentByParams(long groupId, String language, String fieldId, String orgId, String title, int status) throws SystemException { Session session = null;// w ww. ja v a 2 s . c om try { session = openSession(); String sql = "SELECT vdocDocument.* FROM vdocDocument"; StringBuffer query = new StringBuffer(); query.append(sql); if (!orgId.equals("0")) { query.append(" INNER JOIN vdocDORel "); query.append(" ON (vdocDocument.docId = vdocDORel.docId)"); } query.append(" WHERE "); if (Validator.isNull(String.valueOf(groupId))) { return null; } else { query.append("(vdocDocument.groupId = ?) "); } if (Validator.isNull(language)) { return null; } else { query.append("AND "); query.append("(vdocDocument.language = ?) "); } if (Validator.isNotNull(fieldId) && !Validator.equals(fieldId, "0")) { query.append(" AND "); query.append("(vdocDocument.fieldId = ?) "); } if (Validator.isNotNull(orgId) && !Validator.equals(orgId, "0")) { query.append(" AND "); query.append("(vdocDORel.orgId = ?) "); } if (Validator.isNotNull(title)) { query.append(" AND "); query.append("(LOWER(vdocDocument.title) LIKE LOWER(?)) "); } if (status == 2 || status == 1 || status == 0) { query.append("AND "); query.append("(vdocDocument.statusDoc = ?) "); } if (status == 2) { query.append("ORDER BY "); query.append("vdocDocument.publishedDate DESC"); } else if (status == 1) { query.append("ORDER BY "); query.append("vdocDocument.approvedDate DESC"); } else if (status == 0) { query.append("ORDER BY "); query.append("vdocDocument.createdDate DESC"); } SQLQuery q = session.createSQLQuery(query.toString()); q.addEntity("vdocDocument", vdocDocumentImpl.class); int queryPos = 0; q.setLong(queryPos++, groupId); q.setString(queryPos++, language); if (Validator.isNotNull(fieldId) && !Validator.equals(fieldId, "0")) q.setString(queryPos++, fieldId); if (Validator.isNotNull(orgId) && !Validator.equals(orgId, "0")) { q.setString(queryPos++, orgId); } if (Validator.isNotNull(title)) q.setString(queryPos++, "%" + title + "%"); if (status == 2 || status == 1 || status == 0) q.setInteger(queryPos++, status); return q.list(); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.vportal.portlet.vdoc.service.persistence.vdocDocumentFinderImpl.java
License:Open Source License
@SuppressWarnings("unchecked") public List<vdocDocument> findDocumentByParams(long groupId, String language, String fieldId, String orgId, String title, int status, int begin, int end) throws SystemException { Session session = null;//from w w w . j ava 2 s.c o m try { session = openSession(); String sql = "SELECT vdocDocument.* FROM vdocDocument"; StringBuffer query = new StringBuffer(); query.append(sql); if (!orgId.equals("0")) { query.append(" INNER JOIN vdocDORel "); query.append(" ON (vdocDocument.docId = vdocDORel.docId)"); } query.append(" WHERE "); if (Validator.isNull(String.valueOf(groupId))) { return null; } else { query.append("(vdocDocument.groupId = ?) "); } if (Validator.isNull(language)) { return null; } else { query.append("AND "); query.append("(vdocDocument.language = ?) "); } if (Validator.isNotNull(fieldId) && !Validator.equals(fieldId, "0")) { query.append(" AND "); query.append("(vdocDocument.fieldId = ?) "); } if (Validator.isNotNull(orgId) && !Validator.equals(orgId, "0")) { query.append(" AND "); query.append("(vdocDORel.orgId = ?) "); } if (Validator.isNotNull(title)) { query.append(" AND "); query.append("(LOWER(vdocDocument.title) LIKE LOWER(?)) "); } if (status == 2 || status == 1 || status == 0) { query.append("AND "); query.append("(vdocDocument.statusDoc = ?) "); } if (status == 2) { query.append("ORDER BY "); query.append("vdocDocument.publishedDate DESC"); } else if (status == 1) { query.append("ORDER BY "); query.append("vdocDocument.approvedDate DESC"); } else if (status == 0) { query.append("ORDER BY "); query.append("vdocDocument.createdDate DESC"); } SQLQuery q = session.createSQLQuery(query.toString()); q.addEntity("vdocDocument", vdocDocumentImpl.class); int queryPos = 0; q.setLong(queryPos++, groupId); q.setString(queryPos++, language); if (Validator.isNotNull(fieldId) && !Validator.equals(fieldId, "0")) q.setString(queryPos++, fieldId); if (Validator.isNotNull(orgId) && !Validator.equals(orgId, "0")) { q.setString(queryPos++, orgId); } if (Validator.isNotNull(title)) q.setString(queryPos++, "%" + title + "%"); if (status == 2 || status == 1 || status == 0) q.setInteger(queryPos++, status); return (List<vdocDocument>) QueryUtil.list(q, getDialect(), begin, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.vportal.portlet.vdoc.service.persistence.vdocDocumentFinderImpl.java
License:Open Source License
public List findDocsByPublishedDate(long groupId, String language, Date pubDateFrom, Date pubDateTo, int status, int quantity) throws SystemException { Session session = null;/*from w ww . j a va2s .c o m*/ try { session = openSession(); String sql = "SELECT * FROM vdocDocument"; StringBuffer query = new StringBuffer(); query.append(sql); query.append(" WHERE "); if (Validator.isNull(String.valueOf(groupId))) { return null; } else { query.append(" vdocDocument.groupId = ? "); } if (Validator.isNull(language)) { return null; } else { query.append(" AND "); query.append(" vdocDocument.language = ? "); } if (pubDateTo != null) { query.append(" AND "); query.append(" vdocDocument.publishedDate >= ? "); } if (pubDateFrom != null) { query.append(" AND "); query.append("vdocDocument.publishedDate <= ? "); } if (status == 2 || status == 1 || status == 0) { query.append(" AND "); query.append("vdocDocument.statusDoc = ? "); } query.append("ORDER BY "); query.append("vdocDocument.publishedDate DESC"); SQLQuery q = session.createSQLQuery(query.toString()); q.addEntity("vdocDocument", vdocDocumentImpl.class); int queryPos = 0; q.setLong(queryPos++, groupId); q.setString(queryPos++, language); if (pubDateFrom != null) q.setTimestamp(queryPos++, new Timestamp(pubDateFrom.getTime())); if (pubDateTo != null) q.setTimestamp(queryPos++, new Timestamp(pubDateTo.getTime())); if (status == 2 || status == 1 || status == 0) q.setInteger(queryPos++, status); return QueryUtil.list(q, getDialect(), 0, quantity); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.vportal.portlet.vdoc.service.persistence.vdocDocumentFinderImpl.java
License:Open Source License
public List findDocbyModifyDate(long groupId, String language, Date modiDateFrom, Date modiDateTo, int status) throws SystemException { Session session = null;//from ww w .jav a 2 s . c om try { session = openSession(); String sql = "SELECT * FROM vdocDocument"; StringBuffer query = new StringBuffer(); query.append(sql); query.append(" WHERE "); if (Validator.isNull(String.valueOf(groupId))) { return null; } else { query.append(" vdocDocument.groupId = ? "); } if (Validator.isNull(language)) { return null; } else { query.append(" AND "); query.append(" vdocDocument.language = ? "); } if (modiDateTo != null) { query.append(" AND "); query.append(" vdocDocument.modifiedDate >= ? "); } if (modiDateFrom != null) { query.append(" AND "); query.append("vdocDocument.modifiedDate <= ? "); } if (status == 2 || status == 1 || status == 0) { query.append(" AND "); query.append("vdocDocument.statusDoc = ? "); } query.append("ORDER BY "); query.append("vdocDocument.modifiedDate DESC"); SQLQuery q = session.createSQLQuery(query.toString()); q.addEntity("vdocDocument", vdocDocumentImpl.class); int queryPos = 0; q.setLong(queryPos++, groupId); q.setString(queryPos++, language); if (modiDateFrom != null) q.setTimestamp(queryPos++, new Timestamp(modiDateFrom.getTime())); if (modiDateTo != null) q.setTimestamp(queryPos++, new Timestamp(modiDateTo.getTime())); if (status == 2 || status == 1 || status == 0) q.setInteger(queryPos++, status); return q.list(); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.vportal.portlet.vdoc.service.persistence.vdocDocumentFinderImpl.java
License:Open Source License
public List findOtherDoc(long groupId, String language, String Id, int status, int begin, int end) throws SystemException { Session session = null;/*from w w w. jav a2 s .c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_D1); StringBuffer query = new StringBuffer(); query.append(sql); query.append(" WHERE "); query.append("vdocDocument.groupId = ? "); query.append("AND "); query.append("vdocDocument.language = ? "); if (Validator.isNotNull(String.valueOf(Id))) { query.append("AND "); query.append("vdocDocument.docId <> ? "); } if (status == 2 || status == 1 || status == 0) { query.append("AND "); query.append("(vdocDocument.statusDoc = ?) "); } if (status == 2) { query.append("ORDER BY "); query.append("vdocDocument.publishedDate DESC"); } else if (status == 1) { query.append("ORDER BY "); query.append("vdocDocument.approvedDate DESC"); } else if (status == 0) { query.append("ORDER BY "); query.append("vdocDocument.createdDate DESC"); } SQLQuery q = session.createSQLQuery(query.toString()); q.addEntity("vdocDocument", vdocDocumentImpl.class); int queryPos = 0; q.setLong(queryPos++, groupId); q.setString(queryPos++, language); if (Validator.isNotNull(String.valueOf(Id))) { q.setString(queryPos++, Id); } if (status == 2 || status == 1 || status == 0) q.setInteger(queryPos++, status); return QueryUtil.list(q, getDialect(), begin, end); } catch (Exception e) { throw new SystemException(); } finally { closeSession(session); } }
From source file:com.vportal.portlet.vdoc.service.persistence.vdocDocumentFinderImpl.java
License:Open Source License
public int countDoc(long groupId, String language, String Id, int status, int begin, int end) throws SystemException { Session session = null;//from www. j av a 2 s. c om try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_D); StringBuffer query = new StringBuffer(); query.append(sql); SQLQuery q = session.createSQLQuery(sql); q.addScalar("total", Type.LONG); int queryPos = 0; q.setLong(queryPos++, groupId); q.setString(queryPos++, language); if (Validator.isNotNull(Id)) { q.setString(queryPos++, Id); } if (status == 2 || status == 1 || status == 0) q.setInteger(queryPos++, status); Long count = null; Iterator ite = q.list().iterator(); while (ite.hasNext()) { count = (Long) ite.next(); } if (count == null) { count = new Long(0); } return count.intValue(); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:org.oep.cmon.dao.hosohcc.service.persistence.HoSoTTHCCongFinderImpl.java
License:Apache License
/** * This is fucntion findHoSoTTHCCong/* www. j a v a 2 s . c o m*/ * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param String maSoHoSo, int trangThaiHoSo, long cqqlId, int start, int end * @return List<HoSoTTHCCong> */ public List<HoSoTTHCCong> findHoSoTTHCCong(String maSoHoSo, int trangThaiHoSo, long cqqlId, int start, int end) { Session session = null; try { session = openSession(); StringBuffer sqlBuilder = new StringBuffer( "SELECT * FROM CMON_HOSOTTHCCONG WHERE COQUANTIEPNHANID = ? AND TRANGTHAIHOSO = ? "); if (Validator.isNotNull(maSoHoSo)) { sqlBuilder.append(" MASOHOSO lIKE ?"); } sqlBuilder.append(" ORDER BY NGAYSUA DESC NULLS LAST "); SQLQuery q = session.createSQLQuery(sqlBuilder.toString()); q.addEntity("HoSoTTHCCong", HoSoTTHCCongImpl.class); q.setLong(0, cqqlId); q.setInteger(1, trangThaiHoSo); if (Validator.isNotNull(maSoHoSo)) { q.setString(2, "%" + maSoHoSo + "%"); } // execute the query and return a list from the db return (List<HoSoTTHCCong>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { e.printStackTrace(); } finally { // must have this to close the hibernate session.. // if you fail to do this.. you will have a lot of open sessions closeSession(session); } return new ArrayList<HoSoTTHCCong>(); }
From source file:org.oep.cmon.dao.hosohcc.service.persistence.HoSoTTHCCongFinderImpl.java
License:Apache License
/** * This is fucntion countHoSoTTHCCongByCoQuanQuanLy * Version: 1.0//w w w . ja v a 2 s . c om * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param String maSoHoSo, int trangThaiHoSo, long cqqlId * @return long */ public long countHoSoTTHCCongByCoQuanQuanLy(String maSoHoSo, int trangThaiHoSo, long cqqlId) { Session session = null; try { session = openSession(); StringBuffer sqlBuilder = new StringBuffer( "SELECT count(*) FROM CMON_HOSOTTHCCONG WHERE COQUANTIEPNHANID = ? AND TRANGTHAIHOSO = ? "); new ArrayList<String>(); if (Validator.isNotNull(maSoHoSo)) { sqlBuilder.append(" MASOHOSO lIKE ?"); } SQLQuery q = session.createSQLQuery(sqlBuilder.toString()); q.addEntity("HoSoTTHCCong", HoSoTTHCCongImpl.class); q.setLong(0, cqqlId); q.setInteger(1, trangThaiHoSo); if (Validator.isNotNull(maSoHoSo)) { q.setString(2, "%" + maSoHoSo + "%"); } Iterator<Long> itr = q.list().iterator(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } } catch (Exception e) { e.printStackTrace(); } finally { // must have this to close the hibernate session.. // if you fail to do this.. you will have a lot of open sessions closeSession(session); } return 0; }
From source file:org.oep.cmon.dao.hosohcc.service.persistence.HoSoTTHCCongFinderImpl.java
License:Apache License
/** * This is fucntion findByMutilStatusAndTTHC * Version: 1.0//from w w w . j ava 2s. co m * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param String tthcIds, String maSoHoSo, long idCanBo, String maUngDung, long cqqlId, String trangThais, int yeuCauRut, String tuNgay, String denNgay, int start, int end * @return List<HoSoTTHCCong> */ public List<HoSoTTHCCong> findByMutilStatusAndTTHC(String tthcIds, String maSoHoSo, long idCanBo, String maUngDung, long cqqlId, String trangThais, int yeuCauRut, String tuNgay, String denNgay, int start, int end) throws SystemException { Session session = null; try { session = openSession(); String base = "SELECT * FROM CMON_HOSOTTHCCONG A "; StringBuffer sqlBuilder = new StringBuffer(base); List<String> criteria = new ArrayList<String>(); if (Validator.isNotNull(maSoHoSo)) { if (IsNumeral.check(maSoHoSo)) { criteria.add(" (A.MASOHOSO lIKE ? OR A.MASOBIENNHAN LIKE ? )"); } else { criteria.add(" LOWER(REGEXP_REPLACE(TRIM(A.HOTENNGUOINOPHOSO),' +',' '))" + " LIKE" + " '%' || LOWER(REGEXP_REPLACE(TRIM(?),' +',' ')) || '%' "); } } if (tthcIds != null && tthcIds.length() > 0) { criteria.add("A.thutuchanhchinhid IN (" + tthcIds + ") "); } if (idCanBo > 0 && (!"0".equals(trangThais))) { criteria.add("A.CANBOTIEPNHANID = " + idCanBo + " "); } if (Validator.isNotNull(maUngDung)) { criteria.add("A.MAUNGDUNG = ?"); } if (cqqlId > 0) { criteria.add( "A.thutuchanhchinhid in (select B.thutuchanhchinhid from cmon_tthc2coquanquanly B where B.COQUANQUANLYID = ? AND B.COQUANQUANLYID = A.COQUANTIEPNHANID)"); } if (trangThais != null && trangThais.length() > 0) { criteria.add("A.TRANGTHAIHOSO IN (" + trangThais + ") "); } if (Validator.isNotNull(tuNgay) && Validator.isNotNull(denNgay)) { criteria.add("A.NGAYNOPHOSO BETWEEN TO_DATE ('" + tuNgay + "','dd/MM/yyyy') AND TO_DATE('" + denNgay + "','dd/MM/yyyy') "); } criteria.add("A.YEUCAUHUYHOSO = ?"); criteria.add("A.DAXOA = 0"); if (!criteria.isEmpty()) { sqlBuilder.append("WHERE "); sqlBuilder.append(criteria.remove(0) + " "); for (String criterion : criteria) { sqlBuilder.append(" AND " + criterion); } } sqlBuilder.append(" ORDER BY A.NGAYSUA DESC NULLS LAST "); String sql = sqlBuilder.toString(); SQLQuery q = session.createSQLQuery(sql); q.addEntity("HoSoTTHCCong", HoSoTTHCCongImpl.class); int queryPos = 0; if (Validator.isNotNull(maSoHoSo)) { if (IsNumeral.check(maSoHoSo)) { q.setString(queryPos++, "%" + maSoHoSo + "%"); q.setString(queryPos++, "%" + maSoHoSo + "%"); } else { q.setString(queryPos++, "%" + maSoHoSo + "%"); } } if (Validator.isNotNull(maUngDung)) { q.setString(queryPos++, maUngDung); } if (cqqlId > 0) { q.setLong(queryPos++, cqqlId); } q.setInteger(queryPos++, yeuCauRut); return (List<HoSoTTHCCong>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { // must have this to close the hibernate session.. // if you fail to do this.. you will have a lot of open sessions closeSession(session); } }
From source file:org.oep.cmon.dao.hosohcc.service.persistence.HoSoTTHCCongFinderImpl.java
License:Apache License
/** * This is fucntion getDSCongChuc2ThuTuc * Version: 1.0/*www.j ava2 s . c o m*/ * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param String maSoHoSo, String thuTucHanhChinhIds, String maUngDung, long cqqlId, String trangThais, int yeuCauRut, int start, int end * @return List<HoSoTTHCCong> */ public List<HoSoTTHCCong> getDSCongChuc2ThuTuc(String maSoHoSo, String thuTucHanhChinhIds, String maUngDung, long cqqlId, String trangThais, int yeuCauRut, int start, int end) throws SystemException { Session session = null; try { session = openSession(); String base = "SELECT * FROM CMON_HOSOTTHCCONG A"; StringBuffer sqlBuilder = new StringBuffer(base); List<String> criteria = new ArrayList<String>(); if (Validator.isNotNull(maSoHoSo)) { if (IsNumeral.check(maSoHoSo)) { criteria.add(" A.MASOHOSO lIKE ? OR A.MASOBIENNHAN LIKE ? "); } else { criteria.add(" LOWER(REGEXP_REPLACE(TRIM(A.HOTENNGUOINOPHOSO),' +',' '))" + " LIKE" + " '%' || LOWER(REGEXP_REPLACE(TRIM(?),' +',' ')) || '%' "); } } if (thuTucHanhChinhIds != null && thuTucHanhChinhIds.length() > 0) { criteria.add("A.thutuchanhchinhid IN (" + thuTucHanhChinhIds + ") "); } if (Validator.isNotNull(maUngDung)) { criteria.add("A.MAUNGDUNG = ?"); } if (cqqlId > 0) { criteria.add( "A.thutuchanhchinhid in (select B.thutuchanhchinhid from cmon_tthc2coquanquanly B where B.COQUANQUANLYID = ? AND B.COQUANQUANLYID = A.COQUANTIEPNHANID)"); } if (trangThais != null && trangThais.length() > 0) { criteria.add("A.TRANGTHAIHOSO IN (" + trangThais + ") "); } criteria.add("A.YEUCAUHUYHOSO = ?"); criteria.add("A.DAXOA = 0"); if (!criteria.isEmpty()) { sqlBuilder.append("WHERE"); sqlBuilder.append(criteria.remove(0) + " "); for (String criterion : criteria) { sqlBuilder.append(" AND " + criterion); } } sqlBuilder.append(" ORDER BY A.NGAYSUA DESC NULLS LAST "); String sql = sqlBuilder.toString(); SQLQuery q = session.createSQLQuery(sql); q.addEntity("HoSoTTHCCong", HoSoTTHCCongImpl.class); int queryPos = 0; if (Validator.isNotNull(maSoHoSo)) { if (IsNumeral.check(maSoHoSo)) { q.setString(queryPos++, "%" + maSoHoSo + "%"); q.setString(queryPos++, "%" + maSoHoSo + "%"); } else { q.setString(queryPos++, "%" + maSoHoSo + "%"); } } if (Validator.isNotNull(maUngDung)) { q.setString(queryPos++, maUngDung); } if (cqqlId > 0) { q.setLong(queryPos++, cqqlId); } q.setInteger(queryPos++, yeuCauRut); return (List<HoSoTTHCCong>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { // must have this to close the hibernate session.. // if you fail to do this.. you will have a lot of open sessions closeSession(session); } }