Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.ISearchMark


   * the database.
   */
  @Test
  public void testDeleteSearchCondition() {
    IFolder folder = fTypesFactory.createFolder(null, null, "Folder");
    ISearchMark searchMark = fTypesFactory.createSearchMark(null, folder, "Mark");
    DynamicDAO.save(folder);
    ISearchField searchField = fTypesFactory.createSearchField(0, "SomeEntity");
    ISearchCondition searchCondition = fTypesFactory.createSearchCondition(null, searchMark, searchField, SearchSpecifier.BEGINS_WITH, "value");
    DynamicDAO.save(searchMark);
    assertNotNull(DynamicDAO.load(ISearchCondition.class, searchCondition.getId()));
    long searchFieldId = fDb.ext().getID(searchCondition.getField());
    assertNotNull(fDb.ext().getByID(searchFieldId));
    DynamicDAO.delete(searchCondition);
    assertNull(DynamicDAO.load(ISearchCondition.class, searchCondition.getId()));
    assertNull(fDb.ext().getByID(searchFieldId));
    assertEquals(0, searchMark.getSearchConditions().size());
  }
View Full Code Here


   * it appropriately to its children.
   */
  @Test
  public void testDeleteSearchMark() {
    IFolder folder = fTypesFactory.createFolder(null, null, "Folder");
    ISearchMark searchMark = fTypesFactory.createSearchMark(null, folder, "Mark");
    ISearchField searchField = fTypesFactory.createSearchField(0, "SomeEntity");
    ISearchCondition searchCondition = fTypesFactory.createSearchCondition(null, searchMark, searchField, SearchSpecifier.BEGINS_WITH, "value");
    DynamicDAO.save(folder);
    assertNotNull(DynamicDAO.load(ISearchMark.class, searchMark.getId()));
    assertNotNull(DynamicDAO.load(ISearchCondition.class, searchCondition.getId()));
    long searchFieldId = fDb.ext().getID(searchCondition.getField());
    assertNotNull(fDb.ext().getByID(searchFieldId));
    DynamicDAO.delete(searchMark);
    assertNull(DynamicDAO.load(ISearchMark.class, searchMark.getId()));
    assertNull(DynamicDAO.load(ISearchCondition.class, searchCondition.getId()));
    assertNull(fDb.ext().getByID(searchFieldId));
  }
View Full Code Here

      IBookMark child = createBookMark(root);
      child.setName(String.valueOf(i));
    }
    int count2 = count * 2;
    for (int i = count; i < count2; ++i) {
      ISearchMark child = createSearchMark(root);
      child.setName(String.valueOf(i));
    }
    root = DynamicDAO.save(root);
    int counter = 0;
    for (IMark child : root.getMarks()) {
      String name = String.valueOf(counter++);
      assertEquals(name, child.getName());
    }
  }
View Full Code Here

      assertEquals(name, child.getName());
    }
  }

  private ISearchMark createSearchMark(IFolder folder) {
    ISearchMark mark = fTypesFactory.createSearchMark(null, folder, "SomeName");
    mark.setCreationDate(new Date());
    mark.setLastVisitDate(createDate());
    mark.setPopularity(50);
    ISearchField field1 = fTypesFactory.createSearchField(INews.STATE, INews.class.getName());
    fTypesFactory.createSearchCondition(null, mark, field1, SearchSpecifier.IS, State.NEW);

    ISearchField field2 = fTypesFactory.createSearchField(INews.STATE, INews.class.getName());
    fTypesFactory.createSearchCondition(null, mark, field2, SearchSpecifier.IS, State.UPDATED);
View Full Code Here

  public void testFlatSearchMarkEvents() throws Exception {
    SearchMarkListener searchMarkListener = null;
    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);

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

View Full Code Here

  public void testFlatSearchConditionEvents() throws Exception {
    SearchConditionListener searchConditionListener = null;
    try {
      /* Add */
      FolderReference folderRef = new FolderReference(DynamicDAO.save(fFactory.createFolder(null, null, "Folder")).getId());
      ISearchMark searchMark = DynamicDAO.save(fFactory.createSearchMark(null, folderRef.resolve(), "SearchMark"));
      ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
      ISearchCondition searchCondition = fFactory.createSearchCondition(null, searchMark, field, SearchSpecifier.CONTAINS, "Foo");
      final boolean searchConditionEvents[] = new boolean[3];
      final SearchConditionReference searchConditionReference[] = new SearchConditionReference[1];
      searchConditionListener = new SearchConditionListener() {
View Full Code Here

    NewsCounterItem item = new NewsCounterItem(1, 2, 3);
    counter.put(bm.getFeedLinkReference().getLinkAsText(), item);
    DynamicDAO.save(counter);
    ((BookMark) bm).setNewsCounter(counter);

    ISearchMark sm = fFactory.createSearchMark(null, folder, "SM");
    sm.setProperty("key", "value");
    sm.setProperty("value", "key");

    ISearchCondition sc1 = fFactory.createSearchCondition(fFactory.createSearchField(INews.TITLE, INews.class.getName()), SearchSpecifier.IS, "foobar");
    ISearchCondition sc2 = fFactory.createSearchCondition(fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName()), SearchSpecifier.CONTAINS, "test");
    ISearchCondition sc3 = fFactory.createSearchCondition(fFactory.createSearchField(INews.PUBLISH_DATE, INews.class.getName()), SearchSpecifier.IS, new Date());

    sm.addSearchCondition(sc1);
    sm.addSearchCondition(sc2);
    sm.addSearchCondition(sc3);

    /* News Bin with News */
    INewsBin bin = fFactory.createNewsBin(null, folder, "NewsBin");
    DynamicDAO.save(folder);
    INews newsCopy = fFactory.createNews(news, bin);
View Full Code Here

      IFolder otherFolder = result.get(0);
      assertTrue(folder.getName().equals(otherFolder.getName()));
      assertTrue(folder.getProperties().equals(otherFolder.getProperties()));

      IBookMark bm = null;
      ISearchMark sm = null;
      List<IFolderChild> children = folder.getChildren();
      for (IFolderChild child : children) {
        if (child instanceof IBookMark)
          bm = (IBookMark) child;
        else if (child instanceof ISearchMark)
          sm = (ISearchMark) child;
      }

      IBookMark otherBM = null;
      ISearchMark otherSM = null;
      List<IFolderChild> otherChildren = otherFolder.getChildren();
      for (IFolderChild otherChild : otherChildren) {
        if (otherChild instanceof IBookMark)
          otherBM = (IBookMark) otherChild;
        else if (otherChild instanceof ISearchMark)
          otherSM = (ISearchMark) otherChild;
      }

      assertNotNull(bm);
      assertNotNull(sm);
      assertNotNull(otherBM);
      assertNotNull(otherSM);

      assertTrue(bm.getName().equals(otherBM.getName()));
      assertTrue(bm.getProperties().equals(otherBM.getProperties()));

      assertTrue(sm.getSearchConditions().size() == otherSM.getSearchConditions().size());
    }

    /* Assert Preference */
    List<IPreference> preferences = db.query(IPreference.class);
    assertEquals(preferences.size(), defragmentedDb.query(IPreference.class).size());
View Full Code Here

    children = secondSet.getChildren();
    assertEquals(4, children.size());
    IFolder folderB = null;
    IBookMark macOsHints = null;
    INewsBin binC = null;
    ISearchMark searchA = null;
    for (IFolderChild foo : children) {
      if (foo instanceof IFolder && "Folder B".equals(foo.getName()))
        folderB = (IFolder) foo;
      else if (foo instanceof IBookMark && "MacOSXHints.com".equals(foo.getName()))
        macOsHints = (IBookMark) foo;
      else if (foo instanceof INewsBin && "Bin C".equals(foo.getName()))
        binC = (INewsBin) foo;
      else if (foo instanceof ISearchMark && "Search A".equals(foo.getName()))
        searchA = (ISearchMark) foo;
    }

    assertEquals(2, searchA.getSearchConditions().size());
    List<ISearchCondition> conditions = searchA.getSearchConditions();
    for (ISearchCondition condition : conditions) {
      if (condition.getField().getId() == INews.LOCATION) {
        List<IFolderChild> entities = CoreUtils.toEntities((Long[][]) condition.getValue());
        assertEquals(1, entities.size());
        assertTrue(entities.contains(folderA));
View Full Code Here

    fFactory.createBookMark(null, folderA, new FeedLinkReference(new URI("bmB")), "BM Folder A");

    fFactory.createNewsBin(null, rootA, "BIN Root A");
    fFactory.createNewsBin(null, folderA, "BIN Folder A");

    ISearchMark smRootA = createSimpleSearchMark(rootA, "SM Root A");
    ISearchMark smRootALocation = createLocationSearchMark(rootA, "SM Root A Location");
    ISearchMark smFolderA = createSimpleSearchMark(folderA, "SM Folder A");
    ISearchMark smFolderALocation = createLocationSearchMark(folderA, "SM Folder A Location");

    rootA = DynamicDAO.save(rootA);

    IFolder rootB = fFactory.createFolder(null, null, "Root B");
    IFolder folderB = fFactory.createFolder(null, rootB, "Folder B");

    fFactory.createBookMark(null, rootB, new FeedLinkReference(new URI("bmC")), "BM Root B");
    fFactory.createBookMark(null, folderB, new FeedLinkReference(new URI("bmD")), "BM Folder B");

    fFactory.createNewsBin(null, rootB, "BIN Root B");
    fFactory.createNewsBin(null, folderB, "BIN Folder B");

    ISearchMark smRootB = createSimpleSearchMark(rootB, "SM Root B");
    ISearchMark smRootBAuthor = createAuthorSearchMark(rootB, "SM Root B Author");
    ISearchMark smFolderB = createSimpleSearchMark(folderB, "SM Folder B");
    ISearchMark smFolderBAuthor = createAuthorSearchMark(folderB, "SM Folder B Author");

    rootB = DynamicDAO.save(rootB);

    /* Start Testing */
    IFolder rootACopy = fFactory.createFolder(null, null, "Root A");
    IFolder folderACopy = fFactory.createFolder(null, rootACopy, "Folder A");

    fFactory.createNewsBin(null, rootA, "BIN Root A");
    fFactory.createNewsBin(null, folderACopy, "BIN Folder A");

    ISearchMark smRootACopy = createSimpleSearchMark(rootACopy, "SM Root A");
    ISearchMark smRootACopyLocation = createLocationSearchMark(rootACopy, "SM Root A Location");
    ISearchMark smFolderACopy = createSimpleSearchMark(folderACopy, "SM Folder A");
    ISearchMark smFolderACopyLocation = createLocationSearchMark(folderACopy, "SM Folder A Location");

    IFolder rootBCopy = fFactory.createFolder(null, null, "Root B");
    IFolder folderBCopy = fFactory.createFolder(null, rootBCopy, "Folder B");

    fFactory.createNewsBin(null, rootB, "BIN Root B");
    fFactory.createNewsBin(null, folderBCopy, "BIN Folder B");

    ISearchMark smRootBCopy = createSimpleSearchMark(rootBCopy, "SM Root B");
    ISearchMark smRootBAuthorCopy = createAuthorSearchMark(rootBCopy, "SM Root B Other");
    ISearchMark smFolderBCopy = createSimpleSearchMark(folderBCopy, "SM Folder B");
    ISearchMark smFolderBAuthorCopy = createSimpleSearchMark(folderBCopy, "SM Folder B");

    IFolder rootC = fFactory.createFolder(null, null, "Root C");
    IFolder folderC = fFactory.createFolder(null, rootC, "Folder C");

    fFactory.createNewsBin(null, rootC, "BIN Root C");
    fFactory.createNewsBin(null, folderC, "BIN Folder C");

    ISearchMark smRootC = createSimpleSearchMark(rootC, "SM Root C");
    ISearchMark smFolderC = createSimpleSearchMark(folderC, "SM Folder C");

    assertTrue(smRootA.getId() != -1);
    assertTrue(smRootALocation.getId() != -1);
    assertTrue(smFolderA.getId() != -1);
    assertTrue(smFolderALocation.getId() != -1);
View Full Code Here

TOP

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

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.