Package com.db4o.query

Examples of com.db4o.query.Query


    return feed;
  }
 
  private <T extends IEntity>T loadEntity(Class<T> klass, long id)  {
    try {
      Query query = fDb.query();
      query.constrain(klass);
      query.descend("fId").constrain(Long.valueOf(id)); //$NON-NLS-1$

      @SuppressWarnings("unchecked")
      ObjectSet<T> set = query.execute();
      for (T entity : set) {
        // TODO Activate completely by default for now. Must decide how to deal
        // with this.
        fDb.activate(entity, Integer.MAX_VALUE);
        return entity;
View Full Code Here


    fDb.delete(searchCondition.getField());
  }

  @SuppressWarnings("unchecked")
  private ISearchMark getSearchMark(ISearchCondition searchCondition) {
    Query query = fDb.query();
    query.constrain(ISearchMark.class);
    query.descend("fSearchConditions").constrain(searchCondition);
    List<ISearchMark> marks = query.execute();
    if (marks.size() != 1)
      throw new IllegalStateException("searchCondition has less than or more than 1 parent ISearchMark");

    return marks.get(0);
  }
View Full Code Here

    return entities.contains(entity);
  }

  private void deleteFeedIfNecessary(IBookMark mark) {
    //TODO Share logic with IApplicationLayer method that does the same
    Query query = fDb.query();
    query.constrain(Feed.class);
    query.descend("fLinkText").constrain(mark.getFeedLinkReference().getLink().toString()); //$NON-NLS-1$
    @SuppressWarnings("unchecked")
    List<IFeed> feeds = query.execute();
    for (IFeed feed : feeds) {
      if(onlyBookMarkReference(feed)) {
        fDb.delete(feed);
      }
    }
View Full Code Here

    }
  }

  private boolean onlyBookMarkReference(IFeed feed) {
    //TODO Share logic with IApplicationLayer method that does the same
    Query query = fDb.query();
    query.constrain(BookMark.class);
    query.descend("fFeedLink").constrain(feed.getLink().toString()); //$NON-NLS-1$

    @SuppressWarnings("unchecked")
    List<IBookMark> marks = query.execute();

    if (marks.size() == 1) {
      return true;
    }
    return false;
View Full Code Here

    return new FolderEvent(entity, null, true);
  }

  public Collection<IFolder> loadRoots() {
    try {
      Query query = fDb.query();
      query.constrain(fEntityClass);
      query.descend("fParent").constrain(null); //$NON-NLS-1$
      List<IFolder> folders = getList(query);
      activateAll(folders);
      return new ArrayList<IFolder>(folders);
    } catch (Db4oException e) {
      throw new PersistenceException(e);
View Full Code Here

  }

  public IConditionalGet load(URI link) {
    Assert.isNotNull(link, "link cannot be null"); //$NON-NLS-1$
    try {
      Query query = fDb.query();
      query.constrain(fEntityClass);
      query.descend("fLink").constrain(link.toString()); //$NON-NLS-1$

      for (IConditionalGet entity : getList(query)) {
        fDb.activate(entity, Integer.MAX_VALUE);
        return entity;
      }
View Full Code Here

    List<NewsBin> newsBins = oc.query(NewsBin.class);

    for (INewsBin newsBin : newsBins) {
      oc.activate(newsBin, Integer.MAX_VALUE);
      for (NewsReference newsRef : newsBin.getNewsRefs()) {
        Query query = oc.query();
        query.constrain(News.class);
        query.descend("fId").constrain(newsRef.getId()); //$NON-NLS-1$
        News news = (News) query.execute().iterator().next();
        oc.activate(news, Integer.MAX_VALUE);
        String parentIdFieldName = "fParentId"; //$NON-NLS-1$
        MigrationHelper.setField(news, parentIdFieldName, newsBin.getId().longValue());
        oc.ext().store(news, Integer.MAX_VALUE);
      }
View Full Code Here

    return !getFeeds(db, link).isEmpty();
  }

  @SuppressWarnings("unchecked")
  private static List<Feed> getFeeds(ObjectContainer db, URI link) {
    Query query = db.query();
    query.constrain(Feed.class);
    query.descend("fLinkText").constrain(link.toString()); //$NON-NLS-1$
    List<Feed> set = query.execute();
    return set;
  }
View Full Code Here

    return marks.size();
  }

  @SuppressWarnings("unchecked")
  public static Collection<IBookMark> loadAllBookMarks(ObjectContainer db, FeedLinkReference feedRef) {
    Query query = db.query();
    query.constrain(BookMark.class);
    query.descend("fFeedLink").constrain(feedRef.getLink().toString()); //$NON-NLS-1$
    return query.execute();
  }
View Full Code Here

    query.descend("fFeedLink").constrain(feedRef.getLink().toString()); //$NON-NLS-1$
    return query.execute();
  }

  static boolean feedHasNewsWithCopies(ObjectContainer db, FeedLinkReference feedRef) {
    Query query = db.query();
    query.constrain(News.class);
    query.descend("fFeedLink").constrain(feedRef.getLink().toString()); //$NON-NLS-1$
    query.descend("fParentId").constrain(0).not(); //$NON-NLS-1$
    return !query.execute().isEmpty();
  }
View Full Code Here

TOP

Related Classes of com.db4o.query.Query

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.