Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.ISearchCondition


  @Test
  public void testSearchMark() throws Exception {
    IFolder root = fFactory.createFolder(null, null, "Root");

    ISearchField field = fFactory.createSearchField(INews.IS_FLAGGED, INews.class.getName());
    ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, true);

    ISearchMark search = fFactory.createSearchMark(null, root, "Search");
    search.addSearchCondition(condition);

    DynamicDAO.save(root);
View Full Code Here


  @Test
  public void testLoadSearchFromCondition() throws Exception {
    IFolder root = fFactory.createFolder(null, null, "Root");

    ISearchField field = fFactory.createSearchField(INews.IS_FLAGGED, INews.class.getName());
    ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.IS, true);

    ISearchMark search = fFactory.createSearchMark(null, root, "Search");
    search.addSearchCondition(condition);

    DynamicDAO.save(root);
View Full Code Here

  private List<ISearchCondition> getDefaultConditions() {
    List<ISearchCondition> conditions = new ArrayList<ISearchCondition>(1);
    IModelFactory factory = Owl.getModelFactory();

    ISearchField field = factory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
    ISearchCondition condition = factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, ""); //$NON-NLS-1$

    conditions.add(condition);

    return conditions;
  }
View Full Code Here

    return conditions;
  }

  void onGenerateName() {
    List<ISearchCondition> conditions = fSearchConditionList.createConditions();
    ISearchCondition locationCondition = fLocationControl.toScopeCondition();
    if (locationCondition != null)
      conditions.add(locationCondition);

    String name = CoreUtils.getName(conditions, fMatchAllRadio.getSelection());
    if (name.length() > 0) {
View Full Code Here

      /* Delete from DB */
      DynamicDAO.deleteAll(oldConditions);

      /* Add New Conditions */
      fSearchConditionList.createConditions(mark);
      ISearchCondition locationCondition = fLocationControl.toScopeCondition();
      if (locationCondition != null)
        mark.addSearchCondition(locationCondition);
    }

    /* Re-Run search if conditions changed */
 
View Full Code Here

    waitForIndexer();

    /* Location IS Root Folder */
    {
      ISearchField field1 = fFactory.createSearchField(INews.LOCATION, fNewsEntityName);
      ISearchCondition cond1 = fFactory.createSearchCondition(field1, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { rootFolder })));

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(cond1), true);
      assertSame(result, news1Copy, news2Copy, news3CopyRoot, news3CopySubRoot, news4Copy, news5Copy, news6Copy);
    }

    /* Location IS Sub Folder */
    {
      ISearchField field1 = fFactory.createSearchField(INews.LOCATION, fNewsEntityName);
      ISearchCondition cond1 = fFactory.createSearchCondition(field1, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { subFolder })));

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(cond1), true);
      assertSame(result, news3CopySubRoot, news4Copy, news5Copy, news6Copy);
    }

    /* Location IS Root Bin */
    {
      ISearchField field1 = fFactory.createSearchField(INews.LOCATION, fNewsEntityName);
      ISearchCondition cond1 = fFactory.createSearchCondition(field1, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { rootBin })));

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(cond1), true);
      assertSame(result, news1Copy, news2Copy, news3CopyRoot);
    }

    /* Location IS Root Bin or Sub Root Bin */
    {
      ISearchField field1 = fFactory.createSearchField(INews.LOCATION, fNewsEntityName);
      ISearchCondition cond1 = fFactory.createSearchCondition(field1, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { rootBin })));

      ISearchField field2 = fFactory.createSearchField(INews.LOCATION, fNewsEntityName);
      ISearchCondition cond2 = fFactory.createSearchCondition(field2, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { subRootBin })));

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(cond1, cond2), false);
      assertSame(result, news1Copy, news2Copy, news3CopyRoot, news3CopySubRoot, news4Copy, news5Copy, news6Copy);
    }

    /* Location IS (Root Bin, Sub Root Bin) */
    {
      ISearchField field1 = fFactory.createSearchField(INews.LOCATION, fNewsEntityName);
      ISearchCondition cond1 = fFactory.createSearchCondition(field1, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { rootBin, subRootBin })));

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(cond1), false);
      assertSame(result, news1Copy, news2Copy, news3CopyRoot, news3CopySubRoot, news4Copy, news5Copy, news6Copy);
    }

    /* Location IS Sub Folder AND State is new */
    {
      ISearchField field1 = fFactory.createSearchField(INews.LOCATION, fNewsEntityName);
      ISearchCondition cond1 = fFactory.createSearchCondition(field1, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { subFolder })));

      ISearchField field2 = fFactory.createSearchField(INews.STATE, fNewsEntityName);
      ISearchCondition cond2 = fFactory.createSearchCondition(field2, SearchSpecifier.IS, EnumSet.of(INews.State.NEW));

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(cond1, cond2), true);
      assertSame(result, news4Copy, news6Copy);
    }
  }
View Full Code Here

      /* Wait for Indexer */
      waitForIndexer();

      /* All Fields */
      ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "(DVD)");

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(condition), false);
      assertSame(result, news1, news2);

      field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      ISearchCondition condition1 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "(DVD)");
      ISearchCondition condition2 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "no");

      result = fModelSearch.searchNews(list(condition1, condition2), true);
      assertSame(result, news1, news2);

      field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      condition1 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "(DVD)");
      condition2 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "no");
      ISearchCondition condition3 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "RadIO");

      result = fModelSearch.searchNews(list(condition1, condition2, condition3), true);
      assertSame(result, news1, news2);
    } catch (PersistenceException e) {
      TestUtils.fail(e);
View Full Code Here

      /* Wait for Indexer */
      waitForIndexer();

      /* All Fields */
      ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "Benjamin Pasero");

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(condition), false);
      assertSame(result, news1, news2, news3, news4, news5);

      field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      ISearchCondition condition1 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS, "Benjamin P*");

      result = fModelSearch.searchNews(list(condition1), false);
      assertSame(result, news1, news2, news3, news4, news5);

      field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
View Full Code Here

      /* Wait for Indexer */
      waitForIndexer();

      /* All Fields */
      ISearchField field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      ISearchCondition condition = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "(DVD)");

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(condition), false);
      assertSame(result, news1, news2);

      field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      condition = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "(DVD) description included");

      result = fModelSearch.searchNews(list(condition), false);
      assertSame(result, news2);

      field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      ISearchCondition condition1 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "(DVD)");
      ISearchCondition condition2 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "no");

      result = fModelSearch.searchNews(list(condition1, condition2), true);
      assertSame(result, news1, news2);

      field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      condition1 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "(DVD) no");

      result = fModelSearch.searchNews(list(condition1), true);
      assertSame(result, news1, news2);

      field = fFactory.createSearchField(IEntity.ALL_FIELDS, fNewsEntityName);
      condition1 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "(DVD)");
      condition2 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "no");
      ISearchCondition condition3 = fFactory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "RadIO");

      result = fModelSearch.searchNews(list(condition1, condition2, condition3), true);
      assertSame(result, news1, news2);
    } catch (PersistenceException e) {
      TestUtils.fail(e);
View Full Code Here

    waitForIndexer();

    /* Location IS Empty Folder */
    {
      ISearchField field1 = fFactory.createSearchField(INews.LOCATION, fNewsEntityName);
      ISearchCondition cond1 = fFactory.createSearchCondition(field1, SearchSpecifier.IS, ModelUtils.toPrimitive(Arrays.asList(new IFolderChild[] { emptyFolder })));

      List<SearchHit<NewsReference>> result = fModelSearch.searchNews(list(cond1), true);
      assertEquals(0, result.size());
    }
  }
View Full Code Here

TOP

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

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.