Examples of InAppNotificationEntity


Examples of org.eurekastreams.server.domain.InAppNotificationEntity

                oneOf(insertMapper).execute(with(new EasyMatcher<PersistenceRequest>()
                {
                    @Override
                    protected boolean isMatch(final PersistenceRequest testObject)
                    {
                        InAppNotificationEntity notif = (InAppNotificationEntity) testObject.getDomainEnity();
                        return person1 == notif.getRecipient() && RENDERED.equals(notif.getMessage())
                                && OK_TYPE == notif.getNotificationType() && notif.getUrl() == null
                                && !notif.isHighPriority() && notif.getSourceType() == EntityType.NOTSET
                                && notif.getSourceUniqueId() == null && notif.getSourceName() == null
                                && notif.getAvatarOwnerType() == EntityType.NOTSET
                                && notif.getAvatarOwnerUniqueId() == null;
                    }
                }));
                when(state.is("person1"));

                oneOf(syncMapper).execute(RECIPIENT1);
                when(state.is("person1"));

                oneOf(placeholderPersonMapper).execute(RECIPIENT2);
                will(returnValue(person2));
                then(state.is("person2"));

                oneOf(person1).getId();
                will(returnValue(RECIPIENT1));
                when(state.is("person1"));

                oneOf(person2).getId();
                will(returnValue(RECIPIENT2));
                when(state.is("person2"));

                oneOf(insertMapper).execute(with(new EasyMatcher<PersistenceRequest>()
                {
                    @Override
                    protected boolean isMatch(final PersistenceRequest testObject)
                    {
                        InAppNotificationEntity notif = (InAppNotificationEntity) testObject.getDomainEnity();
                        return person2 == notif.getRecipient() && RENDERED.equals(notif.getMessage())
                                && OK_TYPE == notif.getNotificationType() && notif.getUrl() == null
                                && !notif.isHighPriority() && notif.getSourceType() == EntityType.NOTSET
                                && notif.getSourceUniqueId() == null && notif.getSourceName() == null
                                && notif.getAvatarOwnerType() == EntityType.NOTSET
                                && notif.getAvatarOwnerUniqueId() == null;
                    }
                }));
                when(state.is("person2"));

                oneOf(syncMapper).execute(RECIPIENT2);
View Full Code Here

Examples of org.eurekastreams.server.domain.InAppNotificationEntity

                oneOf(insertMapper).execute(with(new EasyMatcher<PersistenceRequest>()
                {
                    @Override
                    protected boolean isMatch(final PersistenceRequest testObject)
                    {
                        InAppNotificationEntity notif = (InAppNotificationEntity) testObject.getDomainEnity();
                        return person1 == notif.getRecipient() && RENDERED.equals(notif.getMessage())
                                && OK_TYPE == notif.getNotificationType() && url.equals(notif.getUrl())
                                && notif.isHighPriority() && notif.getSourceType() == EntityType.GROUP
                                && sourceUniqueId.equals(notif.getSourceUniqueId())
                                && sourceName.equals(notif.getSourceName())
                                && notif.getAvatarOwnerType() == EntityType.PERSON
                                && actorUniqueId.equals(notif.getAvatarOwnerUniqueId());
                    }
                }));

                oneOf(syncMapper).execute(RECIPIENT1);
View Full Code Here

Examples of org.eurekastreams.server.domain.InAppNotificationEntity

                oneOf(velocityEngine).evaluate(with(any(VelocityContext.class)), with(any(StringWriter.class)),
                        with(equal("InAppNotification-COMMENT_TO_COMMENTED_POST")), with(equal(AGGREGATE_TEMPLATE)));
                will(new AppendRenderedAction());

                InAppNotificationEntity existingNotification = new InAppNotificationEntity();
                existingNotification.setAggregationCount(3);
                oneOf(existingNotificationMapper).execute(with(any(InAppNotificationEntity.class)));
                will(returnValue(existingNotification));

                oneOf(updateMapper).execute(with(new EasyMatcher<PersistenceRequest>()
                {
                    @Override
                    protected boolean isMatch(final PersistenceRequest testObject)
                    {
                        InAppNotificationEntity notif = (InAppNotificationEntity) testObject.getDomainEnity();
                        return RENDERED.equals(notif.getMessage()) && notif.getAggregationCount() == 4;
                    }
                }));

                oneOf(person1).getId();
                will(returnValue(RECIPIENT1));
View Full Code Here

Examples of org.eurekastreams.server.domain.InAppNotificationEntity

     */
    @Override
    public Serializable execute(final SendPrebuiltNotificationRequest inRequest)
    {
        // insert a notification like the one we want into the DB, but without a recipient
        InAppNotificationEntity dbNotif = new InAppNotificationEntity();
        dbNotif.setNotificationType(NotificationType.PASS_THROUGH);
        dbNotif.setMessage(inRequest.getMessage());
        dbNotif.setUrl(inRequest.getUrl());
        dbNotif.setHighPriority(inRequest.isHighPriority());

        getEntityManager().persist(dbNotif);

        // use a bulk insert to duplicate it for all non-locked users
        String q = "insert into InAppNotification (recipient, notificationType, notificationDate, message, url, "
                + "highPriority, isRead, sourceType, avatarOwnerType, aggregationCount) "
                + "select p, n.notificationType, n.notificationDate, n.message, n.url, n.highPriority, n.isRead, "
                + "n.sourceType, n.avatarOwnerType, n.aggregationCount from Person p, InAppNotification n "
                + "where n.id = :id and p.accountLocked = false";
        Query query = getEntityManager().createQuery(q).setParameter("id", dbNotif.getId());
        int count = query.executeUpdate();

        // delete the template notification
        getEntityManager().remove(dbNotif);

View Full Code Here

Examples of org.eurekastreams.server.domain.InAppNotificationEntity

     */
    @Test
    public void testExecute()
    {
        // test
        InAppNotificationEntity searchCriteria = new InAppNotificationEntity();
        final Person recipient = context.mock(Person.class);
        context.checking(new Expectations()
        {
            {
                oneOf(recipient).getId();
                will(returnValue(42L));
            }
        });
        searchCriteria.setRecipient(recipient);
        searchCriteria.setNotificationType(NotificationType.LIKE_ACTIVITY);
        searchCriteria.setUrl("#activity/6789");
        InAppNotificationEntity result = sut.execute(searchCriteria);

        // verify
        assertEquals(6L, result.getId());
    }
View Full Code Here

Examples of org.eurekastreams.server.domain.InAppNotificationEntity

     *            Velocity context used to generate notification message
     */
    private void updateAggregateNotification(final Person recipient, final NotificationType inType,
            final Map<String, Object> inProperties, final Context velocityContext)
    {
        InAppNotificationEntity searchCriteria = new InAppNotificationEntity();
        searchCriteria.setRecipient(recipient);
        searchCriteria.setNotificationType(inType);
        searchCriteria.setUrl((String) inProperties.get(NotificationPropertyKeys.URL));
        InAppNotificationEntity existingAggregateNotification = existingNotificationMapper.execute(searchCriteria);

        if (existingAggregateNotification == null)
        {
            createNewNotification(recipient, inType, inProperties, velocityContext);
            return;
        }

        int newAggregationCount = existingAggregateNotification.getAggregationCount() + 1;
        existingAggregateNotification.setAggregationCount(newAggregationCount);

        existingAggregateNotification.setNotificationDate(new Date());

        String template = aggregateTemplates.get(inType);
        if (template == null)
        {
            return;
        }

        velocityContext.put("recipient", recipient);
        velocityContext.put("aggregationCount", newAggregationCount);
        StringWriter writer = new StringWriter();
        velocityEngine.evaluate(velocityContext, writer, "InAppNotification-" + inType, template);

        String message = writer.toString();
        existingAggregateNotification.setMessage(message);

        try
        {
            updateMapper.execute(new PersistenceRequest<InAppNotificationEntity>(existingAggregateNotification));
        }
View Full Code Here

Examples of org.eurekastreams.server.domain.InAppNotificationEntity

     *            Velocity context used to generate notification message
     */
    private void createNewNotification(final Person recipient, final NotificationType inType,
            final Map<String, Object> inProperties, final Context velocityContext)
    {
        InAppNotificationEntity dbNotif = new InAppNotificationEntity();
        dbNotif.setNotificationType(inType);
        dbNotif.setRecipient(recipient);
        dbNotif.setUrl((String) inProperties.get(NotificationPropertyKeys.URL));
        dbNotif.setHighPriority(Boolean.TRUE.equals(inProperties.get(NotificationPropertyKeys.HIGH_PRIORITY)));

        Object obj = inProperties.get(NotificationPropertyKeys.SOURCE);
        if (obj instanceof Identifiable)
        {
            Identifiable source = (Identifiable) obj;
            dbNotif.setSourceType(source.getEntityType());
            dbNotif.setSourceUniqueId(source.getUniqueId());
            dbNotif.setSourceName(source.getDisplayName());
        }
        obj = inProperties.get(NotificationPropertyKeys.ACTOR);
        if (obj instanceof Identifiable)
        {
            Identifiable actor = (Identifiable) obj;
            dbNotif.setAvatarOwnerType(actor.getEntityType());
            dbNotif.setAvatarOwnerUniqueId(actor.getUniqueId());
        }

        String template = templates.get(inType);
        if (template == null)
        {
            return;
        }

        velocityContext.put("recipient", recipient);
        StringWriter writer = new StringWriter();
        velocityEngine.evaluate(velocityContext, writer, "InAppNotification-" + inType, template);

        String message = writer.toString();
        dbNotif.setMessage(message);

        insertMapper.execute(new PersistenceRequest<InAppNotificationEntity>(dbNotif));

        syncMapper.execute(recipient.getId());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.