Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package th.in.oneauthen.object.DAO;
- import java.util.List;
- import javax.persistence.TemporalType;
- import java.util.Date;
- import org.apache.log4j.Logger;
- import th.athichitsakul.dao.impl.StandardDAOImpl;
- import th.in.oneauthen.object.LogReportDB;
- import th.in.oneauthen.object.UserUidDB;
- import th.in.oneauthen.util.SystemLogger;
- public class LogReportDAO extends StandardDAOImpl<LogReportDB>{
- private Logger logger = SystemLogger.generateSystemLogger(LogReportDAO.class);
- public LogReportDAO() {
- super("esigning");
- }
- public List<LogReportDB> findByUserUIDLog ( UserUidDB userUID ) {
- List<LogReportDB> history = null;
- try {
- DAO.begin();
- history = (List<LogReportDB>) DAO.getEntityManager().createNamedQuery("queryByUserId")
- .setParameter("creator", userUID)
- .setMaxResults(75)
- .getResultList();
- } catch (Exception e) {
- logger.error("Invalid user loading with ID "+userUID , e);
- } finally {
- DAO.close();
- }
- return history;
- }
- public List<LogReportDB> findByDateAndYear2Log (int month ,int year ,UserUidDB userUID) {
- List<LogReportDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<LogReportDB>) DAO.getEntityManager().createNamedQuery("queryByMonthAndYear")
- .setParameter("monthDoc", month)
- .setParameter("yearDoc", year)
- .setParameter("creator", userUID)
- .getResultList();
- } catch (Exception e) {
- logger.error("Invalid month/year loading with "+month+"/"+year , e);
- } finally {
- DAO.close();
- }
- return historyTotal;
- }
- public List<LogReportDB> findCountTotalByMonthLog (int month ,int year ,UserUidDB userUID) {
- List<LogReportDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<LogReportDB>) DAO.getEntityManager().createNamedQuery("queryByMonthAndYearTotal")
- .setParameter("monthDoc", month)
- .setParameter("yearDoc", year)
- .setParameter("creator", userUID)
- .getResultList();
- } catch (Exception e) {
- logger.error("Invalid month/year loading with "+month+"/"+year , e);
- } finally {
- DAO.close();
- }
- return historyTotal;
- }
- public List<LogReportDB> findMinDateLog (UserUidDB userUID) {
- List<LogReportDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<LogReportDB>) DAO.getEntityManager().createNamedQuery("queryMinDate")
- .setParameter("creator", userUID)
- .getResultList();
- } catch (Exception e) {
- logger.error("Invalid minDate loading with userUid" , e);
- } finally {
- DAO.close();
- }
- return historyTotal;
- }
- public List<LogReportDB> findBetweenDateLog (Date fristDate,Date lastDate, UserUidDB userUID) {
- List<LogReportDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<LogReportDB>) DAO.getEntityManager().createNamedQuery("queryBetweenDate")
- .setParameter("stDate", fristDate)
- .setParameter("edDate", lastDate)
- .setParameter("creator", userUID)
- .getResultList();
- } catch (Exception e) {
- logger.error("Invalid loading with "+lastDate +"and"+fristDate , e);
- } finally {
- DAO.close();
- }
- return historyTotal;
- }
- public List<LogReportDB> findInDateLog (Date dateFind, UserUidDB userUID) {
- List<LogReportDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<LogReportDB>) DAO.getEntityManager().createNamedQuery("queryInDate")
- .setParameter("dateFind", dateFind,TemporalType.DATE)
- .setParameter("creator", userUID)
- .getResultList();
- } catch (Exception e) {
- logger.error("Invalid loading with "+ dateFind +"and userID"+userUID , e);
- } finally {
- DAO.close();
- }
- return historyTotal;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement