Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IModelFactory


    return Collections.emptyList();
  }

  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


  }

  private List<IFilterAction> getDefaultActions() {
    List<IFilterAction> defaultActions = new ArrayList<IFilterAction>(1);

    IModelFactory factory = Owl.getModelFactory();
    defaultActions.add(factory.createFilterAction(MoveNewsAction.ID));

    return defaultActions;
  }
View Full Code Here

      }
    });
  }

  private void onCreateSavedSearch(boolean withQuickSearch) {
    IModelFactory factory = Owl.getModelFactory();
    List<ISearchCondition> conditions = new ArrayList<ISearchCondition>(2);

    /* Create Condition from Location */
    List<IFolderChild> searchScope = new ArrayList<IFolderChild>(1);
    searchScope.add(((FeedViewInput) fFeedView.getEditorInput()).getMark());
    ISearchField field = factory.createSearchField(INews.LOCATION, INews.class.getName());
    conditions.add(factory.createSearchCondition(field, SearchSpecifier.SCOPE, ModelUtils.toPrimitive(searchScope)));

    /* Create Condition from Filter */
    Type filterType = fFeedView.getFilter().getType();
    switch (filterType) {
      case SHOW_ALL:
        if (!withQuickSearch) {
          field = factory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
          conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "")); //$NON-NLS-1$
        }
        break;

      case SHOW_NEW:
        field = factory.createSearchField(INews.STATE, INews.class.getName());
        conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, EnumSet.of(INews.State.NEW)));
        break;

      case SHOW_RECENT:
        field = factory.createSearchField(INews.AGE_IN_DAYS, INews.class.getName());
        conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS_LESS_THAN, 2));
        break;

      case SHOW_LAST_5_DAYS:
        field = factory.createSearchField(INews.AGE_IN_DAYS, INews.class.getName());
        conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS_LESS_THAN, 6));
        break;

      case SHOW_STICKY:
        field = factory.createSearchField(INews.IS_FLAGGED, INews.class.getName());
        conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, true));
        break;

      case SHOW_UNREAD:
        field = factory.createSearchField(INews.STATE, INews.class.getName());
        conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, INews.State.UNREAD, INews.State.UPDATED)));
        break;
    }

    /* Also add Quick Search if required */
    if (withQuickSearch) {
      SearchTarget target = fFeedView.getFilter().getSearchTarget();
      String text = fSearchInput.getText();

      /* Convert to Wildcard Query */
      if (StringUtils.isSet(text) && !text.endsWith("*")) //$NON-NLS-1$
        text = text + "*"; //$NON-NLS-1$

      switch (target) {
        case ALL:
          field = factory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
          conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, text));
          break;

        case HEADLINE:
          field = factory.createSearchField(INews.TITLE, INews.class.getName());
          conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, text));
          break;

        case ATTACHMENTS:
          field = factory.createSearchField(INews.ATTACHMENTS_CONTENT, INews.class.getName());
          conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, text));
          break;

        case AUTHOR:
          field = factory.createSearchField(INews.AUTHOR, INews.class.getName());
          conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, text));
          break;

        case CATEGORY:
          field = factory.createSearchField(INews.CATEGORIES, INews.class.getName());
          conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, text));
          break;

        case LABELS:
          field = factory.createSearchField(INews.LABEL, INews.class.getName());
          conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, text));
          break;

        case SOURCE:
          field = factory.createSearchField(INews.SOURCE, INews.class.getName());
          conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, text));
          break;
      }
    }

    /* Create and Show SM Dialog */
 
View Full Code Here

   * @see org.eclipse.jface.wizard.Wizard#performFinish()
   */
  @Override
  public boolean performFinish() {
    String name = fPage.getBinName();
    IModelFactory factory = Owl.getModelFactory();

    /* Require Name */
    if (!StringUtils.isSet(name)) {
      fPage.setErrorMessage(Messages.NewsBinWizard_ENTER_NAME);
      fPage.focusInput();
      return false;
    }

    /* Get the parent Folder */
    IFolder parent = fPage.getFolder();

    /* Create the NewsBin */
    INewsBin fNewsbin = factory.createNewsBin(null, parent, name, fPosition, fPosition != null ? true : null);

    /* Copy all Properties from Parent into this Mark */
    Map<String, Serializable> properties = parent.getProperties();
    for (Map.Entry<String, Serializable> property : properties.entrySet())
      fNewsbin.setProperty(property.getKey(), property.getValue());
View Full Code Here

   * @throws Exception
   * See http://dev.rssowl.org/show_bug.cgi?id=1107
   */
  @Test
  public void testDeleteFolderHierarchyWithBin() throws Exception {
    IModelFactory factory = Owl.getModelFactory();
    IFolder root = factory.createFolder(null, null, "Root");
    IFolder folder = factory.createFolder(null, root, "Folder");
    IFolder childFolder = factory.createFolder(null, folder, "Child Folder");

    IFeed feed = factory.createFeed(null, new URI("http://www.rssowl.org/rssowl2dg/tests/manager/rss_2_0.xml"));

    DynamicDAO.save(feed);

    IBookMark mark = factory.createBookMark(null, childFolder, new FeedLinkReference(feed.getLink()), "Bookmark");
    INewsBin bin = factory.createNewsBin(null, folder, "Bin");

    DynamicDAO.save(root);

    Controller.getDefault().reload(mark, null, new NullProgressMonitor());

    /* Move News to Bin */
    INews copiedNews = factory.createNews(feed.getNews().get(0), bin);
    DynamicDAO.save(copiedNews);
    DynamicDAO.save(bin);

    DynamicDAO.getDAO(INewsDAO.class).setState(Collections.singletonList(feed.getNews().get(0)), INews.State.HIDDEN, false, false);

View Full Code Here

  public SearchNewsDialog(Shell parentShell, List<IFolderChild> searchScope) {
    this(parentShell, toSearchConditions(searchScope), true, false);
  }

  private static List<ISearchCondition> toSearchConditions(List<IFolderChild> searchScope) {
    IModelFactory factory = Owl.getModelFactory();
    List<ISearchCondition> conditions = new ArrayList<ISearchCondition>(2);

    /* Add scope as condition if provided */
    if (!searchScope.isEmpty()) {
      ISearchField field = factory.createSearchField(INews.LOCATION, INews.class.getName());
      conditions.add(factory.createSearchCondition(field, SearchSpecifier.SCOPE, ModelUtils.toPrimitive(searchScope)));
    }

    /* Add default condition as well */
    ISearchField field = factory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
    conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "")); //$NON-NLS-1$

    return conditions;
  }
View Full Code Here

    return news.toArray();
  }

  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

  /*
   * @see org.rssowl.core.connection.IProtocolHandler#reload(java.net.URI,
   * org.eclipse.core.runtime.IProgressMonitor, java.util.Map)
   */
  public Triple<IFeed, IConditionalGet, URI> reload(URI link, IProgressMonitor monitor, Map<Object, Object> properties) throws CoreException {
    IModelFactory factory = Owl.getModelFactory();

    /* Create a new empty feed from the existing one */
    IFeed feed = factory.createFeed(null, link);

    /* Retrieve last article pointer (If-None-Match header value) */
    Integer lastArticleId = getLastArticleId(properties);

    /* Create a new HttpClient */
    NNTPClient client = new NNTPClient();

    try {

      /* Support early cancellation */
      if (monitor.isCanceled())
        return null;

      /* Connect to Server */
      if (link.getPort() != -1)
        client.connect(link.getHost(), link.getPort());
      else
        client.connect(link.getHost());

      /* Set Timeout */
      setTimeout(client, properties);

      /* Support early cancellation */
      if (monitor.isCanceled())
        return null;

      /* Authentication if provided */
      setupAuthentication(link, client);

      /* Check Authentication Required */
      checkAuthenticationRequired(client, link);

      /* Support early cancellation */
      if (monitor.isCanceled())
        return null;

      /* Enable Reader Mode */
      client.sendCommand(MODE_READER);

      /* Support early cancellation */
      if (monitor.isCanceled())
        return null;

      /* Select Newsgroup */
      String newsgroup = link.getPath().replace("/", ""); //$NON-NLS-1$ //$NON-NLS-2$
      NewsgroupInfo groupInfo = new NewsgroupInfo();
      boolean selected = client.selectNewsgroup(newsgroup, groupInfo);

      /* Check Authentication Required */
      checkAuthenticationRequired(client, link);

      /* Check Newsgroup Selected */
      if (!selected)
        throwConnectionException(Messages.NewsGroupHandler_ERROR_SELECT_NEWSGROUP, client);

      /* Support early cancellation */
      if (monitor.isCanceled())
        return null;

      boolean downloadWithoutPointer = (lastArticleId == null); //Last article servers as pointer

      /* Subsequent reload: Set pointer to last retrieved News and go from there */
      if (lastArticleId != null) {

        /* Set Article Pointer to last retrieved News */
        int status = client.stat(lastArticleId);
        if (status == NO_SUCH_ARTICLE_ERROR)
          downloadWithoutPointer = true; //This can happen if the last article id was not found, grab the latest news then
        else if (status != STATUS_ARTICLE_POINTER_OK)
          throwConnectionException(Messages.NewsGroupHandler_ERROR_RETRIEVE_NEWS, client);

        /* Retrieve all the following News */
        if (!downloadWithoutPointer) {
          while (client.next() == STATUS_ARTICLE_POINTER_OK && !monitor.isCanceled())
            createNews(client.retrieveArticle(), feed, monitor);
        }
      }

      /* Retrieve the last 50 News of the group */
      if (downloadWithoutPointer) {

        /* Set Article Pointer to last Article */
        int status = client.stat(groupInfo.getLastArticle());
        if (status != STATUS_ARTICLE_POINTER_OK)
          throwConnectionException(Messages.NewsGroupHandler_ERROR_RETRIEVE_NEWS, client);

        /* Retrieve initial news */
        for (int i = 0; i < INITIAL_NEWS && !monitor.isCanceled(); i++) {
          createNews(client.retrieveArticle(), feed, monitor);

          /* Goto previous news if provided */
          int result = client.last();
          if (result != STATUS_ARTICLE_POINTER_OK)
            break;
        }
      }

      /* Remember last article's ID */
      lastArticleId = groupInfo.getLastArticle();
    }

    /* Wrap Exceptions */
    catch (IOException e) {
      throw new ConnectionException(Activator.createErrorStatus(e.getMessage(), e));
    }

    /* Disconnect */
    finally {
      try {
        if (client.isConnected())
          client.disconnect();
      } catch (IOException e) {
        throw new ConnectionException(Activator.createErrorStatus(e.getMessage(), e));
      }
    }

    /* Create Conditional Get Object */
    IConditionalGet conditionalGet = null;
    if (lastArticleId != null)
      conditionalGet = factory.createConditionalGet(null, link, String.valueOf(lastArticleId));

    return Triple.create(feed, conditionalGet, link);
  }
View Full Code Here

    /* In case Article is unavailable */
    if (articleReader == null)
      return;

    IModelFactory factory = Owl.getModelFactory();
    final INews news = factory.createNews(null, feed, new Date());
    final Map<String, StringBuilder> mimeToContent = new HashMap<String, StringBuilder>();

    /* Create parser for this message */
    final MimeStreamParser parser = new MimeStreamParser();
    parser.setContentHandler(new AbstractContentHandler() {
View Full Code Here

   * @see org.eclipse.jface.wizard.Wizard#performFinish()
   */
  @Override
  public boolean performFinish() {
    String name = fPage.getSearchMarkName();
    IModelFactory factory = Owl.getModelFactory();

    /* Generate Name if necessary */
    if (!StringUtils.isSet(name)) {
      fPage.onGenerateName();
      name = fPage.getSearchMarkName();
    }

    /* Make sure Conditions are provided */
    if (fPage.fSearchConditionList.isEmpty()) {
      fPage.setErrorMessage(Messages.SearchMarkWizard_SPECIFY_SEARCH);
      return false;
    }

    IFolder folder = fPage.getFolder();

    ISearchMark searchMark = factory.createSearchMark(null, folder, name, fPosition, fPosition != null ? true : null);
    searchMark.setMatchAllConditions(fPage.fMatchAllRadio.getSelection());

    fPage.fSearchConditionList.createConditions(searchMark);
    ISearchCondition locationCondition = fPage.getScopeCondition();
    if (locationCondition != null)
View Full Code Here

TOP

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

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.