Examples of Postgres9StatementAndResultSet


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

    @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

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

    }

    @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

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

    @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

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

    }

    @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

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

    }

    @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

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

    }

    @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

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

        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

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

        return DAOUtil.convertToList(new Postgres9DataIterator<EventTicketNotification>(idMapper, psars));
    }

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

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

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

        return DAOUtil.convertToList(new Postgres9DataIterator<EventTicketNotification>(idMapper, psars));
    }

    @Override
    public EventTicketNotification findLastNotification(PartakeConnection con, UUID ticketId, NotificationType type) throws DAOException {
        Postgres9StatementAndResultSet psars = indexDao.select((Postgres9Connection) con,
                "SELECT id FROM " + INDEX_TABLE_NAME + " WHERE ticketId = ? AND notificationType = ? ORDER BY createdAt DESC LIMIT 1",
                new Object[] { ticketId.toString(), type.toString() });

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

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

        return new MapperDataIterator<Postgres9Entity, UserImage>(mapper, entityDao.getIterator((Postgres9Connection) con));
    }

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

        ArrayList<String> result = new ArrayList<String>();
        try {
            ResultSet rs = psars.getResultSet();
            while (rs.next())
                result.add(rs.getString(1));
        } catch (SQLException e) {
            throw new DAOException(e);
        } finally {
            psars.close();
        }

        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.