Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.ISearch


    return filterMatchedAll || !filteredNews.isEmpty();
  }

  private boolean needToIndexDescription(Set<ISearchFilter> filters) {
    for (ISearchFilter filter : filters) {
      ISearch search = filter.getSearch();
      if (search != null) {
        List<ISearchCondition> conditions = search.getSearchConditions();
        for (ISearchCondition condition : conditions) {
          int fieldId = condition.getField().getId();
          if (fieldId == IEntity.ALL_FIELDS || fieldId == INews.DESCRIPTION)
            return true;
        }
View Full Code Here


  }

  private void doTestAddUpdateGetAndDeleteSearchFilter(boolean gc) {
    /* Add */
    {
      ISearch search = fTypesFactory.createSearch(null);
      search.setMatchAllConditions(true);

      ISearchCondition condition1 = fTypesFactory.createSearchCondition(fTypesFactory.createSearchField(INews.TITLE, INews.class.getName()), SearchSpecifier.IS, "Foo");
      search.addSearchCondition(condition1);
      ISearchCondition condition2 = fTypesFactory.createSearchCondition(fTypesFactory.createSearchField(INews.ATTACHMENTS_CONTENT, INews.class.getName()), SearchSpecifier.CONTAINS, "Bar");
      search.addSearchCondition(condition2);

      ISearchFilter filter = fTypesFactory.createSearchFilter(null, search, "Filter");
      filter.setEnabled(true);
      filter.setOrder(5);

      IFilterAction action = fTypesFactory.createFilterAction("org.rssowl.ActionId1");
      action.setData(100);
      filter.addAction(action);

      action = fTypesFactory.createFilterAction("org.rssowl.ActionId2");
      action.setData(new Long[] { 1l, 2l, 3l });
      filter.addAction(action);

      filter = DynamicDAO.save(filter);
      if (gc)
        System.gc();

      Collection<ISearchFilter> filters = DynamicDAO.loadAll(ISearchFilter.class);
      assertEquals(1, filters.size());
      ISearchFilter savedFilter = filters.iterator().next();
      assertEquals(filter.getName(), savedFilter.getName());
      assertEquals(filter.getOrder(), savedFilter.getOrder());
      assertEquals(filter.isEnabled(), savedFilter.isEnabled());

      List<IFilterAction> actions = savedFilter.getActions();
      assertEquals(2, actions.size());
      assertEquals("org.rssowl.ActionId1", actions.get(0).getActionId());
      assertEquals(100, actions.get(0).getData());
      assertEquals("org.rssowl.ActionId2", actions.get(1).getActionId());
      assertEquals(true, Arrays.equals((Object[]) actions.get(1).getData(), new Long[] { 1l, 2l, 3l }));

      ISearch savedSearch = savedFilter.getSearch();
      assertEquals(search.matchAllConditions(), savedSearch.matchAllConditions());
      List<ISearchCondition> savedConditions = savedSearch.getSearchConditions();
      assertEquals(2, savedConditions.size());

      assertEquals(true, ((SearchCondition) savedConditions.get(0)).isIdentical(condition1));
      assertEquals(true, ((SearchCondition) savedConditions.get(1)).isIdentical(condition2));
    }

    /* Update */
    {
      Collection<ISearchFilter> filters = DynamicDAO.loadAll(ISearchFilter.class);
      ISearchFilter savedFilter = filters.iterator().next();

      savedFilter.setName("Disabled Filter");
      savedFilter.setEnabled(false);
      savedFilter.setOrder(1);

      List<IFilterAction> actions = savedFilter.getActions();
      savedFilter.removeAction(actions.get(0));
      actions.get(1).setData(new Long[] { 3l, 2l, 1l });
      IFilterAction action = fTypesFactory.createFilterAction("org.rssowl.ActionId3");
      action.setData(200);
      savedFilter.addAction(action);

      ISearch savedSearch = savedFilter.getSearch();
      savedSearch.setMatchAllConditions(false);
      List<ISearchCondition> savedConditions = savedSearch.getSearchConditions();

      ISearchCondition condition1 = savedConditions.get(0);
      condition1.setSpecifier(SearchSpecifier.CONTAINS_NOT);
      savedSearch.removeSearchCondition(savedConditions.get(1));

      ISearchCondition condition2 = fTypesFactory.createSearchCondition(fTypesFactory.createSearchField(INews.LOCATION, INews.class.getName()), SearchSpecifier.IS, new Long[][] { { 2l } });
      savedSearch.addSearchCondition(condition2);

      DynamicDAO.save(savedFilter);
      if (gc)
        System.gc();

      filters = DynamicDAO.loadAll(ISearchFilter.class);
      assertEquals(1, filters.size());
      ISearchFilter loadedFilter = filters.iterator().next();
      assertEquals(savedFilter.getName(), loadedFilter.getName());
      assertEquals(savedFilter.getOrder(), loadedFilter.getOrder());
      assertEquals(savedFilter.isEnabled(), loadedFilter.isEnabled());

      List<IFilterAction> loadedActions = loadedFilter.getActions();
      assertEquals(2, loadedActions.size());
      assertEquals("org.rssowl.ActionId2", loadedActions.get(0).getActionId());
      assertEquals(true, Arrays.equals((Object[]) actions.get(1).getData(), new Long[] { 3l, 2l, 1l }));
      assertEquals("org.rssowl.ActionId3", loadedActions.get(1).getActionId());
      assertEquals(200, loadedActions.get(1).getData());

      ISearch loadedSearch = loadedFilter.getSearch();
      assertEquals(savedSearch.matchAllConditions(), loadedSearch.matchAllConditions());
      List<ISearchCondition> loadedConditions = loadedSearch.getSearchConditions();
      assertEquals(2, loadedConditions.size());

      assertEquals(true, ((SearchCondition) loadedConditions.get(0)).isIdentical(condition1));
      assertEquals(true, ((SearchCondition) loadedConditions.get(1)).isIdentical(condition2));
    }
View Full Code Here

   */
  @Test
  public void testDeleteSearchFilter() throws Exception {
    ISearchField field = fFactory.createSearchField(INews.IS_FLAGGED, INews.class.getName());
    ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, true);
    ISearch search = fFactory.createSearch(null);
    search.addSearchCondition(condition);

    ISearchFilter filter = fFactory.createSearchFilter(null, search, "Filter");
    DynamicDAO.save(filter);

    assertNotNull(filter.toReference().resolve());
    assertNotNull(search.toReference().resolve());
    assertNotNull(condition.toReference().resolve());

    DynamicDAO.delete(filter);

    assertNull(filter.toReference().resolve());
    assertNull(search.toReference().resolve());
    assertNull(condition.toReference().resolve());
  }
View Full Code Here

    pref = new Preference("integer");
    pref.putIntegers(8);
    DynamicDAO.save(pref);

    /* ISearchFilter with ISearch */
    ISearch search = fFactory.createSearch(null);
    sc1 = fFactory.createSearchCondition(fFactory.createSearchField(INews.TITLE, INews.class.getName()), SearchSpecifier.IS, "foobar");
    sc2 = fFactory.createSearchCondition(fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName()), SearchSpecifier.CONTAINS, "test");
    sc3 = fFactory.createSearchCondition(fFactory.createSearchField(INews.PUBLISH_DATE, INews.class.getName()), SearchSpecifier.IS, new Date());
    search.addSearchCondition(sc1);
    search.addSearchCondition(sc2);
    search.addSearchCondition(sc3);

    ISearchFilter filter = fFactory.createSearchFilter(null, search, "filter");
    filter.addAction(fFactory.createFilterAction("action1"));
    filter.addAction(fFactory.createFilterAction("action2"));

View Full Code Here

      ISearchFilter otherFilter = (ISearchFilter) result.get(0);
      assertTrue(filter.getName().equals(otherFilter.getName()));
      assertEquals(filter.getActions().size(), otherFilter.getActions().size());

      ISearch search = filter.getSearch();
      ISearch otherSearch = otherFilter.getSearch();

      assertEquals(search.getSearchConditions().size(), otherSearch.getSearchConditions().size());
    }

    /* Assert Conditional Get */
    List<IConditionalGet> condGets = db.query(IConditionalGet.class);
    assertEquals(condGets.size(), defragmentedDb.query(IConditionalGet.class).size());
View Full Code Here

    filter.addAction(fFactory.createFilterAction("org.rssowl.core.MarkReadNewsAction"));
    filter.addAction(fFactory.createFilterAction("org.rssowl.core.MarkStickyNewsAction"));
    DynamicDAO.save(filter);

    /* 3) Entire News contains "Foo" - Enabled - Mark Read */
    ISearch search = fFactory.createSearch(null);
    ISearchField entireNewsField = fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
    search.addSearchCondition(fFactory.createSearchCondition(entireNewsField, SearchSpecifier.CONTAINS, "Foo"));
    filter = fFactory.createSearchFilter(null, search, "Filter 3");
    filter.setMatchAllNews(false);
    filter.setOrder(3);
    filter.addAction(fFactory.createFilterAction("org.rssowl.core.MarkReadNewsAction"));
    DynamicDAO.save(filter);

    /* 4) Entire News contains "Foo" or "Bar" - Enabled - Mark Read */
    search = fFactory.createSearch(null);
    search.setMatchAllConditions(true);
    search.addSearchCondition(fFactory.createSearchCondition(entireNewsField, SearchSpecifier.CONTAINS, "Foo"));
    search.addSearchCondition(fFactory.createSearchCondition(entireNewsField, SearchSpecifier.CONTAINS, "Bar"));
    filter = fFactory.createSearchFilter(null, search, "Filter 4");
    filter.setMatchAllNews(false);
    filter.setOrder(4);
    filter.addAction(fFactory.createFilterAction("org.rssowl.core.MarkReadNewsAction"));
    DynamicDAO.save(filter);

    /* 5) Location is "XY" - Enabled - Mark Read */
    search = fFactory.createSearch(null);
    ISearchField locationField = fFactory.createSearchField(INews.LOCATION, INews.class.getName());
    search.addSearchCondition(fFactory.createSearchCondition(locationField, SearchSpecifier.SCOPE, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { fBookMark1, fNewsBin }))));
    filter = fFactory.createSearchFilter(null, search, "Filter 5");
    filter.setMatchAllNews(false);
    filter.setOrder(8);
    filter.addAction(fFactory.createFilterAction("org.rssowl.core.MarkReadNewsAction"));
    DynamicDAO.save(filter);
View Full Code Here

  /**
   * @throws Exception
   */
  @Test
  public void testSearchReference() throws Exception {
    ISearch search = fFactory.createSearch(null);
    search = DynamicDAO.save(search);

    assertEquals(search, search.toReference().resolve());
  }
View Full Code Here

    INews news3 = createNews(feed, "News3");
    news3.setState(INews.State.NEW);

    {
      ISearch search = createStickySearch(true);

      ISearchFilter filter = fFactory.createSearchFilter(null, search, "New News");
      filter.setEnabled(true);

      IFilterAction action = fFactory.createFilterAction(STOP_FILTER_ID);
View Full Code Here

    INews news3 = createNews(feed, "News3");
    news3.setState(INews.State.NEW);

    {
      ISearch search = createStickySearch(true);

      ISearchFilter filter = fFactory.createSearchFilter(null, search, "New News");
      filter.setEnabled(false);

      IFilterAction action = fFactory.createFilterAction(STOP_FILTER_ID);
View Full Code Here

      DynamicDAO.save(filter);
    }

    {
      ISearch search = createStickySearch(true);

      ISearchFilter filter = fFactory.createSearchFilter(null, search, "New News");
      filter.setEnabled(true);

      IFilterAction action = fFactory.createFilterAction(STOP_FILTER_ID);
View Full Code Here

TOP

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

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.