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.DocumentDB;
- import th.in.oneauthen.object.UserUidDB;
- import th.in.oneauthen.util.SystemLogger;
- public class DocumentDAO extends StandardDAOImpl<DocumentDB>{
- private Logger logger = SystemLogger.generateSystemLogger(DocumentDAO.class);
- public DocumentDAO() {
- super("esigning");
- }
- public List<DocumentDB> findByUserUID ( UserUidDB userUID ) {
- List<DocumentDB> history = null;
- try {
- // UserUidDB user = new UserUidDAO().find(userUID);;
- // if ( user == null ) {
- // logger.error("User not found with ID "+userUID);
- // } else {
- DAO.begin();
- history = (List<DocumentDB>) DAO.getEntityManager().createNamedQuery("gethistoryByOwner")
- .setParameter("creator", userUID)
- .getResultList();
- // }
- } catch (Exception e) {
- logger.error("Invalid user loading with ID "+userUID , e);
- } finally {
- DAO.close();
- }
- return history;
- }
- public List<DocumentDB> findByDateAndYear2 (int month ,int year ,UserUidDB userUID) {
- List<DocumentDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<DocumentDB>) DAO.getEntityManager().createNamedQuery("getHistoryTotalByMonthAndYear2")
- .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<DocumentDB> findCountTotalByMonth (int month ,int year ,UserUidDB userUID) {
- List<DocumentDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<DocumentDB>) DAO.getEntityManager().createNamedQuery("getHistoryTotalByMonthAndYear3")
- .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<DocumentDB> findMinDate (UserUidDB userUID) {
- List<DocumentDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<DocumentDB>) DAO.getEntityManager().createNamedQuery("getMinDate")
- .setParameter("creator", userUID)
- .getResultList();
- } catch (Exception e) {
- logger.error("Invalid minDate loading with userUid" , e);
- } finally {
- DAO.close();
- }
- return historyTotal;
- }
- public List<DocumentDB> findBetweenDate (Date fristDate,Date lastDate, UserUidDB userUID) {
- List<DocumentDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<DocumentDB>) DAO.getEntityManager().createNamedQuery("getBetweenDate")
- .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<DocumentDB> findInDate (Date dateFind, UserUidDB userUID) {
- List<DocumentDB> historyTotal = null;
- try {
- DAO.begin();
- historyTotal = (List<DocumentDB>) DAO.getEntityManager().createNamedQuery("getInDate")
- .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