Package org.rssowl.core.persist.reference

Examples of org.rssowl.core.persist.reference.SearchMarkReference


    return super.toString() + "Search Conditions = " + fSearchConditions.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
  }

  /* getIdAsPrimitive is synchronized so this method doesn't need to be */
  public SearchMarkReference toReference() {
    return new SearchMarkReference(getIdAsPrimitive());
  }
View Full Code Here


    try {
      /* Add */
      final FolderReference folderRef = new FolderReference(DynamicDAO.save(fFactory.createFolder(null, null, "Folder")).getId());
      ISearchMark searchMark = fFactory.createSearchMark(null, folderRef.resolve(), "SearchMark");
      final boolean searchMarkEvents[] = new boolean[3];
      final SearchMarkReference searchMarkReference[] = new SearchMarkReference[1];
      searchMarkListener = new SearchMarkListener() {
        public void entitiesAdded(Set<SearchMarkEvent> events) {
          for (SearchMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getParent().getId().longValue());
            searchMarkEvents[0] = true;
          }
        }

        public void entitiesDeleted(Set<SearchMarkEvent> events) {
          for (SearchMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getParent().getId().longValue());
            if (searchMarkReference[0].references(event.getEntity()))
              searchMarkEvents[1] = true;
          }
        }

        public void entitiesUpdated(Set<SearchMarkEvent> events) {
          for (SearchMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getParent().getId().longValue());
            if (searchMarkReference[0].references(event.getEntity()))
              searchMarkEvents[2] = true;
          }
        }

        public void resultsChanged(Set<SearchMarkEvent> events) {
          fail("Unexpected event");
        }
      };
      DynamicDAO.addEntityListener(ISearchMark.class, searchMarkListener);
      searchMarkReference[0] = new SearchMarkReference(DynamicDAO.save(searchMark).getId());

      /* Update */
      searchMark = searchMarkReference[0].resolve();
      searchMark.setName("SearchMark Updated");
      DynamicDAO.save(searchMark);
View Full Code Here

      ISearchField field1 = fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
      fFactory.createSearchCondition(null, searchMark, field1, SearchSpecifier.BEGINS_WITH, "Bar");

      DynamicDAO.save(searchMark);

      SearchMarkReference searchMarkRef = new SearchMarkReference(searchMark.getId());
      int popularity = searchMark.getPopularity();
      Date lastVisitDate = searchMark.getLastVisitDate();

      if (lastVisitDate == null) {
        lastVisitDate = new Date();
      }
      Thread.sleep(100);

      ISearchMarkDAO dao = DynamicDAO.getDAO(ISearchMarkDAO.class);
      DynamicDAO.addEntityListener(ISearchCondition.class, listener);
      dao.visited(searchMark);
      searchMark = null;
      System.gc();

      searchMark = searchMarkRef.resolve();
      assertEquals(popularity + 1, searchMark.getPopularity());
      assertTrue(searchMark.getLastVisitDate().compareTo(lastVisitDate) > 0);
      assertTrue(searchMark.getLastVisitDate().compareTo(new Date()) < 0);
    } finally {
      DynamicDAO.removeEntityListener(ISearchCondition.class, listener);
View Full Code Here

      /* Check SearchMark Deleted */
      ISearchMark searchMark1 = fFactory.createSearchMark(null, rootRef.resolve(), "Root SearchMark");
      root = DynamicDAO.save(searchMark1.getParent());
      searchMark1 = (ISearchMark) root.getMarks().get(root.getMarks().size() - 1);
      final SearchMarkReference searchMarkRef1 = new SearchMarkReference(searchMark1.getId());

      ISearchMark searchMark2 = fFactory.createSearchMark(null, rootChildRef.resolve(), "Root Child SearchMark");
      rootChild = DynamicDAO.save(searchMark2.getParent());
      searchMark2 = (ISearchMark) rootChild.getMarks().get(rootChild.getMarks().size() - 1);
      final SearchMarkReference searchMarkRef2 = new SearchMarkReference(searchMark2.getId());

      ISearchMark searchMark3 = fFactory.createSearchMark(null, rootChildChild1ChildRef.resolve(), "Root Child Child #1 Child SearchMark");
      rootChildChild1Child = DynamicDAO.save(searchMark3.getParent());
      searchMark3 = (ISearchMark) rootChildChild1Child.getMarks().get(rootChildChild1Child.getMarks().size() - 1);
      final SearchMarkReference searchMarkRef3 = new SearchMarkReference(searchMark3.getId());

      final boolean searchMarkEventsIssued[] = new boolean[3];

      searchMarkListener = new SearchMarkAdapter() {
        @Override
        public void entitiesDeleted(Set<SearchMarkEvent> events) {
          for (SearchMarkEvent event : events) {
            ISearchMark searchMark = event.getEntity();

            if (searchMarkRef1.references(searchMark))
              searchMarkEventsIssued[0] = true;

            else if (searchMarkRef2.references(searchMark))
              searchMarkEventsIssued[1] = true;

            else if (searchMarkRef3.references(searchMark))
              searchMarkEventsIssued[2] = true;
          }
        }
      };
      DynamicDAO.addEntityListener(ISearchMark.class, searchMarkListener);
View Full Code Here

        if (end < 0)
          end = parameters.length();

        StringTokenizer tokenizer = new StringTokenizer(parameters.substring(start, end), ",");//$NON-NLS-1$
        while (tokenizer.hasMoreElements()) {
          SearchMarkReference ref = new SearchMarkReference(Long.valueOf((String) tokenizer.nextElement()));
          elements.addAll(Arrays.asList(newsContentProvider.getElements(ref)));
        }
      }

      /* Look for News that are to displayed */
 
View Full Code Here

    fMatchAllConditions = requiresAllConditions;
  }

  /* getIdAsPrimitive is synchronized so this method doesn't need to be */
  public SearchMarkReference toReference() {
    return new SearchMarkReference(getIdAsPrimitive());
  }
View Full Code Here

    try {
      /* Add */
      final FolderReference folderRef = new FolderReference(DynamicDAO.save(fFactory.createFolder(null, null, "Folder")).getId());
      ISearchMark searchMark = fFactory.createSearchMark(null, folderRef.resolve(), "SearchMark");
      final boolean searchMarkEvents[] = new boolean[3];
      final SearchMarkReference searchMarkReference[] = new SearchMarkReference[1];
      searchMarkListener = new SearchMarkListener() {
        public void entitiesAdded(Set<SearchMarkEvent> events) {
          for (SearchMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getParent().getId().longValue());
            searchMarkEvents[0] = true;
          }
        }

        public void entitiesDeleted(Set<SearchMarkEvent> events) {
          for (SearchMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getParent().getId().longValue());
            if (searchMarkReference[0].references(event.getEntity()))
              searchMarkEvents[1] = true;
          }
        }

        public void entitiesUpdated(Set<SearchMarkEvent> events) {
          for (SearchMarkEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            assertEquals(folderRef.getId(), event.getEntity().getParent().getId().longValue());
            if (searchMarkReference[0].references(event.getEntity()))
              searchMarkEvents[2] = true;
          }
        }

        public void newsChanged(Set<SearchMarkEvent> events) {
          fail("Unexpected event");
        }
      };
      DynamicDAO.addEntityListener(ISearchMark.class, searchMarkListener);
      searchMarkReference[0] = new SearchMarkReference(DynamicDAO.save(searchMark).getId());

      /* Update */
      searchMark = searchMarkReference[0].resolve();
      searchMark.setName("SearchMark Updated");
      DynamicDAO.save(searchMark);
View Full Code Here

      ISearchField field1 = fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
      fFactory.createSearchCondition(null, searchMark, field1, SearchSpecifier.BEGINS_WITH, "Bar");

      DynamicDAO.save(searchMark);

      SearchMarkReference searchMarkRef = new SearchMarkReference(searchMark.getId());
      int popularity = searchMark.getPopularity();
      Date lastVisitDate = searchMark.getLastVisitDate();

      if (lastVisitDate == null) {
        lastVisitDate = new Date();
      }
      Thread.sleep(100);

      ISearchMarkDAO dao = DynamicDAO.getDAO(ISearchMarkDAO.class);
      DynamicDAO.addEntityListener(ISearchCondition.class, listener);
      dao.visited(searchMark);
      searchMark = null;
      System.gc();

      searchMark = searchMarkRef.resolve();
      assertEquals(popularity + 1, searchMark.getPopularity());
      assertTrue(searchMark.getLastVisitDate().compareTo(lastVisitDate) > 0);
      assertTrue(searchMark.getLastVisitDate().compareTo(new Date()) < 0);
    } finally {
      DynamicDAO.removeEntityListener(ISearchCondition.class, listener);
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.reference.SearchMarkReference

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.