/*
 * Copyright 2015, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package lobby.registration.projection;

import lobby.contracts.common.ConferenceId;
import lobby.registration.Conference;
import org.spine3.server.projection.Projection;

/**
 * The projection of a conference.
 *
 * @see Projection
 * @author Alexander Litus
 */
public class ConferenceProjection extends Projection<ConferenceId, Conference> {

    /**
     * Creates a new instance.
     *
     * @param id the ID for the new instance
     * @throws IllegalArgumentException if the ID is not of one of the supported types
     */
    public ConferenceProjection(ConferenceId id) {
        super(id);
    }

    @Override
    protected Conference getDefaultState() {
        return Conference.getDefaultInstance();
    }

    // TODO:2015-12-11:alexander.litus: store info about the seats
}

@@ -1111,79 +1111,343 @@
 bby.
-registration.Conference;%0Aimport org.spine3.server.projection.Projection
+contracts.common.SeatType;%0Aimport lobby.contracts.conference.*;%0Aimport lobby.registration.Conference;%0Aimport org.spine3.eventbus.Subscribe;%0Aimport org.spine3.server.projection.Projection;%0A%0Aimport static lobby.registration.Conference.PublishingStatus.NOT_PUBLISHED;%0Aimport static lobby.registration.Conference.PublishingStatus.PUBLISHED
 ;%0A%0A/
@@ -1537,16 +1537,55 @@
 tus%0A */%0A
+@SuppressWarnings(%22TypeMayBeWeakened%22)%0A
 public c
@@ -2043,69 +2043,1804 @@
     
-// TODO:2015-12-11:alexander.litus: store info about the seats
+@Subscribe%0A    public void on(ConferenceCreated event) %7B%0A        final Conference newState = convert(event.getConference());%0A        incrementState(newState);%0A    %7D%0A%0A    @Subscribe%0A    public void on(ConferenceUpdated event) %7B%0A        final Conference newState = convert(event.getConference());%0A        incrementState(newState);%0A    %7D%0A%0A    @Subscribe%0A    public void on(ConferencePublished event) %7B%0A        updatePublishingStatus(PUBLISHED);%0A    %7D%0A%0A    @Subscribe%0A    public void on(ConferenceUnpublished event) %7B%0A        updatePublishingStatus(NOT_PUBLISHED);%0A    %7D%0A%0A    private void updatePublishingStatus(Conference.PublishingStatus status) %7B%0A        final Conference.Builder conference = getState().toBuilder();%0A        conference.setPublishingStatus(status);%0A        incrementState(conference.build());%0A    %7D%0A%0A    @Subscribe%0A    public void on(SeatTypeCreated event) %7B%0A        updateSeatType(event.getSeatType());%0A    %7D%0A%0A    @Subscribe%0A    public void on(SeatTypeUpdated event) %7B%0A        updateSeatType(event.getSeatType());%0A    %7D%0A%0A    private void updateSeatType(SeatType seatType) %7B%0A        final Conference.Builder conference = getState().toBuilder();%0A        conference.addSeatType(seatType);%0A        incrementState(conference.build());%0A    %7D%0A%0A    private static Conference convert(lobby.contracts.conference.Conference c) %7B%0A        final Conference.Builder newState = Conference.newBuilder()%0A                .setId(c.getId())%0A                .setSlug(c.getSlug())%0A                .setName(c.getName())%0A                .setDescription(c.getDescription())%0A                .setLocation(c.getLocation())%0A                .setTagline(c.getTagline())%0A                .setTwitterSearch(c.getTwitterSearch())%0A                .setStartDate(c.getStartDate());%0A        return newState.build();%0A    %7D
 %0A%7D%0A

Handle events in conference projection.