}
}
private void sendChangeNotificationImpl(PartakeConnection con, IPartakeDAOs daos, EventTicket ticket, String eventId, EventEx event) throws DAOException {
List<UserTicketEx> participations = EnrollmentDAOFacade.getEnrollmentExs(con, daos, ticket, event);
EventTicketHolderList list = ticket.calculateParticipationList(event, participations);
// TODO: ここのソース汚い。同一化できる。とくに、あとの2つは一緒。
List<String> userIdsToBeEnrolled = new ArrayList<String>();
for (UserTicket p : list.getEnrolledParticipations()) {
// -- 参加者向
ModificationStatus status = p.getModificationStatus();
if (status == null) { continue; }
switch (status) {
case CHANGED: { // 自分自身の力で変化させていた場合は status を enrolled にのみ変更して対応
updateLastStatus(con, daos, eventId, p, ModificationStatus.ENROLLED);
break;
}
case NOT_ENROLLED: {
userIdsToBeEnrolled.add(p.getUserId());
updateLastStatus(con, daos, eventId, p, ModificationStatus.ENROLLED);
break;
}
case ENROLLED:
break;
}
}
if (!userIdsToBeEnrolled.isEmpty()) {
String eventNotificationId = daos.getEventNotificationAccess().getFreshId(con);
EventTicketNotification notification = new EventTicketNotification(eventNotificationId, ticket.getId(), ticket.getEventId(), userIdsToBeEnrolled, NotificationType.BECAME_TO_BE_ENROLLED, TimeUtil.getCurrentDateTime());
daos.getEventNotificationAccess().put(con, notification);
for (String userId : userIdsToBeEnrolled) {
String userNotificationid = daos.getUserNotificationAccess().getFreshId(con);
UserNotification userNotification = new UserNotification(userNotificationid, ticket.getId(), userId, NotificationType.BECAME_TO_BE_ENROLLED, MessageDelivery.INQUEUE, TimeUtil.getCurrentDateTime(), null);
daos.getUserNotificationAccess().put(con, userNotification);
String envelopeId = daos.getMessageEnvelopeAccess().getFreshId(con);
MessageEnvelope envelope = MessageEnvelope.createForUserNotification(envelopeId, userNotificationid, null);
daos.getMessageEnvelopeAccess().put(con, envelope);
}
}
List<String> userIdsToBeCancelled = new ArrayList<String>();
for (UserTicket p : list.getSpareParticipations()) {
ModificationStatus status = p.getModificationStatus();
if (status == null) { continue; }
switch (status) {
case CHANGED: // 自分自身の力で変化させていた場合は status を not_enrolled にのみ変更して対応
updateLastStatus(con, daos, eventId, p, ModificationStatus.NOT_ENROLLED);
break;
case NOT_ENROLLED:
break;
case ENROLLED:
updateLastStatus(con, daos, eventId, p, ModificationStatus.NOT_ENROLLED);
userIdsToBeCancelled.add(p.getUserId());
break;
}
}
for (UserTicket p : list.getCancelledParticipations()) {
ModificationStatus status = p.getModificationStatus();
if (status == null) { continue; }
switch (status) {
case CHANGED: // 自分自身の力で変化させていた場合は status を not_enrolled にのみ変更して対応