Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IAttachment


    assertEquals(sourceLink, news.getSource().getLink());
  }

  private INews createNews(IFeed feed) {
    INews news = fTypesFactory.createNews(null, feed, createDate());
    IAttachment attachment = fTypesFactory.createAttachment(null, news);
    attachment.setLink(createURI("http://attachmenturi.com"));
    ICategory category = fTypesFactory.createCategory(null, news);
    category.setName("Category name #1");
    news.setAuthor(createPersonMary(news));
    news.setBase(createURI("http://www.someuri.com"));
    news.setComments("One comment");
View Full Code Here


    AttachmentListener attachmentListener = null;
    try {
      /* Add */
      FeedReference feedRef = new FeedReference(DynamicDAO.save(fFactory.createFeed(null, new URI("http://www.feed1.com"))).getId());
      NewsReference newsRef = new NewsReference(DynamicDAO.save(fFactory.createNews(null, feedRef.resolve(), new Date())).getId());
      IAttachment attachment = fFactory.createAttachment(null, newsRef.resolve());
      attachment.setLink(new URI("http://www.attachment.com"));
      final boolean attachmentEvents[] = new boolean[3];
      final AttachmentReference attachmentReference[] = new AttachmentReference[1];
      attachmentListener = new AttachmentAdapter() {
        @Override
        public void entitiesAdded(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            attachmentEvents[0] = true;
          }
        }

        @Override
        public void entitiesDeleted(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            if (attachmentReference[0].references(event.getEntity()))
              attachmentEvents[1] = true;
          }
        }

        @Override
        public void entitiesUpdated(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            if (attachmentReference[0].references(event.getEntity()))
              attachmentEvents[2] = true;
          }
        }
      };
      DynamicDAO.addEntityListener(IAttachment.class, attachmentListener);
      attachmentReference[0] = new AttachmentReference(DynamicDAO.save(attachment).getId());

      /* Update */
      attachment = attachmentReference[0].resolve();
      attachment.setType("MP3");
      DynamicDAO.save(attachment);

      /* Delete */
      DynamicDAO.delete(attachmentReference[0].resolve());

View Full Code Here

      assertEquals(true, news.getProperty("Boolean"));
      assertEquals(2.2D, news.getProperty("Double"));
      assertEquals(3.3F, news.getProperty("Float"));

      /* Add Properties to an Attachment */
      IAttachment attachment = fFactory.createAttachment(null, newsRef.resolve());
      attachment.setLink(new URI("http://www.attachment.com"));
      attachment.setProperty("String", "Foo");
      attachment.setProperty("Integer", 1);
      attachment.setProperty("Boolean", true);
      attachment.setProperty("Double", 2.2D);
      attachment.setProperty("Float", 3.3F);
      AttachmentReference attachmentRef = new AttachmentReference(DynamicDAO.save(attachment).getId());
      attachment = attachmentRef.resolve();
      assertEquals("Foo", attachment.getProperty("String"));
      assertEquals(1, attachment.getProperty("Integer"));
      assertEquals(true, attachment.getProperty("Boolean"));
      assertEquals(2.2D, attachment.getProperty("Double"));
      assertEquals(3.3F, attachment.getProperty("Float"));

    } catch (PersistenceException e) {
      TestUtils.fail(e);
    }
  }
View Full Code Here

      news.getState();
      news.getTitle();
    }

    else if (type instanceof IAttachment) {
      IAttachment attachment = (IAttachment) type;
      attachment.getLength();
      attachment.getType();
      attachment.getLink();
    }

    else if (type instanceof ICategory) {
      ICategory category = (ICategory) type;
      category.getDomain();
View Full Code Here

        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* Check Attachment Added */
      final IAttachment attachment1 = fFactory.createAttachment(null, news1);
      attachment1.setLink(new URI("http://www.attachment1.com"));
      final IAttachment attachment2 = fFactory.createAttachment(null, news2);
      attachment2.setLink(new URI("http://www.attachment2.com"));
      final IAttachment attachment3 = fFactory.createAttachment(null, news3);
      attachment3.setLink(new URI("http://www.attachment3.com"));
      final boolean attachmentAdded[] = new boolean[3];
      attachmentListener = new AttachmentAdapter() {
        @Override
        public void entitiesAdded(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());

            IAttachment attachment = event.getEntity();

            if (attachment.getLink().equals(attachment1.getLink()))
              attachmentAdded[0] = true;

            else if (attachment.getLink().equals(attachment2.getLink()))
              attachmentAdded[1] = true;

            else if (attachment.getLink().equals(attachment3.getLink()))
              attachmentAdded[2] = true;

          }
        }
      };
View Full Code Here

        }
      };
      DynamicDAO.addEntityListener(IPerson.class, personListener);

      /* Check Attachments Added */
      final IAttachment attachment1 = fFactory.createAttachment(null, news);
      attachment1.setLink(new URI("http://www.attachment1.com"));
      final IAttachment attachment2 = fFactory.createAttachment(null, news);
      attachment2.setLink(new URI("http://www.attachment2.com"));
      final IAttachment attachment3 = fFactory.createAttachment(null, news);
      attachment3.setLink(new URI("http://www.attachment3.com"));
      final boolean attachmentAdded[] = new boolean[3];
      attachmentListener = new AttachmentAdapter() {
        @Override
        public void entitiesAdded(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());

            IAttachment attachment = event.getEntity();

            if (attachment.getLink().equals(attachment1.getLink()))
              attachmentAdded[0] = true;
            else if (attachment.getLink().equals(attachment2.getLink()))
              attachmentAdded[1] = true;
            else if (attachment.getLink().equals(attachment3.getLink()))
              attachmentAdded[2] = true;
          }
        }
      };
      DynamicDAO.addEntityListener(IAttachment.class, attachmentListener);
View Full Code Here

      FeedReference feedReference = new FeedReference(DynamicDAO.save(feed).getId());

      /* Check News Added */
      final INews news = fFactory.createNews(null, feedReference.resolve(), new Date());
      news.setTitle("News Title");
      final IAttachment attachment0 = fFactory.createAttachment(null, news);
      attachment0.setLink(new URI("http://www.attachment1.com"));
      final IAttachment attachment1 = fFactory.createAttachment(null, news);
      attachment1.setLink(new URI("http://www.attachment1.com"));
      DynamicDAO.save(feed);
      NewsReference newsRef = new NewsReference(feed.getNews().get(0).getId());
      AttachmentReference attachmentRef0 = new AttachmentReference(news.getAttachments().get(0).getId());
      AttachmentReference attachmentRef1 = new AttachmentReference(news.getAttachments().get(1).getId());

      final boolean[] newsDeleted = new boolean[1];
      newsListener = new NewsListener() {
        public void entitiesDeleted(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());
            if (event.getEntity().getTitle().equals(news.getTitle()))
              newsDeleted[0] = true;

            try {
              assertEquals(new URI("http://www.foobar.com").toString(), event.getEntity().getFeedReference().getLink().toString());
            } catch (URISyntaxException e) {
              fail(e.getMessage());
            }
          }
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesAdded(Set<NewsEvent> events) {
          fail("Unexpected event");
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* Check Attachments Added */
      final boolean attachmentDeleted[] = new boolean[2];
      attachmentListener = new AttachmentAdapter() {
        @Override
        public void entitiesDeleted(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());

            IAttachment attachment = event.getEntity();

            if (attachment.getLink().equals(attachment0.getLink()))
              attachmentDeleted[0] = true;
            if (attachment.getLink().equals(attachment1.getLink()))
              attachmentDeleted[1] = true;
          }
        }
      };
      DynamicDAO.addEntityListener(IAttachment.class, attachmentListener);
View Full Code Here

      FeedReference feedReference = new FeedReference(DynamicDAO.save(feed).getId());

      /* Check News Added */
      final INews news = fFactory.createNews(null, feedReference.resolve(), new Date());
      news.setTitle("News Title");
      final IAttachment attachment1 = fFactory.createAttachment(null, news);
      attachment1.setLink(new URI("http://www.attachment1.com"));
      DynamicDAO.save(news);

      final boolean[] newsUpdated = new boolean[1];
      newsListener = new NewsAdapter() {
        @Override
        public void entitiesUpdated(Set<NewsEvent> events) {
          for (NewsEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());
            if (event.getEntity().getTitle().equals(news.getTitle()))
              newsUpdated[0] = true;

            assertEquals(feedURI.toString(), event.getEntity().getFeedReference().getLink().toString());
            assertNotNull(event.getOldNews());
          }
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* Check Attachments Added */
      final boolean attachmentDeleted[] = new boolean[1];
      attachmentListener = new AttachmentAdapter() {
        @Override
        public void entitiesDeleted(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());

            IAttachment attachment = event.getEntity();

            if (attachment.getLink().equals(attachment1.getLink()))
              attachmentDeleted[0] = true;
          }
        }
      };
      DynamicDAO.addEntityListener(IAttachment.class, attachmentListener);

      IAttachment attachment = news.getAttachments().get(0);
      DynamicDAO.delete(attachment);

      assertNull(DynamicDAO.load(IAttachment.class, attachment.getId()));
      /* Asserts Follow */
      assertTrue("Missed newsUpdated Event in NewsListener!", newsUpdated[0]);
      assertTrue("Missed attachmentDeleted Event in PersonListener!", attachmentDeleted[0]);
    } finally {
      if (newsListener != null)
View Full Code Here

        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* Check Attachment Deleted */
      final IAttachment attachment1 = fFactory.createAttachment(null, newsRef1.resolve());
      final AttachmentReference attachmentRef1 = new AttachmentReference(DynamicDAO.save(attachment1).getId());
      final IAttachment attachment2 = fFactory.createAttachment(null, newsRef2.resolve());
      final AttachmentReference attachmentRef2 = new AttachmentReference(DynamicDAO.save(attachment2).getId());
      final IAttachment attachment3 = fFactory.createAttachment(null, newsRef3.resolve());
      final AttachmentReference attachmentRef3 = new AttachmentReference(DynamicDAO.save(attachment3).getId());

      final boolean attachmentDeleted[] = new boolean[3];
      attachmentListener = new AttachmentAdapter() {
        @Override
        public void entitiesDeleted(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());

            IAttachment attachment = event.getEntity();

            if (attachmentRef1.references(attachment))
              attachmentDeleted[0] = true;

            else if (attachmentRef2.references(attachment))
View Full Code Here

        @Override
        public void entitiesDeleted(Set<AttachmentEvent> events) {
          for (AttachmentEvent event : events) {
            assertFalse("Expected this Event to be no Root Event", event.isRoot());

            IAttachment attachment = event.getEntity();

            if (attachmentRef1.references(attachment))
              attachmentDeleted[0] = true;
            else if (attachmentRef2.references(attachment))
              attachmentDeleted[1] = true;
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.IAttachment

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.