public String addItemListener(ItemListener<E> listener, boolean includeValue) {
   final EventService eventService = getNodeEngine().getEventService();
   final EventRegistration registration =
       eventService.registerListener(
           getServiceName(), name, new CollectionEventFilter(includeValue), listener);
   return registration.getId();
 }
Exemplo n.º 2
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));
  }
  @Transactional
  @Rollback(true)
  @Test
  public void testSaveEventToCreate() {

    final Event event = new Event();
    event.setEventName("Test Name123");
    event.setEventDescription("Test Description");
    event.setEventCategory("Test category");
    event.setEventSource("Test Event");
    event.setEventSubCategory("Event sub category");
    event.setEventType("Test type");

    Set<EventEventHandler> eeHandlerSet = new HashSet<EventEventHandler>();

    final EventHandler eHandler = new EventHandler();
    eHandler.setEventHandlerId(Long.valueOf(1));

    EventEventHandler eeHandler = new EventEventHandler();
    eeHandler.setEventEventHandlerId(null);
    eeHandler.setSeq(2);
    eeHandler.setEventHandler(eHandler);
    eeHandlerSet.add(eeHandler);

    eeHandler = new EventEventHandler();
    eeHandler.setEventEventHandlerId(null);
    eeHandler.setSeq(2);
    eHandler.setEventHandlerId(Long.valueOf(2));
    eeHandler.setEventHandler(eHandler);
    eeHandlerSet.add(eeHandler);

    eventService.saveEvent(event);
    Event eventTestNew = eventService.getEventByName("Test Name123");
    Assert.isTrue(eventTestNew.getEventDescription().equals("Test Description"));
  }
Exemplo n.º 4
0
 private void sendClientEvent(ClientEndpoint endpoint) {
   if (endpoint.isFirstConnection()) {
     final EventService eventService = nodeEngine.getEventService();
     final Collection<EventRegistration> regs =
         eventService.getRegistrations(SERVICE_NAME, SERVICE_NAME);
     eventService.publishEvent(SERVICE_NAME, regs, endpoint, endpoint.getUuid().hashCode());
   }
 }
 @Transactional
 @Rollback(true)
 @Test
 public void testDeleteEventHandler() {
   EventHandler eventHandlerTest = eventService.getEventHandlerById(NUMBER_ONE);
   Assert.isTrue(eventHandlerTest.getEventHandlerName().equals("Users data import"));
   eventService.deleteEventHandlerById(NUMBER_ONE);
   EventHandler eventHandlerTestNew = eventService.getEventHandlerById(NUMBER_ONE);
   Assert.isNull(eventHandlerTestNew);
 }
  @Before
  public void setUp() throws ValidationException {
    UserAccount user =
        new UserAccount(
            AccountType.LOCAL,
            "user",
            "displayName",
            "password",
            "*****@*****.**",
            Arrays.asList(new Permission[] {Permission.USER}));
    voter = userAccountDao.add(user);

    UserAccount admin1 =
        new UserAccount(
            AccountType.LOCAL,
            "user2",
            "displayName",
            "password",
            "*****@*****.**",
            Arrays.asList(new Permission[] {Permission.ADMIN}));
    admin = userAccountDao.add(admin1);

    firstEvent =
        eventService.createEvent(
            voter,
            "FirstEvent Name",
            "Event Description",
            EventType.PUBLIC,
            DateTime.now(),
            DateTime.now().plus(Duration.standardDays(1)),
            createBogusCategories(),
            new ArrayList<String>());

    secondEvent =
        eventService.createEvent(
            voter,
            "SecondEvent Name",
            "Event Description",
            EventType.PUBLIC,
            DateTime.now(),
            DateTime.now().plus(Duration.standardDays(1)),
            createBogusCategories(),
            new ArrayList<String>());

    privateEvent =
        eventService.createEvent(
            admin,
            "PrivateEvent Name",
            "Event Description",
            EventType.PRIVATE,
            DateTime.now(),
            DateTime.now().plus(Duration.standardDays(1)),
            createBogusCategories(),
            new ArrayList<String>());
  }
 @Transactional
 @Rollback(true)
 @Test
 public void testDeleteEvent() {
   Event eventTest = eventService.getEventById(NUMBER_ONE);
   Assert.isTrue(
       eventTest.getEventDescription().equals("Import user details to the lucas system"));
   eventService.deleteEventById(eventTest.getEventId());
   Event eventTestNew = eventService.getEventById(NUMBER_ONE);
   Assert.isNull(eventTestNew);
 }
 @Transactional
 @Rollback(true)
 @Test
 public void testSaveEventToUpdate() {
   Event eventTest = eventService.getEventById(NUMBER_ONE);
   Assert.isTrue(
       eventTest.getEventDescription().equals("Import user details to the lucas system"));
   eventTest.setEventDescription("Test Description");
   eventService.saveEvent(eventTest);
   Event eventTestNew = eventService.getEventById(NUMBER_ONE);
   Assert.isTrue(eventTestNew.getEventDescription().equals("Test Description"));
 }
Exemplo n.º 9
0
 public void publishEvent(ItemEventType eventType, Data data) {
   EventService eventService = getNodeEngine().getEventService();
   Collection<EventRegistration> registrations =
       eventService.getRegistrations(getServiceName(), name);
   for (EventRegistration registration : registrations) {
     QueueEventFilter filter = (QueueEventFilter) registration.getFilter();
     QueueEvent event =
         new QueueEvent(
             name,
             filter.isIncludeValue() ? data : null,
             eventType,
             getNodeEngine().getThisAddress());
     eventService.publishEvent(getServiceName(), registration, event, name.hashCode());
   }
 }
  @Test
  public void testGetEventListBySearchAndSortCriteria()
      throws ParseException, JsonProcessingException {
    final SearchAndSortCriteria searchAndSortCriteria = new SearchAndSortCriteria();
    final Map<String, Object> searchMap = new HashMap<String, Object>();

    searchMap.put(
        "eventName",
        new ArrayList<String>() {
          {
            add(EVENT_NAME);
          }
        });

    searchAndSortCriteria.setSearchMap(searchMap);
    searchAndSortCriteria.setSortMap(
        new HashMap<String, SortType>() {
          {
            put("eventName", SortType.ASC);
          }
        });
    searchAndSortCriteria.setPageNumber(0);
    searchAndSortCriteria.setPageSize(3);
    ObjectMapper objectMapper = new ObjectMapper();

    final List<Event> eventList =
        eventService.getEventListBySearchAndSortCriteria(searchAndSortCriteria);
    Assert.notNull(eventList, "Event List is Null");
    Assert.isTrue(eventList.size() >= 1, "Event list is not having the expected size");
  }
  @Test
  public void testIfEventDoesNotExists()
      throws JsonParseException, JsonMappingException, IOException {
    Event eaiEventTest = eventService.getEventByName(EVENT_NAME_DOES_NOT_EXISTS);

    org.junit.Assert.assertNull(eaiEventTest);
  }
Exemplo n.º 12
0
  @RequestMapping(value = "/admin/event/updateeventform", method = RequestMethod.GET)
  public ModelAndView eventUpdateForm(
      HttpSession session,
      @RequestParam(value = "eventNum") int eventNum,
      @RequestParam(value = "pageNum") String pageNum)
      throws Exception {
    SessionInfo info = (SessionInfo) session.getAttribute("member");
    if (info == null) {
      return new ModelAndView("redirect:/member/login");
    }

    Event dto = (Event) service.readEvent(eventNum);
    if (dto == null) {
      return new ModelAndView("redirect:/event/eventlist?pageNum=" + pageNum);
    }

    if (!info.getUserId().equals(dto.getUserId())) {
      return new ModelAndView("redirct:/event/eventlist?pageNum=" + pageNum);
    }

    ModelAndView mav = new ModelAndView(".four.admin.adminevent.main");

    mav.addObject("active", "created");
    mav.addObject("eventNum", eventNum);
    mav.addObject("mode", "update");

    return mav;
  }
Exemplo n.º 13
0
  public static synchronized UserService getInstance() {
    if (userService == null) {
      userService = new UserService();

      EventService.getInstance().getEventBus().subscribe(userService);

      userService.users = new HashMap<>();

      // TODO: Load all real users.
      OrderUser user = getDemoUser();
      userService.users.put(user.token, user);

      userService.loggedInUsers = new LinkedHashMap<>();
      userService.loggedInUsers.put(user.token, user);
    }

    // TODO: load providers:

    // TODO: subscribe to userSignin, create context add to list.

    // TODO: Depending on the event and config mode, change the listener provider.

    // TODO: determine communication pattern with server, peers. When to send updates to server?
    // Maybe just post event.

    return userService;
  }
Exemplo n.º 14
0
  @RequestMapping(value = "/event/article")
  public ModelAndView article(
      HttpSession session,
      @RequestParam(value = "eventNum") int eventNum,
      @RequestParam(value = "pageNum") String pageNum,
      @RequestParam(value = "searchKey", defaultValue = "subject") String searchKey,
      @RequestParam(value = "searchValue", defaultValue = "") String searchValue)
      throws Exception {
    SessionInfo info = (SessionInfo) session.getAttribute("member");
    if (info == null) {
      return new ModelAndView("redirect:/member/login");
    }
    searchValue = URLDecoder.decode(searchValue, "utf-8");

    Event dto = service.readEvent(eventNum);
    if (dto == null) return new ModelAndView("redirect:/event/eventlist?pageNum=" + pageNum);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("searchKey", searchKey);
    map.put("searchValue", searchValue);
    map.put("eventNum", eventNum);

    String params = "pageNum=" + pageNum;
    if (!searchValue.equals("")) {
      params +=
          "&searchKey=" + searchKey + "&searchValue=" + URLEncoder.encode(searchValue, "utf-8");
    }

    ModelAndView mav = new ModelAndView(".event.article");
    mav.addObject("dto", dto);
    mav.addObject("pageNum", pageNum);
    mav.addObject("params", params);

    return mav;
  }
Exemplo n.º 15
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");
  }
 @Test
 public void testIfEventNameExists() throws JsonParseException, JsonMappingException, IOException {
   Event eaiEventTest = eventService.getEventByName(eventName);
   String ExpectedEventName = "Users data import";
   Assert.isTrue(
       eaiEventTest.getEventName().equals(ExpectedEventName),
       "WMS user import service was expected but got " + eaiEventTest.getEventName());
 }
Exemplo n.º 17
0
 @After
 public void tearDown() {
   groupService.deleteAll();
   organizationService.deleteAll();
   committeeService.deleteAll();
   eventService.deleteAll();
   contactService.deleteAll();
 }
Exemplo n.º 18
0
  @Test
  public void testThatChangeToCoreObjectChangesHash() throws Exception {
    // Get starting Hash
    StateService svc = StateService.getInstance();
    String hash = svc.getCurrentHash(CoreObjectType.ITEM);

    // Create a new item, with same attributes.
    SalesItem initialItem = CoreObjectService.getInstance().getAllItems().get(0);
    SalesItem item = new SalesItem();
    item.token = initialItem.token;
    item.name = "Cheezbureger";
    item.category = 1;
    item.clazz = "com.openpos.salesitem";
    item.unitPrice = new BigDecimal(19.99);
    item.category = 1;
    item.setId(1);
    List<SalesItem> items = new ArrayList<>();
    items.add(item);

    // update the state with same object, make sure hash doesn't change
    EventService.getInstance().postEvent(new NewProgramState(CoreObjectType.ITEM, items));
    Thread.sleep(150);
    assertEquals(hash, svc.getCurrentHash(CoreObjectType.ITEM));

    // Change one attribute, and make sure hash changes.
    items.clear();
    item.name = "Burger";

    // update the state with same object, make sure hash doesn't change
    EventService.getInstance().postEvent(new NewProgramState(CoreObjectType.ITEM, items));
    Thread.sleep(150);
    assertNotEquals(hash, svc.getCurrentHash(CoreObjectType.ITEM));

    // Test that changing a non-serialized field doesn't cause update.
    // Change one attribute, and make sure hash changes.
    items.clear();
    item.name = "Cheezbureger";
    item.client = 33;
    items.add(item);
    // update the state with same object, make sure hash doesn't change
    EventService.getInstance().postEvent(new NewProgramState(CoreObjectType.ITEM, items));
    Thread.sleep(190);
    assertEquals(hash, svc.getCurrentHash(CoreObjectType.ITEM));
  }
Exemplo n.º 19
0
  public void testAddEvent() {
    Event event = new Event();
    event.setContent("测试内容");
    event.setEventID(0);
    event.setBeginTime(DateUtil.getInstance().fromString("2000-12-12 12:12:12"));
    event.setEndTime(DateUtil.getInstance().fromString("2000-12-12 12:12:12"));
    event.setTitle("标题");
    event.setLocation("loc");

    es.addEvent(event);
  }
Exemplo n.º 20
0
  @RequestMapping(value = "/event/delete")
  public ModelAndView deleteEvent(
      HttpSession session,
      @RequestParam(value = "eventNum") int eventNum,
      @RequestParam(value = "pageNum") String pageNum)
      throws Exception {
    SessionInfo info = (SessionInfo) session.getAttribute("member");
    if (info == null) {
      return new ModelAndView("redirect:/member/login");
    }

    Event dto = service.readEvent(eventNum);
    if (dto == null) {
      return new ModelAndView("redirect:/event/eventlist?pageNum=" + pageNum);
    }
    if (!info.getUserId().equals(dto.getUserId()) && !info.getUserId().equals("admin")) {
      return new ModelAndView("redirect:/event/eventlist?pageNum=" + pageNum);
    }
    service.deleteEvent(eventNum);
    return new ModelAndView("redirect:/event/event");
  }
Exemplo n.º 21
0
  @Test
  @Transactional
  public void testAddContactToMultipleGroupsMultipleConstituents() throws Exception {

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

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

    Contact contact = new Contact();
    contact.setFirstName("Test Contact");
    contact.setEmail("*****@*****.**");
    contactService.create(contact);

    contactService.addContactToCommittee(contact, committee);
    contactService.attendEvent(contact, event);
    contactService.addToGroup(contact, group);
    contactService.addToGroup(contact, secondGroup);

    contact = contactService.findById(contact.getId());
    group = groupService.findById(group.getId());
    secondGroup = groupService.findById(secondGroup.getId());
    event = eventService.findById(event.getId());
    committee = committeeService.findById(committee.getId());

    assertTrue(contact.getGroups().contains(group));
    assertTrue(contact.getGroups().contains(secondGroup));
    assertTrue(contact.getCommittees().contains(committee));
    assertTrue(contact.getAttendedEvents().contains(event));

    assertTrue(event.getAttendees().contains(contact));
    assertTrue(event.getGroups().contains(group));
    assertTrue(event.getGroups().contains(secondGroup));

    assertTrue(committee.getMembers().contains(contact));
    assertTrue(committee.getGroups().contains(group));
    assertTrue(committee.getGroups().contains(secondGroup));

    assertTrue(group.getTopLevelMembers().contains(contact));
    assertTrue(group.getAggregations().contains(committee));
    assertTrue(group.getAggregations().contains(event));

    assertTrue(secondGroup.getTopLevelMembers().contains(contact));
    assertTrue(secondGroup.getAggregations().contains(committee));
    assertTrue(secondGroup.getAggregations().contains(event));
  }
Exemplo n.º 22
0
  @Override
  public BaseMessage dispose(String requestXML) throws Exception {
    // 获取msgType
    String msgType = super.getMsgType(requestXML);
    if (Constants.MSG_TYPE_EVENT.equals(msgType)) {
      // "事件"处理
      return eventService.dispose(requestXML);
    } else if (Constants.MSG_TYPE_TEXT.equals(msgType)) {
      // "文本"处理
      return textService.dispose(requestXML);
    }

    return null;
  }
Exemplo n.º 23
0
  // 이벤트 추가 서브밋
  @RequestMapping(value = "/admin/eventcreated", method = RequestMethod.POST)
  public String eventCreatedSubmit(HttpSession session, Event dto) throws Exception {
    String root = session.getServletContext().getRealPath("/");
    String path = root + File.separator + "uploads" + File.separator + "event";

    SessionInfo info = (SessionInfo) session.getAttribute("member");
    if (info == null) {
      return "redirect:/memeber/login";
    }

    dto.setUserId(info.getUserId());
    service.insertEvent(dto, path);

    return "redirect:/admin/event";
  }
Exemplo n.º 24
0
  @RequestMapping(value = "/admin/updateevent", method = RequestMethod.POST)
  public String eventUpdateSubmit(
      HttpSession session, Event dto, @RequestParam(value = "pageNum") String pageNum)
      throws Exception {
    SessionInfo info = (SessionInfo) session.getAttribute("member");
    if (info == null) {
      return "redirect:/memeber/login";
    }

    String root = session.getServletContext().getRealPath("/");
    String pathname = root + File.separator + "uploads" + File.separator + "event";
    service.updateEvent(dto, pathname);

    return "redirect:/event/article?pageNum=" + pageNum + "&eventNum=" + dto.getEventNum();
  }
Exemplo n.º 25
0
  @Test
  public void shouldUpdateEvent() {
    @SuppressWarnings("unchecked")
    Set<Student> newAttendees = new HashSet();
    newAttendees.add(pat);
    newAttendees.add(jim);

    EventForm updateParameter =
        new EventUpdateParameterBuilder()
            .id(1)
            .title("Spice Girls")
            .date(new Date(12, 12, 2011))
            .time("10:10")
            .description("Spice Girls 4 Lyf")
            .venue("P-81")
            .coordinator("Joel Tellez")
            .notes("Sick as party")
            .attendees(newAttendees)
            .build();

    Event newEvent =
        new EventBuilder()
            .title("Spice Girls")
            .attendees(newAttendees)
            .date(new Date(12, 12, 2011))
            .description("Spice Girls 4 Lyf")
            .venue("P-81")
            .coordinator("Joel Tellez")
            .notes("Sick as party")
            .build();

    when(eventRepository.load(1)).thenReturn(sportsEvent);
    when(service.update(updateParameter)).thenReturn(newEvent);
    Event updatedEvent = service.update(updateParameter);
    assertEquals(newEvent, updatedEvent);
  }
Exemplo n.º 26
0
  // 이벤트 추가 폼
  @RequestMapping(value = "/admin/event/eventcreatedform", method = RequestMethod.POST)
  public ModelAndView eventCreatedForm(
      HttpSession session,
      @RequestParam(value = "eventNum", defaultValue = "0") int eventNum,
      @RequestParam(value = "pageNum", defaultValue = "1") String pageNum)
      throws Exception {

    SessionInfo info = (SessionInfo) session.getAttribute("member");
    if (info == null) {
      return new ModelAndView("member/login");
    }

    Event dto = service.readEvent(eventNum);

    ModelAndView mav = new ModelAndView("admin/adminevent/eventcreated");
    if (eventNum == 0) mav.addObject("mode", "created");
    else mav.addObject("mode", "update");
    mav.addObject("dto", dto);
    mav.addObject("pageNum", pageNum);
    return mav;
  }
Exemplo n.º 27
0
  @Handler(
      delivery = Invoke.Asynchronously,
      priority = 10 /*, condition = "event.type.equals(UserLogEventType.AUTHENTICATE_ATTEMPT)"*/)
  public void onEvent(UserLogEvent event) {
    log.info("UserService attempting logon...");
    if (event.type.equals(UserLogEventType.LOGOFF)) {
      userService.currentUser = null;
    } else if (event.type.equals(UserLogEventType.AUTHENTICATE_ATTEMPT)) {

      // TODO: could be faster with a map of users by code.
      for (OrderUser user : getUsers().values()) {
        if (event.code.equals(user.signInCode)) {

          // User is logged on
          userService.currentUser = userService.loggedInUsers.get(user.token);
          log.info("UserService user logged on...");
          log.info("Current Context is" + userService.getCurrentUser());

          // Just update this event and re-post it as a Logon event.
          UserLogEvent logonEvent = new UserLogEvent();
          logonEvent.type = UserLogEventType.LOGON;
          logonEvent.user = user;

          EventService.getInstance().postEvent(logonEvent);

          return; // go ahead and exit.
        }
      }

      log.info("UserService No user found with that logon...");
      // Post auth failed event....
      event.type = UserLogEventType.AUTHENTICATED_FAILED;

      // If the sign on isn't successful, cast an Authentication Fail event..
      // TODO: catch enough of these, take a picture and email it!!! catch the crook...If anything,
      // limit failed attempts.
    }
  }
Exemplo n.º 28
0
  @Test
  @Transactional
  public void testAddEventMultipleGroups() throws Exception {

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

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

    event = eventService.findById(event.getId());
    assertTrue(event.getGroups().contains(group));
    assertTrue(event.getGroups().contains(secondGroup));

    group = groupService.findById(group.getId());
    assertTrue(group.getAggregations().contains(event));

    secondGroup = groupService.findById(secondGroup.getId());
    assertTrue(secondGroup.getAggregations().contains(event));
  }
 public boolean removeItemListener(String registrationId) {
   EventService eventService = getNodeEngine().getEventService();
   return eventService.deregisterListener(getServiceName(), name, registrationId);
 }
Exemplo n.º 30
0
 @Test
 public void shouldListAllEvents() {
   when(eventRepository.list()).thenReturn(events);
   assertThat(service.list(), hasItems(sportsEvent, annualEvent));
 }