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_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 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, IProgressMonitor monitor) {
    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

  @Test
  public void testNormalize() throws Exception {
    CoreUtils.normalize(null);
    CoreUtils.normalize(Collections.EMPTY_LIST);

    IModelFactory factory = Owl.getModelFactory();
    IFolder root = factory.createFolder(null, null, "Root");
    IFolder folder1 = factory.createFolder(null, root, "Folder 1");
    IFolder folder2 = factory.createFolder(null, root, "Folder 2");
    IFolder folder3 = factory.createFolder(null, folder2, "Folder 3");
    IBookMark mark1 = factory.createBookMark(null, root, new FeedLinkReference(new URI("#")), "Mark 1");
    IBookMark mark2 = factory.createBookMark(null, folder1, new FeedLinkReference(new URI("#")), "Mark 2");
    IBookMark mark3 = factory.createBookMark(null, folder2, new FeedLinkReference(new URI("#")), "Mark 3");
    IBookMark mark4 = factory.createBookMark(null, folder3, new FeedLinkReference(new URI("#")), "Mark 4");

    List<IEntity> entities = new ArrayList<IEntity>();
    entities.add(root);
    CoreUtils.normalize(entities);
    assertEquals(1, entities.size());
View Full Code Here

  private static boolean isLocationScopeCondition(ISearchCondition condition) {
    return condition.getSpecifier() == SearchSpecifier.SCOPE;
  }

  private static BooleanClause createAllNewsFieldsClause(Analyzer analyzer, ISearchCondition condition, boolean matchAllConditions) throws IOException {
    IModelFactory factory = Owl.getModelFactory();
    BooleanQuery allFieldsQuery = new BooleanQuery();

    /* Require all words to be contained or not contained */
    if (condition.getSpecifier() == SearchSpecifier.CONTAINS_ALL) {
      List<ISearchCondition> tokenConditions = new ArrayList<ISearchCondition>();

      List<String> tokens = StringUtils.tokenizePhraseAware((String) condition.getValue(), true);
      for (String token : tokens) {
        ISearchCondition tokenCondition = factory.createSearchCondition(condition.getField(), condition.getSpecifier(), token);

        /* Rewrite Specifier */
        if (condition.getSpecifier() == SearchSpecifier.CONTAINS_ALL)
          tokenCondition.setSpecifier(SearchSpecifier.CONTAINS);
        else
          tokenCondition.setSpecifier(SearchSpecifier.CONTAINS_NOT);

        tokenConditions.add(tokenCondition);
      }

      /* Build custom Query out of Conditions */
      for (ISearchCondition tokenCondition : tokenConditions) {
        BooleanClause tokenClause = createAllNewsFieldsClause(analyzer, tokenCondition, matchAllConditions);

        /* Ignore empty clauses (e.g. due to Stop Words) */
        if (tokenClause.getQuery() instanceof BooleanQuery && ((BooleanQuery) tokenClause.getQuery()).getClauses().length == 0)
          continue;

        tokenClause.setOccur(Occur.MUST);
        allFieldsQuery.add(tokenClause);
      }
    }

    /* Require any word to be contained or not contained */
    else {
      List<ISearchCondition> allFieldsConditions = new ArrayList<ISearchCondition>(5);

      /* Title */
      ISearchField field = factory.createSearchField(INews.TITLE, condition.getField().getEntityName());
      allFieldsConditions.add(factory.createSearchCondition(field, condition.getSpecifier(), condition.getValue()));

      /* Description */
      field = factory.createSearchField(INews.DESCRIPTION, condition.getField().getEntityName());
      allFieldsConditions.add(factory.createSearchCondition(field, condition.getSpecifier(), condition.getValue()));

      /* Author */
      field = factory.createSearchField(INews.AUTHOR, condition.getField().getEntityName());
      allFieldsConditions.add(factory.createSearchCondition(field, condition.getSpecifier(), condition.getValue()));

      /* Category (Phrase search stripped because unsupported */
      field = factory.createSearchField(INews.CATEGORIES, condition.getField().getEntityName());
      List<String> tokens = StringUtils.tokenizePhraseAware(condition.getValue().toString(), false);
      if (!tokens.contains(condition.getValue().toString()))
        tokens.add(condition.getValue().toString());
      for (String token : tokens) {
        if (token.length() != 0)
          allFieldsConditions.add(factory.createSearchCondition(field, condition.getSpecifier().isNegation() ? SearchSpecifier.IS_NOT : SearchSpecifier.IS, token));
      }

      /* Attachment Content */
      field = factory.createSearchField(INews.ATTACHMENTS_CONTENT, condition.getField().getEntityName());
      allFieldsConditions.add(factory.createSearchCondition(field, condition.getSpecifier(), condition.getValue()));

      /* Create Clauses out of Conditions */
      boolean anyClauseIsEmpty = false;
      List<BooleanClause> clauses = new ArrayList<BooleanClause>();
      for (ISearchCondition allFieldCondition : allFieldsConditions) {
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(Messages.FolderWizard_ENTER_NAME);
      fPage.focusInput();
      return false;
    }

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

    /* Create the Folder */
    IFolder folder = factory.createFolder(null, parent, name);

    /* Copy all Properties from Parent into this Mark */
    if (parent != null) {
      Map<String, Serializable> properties = parent.getProperties();
      for (Map.Entry<String, Serializable> property : properties.entrySet())
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

   * @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

    OwlUI.adjustSizeForScrollbar(getShell(), getVerticalBar(), wasScrollbarShowing);
  }

  private IFilterAction createAction(IFilterAction current) {
    IModelFactory factory = Owl.getModelFactory();
    return factory.createFilterAction(current.getActionId());
  }
View Full Code Here

    IModelFactory factory = Owl.getModelFactory();
    return factory.createFilterAction(current.getActionId());
  }

  private IFilterAction getDefaultAction() {
    IModelFactory factory = Owl.getModelFactory();
    return factory.createFilterAction(MoveNewsAction.ID); //TODO Layer break
  }
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.