Package com.google.code.twig.annotation

Examples of com.google.code.twig.annotation.AnnotationObjectDatastore


       
        // 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

   */
  public void onMessage(@Name("message") Message message) throws Exception {
    // store the message in the inbox
    message.setAgent(getFirstUrl());
    message.setBox("inbox");
    ObjectDatastore datastore = new AnnotationObjectDatastore();
    datastore.store(message);
   
    // trigger receive event (not necessary)
    String event = "receive";
    ObjectNode params = JOM.createObjectNode();
    params.put("message", JOM.getInstance().convertValue(message, ObjectNode.class));
View Full Code Here

    message.setStatus("unread");

    // store the message in the outbox
    message.setAgent(getFirstUrl());
    message.setBox("outbox");
    ObjectDatastore datastore = new AnnotationObjectDatastore();
    datastore.store(message);
   
    // send the message to all recipients
    Set<String> to = message.getTo();
    if (to != null) {
      for (String url : to) {
View Full Code Here

   * @return messages
   * @throws Exception
   */
  private List<Message> find (String box, String since, String status)
      throws Exception {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
   
    RootFindCommand<Message> command = datastore.find()
      .type(Message.class)
      .addFilter("agent", FilterOperator.EQUAL, getFirstUrl());
    if (box != null) {
      command = command.addFilter("box", FilterOperator.EQUAL, box);
    }
View Full Code Here

  /**
   * Clear inbox and outbox and everything the agent has stored.
   */
  @Override
  public void clear() throws Exception {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
    QueryResultIterator<Message> it = datastore.find()
      .type(Message.class)
      .addFilter("agent", FilterOperator.EQUAL, getFirstUrl())
      .now();
   
    while (it.hasNext()) {
      Message message = it.next();
      datastore.delete(message);
      // TODO: bulk delete all messages instead of one by one
    }
  }
View Full Code Here

TOP

Related Classes of com.google.code.twig.annotation.AnnotationObjectDatastore

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.