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 にのみ変更して対応
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;
}
}
if (!userIdsToBeCancelled.isEmpty()) {
String notificationId = daos.getEventNotificationAccess().getFreshId(con);
EventTicketNotification notification = new EventTicketNotification(notificationId, ticket.getId(), ticket.getEventId(), userIdsToBeEnrolled, NotificationType.BECAME_TO_BE_CANCELLED, TimeUtil.getCurrentDateTime());
daos.getEventNotificationAccess().put(con, notification);
for (String userId : userIdsToBeCancelled) {
String userNotificationid = daos.getUserNotificationAccess().getFreshId(con);
UserNotification userNotification = new UserNotification(userNotificationid, ticket.getId(), userId, NotificationType.BECAME_TO_BE_CANCELLED, 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);
}
}
}