Package in.partake.base

Examples of in.partake.base.DateTime


                String eventId1 = "eventId-findByEventId-1-" + System.currentTimeMillis();
                String eventId2 = "eventId-findByEventId-2-" + System.currentTimeMillis();

                con.beginTransaction();
                for (int i = 0; i < 100; ++i) {
                    EventActivity activity = new EventActivity(dao.getFreshId(con), eventId1, "title-" + i, "content", new DateTime(i));
                    dao.put(con, activity);
                }
                con.commit();
                con.beginTransaction();
                for (int i = 0; i < 100; ++i) {
                    EventActivity activity = new EventActivity(dao.getFreshId(con), eventId2, "title-" + i, "content", new DateTime(i));
                    dao.put(con, activity);
                }
                con.commit();

View Full Code Here


            return renderInvalid(UserErrorCode.INVALID_PARAMETERS, Collections.singletonMap("title", "タイトルは 100 文字以下で必ず入力してください。"));
        embryo.setTitle(title);

        // beginDate
        {
            DateTime beginDate = getDateTimeParameter("beginDate");
            if (beginDate == null)
                return renderInvalid(UserErrorCode.INVALID_PARAMETERS, Collections.singletonMap("beginDate", "開始日時は必ず入力して下さい。"));

            Calendar beginCalendar = TimeUtil.calendar(beginDate.toDate());
            if (beginCalendar.get(Calendar.YEAR) < 2000 || 2100 < beginCalendar.get(Calendar.YEAR))
                return renderInvalid(UserErrorCode.INVALID_PARAMETERS, Collections.singletonMap("beginDate", "開始日時の範囲が不正です。"));

            embryo.setBeginDate(beginDate);
        }

        // endDate
        {
            DateTime endDate = getDateTimeParameter("endDate");
            if (endDate != null) {
                Calendar endCalendar = TimeUtil.calendar(endDate.toDate());
                if (endCalendar.get(Calendar.YEAR) < 2000 || 2100 < endCalendar.get(Calendar.YEAR))
                    return renderInvalid(UserErrorCode.INVALID_PARAMETERS, Collections.singletonMap("endDate", "終了日時の範囲が不正です。"));

                if (!embryo.getBeginDate().isBefore(endDate))
                    return renderInvalid(UserErrorCode.INVALID_PARAMETERS, Collections.singletonMap("endDate", "終了日時が開始日時より前になっています。"));
View Full Code Here

    }

    @Override
    protected Void doExecute(PartakeConnection con, IPartakeDAOs daos) throws DAOException, PartakeException {
        String topPath = PartakeConfiguration.toppath();
        DateTime now = TimeUtil.getCurrentDateTime();

        // TODO: 開始時刻が現在時刻より後の event のみを取り出したい、というかリマインダーを送るべりイベントのみを取り出したい
        DataIterator<Event> it = daos.getEventAccess().getIterator(con);
        try {
            while (it.hasNext()) {
View Full Code Here

    private static boolean needsToSend(DateTime now, DateTime targetDate, DateTime lastSent) {
        if (now.isBefore(targetDate)) { return false; }
        if (lastSent == null) { return true; }
        if (targetDate.isBefore(lastSent)) { return false; }
        if (now.isBefore(new DateTime(lastSent.getTime() + 1000 * 3600))) { return false; }
        return true;
    }
View Full Code Here

        // TODO: ここから下のコードは、参加者のみにおくる場合と仮参加者のみに送る場合で共有するべき
        String eventNotificationId = daos.getEventNotificationAccess().getFreshId(con);
        EventTicketNotification notification = new EventTicketNotification(eventNotificationId, ticket.getId(), ticket.getEventId(), userIds, notificationType, TimeUtil.getCurrentDateTime());
        daos.getEventNotificationAccess().put(con, notification);

        DateTime invalidAfter = ticket.acceptsReservationTill(event);
        for (String userId : userIds) {
            String notificationId = daos.getUserNotificationAccess().getFreshId(con);
            UserNotification userNotification = new UserNotification(notificationId, ticket.getId(), userId, notificationType, MessageDelivery.INQUEUE, TimeUtil.getCurrentDateTime(), null);
            daos.getUserNotificationAccess().put(con, userNotification);
View Full Code Here

            Logger.info("sendEnvelope : " + userId + " : " + notificationType);
        }
    }

    private void sendEventNotification(PartakeConnection con, IPartakeDAOs daos, EventTicket ticket, EventEx event, String topPath, DateTime now) throws DAOException {
        DateTime beginDate = event.getBeginDate();
        DateTime deadline = event.getBeginDate();

        // TODO: isBeforeDeadline() とかわかりにくいな。
        // 締め切り1日前になっても RESERVED ステータスの人がいればメッセージを送付する。
        // 次の条件でメッセージを送付する
        //  1. 現在時刻が締め切り24時間前よりも後
        //  2. 次の条件のいずれか満たす
        //    2.1. まだメッセージが送られていない
        //    2.2. 前回送った時刻が締め切り24時間以上前で、かつ送った時刻より1時間以上経過している。
        {
            EventTicketNotification notification = daos.getEventNotificationAccess().findLastNotification(con, ticket.getId(), NotificationType.ONE_DAY_BEFORE_REMINDER_FOR_RESERVATION);
            DateTime lastSent = notification != null ? notification.getCreatedAt() : null;
            if (needsToSend(now, deadline.nDayBefore(1), lastSent))
                sendNotificationOnlyForReservedParticipants(con, daos, ticket, event, NotificationType.ONE_DAY_BEFORE_REMINDER_FOR_RESERVATION);
        }

        // 締め切り12時間前になっても RESERVED な人がいればメッセージを送付する。
        {
            EventTicketNotification notification = daos.getEventNotificationAccess().findLastNotification(con, ticket.getId(), NotificationType.HALF_DAY_BEFORE_REMINDER_FOR_RESERVATION);
            DateTime lastSent = notification != null ? notification.getCreatedAt() : null;
            if (needsToSend(now, deadline.nHourBefore(12), lastSent))
                sendNotificationOnlyForReservedParticipants(con, daos, ticket, event, NotificationType.HALF_DAY_BEFORE_REMINDER_FOR_RESERVATION);
        }

        // イベント1日前で、参加が確定している人にはメッセージを送付する。
        // 参加が確定していない人には、RESERVED なメッセージが送られている。
        {
            EventTicketNotification notification = daos.getEventNotificationAccess().findLastNotification(con, ticket.getId(), NotificationType.EVENT_ONEDAY_BEFORE_REMINDER);
            DateTime lastSent = notification != null ? notification.getCreatedAt() : null;
            if (needsToSend(now, beginDate.nDayBefore(1), lastSent))
                sendNotificationOnlyForParticipants(con, daos, ticket, event, NotificationType.EVENT_ONEDAY_BEFORE_REMINDER);
        }
    }
View Full Code Here

        String eventNotificationId = daos.getEventNotificationAccess().getFreshId(con);
        EventTicketNotification notification = new EventTicketNotification(eventNotificationId, ticket.getId(), ticket.getEventId(), userIds, notificationType, TimeUtil.getCurrentDateTime());
        daos.getEventNotificationAccess().put(con, notification);

        DateTime invalidAfter = event.getBeginDate();
        for (String userId : userIds) {
            String notificationId = daos.getUserNotificationAccess().getFreshId(con);
            UserNotification userNotification = new UserNotification(notificationId, ticket.getId(), userId, notificationType, MessageDelivery.INQUEUE, TimeUtil.getCurrentDateTime(), null);
            daos.getUserNotificationAccess().put(con, userNotification);
View Full Code Here

        sendParticipationStatusChangeNotifications(con, daos);
        return null;
    }

    public void sendParticipationStatusChangeNotifications(PartakeConnection con, IPartakeDAOs daos) throws DAOException {
        DateTime now = TimeUtil.getCurrentDateTime();

        // TODO: 開催前のイベントだけiterateすれば充分
        DataIterator<Event> it = daos.getEventAccess().getIterator(con);
        try {
            while (it.hasNext()) {
                Event e = it.next();
                if (e == null)
                    continue;
                String eventId = e.getId();
                if (eventId == null)
                    continue;
                if (!Util.isUUID(eventId)) {
                    Logger.warn("eventId is not UUID.... Should not happen. : " + eventId);
                    continue;
                }

                EventEx event = EventDAOFacade.getEventEx(con, daos, eventId);
                if (event == null)
                    continue;

                if (!now.isBefore(event.getBeginDate()))
                    continue;

                try {
                    List<EventTicket> tickets = daos.getEventTicketAccess().findEventTicketsByEventId(con, eventId);
                    for (EventTicket ticket : tickets)
View Full Code Here

        this.id = obj.get("id").asText();
        this.ticketId = UUID.fromString(obj.get("ticketId").asText());
        this.userId = obj.get("userId").asText();
        this.notificationType = NotificationType.safeValueOf(obj.get("notificationType").asText());
        this.delivery = MessageDelivery.safeValueOf(obj.get("delivery").asText());
        this.createdAt = new DateTime(obj.get("createdAt").asLong());
        if (obj.has("modifiedAt"))
            this.modifiedAt = new DateTime(obj.get("modifiedAt").asLong());
    }
View Full Code Here

        this.userNotificationId = Strings.emptyToNull(json.path("userNotificationId").asText());

        this.numTried = json.get("numTried").asInt();

        if (json.has("lastTriedAt"))
            this.lastTriedAt = new DateTime(json.get("lastTriedAt").asLong());
        if (json.has("invalidAfter"))
            this.invalidAfter = new DateTime(json.get("invalidAfter").asLong());
        if (json.has("tryAfter"))
            this.tryAfter = new DateTime(json.get("tryAfter").asLong());
        if (json.has("createdAt"))
            this.createdAt = new DateTime(json.get("createdAt").asLong());
        if (json.has("modifiedAt"))
            this.modifiedAt = new DateTime(json.get("modifiedAt").asLong());
    }
View Full Code Here

TOP

Related Classes of in.partake.base.DateTime

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.