Package in.partake.model.dao.access

Examples of in.partake.model.dao.access.IEventTicketAccess


        return list;
    }

    @Override
    public void createFixtures(PartakeConnection con, IPartakeDAOs daos) throws DAOException {
        IEventTicketAccess dao = daos.getEventTicketAccess();
        dao.truncate(con);

        dao.put(con, EventTicket.createDefaultTicket(DEFAULT_EVENT_TICKET_ID, DEFAULT_EVENT_ID));
        dao.put(con, EventTicket.createDefaultTicket(PRIVATE_EVENT_TICKET_ID, PRIVATE_EVENT_ID));
        dao.put(con, EventTicket.createDefaultTicket(JAPANESE_EVENT_TICKET_ID, JAPANESE_EVENT_ID));
        dao.put(con, EventTicket.createDefaultTicket(UNIQUEIDENTIFIER_EVENT_TICKET_ID, UNIQUEIDENTIFIER_EVENT_ID));
        dao.put(con, EventTicket.createDefaultTicket(UNPUBLISHED_EVENT_TICKET_ID, UNPUBLISHED_EVENT_ID));
        dao.put(con, EventTicket.createDefaultTicket(NO_PARTICIPANTS_EVENT_TICKET_ID, NO_PARTICIPANTS_EVENT_ID));
    }
View Full Code Here


        modifyTickets(con, daos, event.isDraft());
        return null;
    }

    private void modifyTickets(PartakeConnection con, IPartakeDAOs daos, boolean forDraft) throws DAOException, PartakeException {
        IEventTicketAccess dao = daos.getEventTicketAccess();
        List<EventTicket> originalTickets = dao.findEventTicketsByEventId(con, eventId);
        boolean[] processed = new boolean[originalTickets.size()];

        // |tickets| should contain all the original ticket.
        for (EventTicket ticket : tickets) {
            EventTicket originalTicket = null;

            for (int i = 0; i < originalTickets.size(); ++i) {
                if (!originalTickets.get(i).getId().equals(ticket.getId()))
                    continue;
                if (processed[i])
                    throw new PartakeException(UserErrorCode.INVALID_TICKET_DUPLICATE_ID);

                // Found the original ticket.
                processed[i] = true;
                originalTicket = originalTickets.get(i);
                break;
            }

            if (originalTicket == null) {
                // If new ticket has id, it's strange. Otherwise, add a new ticket id.
                if (ticket.getId() != null)
                    throw new PartakeException(UserErrorCode.INVALID_PARAMETERS);
                ticket.setId(daos.getEventTicketAccess().getFreshId(con));
            }
        }

        // If the event has already been published, all ticket should be preserved.
        // However, it's OK to remove the ticket that no participants.
        if (!forDraft) {
            for (int i = 0; i < processed.length; ++i) {
                UUID eventTicketId = originalTickets.get(i).getId();
                if (!processed[i] && daos.getEnrollmentAccess().countByTicketId(con, eventTicketId) > 0)
                    throw new PartakeException(UserErrorCode.INVALID_TICKET_REMOVAL_ENROLLED);
            }
        }

        // OK. let's save the tickets.
        dao.removeByEventId(con, eventId);
        for (EventTicket ticket : tickets)
            dao.put(con, ticket);
    }
View Full Code Here

TOP

Related Classes of in.partake.model.dao.access.IEventTicketAccess

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.