Package com.db4o.query

Examples of com.db4o.query.Query


    query.descend("mMessage").constrain(message).identity();
    return new Persistent.InitializingObjectSet<WoTMessageRating>(mFreetalk, query);
  }
 
  public ObjectSet<? extends MessageRating> getAllMessageRatingsBy(OwnIdentity rater) {
    final Query query = db.query();
    query.constrain(WoTMessageRating.class);
    query.descend("mRater").constrain(rater).identity();
    return new Persistent.InitializingObjectSet<WoTMessageRating>(mFreetalk, query);
  }
View Full Code Here


   
    return identity;
  }
 
  public ObjectSet<WoTIdentity> getAllIdentities() {
    Query q = db.query();
    q.constrain(WoTIdentity.class);
    return new Persistent.InitializingObjectSet<WoTIdentity>(mFreetalk, q);
  }
View Full Code Here

      fetchOwnIdentities();
      garbageCollectIdentities();
    }
    catch(Exception e) {} /* Ignore, return the ones which are in database now */
   
    final Query q = db.query();
    q.constrain(WoTOwnIdentity.class);
    return new Persistent.InitializingObjectSet<WoTOwnIdentity>(mFreetalk, q);

  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public synchronized WoTIdentity getIdentity(String id) throws NoSuchIdentityException {
    Query q = db.query();
    q.constrain(WoTIdentity.class);
    q.descend("mID").constrain(id);
    ObjectSet<WoTIdentity> result = q.execute();
   
    switch(result.size()) {
      case 1:
        WoTIdentity identity = result.next();
        identity.initializeTransient(mFreetalk);
View Full Code Here

    return getIdentity(WoTIdentity.getIDFromURI(uri));
  }
 
  @SuppressWarnings("unchecked")
  public synchronized WoTOwnIdentity getOwnIdentity(String id) throws NoSuchIdentityException {
    Query q = db.query();
    q.constrain(WoTOwnIdentity.class);
    q.descend("mID").constrain(id);
    ObjectSet<WoTOwnIdentity> result = q.execute();
   
    switch(result.size()) {
      case 1:
        WoTOwnIdentity identity = result.next();
        identity.initializeTransient(mFreetalk);
View Full Code Here

        // TODO: Maybe handle this in WoT. Would require checks in many places though.
        continue;
      }
     
      synchronized(this) { /* We lock here and not during the whole function to allow other threads to execute */
        Query q = db.query(); // TODO: Encapsulate the query in a function...
        q.constrain(WoTIdentity.class);
        q.descend("mID").constrain(identityID);
        ObjectSet<WoTIdentity> result = q.execute();
        WoTIdentity id = null;
       
        if(result.size() == 0) {
          try {
            importIdentity(bOwnIdentities, identityID, requestURI, insertURI, nickname, fetchID);
View Full Code Here

      if((ownIdentities && mLastOwnIdentityFetchID == 0) || (!ownIdentities && mLastIdentityFetchID == 0))
        return;

      long acceptID = ownIdentities ? mLastOwnIdentityFetchID : mLastIdentityFetchID;

      Query q = db.query();
      if(ownIdentities)
        q.constrain(WoTOwnIdentity.class);
      else {
        q.constrain(WoTIdentity.class);
        q.constrain(WoTOwnIdentity.class).not();
      }
     
      q.descend("mLastReceivedFromWoT").constrain(acceptID).not();
      ObjectSet<WoTIdentity> result = q.execute();

      for(WoTIdentity identity : result) {
        identity.initializeTransient(mFreetalk);
        if(logDEBUG) Logger.debug(this, "Garbage collecting identity " + identity);
        deleteIdentity(identity, messageManager, taskManager);
View Full Code Here

        HashSet<String> deleted = new HashSet<String>();

        Logger.debug(this, "Searching for duplicate identities ...");

        for(WoTIdentity identity : getAllIdentities()) {
          Query q = db.query();
          q.constrain(WoTIdentity.class);
          q.descend("mID").constrain(identity.getID());
          q.constrain(identity).identity().not();
          ObjectSet<WoTIdentity> duplicates = new Persistent.InitializingObjectSet<WoTIdentity>(mFreetalk, q);
         
          for(WoTIdentity duplicate : duplicates) {
            if(deleted.contains(duplicate.getID()) == false) {
              Logger.error(duplicate, "Deleting duplicate identity " + duplicate.getRequestURI());
View Full Code Here

  // TODO: This function should be a feature of WoT.
  private synchronized void updateShortestUniqueNicknameCache() {
    if(logDEBUG) Logger.debug(this, "Updating shortest unique nickname cache...");
   
    // We don't use getAllIdentities() because we do not need to have intializeTransient() called on each identity, we only query strings anyway.
    final Query q = db.query();
    q.constrain(WoTIdentity.class);
    ObjectSet<WoTIdentity> result = new Persistent.InitializingObjectSet<WoTIdentity>(mFreetalk, q);
    final WoTIdentity[] identities = result.toArray(new WoTIdentity[result.size()]);
   
    Arrays.sort(identities, new Comparator<WoTIdentity>() {
View Full Code Here

  private FetcherCommand getCommand(Class<? extends FetcherCommand> commandType, WoTIdentity identity) throws NoSuchCommandException {
    return getCommand(commandType, identity.getID());
  }
 
  private FetcherCommand getCommand(Class<? extends FetcherCommand> commandType, String identityID) throws NoSuchCommandException {
    final Query q = mDB.query();
    q.constrain(commandType);
    q.descend("mIdentityID").constrain(identityID);
    final ObjectSet<FetcherCommand> result = new Persistent.InitializingObjectSet<FetcherCommand>(mFreetalk, q);
   
    switch(result.size()) {
      case 1: return result.next();
      case 0: throw new NoSuchCommandException();
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.