Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.ISearchCondition


  public List<ISearchCondition> createConditions(ISearchMark searchmark) {
    List<ISearchCondition> conditions = new ArrayList<ISearchCondition>();

    /* For each Item */
    for (SearchConditionItem item : fItems) {
      ISearchCondition condition = item.createCondition(searchmark, true);
      if (condition != null)
        conditions.add(condition);
    }

    return conditions;
View Full Code Here


  private ISearchCondition getDefaultCondition() {
    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$

    return condition;
  }
View Full Code Here

  int indexOf(SearchConditionItem item) {
    return fItems.indexOf(item);
  }

  void onAdd(SearchConditionItem selectedItem, ISearchField field) {
    ISearchCondition condition = createCondition(selectedItem.createCondition(null, false));
    condition.setField(field);

    SearchConditionItem addedItem = addItem(condition, indexOf(selectedItem) + 1, true);
    addedItem.focusInput();

    fModified = true;
View Full Code Here

    fModified = true;
  }

  void onAdd(SearchConditionItem selectedItem) {
    ISearchCondition condition = createCondition(selectedItem.createCondition(null, false));
    SearchConditionItem addedItem = addItem(condition, indexOf(selectedItem) + 1, true);
    addedItem.focusInput();

    fModified = true;
  }
View Full Code Here

  /**
   * @return a {@link ISearchCondition} from the selection of the control or
   * <code>null</code> if none.
   */
  public ISearchCondition toScopeCondition() {
    ISearchCondition condition = null;
    Long[][] selection = getSelection();
    if (selection != null) {
      IModelFactory factory = Owl.getModelFactory();
      ISearchField field = factory.createSearchField(INews.LOCATION, INews.class.getName());
      condition = factory.createSearchCondition(field, SearchSpecifier.SCOPE, selection);
View Full Code Here

  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

  @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

    /* 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();
View Full Code Here

    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() {
        public void entitiesAdded(Set<SearchConditionEvent> events) {
          for (SearchConditionEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            searchConditionEvents[0] = true;
          }
        }

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

        public void entitiesUpdated(Set<SearchConditionEvent> events) {
          for (SearchConditionEvent event : events) {
            assertTrue("Expected this Event to be Root Event", event.isRoot());
            if (searchConditionReference[0].references(event.getEntity()))
              searchConditionEvents[2] = true;
          }
        }
      };
      DynamicDAO.addEntityListener(ISearchCondition.class, searchConditionListener);
      searchConditionReference[0] = new SearchConditionReference(DynamicDAO.save(searchCondition).getId());
      DynamicDAO.removeEntityListener(ISearchCondition.class, searchConditionListener);
      DynamicDAO.save(searchMark);
      searchMark = null;
      System.gc();

      /* Update */
      DynamicDAO.addEntityListener(ISearchCondition.class, searchConditionListener);
      searchCondition = searchConditionReference[0].resolve();
      searchCondition.setValue("Bar");
      searchCondition.setSpecifier(SearchSpecifier.CONTAINS_NOT);
      DynamicDAO.save(searchCondition);

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

View Full Code Here

    /* Add */
    IFolder folder = DynamicDAO.save(fFactory.createFolder(null, null, "Folder"));

    ISearchMark searchMark0 = DynamicDAO.save(fFactory.createSearchMark(null, folder, "SearchMark 0"));
    ISearchField field0 = fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
    ISearchCondition searchCondition0 = fFactory.createSearchCondition(null, searchMark0, field0, SearchSpecifier.CONTAINS, "Foo");
    DynamicDAO.save(searchCondition0);
    SearchConditionReference searchCondRef0 = new SearchConditionReference(searchCondition0.getId());

    ISearchField field1 = fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
    ISearchCondition searchCondition1 = fFactory.createSearchCondition(null, searchMark0, field1, SearchSpecifier.BEGINS_WITH, "Bar");
    DynamicDAO.save(searchCondition1);

    DynamicDAO.save(searchMark0);
    Long searchMark0Id = searchMark0.getId();

    ISearchMark searchMark1 = DynamicDAO.save(fFactory.createSearchMark(null, folder, "SearchMark 1"));
    ISearchField field2 = fFactory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
    ISearchCondition searchCondition2 = fFactory.createSearchCondition(null, searchMark1, field2, SearchSpecifier.CONTAINS, "Foo");
    DynamicDAO.save(searchCondition2);

    DynamicDAO.save(searchMark1);

    searchMark0 = null;
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.