@Test
 public void testDeleteById() {
   Event event = genEvent();
   dataRepository.save(event);
   dataRepository.delete(event.getId());
   Assert.assertFalse(dataRepository.exists(event.getId()));
 }
Пример #2
0
 void destroyItem(TabItem item) {
   int index = 0;
   int itemCount = getItemCount();
   while (index < itemCount) {
     if (items[index] == item) break;
     index++;
   }
   if (index == itemCount) error(SWT.ERROR_ITEM_NOT_REMOVED);
   int oldIndex = OS.gtk_notebook_get_current_page(handle);
   OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_notebook_remove_page(handle, index);
   OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   System.arraycopy(items, index + 1, items, index, --itemCount - index);
   items[itemCount] = null;
   if (index == oldIndex) {
     int newIndex = OS.gtk_notebook_get_current_page(handle);
     if (newIndex != -1) {
       Control control = items[newIndex].getControl();
       if (control != null && !control.isDisposed()) {
         control.setBounds(getClientArea());
         control.setVisible(true);
       }
       Event event = new Event();
       event.item = items[newIndex];
       sendSelectionEvent(SWT.Selection, event, true);
       // the widget could be destroyed at this point
     }
   }
 }
Пример #3
0
  @Test
  public void deserializeEventDataAccountEvent() throws IOException {
    String json = resource("account_event.json");
    Event e = StripeObject.PRETTY_PRINT_GSON.fromJson(json, Event.class);

    assertEquals(e.getType(), "account.updated");
  }
Пример #4
0
  /** Servlet GET request: handles event requests. */
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Event event = null;

    try {
      // Event parm identifies event type from the client
      String eventType = Servlets.getParameter(request, P_EVENT);

      // Always must have an event type
      if (eventType == null) {
        Log.warn("Pushlet.doGet(): bad request, no event specified");
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No eventType specified");
        return;
      }
      // Create Event and set attributes from parameters
      event = new Event(eventType);
      for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
        String nextAttribute = (String) e.nextElement();
        event.setField(nextAttribute, request.getParameter(nextAttribute));
      }
    } catch (Throwable t) {
      // Error creating event
      Log.warn("Pushlet: Error creating event in doGet(): ", t);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
    // Handle parsed request
    doRequest(event, request, response);
  }
  public static ProcessDefinition createMilestoneProcessDefinition() {
    ProcessDefinition pd =
        new ProcessDefinition(
            new String[] {
              "start-state start",
              "fork fork",
              "state b",
              "milestone-node m",
              "state c",
              "state d",
              "join join",
              "end-state end"
            },
            new String[] {
              "start --> fork",
              "fork --m--> b",
              "fork --d--> d",
              "b --> m",
              "m --> c",
              "c --> join",
              "d --> join",
              "join --> end"
            });

    Node d = pd.getNode("d");

    Delegation instantiatableDelegate = new Delegation(new MilestoneEvent("m", "../m"));
    Event event = new Event(Event.EVENTTYPE_NODE_LEAVE);
    d.addEvent(event);
    event.addAction(new Action(instantiatableDelegate));

    pd.addDefinition(new ContextDefinition());

    return pd;
  }
Пример #6
0
  /** Obsługa zapytań */
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    long start = System.currentTimeMillis();
    Document response = createDocument();
    Element root = response.createElement("response");
    response.appendChild(root);

    String action = req.getParameter("action");
    if (action == null) {

      root.appendChild(createTextNode(response, "status", "err"));
      root.appendChild(createTextNode(response, "message", "No action parameter defined"));

    } else {

      EventManager em = EventManager.getInstance();
      Event e = em.getByName(action);

      if (e == null) {
        root.appendChild(createTextNode(response, "status", "err"));
        root.appendChild(createTextNode(response, "message", "No such event (" + action + ")"));

      } else {
        root.appendChild(e.processEvent(response, req));
      }
    }
    root.appendChild(
        createTextNode(
            response, "Total_time", String.valueOf(System.currentTimeMillis() - start) + " ms"));
    XML2Writer(response, resp.getWriter());
    XML2Writer(response, new PrintWriter(System.out));
  }
  /**
   * Updates a single Event.<br>
   * Implements the update Event operation of the EventSpot API by calling the ConstantContact
   * server side.
   *
   * @param accessToken Constant Contact OAuth2 access token.
   * @param event The event to update.
   * @return An {@link Event} containing data as returned by the server on success; <br>
   *     An exception is thrown otherwise.
   * @throws ConstantContactServiceException When something went wrong in the Constant Contact flow
   *     or an error is returned from server.
   */
  @Override
  public Event updateEvent(String accessToken, Event event) throws ConstantContactServiceException {
    Event updatedEvent = null;
    try {
      String url =
          String.format(
              "%1$s%2$s",
              Config.Endpoints.BASE_URL, String.format(Config.Endpoints.EVENT_ID, event.getId()));
      String json = event.toJSON();

      CUrlResponse response = getRestClient().put(url, accessToken, json);
      if (response.hasData()) {
        updatedEvent = Component.fromJSON(response.getBody(), Event.class);
      }
      if (response.isError()) {
        ConstantContactServiceException constantContactException =
            new ConstantContactServiceException(
                ConstantContactServiceException.RESPONSE_ERR_SERVICE);
        response.getInfo().add(new CUrlRequestError("url", url));
        constantContactException.setErrorInfo(response.getInfo());
        throw constantContactException;
      }
    } catch (ConstantContactServiceException e) {
      throw new ConstantContactServiceException(e);
    } catch (Exception e) {
      throw new ConstantContactServiceException(e);
    }
    return updatedEvent;
  }
  /**
   * Create and write a json-encoded event to the underlying file.
   *
   * @param eventName Name of the event.
   * @param entityType The entity type.
   * @param entityId The entity ID.
   * @param targetEntityType The target entity type (optional).
   * @param targetEntityId The target entity ID (optional).
   * @param properties Properties (optional).
   * @param eventTime The time of the event (optional).
   * @throws IOException
   */
  public void createEvent(
      String eventName,
      String entityType,
      String entityId,
      String targetEntityType,
      String targetEntityId,
      Map<String, Object> properties,
      DateTime eventTime)
      throws IOException {

    if (eventTime == null) {
      eventTime = new DateTime();
    }

    Event event =
        new Event().event(eventName).entityType(entityType).entityId(entityId).eventTime(eventTime);

    if (targetEntityType != null) {
      event.targetEntityType(targetEntityType);
    }

    if (targetEntityId != null) {
      event.targetEntityId(targetEntityId);
    }

    if (properties != null) {
      event.properties(properties);
    }

    out.write(event.toJsonString().getBytes("UTF8"));
    out.write('\n');
  }
Пример #9
0
 @Override
 protected boolean handleEvent(Event evt) {
   if (evt.isKeyEvent() && content != null && content.canAcceptKeyboardFocus()) {
     if (content.handleEvent(evt)) {
       content.requestKeyboardFocus();
       return true;
     }
   }
   if (super.handleEvent(evt)) {
     return true;
   }
   switch (evt.getType()) {
     case KEY_PRESSED:
     case KEY_RELEASED:
       {
         int keyCode = evt.getKeyCode();
         if (keyCode == Event.KEY_LEFT || keyCode == Event.KEY_RIGHT) {
           return scrollbarH.handleEvent(evt);
         }
         if (keyCode == Event.KEY_UP
             || keyCode == Event.KEY_DOWN
             || keyCode == Event.KEY_PRIOR
             || keyCode == Event.KEY_NEXT) {
           return scrollbarV.handleEvent(evt);
         }
         break;
       }
     case MOUSE_WHEEL:
       if (scrollbarV.isVisible()) {
         return scrollbarV.handleEvent(evt);
       }
       return false;
   }
   return evt.isMouseEvent() && contentArea.isMouseInside(evt);
 }
Пример #10
0
          @Override
          public boolean perform(Game game, Event event, java.util.Map<Parameter, Set> parameters) {
            Set cards = new Set();

            for (Player player : parameters.get(Parameter.PLAYER).getAll(Player.class))
              cards.addAll(player.getHand(game.actualState).objects);

            java.util.Map<Parameter, Set> discardParameters =
                new java.util.HashMap<Parameter, Set>();
            discardParameters.put(EventType.Parameter.CAUSE, parameters.get(Parameter.CAUSE));
            discardParameters.put(EventType.Parameter.CARD, cards);
            Event discardEvent =
                createEvent(
                    game,
                    "Each player discards his or her hand",
                    EventType.DISCARD_CARDS,
                    discardParameters);
            discardEvent.perform(event, true);

            java.util.Map<Parameter, Set> drawParameters = new java.util.HashMap<Parameter, Set>();
            drawParameters.put(EventType.Parameter.CAUSE, parameters.get(Parameter.CAUSE));
            drawParameters.put(EventType.Parameter.PLAYER, parameters.get(Parameter.PLAYER));
            drawParameters.put(EventType.Parameter.NUMBER, new Set(4));
            Event drawEvent =
                createEvent(game, "and draws four cards.", EventType.DRAW_CARDS, drawParameters);
            drawEvent.perform(event, true);

            event.setResult(Empty.set);

            return true;
          }
Пример #11
0
  void populateReminders(Event e) throws RemoteException {
    // reminders
    Uri remindersUri =
        Reminders.CONTENT_URI
            .buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
            .build();
    @Cleanup
    Cursor c =
        providerClient.query(
            remindersUri,
            new String[] {
                /* 0 */
              Reminders.MINUTES, Reminders.METHOD
            },
            Reminders.EVENT_ID + "=?",
            new String[] {String.valueOf(e.getLocalID())},
            null);
    while (c != null && c.moveToNext()) {
      VAlarm alarm = new VAlarm(new Dur(0, 0, -c.getInt(0), 0));

      PropertyList props = alarm.getProperties();
      switch (c.getInt(1)) {
          /*case Reminders.METHOD_EMAIL:
          props.add(Action.EMAIL);
          break;*/
        default:
          props.add(Action.DISPLAY);
          props.add(new Description(e.getSummary()));
      }
      e.addAlarm(alarm);
    }
  }
Пример #12
0
 /**
  * Formats the event using a given pattern. The pattern needs to be compatible with {@link
  * AdvancedMessageFormat}.
  *
  * @param event the event
  * @param pattern the pattern (compatible with {@link AdvancedMessageFormat})
  * @return the formatted message
  */
 public static String format(Event event, String pattern) {
   AdvancedMessageFormat format = new AdvancedMessageFormat(pattern);
   Map params = new java.util.HashMap(event.getParams());
   params.put("source", event.getSource());
   params.put("severity", event.getSeverity());
   return format.format(params);
 }
Пример #13
0
  public static Event getNewReleasedEvent() {
    Event event = getNewEvent();

    event.setReleased(true);

    return event;
  }
Пример #14
0
  public Object up(Event evt) {
    switch (evt.getType()) {
      case Event.MSG:
        Message msg = (Message) evt.getArg();
        ForkHeader hdr = (ForkHeader) msg.getHeader(id);
        if (hdr == null) break;
        if (hdr.fork_stack_id == null)
          throw new IllegalArgumentException("header has a null fork_stack_id");
        Protocol bottom_prot = get(hdr.fork_stack_id);
        return bottom_prot != null
            ? bottom_prot.up(evt)
            : this.unknownForkHandler.handleUnknownForkStack(msg, hdr.fork_stack_id);

      case Event.VIEW_CHANGE:
        for (Protocol bottom : fork_stacks.values()) bottom.up(evt);
        break;

      case Event.STATE_TRANSFER_OUTPUTSTREAM:
        if (!process_state_events) break;
        getStateFromMainAndForkChannels(evt);
        return null;

      case Event.STATE_TRANSFER_INPUTSTREAM:
        if (!process_state_events) break;
        setStateInMainAndForkChannels((InputStream) evt.getArg());
        return null;
    }
    return up_prot.up(evt);
  }
Пример #15
0
  @Test
  @Transactional
  public void testRemoveContactFromEventMultipleGroups() throws Exception {

    groupService.create(group);
    groupService.addAggregation(event, group);

    Group secondGroup = new Group();
    secondGroup.setGroupName("Second Group");
    groupService.create(secondGroup);
    groupService.addAggregation(event, secondGroup);

    Contact newContact = new Contact();
    newContact.setFirstName("Fresh Contact");
    newContact.setEmail("Fresh email");
    contactService.create(newContact);

    event = eventService.findById(event.getId());
    contactService.attendEvent(newContact, event);

    newContact = contactService.findById(newContact.getId());
    contactService.unattendEvent(newContact, event);

    event = eventService.findById(event.getId());
    assertFalse(event.getAttendees().contains(newContact));

    newContact = contactService.findById(newContact.getId());
    assertFalse(newContact.getAttendedEvents().contains(event));
  }
Пример #16
0
 public boolean isCleared() {
   if (!clearable) return false;
   for (Event event : events) {
     if (!event.isCleared()) return false;
   }
   return true;
 }
Пример #17
0
  @Before
  public void setup() throws ConstraintViolation, NullDomainReference {

    createContacts();

    committee = new Committee();
    committee.setName("Committee Name");
    committeeService.create(committee);
    contactService.addContactToCommittee(first, committee);
    contactService.addContactToCommittee(second, committee);

    organization = new Organization();
    organization.setName("Organization Name");
    organizationService.create(organization);
    contactService.addContactToOrganization(first, organization);
    contactService.addContactToOrganization(second, organization);

    event = new Event();
    event.setName("Event Name");
    event.setDateHeld("2015-01-01");
    eventService.create(event);
    contactService.attendEvent(first, event);
    contactService.attendEvent(second, event);

    group = new Group();
    group.setGroupName("New AlinskyGroup");
  }
 @Override
 public void handleOnset(double time, double salience) {
   double roundedTime = Math.round(time * 10000) / 10000.0;
   Event e = newEvent(roundedTime, 0);
   e.salience = salience;
   onsetList.add(e);
 }
Пример #19
0
  @Test
  public void memoryTest() throws InterruptedException {

    final StatefulKnowledgeSession ksession = createKnowledgeSession();
    Event myevent = new Event();
    ksession.setGlobal("event", myevent);

    final Server node1 = new Server(1500, "server1");

    new Thread(
            new Runnable() {
              public void run() {
                ksession.fireUntilHalt();
              }
            })
        .start();

    serverHandle = ksession.insert(node1);

    int memory = 1500;
    for (int i = 0; i < 5; i++) {
      Thread.sleep(6000);
      memory = memory - 200;

      node1.setMemory(memory);
      ksession.update(serverHandle, node1);
    }

    ksession.halt();
    System.out.println(myevent.getEvents());
  }
Пример #20
0
  @Override
  public void makeChoices(Game game, Event event, java.util.Map<Parameter, Set> parameters) {
    int numberOfCards = 1;
    if (parameters.containsKey(Parameter.NUMBER))
      numberOfCards = Sum.get(parameters.get(Parameter.NUMBER));

    if (numberOfCards < 0) numberOfCards = 0;

    java.util.Set<Card> cardsInHand = null;
    boolean specificChoices = parameters.containsKey(Parameter.CHOICE);

    if (specificChoices) cardsInHand = parameters.get(Parameter.CHOICE).getAll(Card.class);

    for (Player player : parameters.get(Parameter.PLAYER).getAll(Player.class)) {
      if (!specificChoices)
        cardsInHand = new Set(player.getHand(game.actualState).objects).getAll(Card.class);

      java.util.Collection<Card> choices =
          player.sanitizeAndChoose(
              game.actualState,
              numberOfCards,
              cardsInHand,
              PlayerInterface.ChoiceType.OBJECTS,
              PlayerInterface.ChooseReason.DISCARD);
      if (choices.size() != numberOfCards) event.allChoicesMade = false;
      event.putChoices(player, choices);
    }
  }
Пример #21
0
  @SuppressWarnings("unchecked")
  protected void dispatch(Event event) {
    // all events go thru this loop
    if (LOG.isDebugEnabled()) {
      LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString());
    }

    Class<? extends Enum> type = event.getType().getDeclaringClass();

    try {
      EventHandler handler = eventDispatchers.get(type);
      if (handler != null) {
        handler.handle(event);
      } else {
        throw new Exception("No handler for registered for " + type);
      }
    } catch (Throwable t) {
      // TODO Maybe log the state of the queue
      LOG.fatal("Error in dispatcher thread", t);
      // If serviceStop is called, we should exit this thread gracefully.
      if (exitOnDispatchException
          && (ShutdownHookManager.get().isShutdownInProgress()) == false
          && stopped == false) {
        Thread shutDownThread = new Thread(createShutDownThread());
        shutDownThread.setName("AsyncDispatcher ShutDown handler");
        shutDownThread.start();
      }
    }
  }
Пример #22
0
  /**
   * parse the String message
   *
   * @return SIPHeader (Event object)
   * @throws SIPParseException if the message does not respect the spec.
   */
  public SIPHeader parse() throws ParseException {

    if (debug) dbg_enter("EventParser.parse");

    try {
      headerName(TokenTypes.EVENT);
      this.lexer.SPorHT();

      Event event = new Event();
      this.lexer.match(TokenTypes.ID);
      Token token = lexer.getNextToken();
      String value = token.getTokenValue();

      event.setEventType(value);
      super.parse(event);

      this.lexer.SPorHT();
      this.lexer.match('\n');

      return event;

    } catch (ParseException ex) {
      throw createParseException(ex.getMessage());
    } finally {
      if (debug) dbg_leave("EventParser.parse");
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_globalevent_detail, container, false);
    LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.layout);

    // Load the GlobalEvent content.
    ((TextView) rootView.findViewById(R.id.title)).setText(globalEvent.getName());
    ((TextView) rootView.findViewById(R.id.subtitle)).setText(globalEvent.getTeam());
    ((TextView) rootView.findViewById(R.id.id_ulg)).setText(globalEvent.getCode());
    ((TextView) rootView.findViewById(R.id.descriptionContent))
        .setText(globalEvent.getDescription());

    if (!globalEvent.getEventList().isEmpty())
      rootView.findViewById(R.id.eventListTitle).setVisibility(View.VISIBLE);

    List<String> ids = new ArrayList<>();
    for (Subevent event : globalEvent.getEventList()) {
      if (!ids.contains(event.getId())) {
        Event e = new Event(rootView.getContext(), event);
        e.setMinimalSize();
        layout.addView(e);
        ids.add(event.getId());
      }
    }

    return rootView;
  }
  @SuppressWarnings("unchecked")
  @Override
  public void dispatchEvent(@Nonnull Event<?> event) {
    AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory();
    List<Event<?>> queue = Lists.<Event<?>>newArrayList(event);

    while (!queue.isEmpty()) {
      Event<?> evt = queue.remove(0);

      for (Class<? extends EventHandler<?>> eventHandler :
          handlers.get((Class<? extends Event<?>>) evt.getClass())) {
        EventHandler<Event<?>> handler =
            (EventHandler<Event<?>>)
                factory.autowire(eventHandler, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);

        EventResult result = handler.onEvent(evt);

        if (result.isAbort()) {
          throw new RuntimeException(
              String.format(
                  "Handler %s aborted event %s with message: %s",
                  handler, evt, result.getMessage()));
        }

        queue.addAll(result.getTriggeredEvents());
      }
    }
  }
Пример #25
0
 long /*int*/ menuItemSelected(long /*int*/ widget, ToolItem item) {
   Event event = new Event();
   switch (item.style) {
     case SWT.DROP_DOWN:
       /*
        * Feature in GTK. The DROP_DOWN item does not
        * contain arrow button in the overflow menu. So, it
        * is impossible to select the menu of that item.
        * The fix is to consider the item selection
        * as Arrow click, in order to popup the drop-down.
        */
       event.detail = SWT.ARROW;
       GtkAllocation allocation = new GtkAllocation();
       OS.gtk_widget_get_allocation(widget, allocation);
       event.x = allocation.x;
       if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth() - allocation.width - event.x;
       event.y = allocation.y + allocation.height;
       break;
     case SWT.RADIO:
       if ((style & SWT.NO_RADIO_GROUP) == 0) item.selectRadio();
       break;
     case SWT.CHECK:
       boolean currentSelection = item.getSelection();
       item.setSelection(!currentSelection);
   }
   item.sendSelectionEvent(SWT.Selection, event, false);
   return 0;
 }
  /*
  Send out and confirm it has been sent
   */
  @RequestMapping(value = path + "send")
  @ResponseBody
  public Request voteSend(
      @RequestParam(value = phoneNumber) String inputNumber,
      @RequestParam(value = entityUidParam) String requestUid)
      throws URISyntaxException {

    User user = userManager.findByInputNumber(inputNumber, null);
    USSDMenu menu;

    try {
      String createdUid = eventRequestBroker.finish(user.getUid(), requestUid, true);
      Event vote = eventBroker.load(createdUid);
      log.info(
          "Vote details confirmed! Closing date and time: "
              + vote.getEventDateTimeAtSAST().format(dateTimeFormat));
      menu = new USSDMenu(getMessage(thisSection, "send", promptKey, user), optionsHomeExit(user));
      return menuBuilder(menu);
    } catch (EventStartTimeNotInFutureException e) {
      final String messageKey = USSDSection.VOTES.toKey() + "send.err.past.";
      menu = new USSDMenu(getMessage(messageKey + promptKey, user));
      menu.setFreeText(false);
      menu.addMenuOption(
          voteMenus + "send-reset" + entityUidUrlSuffix + requestUid,
          getMessage(messageKey + "yes", user));
      menu.addMenuOption(backVoteUrl("time", requestUid), getMessage(messageKey + "no", user));
      return menuBuilder(menu);
    }
  }
Пример #27
0
 void setSelection(int index, boolean notify) {
   if (index < 0) return;
   int oldIndex = OS.gtk_notebook_get_current_page(handle);
   if (oldIndex == index) return;
   if (oldIndex != -1) {
     TabItem item = items[oldIndex];
     Control control = item.control;
     if (control != null && !control.isDisposed()) {
       control.setVisible(false);
     }
   }
   OS.g_signal_handlers_block_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   OS.gtk_notebook_set_current_page(handle, index);
   OS.g_signal_handlers_unblock_matched(handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
   int newIndex = OS.gtk_notebook_get_current_page(handle);
   if (newIndex != -1) {
     TabItem item = items[newIndex];
     Control control = item.control;
     if (control != null && !control.isDisposed()) {
       control.setBounds(getClientArea());
       control.setVisible(true);
     }
     if (notify) {
       Event event = new Event();
       event.item = item;
       sendSelectionEvent(SWT.Selection, event, true);
     }
   }
 }
  @RequestMapping(value = path + "change-vote")
  @ResponseBody
  public Request changeVoteDo(
      @RequestParam(value = phoneNumber) String inputNumber,
      @RequestParam(value = entityUidParam) String eventUid,
      @RequestParam(value = "response") String response)
      throws URISyntaxException {

    final User user = userManager.findByInputNumber(inputNumber, null);
    final Event vote = eventBroker.load(eventUid);

    USSDMenu menu;
    if (vote.getEventStartDateTime().isBefore(Instant.now())) {
      menu = new USSDMenu(getMessage(thisSection, "change", "error", user));
    } else {
      // todo: replace this hack once responses are handled better
      EventRSVPResponse voteResponse =
          "abstain".equals(response)
              ? EventRSVPResponse.MAYBE
              : EventRSVPResponse.fromString(response);
      eventLogBroker.rsvpForEvent(vote.getUid(), user.getUid(), voteResponse);
      menu = new USSDMenu(getMessage(thisSection, "change", "done", response, user));
    }

    menu.addMenuOption(
        voteMenus + "details" + entityUidUrlSuffix + eventUid + "&back=open",
        getMessage(thisSection, "change", optionsKey + "back", user));
    menu.addMenuOptions(optionsHomeExit(user));

    return menuBuilder(menu);
  }
Пример #29
0
  /*! This method runs all the time and listens to data from the SK6 and posts the data through
  	events to the event heap
  */
  public void run() {
    String data;
    String[] tokens;
    Integer value;
    Event e;

    System.out.println("Bluetooth thread, waiting for data");
    while (running == true) {
      try {
        if (inBufReader.ready()) {
          data = inBufReader.readLine();
          tokens = data.split(",");
          e = new Event("Shake");
          e.addField("ProxyID", proxyID);
          e.setPostValue("TimeToLive", new Integer(50)); // set time to live to 50 msec
          e.setPostValue("Sensor", tokens[0]);
          for (int i = 1; i < tokens.length; i++) {
            if (tokens[i].startsWith("+")) { // eliminate Number format exception
              value = new Integer(tokens[i].substring(1));
            } else {
              value = new Integer(tokens[i]);
            }
            e.setPostValue("Data" + i, value);
          }
          eventHeap.putEvent(e);
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    System.out.println("out of run");
  }
  @Test
  public void testFindWithLimitAndSort() {
    Event event = genEvent();
    event.setEventTime(new Date(1436390151975l));
    dataRepository.save(event);
    List<Condition> conditions = new LinkedList<Condition>();
    conditions.add(new Condition("uid", PhoenixConditionOperator.EQUAL, "TEST_USER"));
    Condition c1 = new Condition("event_time", PhoenixConditionOperator.EQUAL, 1436390151975l);
    Condition c2 = new Condition("event_time", PhoenixConditionOperator.EQUAL, 1436216440707l);
    conditions.add(new Condition(c1, PhoenixConditionOperator.OR, c2));

    Query query =
        QueryBuilder.newBuilder()
            .conditions(conditions)
            .sort(new Sort(new Order(Direction.DESC, "receipt_time")))
            .limit(1)
            .build();

    List<Event> list = (List<Event>) dataRepository.find(query);
    Assert.assertTrue(!list.isEmpty());

    for (Event e : list) {
      System.out.println(e);
    }
  }