Package com.google.code.twig

Examples of com.google.code.twig.ObjectDatastore


       
        // store task information
        DateTime timestamp = DateTime.now().plus(delay);
        GaeTask storedTask = new GaeTask(task.getName(),
            agentId, timestamp.toString());
        ObjectDatastore datastore = new AnnotationObjectDatastore();
        datastore.store(storedTask);
       
        return task.getName();     
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }
View Full Code Here


      // stop the task
      Queue queue = QueueFactory.getDefaultQueue();
      queue.deleteTask(id);
     
      // remove stored task
      ObjectDatastore datastore = new AnnotationObjectDatastore();
      GaeTask storedTask = datastore.load(GaeTask.class, id);
      if (storedTask != null) {
        datastore.delete(storedTask);
      }     
    }
View Full Code Here

     * @return tasksIds
     */
    @Override
    @Access(AccessType.PUBLIC)
    public Set<String> getTasks() {
      ObjectDatastore datastore = new AnnotationObjectDatastore();
      QueryResultIterator<GaeTask> query = datastore.find()
          .type(GaeTask.class)
          .addFilter("agentId", FilterOperator.EQUAL, agentId).now();
     
      Set<String> taskIds = new HashSet<String>();
      while (query.hasNext()) {
        GaeTask task = query.next();
        if (new DateTime(task.getTimestamp()).isAfterNow()) {
          taskIds.add(task.getTaskId());
        }
        else {
          // clean up expired entry
          datastore.delete(task);
        }
      }
     
      return taskIds;
    }
View Full Code Here

   * @return
   */
  @SuppressWarnings("unchecked")
  private boolean loadFromDatastore () {
    try {
      ObjectDatastore datastore = new AnnotationObjectDatastore();
      KeyValue entity = datastore.load(KeyValue.class, getAgentId());
     
      @SuppressWarnings("rawtypes")
      Class<? extends HashMap> MAP_OBJECT_CLASS =
        (new HashMap<String, Serializable>()).getClass();
     
View Full Code Here

   * @return success    True if successfully saved
   * @throws IOException
   */
  private boolean saveToDatastore () {
    try {
      ObjectDatastore datastore = new AnnotationObjectDatastore();
      KeyValue entity = new KeyValue(getAgentId(), properties);
      datastore.store(entity);
      return true;
    } catch (IOException e) {
      e.printStackTrace();
    }

View Full Code Here

  /**
   * Delete the entity from the Datastore
   * @param entity
   */
  private void deleteFromDatastore () {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
    KeyValue entity = datastore.load(KeyValue.class, getAgentId());
    if (entity != null) {
      datastore.delete(entity);
    }
  }
View Full Code Here

    registration.setType(type);
    registration.setUsername(username);
    registration.setEmail(email);
   
    // store the registration
    ObjectDatastore datastore = new AnnotationObjectDatastore();
    datastore.store(registration);
   
    // load the registration again, to ensure its indexes are updated
    // TODO: does this actually work?...
    datastore.refresh(registration);
   
    return registration;
  }
View Full Code Here

      @Name("agent") @Required(false) String agent,
      @Name("type") @Required(false) String type,
      @Name("username") @Required(false) String username,
      @Name("email") @Required(false) String email)
      throws Exception {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
   
    RootFindCommand<Registration> command = datastore.find()
      .type(Registration.class)
      .addFilter("directoryAgent", FilterOperator.EQUAL, getFirstUrl());
    if (agent != null) {
      command = command.addFilter("agent", FilterOperator.EQUAL, agent);
    }
View Full Code Here

  private void delete (String field, String value) throws Exception {
    if (field == null || value == null) {
      return;
    }   
   
    ObjectDatastore datastore = new AnnotationObjectDatastore();
   
    QueryResultIterator<Registration> it = datastore.find()
    .type(Registration.class)
    .addFilter("directoryAgent", FilterOperator.EQUAL, getFirstUrl())
    .addFilter(field, FilterOperator.EQUAL, value)
    .now();
 
    while (it.hasNext()) {
      Registration registration = it.next();
      datastore.delete(registration);
   
  }
View Full Code Here

  /**
   * Remove all registrations stored by this DirectoryAgent
   */
  @Override
  public void clear() throws Exception {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
    QueryResultIterator<Registration> it = datastore.find()
      .type(Registration.class)
      .addFilter("directoryAgent", FilterOperator.EQUAL, getFirstUrl())
      .now();
   
    while (it.hasNext()) {
      Registration registration = it.next();
      datastore.delete(registration);
      // TODO: bulk delete all registrations instead of one by one
    }
  }
View Full Code Here

TOP

Related Classes of com.google.code.twig.ObjectDatastore

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.