Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IModelFactory


    return parent;
  }

  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, "");

    conditions.add(condition);

    return conditions;
  }
View Full Code Here


      setControl(control);
    }

    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, "");

      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 Pair<IFeed, IConditionalGet> reload(URI link, IProgressMonitor monitor, Map<Object, Object> properties) throws CoreException {
    IModelFactory typesFactory = Owl.getModelFactory();

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

    /* Add Monitor to support early cancelation */
    properties.put(IConnectionPropertyConstants.PROGRESS_MONITOR, monitor);

    /* Retrieve the InputStream out of the Feed's Link */
 
View Full Code Here

  public byte[] getFeedIcon(URI link) {
    return null;
  }

  private IConditionalGet getConditionalGet(URI link, InputStream inS) {
    IModelFactory typesFactory = Owl.getModelFactory();

    if (inS instanceof IConditionalGetCompatible) {
      String ifModifiedSince = ((IConditionalGetCompatible) inS).getIfModifiedSince();
      String ifNoneMatch = ((IConditionalGetCompatible) inS).getIfNoneMatch();

      if (ifModifiedSince != null || ifNoneMatch != null)
        return typesFactory.createConditionalGet(ifModifiedSince, link, ifNoneMatch);
    }

    return null;
  }
View Full Code Here

  @Override
  public boolean performFinish() {
    String link = fPage.getLink();
    String name = fPage.getBookmarkName();
    IFolder parent = fPage.getFolder();
    IModelFactory factory = Owl.getModelFactory();

    if (!StringUtils.isSet(link)) {
      fPage.setErrorMessage("Please enter the link to the feed.");
      fPage.focusInput(true);
      return false;
    }

    if (!StringUtils.isSet(name)) {
      fPage.setErrorMessage("Please enter a name for the new bookmark.");
      fPage.focusInput(false);
      return false;
    }

    URI uriObj = null;
    try {
      uriObj = new URI(link);
    } catch (URISyntaxException e) {
      fPage.setErrorMessage("Please enter a valid link.");
      fPage.focusInput(true);
      return false;
    }

    /* Check if a Feed with the URL already exists */
    FeedReference feedRef = DynamicDAO.getDAO(IFeedDAO.class).loadReference(uriObj);

    /* Create a new Feed then */
    if (feedRef == null) {
      IFeed feed = factory.createFeed(null, uriObj);
      feed = DynamicDAO.getDAO(IFeedDAO.class).save(feed);
    }

    /* Create the BookMark */
    FeedLinkReference feedLinkRef = new FeedLinkReference(uriObj);
    IBookMark bookmark = factory.createBookMark(null, parent, feedLinkRef, name);

    /* Copy all Properties from Parent into this Mark */
    Map<String, ?> properties = parent.getProperties();

    for (Map.Entry<String, ?> property : properties.entrySet())
View Full Code Here

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

    /* Require Name */
    if (!StringUtils.isSet(name)) {
      fPage.setErrorMessage("Please enter a name for the saved search");
      fPage.focusInput();
      return false;
    }

    /* Make sure Conditions are provided */
    if (fPage.fSearchConditionList.isEmpty()) {
      fPage.setErrorMessage("Please specify your search by defining some conditions below.");
      return false;
    }

    IFolder fParent = fPage.getFolder();

    ISearchMark searchMark = factory.createSearchMark(null, fParent, name);
    searchMark.setMatchAllConditions(fPage.fMatchAllRadio.getSelection());

    fPage.fSearchConditionList.createConditions(searchMark);

    DynamicDAO.save(fParent);
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.IS, 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, ""));

    return conditions;
  }
View Full Code Here

    return DATE_COL_WIDTH;
  }

  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, "");

    conditions.add(condition);

    return conditions;
  }
View Full Code Here

      }
    });
  }

  private void onCreateSavedSearch() {
    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.IS, ModelUtils.toPrimitive(searchScope)));

    /* Create Condition from Filter */
    Type filterType = fFeedView.getFilter().getType();
    switch (filterType) {
      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;
    }

    /* Create and Show SM Dialog */
    SearchMarkDialog dialog = new SearchMarkDialog(fParent.getShell(), OwlUI.getBookMarkExplorerSelection(), null, conditions, true);
View Full Code Here

  /*
   * @see org.rssowl.core.connection.IProtocolHandler#reload(java.net.URI,
   * org.eclipse.core.runtime.IProgressMonitor, java.util.Map)
   */
  public Pair<IFeed, IConditionalGet> 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 */
    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);

      /* 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("/", "");
      NewsgroupInfo groupInfo = new NewsgroupInfo();
      boolean selected = client.selectNewsgroup(newsgroup, groupInfo);

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

      /* Check Newsgroup Selected */
      if (!selected)
        throwConnectionException("Unable to select Newsgroup", client);

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

      /* First reload: Retrieve an initial amount of News */
      if (lastArticleId == null) {

        /* Set Article Pointer to last Article */
        int status = client.stat(groupInfo.getLastArticle());
        if (status != STATUS_ARTICLE_POINTER_OK)
          throwConnectionException("Unable to retrieve any 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;
        }
      }

      /* Subsequent reload: Set pointer to last retrieved News */
      else {

        /* Set Article Pointer to last retrieved News */
        int status = client.stat(lastArticleId);
        if (status != STATUS_ARTICLE_POINTER_OK)
          throwConnectionException("Unable to retrieve any News", client);

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

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

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

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

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

    return Pair.create(feed, conditionalGet);
  }
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.