Package in.partake.model.dao.postgres9

Examples of in.partake.model.dao.postgres9.Postgres9Connection


    private final Postgres9IndexDao indexDao;
    private final EntityUserSentMessageMapper mapper;

    public Postgres9UserSentMessageDao() {
        this.entityDao = new Postgres9EntityDao(ENTITY_TABLE_NAME);
        this.indexDao = new Postgres9IndexDao(INDEX_TABLE_NAME);
        this.mapper = new EntityUserSentMessageMapper();
    }
View Full Code Here


    private final Postgres9IndexDao editorIndexDao;
    private final EntityEventMapper mapper;

    public Postgres9EventDao() {
        this.entityDao = new Postgres9EntityDao(ENTITY_TABLE_NAME);
        this.indexDao = new Postgres9IndexDao(INDEX_TABLE_NAME);
        this.editorIndexDao = new Postgres9IndexDao(EDITOR_INDEX_TABLE_NAME);
        this.mapper = new EntityEventMapper();
    }
View Full Code Here

    private final Postgres9IndexDao indexDao;
    private final EntityEventNotificationMapper mapper;

    public Postgres9EventNotificationDao() {
        this.entityDao = new Postgres9EntityDao(ENTITY_TABLE_NAME);
        this.indexDao = new Postgres9IndexDao(INDEX_TABLE_NAME);
        this.mapper = new EntityEventNotificationMapper();
    }
View Full Code Here

    @Override
    public List<Event> findByOwnerId(PartakeConnection con, String userId, EventFilterCondition criteria, int offset, int limit) throws DAOException {
        String draftSql = conditionClauseForCriteria(criteria);

        Postgres9StatementAndResultSet psars = indexDao.select((Postgres9Connection) con,
                "SELECT id FROM " + INDEX_TABLE_NAME + " WHERE ownerId = ? " + draftSql + " ORDER BY beginDate DESC OFFSET ? LIMIT ?",
                new Object[] { userId, offset, limit });

        Postgres9IdMapper<Event> idMapper = new Postgres9IdMapper<Event>((Postgres9Connection) con, mapper, entityDao);

        try {
            ArrayList<Event> events = new ArrayList<Event>();
            DataIterator<Event> it = new Postgres9DataIterator<Event>(idMapper, psars);
            while (it.hasNext()) {
                Event event = it.next();
                if (event == null)
                    continue;
                events.add(event);
            }

            return events;
        } finally {
            psars.close();
        }
    }
View Full Code Here

    }

    @Override
    public DataIterator<Event> getIterator(PartakeConnection con, EventFilterCondition condition) throws DAOException {
        String draftSql = conditionClauseForCriteria(condition);
        Postgres9StatementAndResultSet psars = indexDao.select((Postgres9Connection) con,
                "SELECT id FROM " + INDEX_TABLE_NAME + " WHERE 1 = 1 " + draftSql + " ORDER BY beginDate DESC",
                new Object[] {});

        Postgres9IdMapper<Event> idMapper = new Postgres9IdMapper<Event>((Postgres9Connection) con, mapper, entityDao);
        return new Postgres9DataIterator<Event>(idMapper, psars);
View Full Code Here

    @Override
    public List<Event> findByEditorUserId(PartakeConnection con, String editorUserId, EventFilterCondition criteria, int offset, int limit) throws DAOException {
        String condition = conditionClauseForCriteria(criteria);

        Postgres9StatementAndResultSet psars = editorIndexDao.select((Postgres9Connection) con,
                "SELECT id FROM " + EDITOR_INDEX_TABLE_NAME + " WHERE editorId = ? " + condition + " ORDER BY beginDate DESC OFFSET ? LIMIT ?",
                new Object[] { editorUserId, offset, limit });

        Postgres9IdMapper<Event> idMapper = new Postgres9IdMapper<Event>((Postgres9Connection) con, mapper, entityDao);

        try {
            DataIterator<Event> it = new Postgres9DataIterator<Event>(idMapper, psars);
            return DAOUtil.convertToList(it);
        } finally {
            psars.close();
        }
    }
View Full Code Here

    }

    @Override
    public int countByEditorUserId(PartakeConnection con, String editorId, EventFilterCondition criteria) throws DAOException {
        String condition = conditionClauseForCriteria(criteria);
        Postgres9StatementAndResultSet psars = editorIndexDao.select((Postgres9Connection) con,
                "SELECT count(1) FROM " + EDITOR_INDEX_TABLE_NAME + " WHERE editorId = ? " + condition,
                new Object[] { editorId });

        try {
            ResultSet rs = psars.getResultSet();
            if (rs.next())
                return rs.getInt(1);
            else
                return 0;
        } catch (SQLException e) {
            throw new DAOException(e);
        } finally {
            psars.close();
        }
    }
View Full Code Here

    }

    @Override
    public int countEventsByOwnerIdAndEditorId(PartakeConnection con, String userId, EventFilterCondition criteria) throws DAOException {
        String condition = conditionClauseForCriteria(criteria);
        Postgres9StatementAndResultSet psars = editorIndexDao.select((Postgres9Connection) con,
                "SELECT count(1) FROM (" +
                    "SELECT id FROM " + INDEX_TABLE_NAME + " WHERE ownerId = ? " + condition +
                    " UNION " +
                    "SELECT id FROM " + EDITOR_INDEX_TABLE_NAME + " WHERE editorId = ? " + condition +
                ") as a",
                new Object[] { userId, userId });
        try {
            ResultSet rs = psars.getResultSet();
            if (rs.next())
                return rs.getInt(1);
            else
                return 0;
        } catch (SQLException e) {
            throw new DAOException(e);
        } finally {
            psars.close();
        }
    }
View Full Code Here

    }

    @Override
    public List<Event> findByOwnerIdAndEditorId(PartakeConnection con, String userId, EventFilterCondition criteria) throws DAOException {
        String condition = conditionClauseForCriteria(criteria);
        Postgres9StatementAndResultSet psars = editorIndexDao.select((Postgres9Connection) con,
                "SELECT id FROM " + INDEX_TABLE_NAME + " WHERE ownerId = ? " + condition +
                " UNION " +
                "SELECT id FROM " + EDITOR_INDEX_TABLE_NAME + " WHERE editorId = ? " + condition,
                new Object[] { userId, userId });

        Postgres9IdMapper<Event> idMapper = new Postgres9IdMapper<Event>((Postgres9Connection) con, mapper, entityDao);

        try {
            DataIterator<Event> it = new Postgres9DataIterator<Event>(idMapper, psars);
            return DAOUtil.convertToList(it);
        } finally {
            psars.close();
        }
    }
View Full Code Here

        return entityDao.getFreshId((Postgres9Connection) con);
    }

    @Override
    public List<EventTicketNotification> findByTicketId(PartakeConnection con, UUID ticketId, int offset, int limit) throws DAOException {
        Postgres9StatementAndResultSet psars = indexDao.select((Postgres9Connection) con,
                "SELECT id FROM " + INDEX_TABLE_NAME + " WHERE ticketId = ? ORDER BY createdAt DESC OFFSET ? LIMIT ?",
                new Object[] { ticketId.toString(), offset, limit });

        Postgres9IdMapper<EventTicketNotification> idMapper = new Postgres9IdMapper<EventTicketNotification>((Postgres9Connection) con, mapper, entityDao);
        return DAOUtil.convertToList(new Postgres9DataIterator<EventTicketNotification>(idMapper, psars));
View Full Code Here

TOP

Related Classes of in.partake.model.dao.postgres9.Postgres9Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.