Ejemplo n.º 1
0
 @Test
 public void exampleEventWithLocation() {
   Event event = createJsonMapper().toJavaObject(jsonFromClasspath("v2_5/event"), Event.class);
   assertNotNull(event);
   assertNotNull(event.getName());
   assertTrue(event.getName().contains("New York"));
   assertEquals(52, event.getAttendingCount().intValue());
   assertNotNull(event.getPlace());
   assertEquals(3.8, event.getPlace().getOverallRating().doubleValue(), 0.1);
   assertNotNull(event.getPlace().getLocation());
   assertTrue(event.getPlace().getName().contains("Ratskeller"));
   assertEquals("Germany", event.getPlace().getLocation().getCountry());
   assertEquals("66111", event.getPlace().getLocation().getZip());
   assertEquals(49.2349091, event.getPlace().getLocation().getLatitude().doubleValue(), 0.1);
 }
 public void addEvent(Event event) {
   if (remainingDuration < event.getDurationInMinutes()) {
     throw new IllegalStateException(
         "Not enough room in this slot to fit the event: '" + event.getName() + "'");
   }
   events.add(event);
   remainingDuration -= event.getDurationInMinutes();
 }
Ejemplo n.º 3
0
  private void generateEvent(final Event event) throws Exception {
    final ClassWriter classWriter =
        new ClassWriter(
            this,
            getSrcGeneratedDirectory(),
            GeneratorHelper.getEventPackage(domain),
            GeneratorHelper.getEventClassName(event));

    if (event.getParameter() != null) {
      for (final Parameter parameter : event.getParameter()) {
        classWriter.addClassMembers(parameter);
      }
    }

    classWriter.addExtend(GeneratorHelper.getBusinessEventExtends(event));

    // Constant
    classWriter.addConstants(
        "public static final com.ponysdk.core.event.Event.Type<"
            + GeneratorHelper.getHandlerClassName(event)
            + "> TYPE = new com.ponysdk.core.event.Event.Type<"
            + GeneratorHelper.getHandlerClassName(event)
            + ">();");

    // Build constructor
    final Parameter sourceComponentParameter = new Parameter();
    sourceComponentParameter.setName("sourceComponent");
    sourceComponentParameter.setClazz("java.lang.Object");
    final List<Parameter> superConstructorParameters = new ArrayList<Parameter>();
    superConstructorParameters.add(sourceComponentParameter);

    final List<Parameter> constructorParameters = new ArrayList<Parameter>(event.getParameter());
    constructorParameters.add(0, sourceComponentParameter);

    final Constructor constructor =
        new Constructor(constructorParameters, superConstructorParameters);
    classWriter.addConstructor(constructor);

    // Build methods
    classWriter.addLine("@Override");
    classWriter.addLine(
        "protected void dispatch(" + GeneratorHelper.getHandlerClassName(event) + " handler) {");
    classWriter.addLine("   handler.on" + event.getName() + "(this);");
    classWriter.addLine("}");
    classWriter.addNewLine();

    classWriter.addLine("@Override");
    classWriter.addLine(
        "public com.ponysdk.core.event.Event.Type<"
            + GeneratorHelper.getHandlerClassName(event)
            + "> getAssociatedType() {");
    classWriter.addLine("   return TYPE;");
    classWriter.addLine("}");

    // Adding
    classWriter.setGenerateGetter(true);
    classWriter.generateContentAndStore();
  }
Ejemplo n.º 4
0
 private void initEvent(Event event) {
   mEvent = event;
   title.setText(event.getName());
   subtitle.setText(event.getEnd().toString("HH:mm", Locale.US));
   usersGoing.setAdapter(new UsersListViewAdapter(event.getUsersGoing()));
   if (isMapReady) {
     moveCameraToLocation();
   }
 }
Ejemplo n.º 5
0
 public void add_event(Event e, Context context) {
   Log.d("DEBUG", "ADD EVENT");
   SQLiteDatabase db = getInstance(context).getWritableDatabase();
   ContentValues initialValues = new ContentValues();
   initialValues.put(COLUMN_EVENT_ID, e.getEvent_id());
   initialValues.put(COLUMN_NAME, e.getName());
   initialValues.put(COLUMN_TIME_STAMP, e.getTime_stamp());
   initialValues.put(COLUMN_PUBLISHER, e.getPublisher());
   ArrayList<String> list = e.getSubcribers();
   if (list == null) {
     list = new ArrayList<String>();
     list.add(e.getName());
   }
   String str = convertArrayListToString(list);
   initialValues.put(COLUMN_SUBSCRIBERS, str);
   db.insert(TABLE_EVENT, null, initialValues);
   db.close();
   return;
 }
 @Override
 public void execute(Event evt) {
   AOIEvent e = (AOIEvent) evt;
   log.debug(
       evt.getName()
           + ": "
           + e.who.getGuid().toString()
           + ", sender: "
           + evt.getSender().getGuid().toString());
 }
 private void _notify(final Event event) {
   for (final NotificationEndpoint endpoint : endpoints) {
     if (endpoint.getEvents().isEmpty()) {
       start(
           new Runnable() {
             public void run() {
               endpoint.notify(event);
             }
           });
     } else if (endpoint.getEvents().containsKey(event.getName())) {
       final EndpointEvent endpointEvent = endpoint.getEvents().get(event.getName());
       start(
           new Runnable() {
             public void run() {
               endpoint.notify(event, endpointEvent);
             }
           });
     }
   }
 }
  public boolean handleEvent(Event event) {
    //        MarsModelInfoEvent modelEvent = (MarsModelInfoEvent) event;

    Long objOid = event.getObjectOid();
    log.info("event=" + event.getName() + ", objOid=" + objOid);

    if (NewObjectHandler.ObjectMap.getObject(objOid) == null) {
      throw new RuntimeException(
          "MarsModelInfoHandler: did not get a newobject event for objoid " + objOid);
    }
    return true;
  }
Ejemplo n.º 9
0
  public void updateEventWithId(int id, Event e) {
    ContentValues cv = new ContentValues();
    cv.put(colName, e.getName());
    cv.put(colStartTime, e.getStartTime());
    cv.put(colEndTime, e.getEndTime());
    cv.put(colLatitude, e.getLatitude());
    cv.put(colLongitude, e.getLongitude());
    cv.put(transport, e.getTransport());
    cv.put(colInfo, e.getInfo());
    cv.put(colPassed, e.getPassed());

    db.update(eventTable, cv, colId + "=" + Integer.toString(id), null);
  }
Ejemplo n.º 10
0
 public EventEntity(Event event)
 {
     mVersionCode = 1;
     zzasD = event.getEventId();
     mName = event.getName();
     zzaoB = event.getDescription();
     zzaqW = event.getIconImageUri();
     zzarh = event.getIconImageUrl();
     zzarZ = (PlayerEntity)event.getPlayer().freeze();
     zzasE = event.getValue();
     zzasF = event.getFormattedValue();
     zzasG = event.isVisible();
 }
Ejemplo n.º 11
0
  public long AddEvent(Event e) {
    ContentValues cv = new ContentValues();

    cv.put(colName, e.getName());
    cv.put(colStartTime, e.getStartTime());
    cv.put(colEndTime, e.getEndTime());
    cv.put(colLatitude, e.getLatitude());
    cv.put(colLongitude, e.getLongitude());
    cv.put(transport, e.getTransport());
    cv.put(colInfo, e.getInfo());
    cv.put(colPassed, e.getPassed());

    return db.insert(eventTable, colName, cv);
  }
Ejemplo n.º 12
0
  private void moveCameraToLocation() {
    ParseGeoPoint geoPoint;
    String title;
    if (mEvent.getLocation() == null) {
      geoPoint = mEvent.getParseGeoPoint("UserLocation");
      title = mEvent.getName();
    } else {
      geoPoint = mEvent.getLocation().getLocation();
      title = mEvent.getLocation().getName();
    }

    LatLng location = new LatLng(geoPoint.getLatitude(), geoPoint.getLongitude());
    mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, 15));
    mGoogleMap.addMarker(new MarkerOptions().position(location).title(title));
  }
Ejemplo n.º 13
0
  public static EventSoap toSoapModel(Event model) {
    EventSoap soapModel = new EventSoap();

    soapModel.setEventId(model.getEventId());
    soapModel.setName(model.getName());
    soapModel.setDescription(model.getDescription());
    soapModel.setDate(model.getDate());
    soapModel.setCompanyId(model.getCompanyId());
    soapModel.setGroupId(model.getGroupId());
    soapModel.setUserId(model.getUserId());
    soapModel.setCreateDate(model.getCreateDate());
    soapModel.setModifiedDate(model.getModifiedDate());
    soapModel.setLocationId(model.getLocationId());

    return soapModel;
  }
Ejemplo n.º 14
0
  public void update_time_stamp(String event_name, long time_stamp, Context context) {

    Log.d("TIME STAMP IN DATABASE", (new Long(time_stamp)).toString());
    Event e = get_event(event_name, context);
    e.setTime_stamp((int) time_stamp);
    Log.d("GET EVENT", e.getName());

    int row = get_row(event_name, context);

    SQLiteDatabase db = getInstance(context).getWritableDatabase();
    db.delete(TABLE_EVENT, COLUMN_NO + "=" + row, null);
    add_event(e, context);
    db.close();
    e = get_event(event_name, context);
    Log.d("Sooooo called update", new Long(e.time_stamp).toString());
  }
Ejemplo n.º 15
0
  public void updateEvent(Event e) {
    ContentValues cv = new ContentValues();
    cv.put(colName, e.getName());
    cv.put(colStartTime, e.getStartTime());
    cv.put(colEndTime, e.getEndTime());
    cv.put(colLatitude, e.getLatitude());
    cv.put(colLongitude, e.getLongitude());
    cv.put(transport, e.getTransport());
    cv.put(colInfo, e.getInfo());

    if (e.getPassed()) {
      cv.put(colPassed, 1);
    } else {
      cv.put(colPassed, 0);
    }

    db.update(eventTable, cv, colId + "=" + Integer.toString(e.getId()), null);
  }
 @MediumTest
 public void testGetEvent_withLocationAndDescription() {
   mockServer
       .expect(requestTo("https://graph.facebook.com/193482154020832"))
       .andExpect(method(GET))
       .andExpect(header("Authorization", "OAuth someAccessToken"))
       .andRespond(withResponse(jsonResource("testdata/full-event"), responseHeaders));
   Event event = facebook.eventOperations().getEvent("193482154020832");
   assertEquals("193482154020832", event.getId());
   assertEquals("100001387295207", event.getOwner().getId());
   assertEquals("Art Names", event.getOwner().getName());
   assertEquals("Breakdancing Class", event.getName());
   assertEquals(Event.Privacy.SECRET, event.getPrivacy());
   assertEquals(toDate("2011-03-30T14:30:00+0000"), event.getStartTime());
   assertEquals(toDate("2011-03-30T17:30:00+0000"), event.getEndTime());
   assertEquals(toDate("2011-03-30T14:38:40+0000"), event.getUpdatedTime());
   assertEquals("Bring your best parachute pants!", event.getDescription());
   assertEquals("2400 Dunlavy Dr, Denton, TX", event.getLocation());
 }
Ejemplo n.º 17
0
  private void generateHandler(final Event event) throws Exception {
    final ClassWriter classWriter =
        new ClassWriter(
            this,
            getSrcGeneratedDirectory(),
            GeneratorHelper.getEventPackage(domain),
            GeneratorHelper.getHandlerClassName(event));

    classWriter.setInterface(true);
    classWriter.addExtend("com.ponysdk.core.event.EventHandler");

    // Build event method
    classWriter.addLine(
        "public void on"
            + event.getName()
            + "("
            + GeneratorHelper.getEventClassName(event)
            + " event);");

    classWriter.generateContentAndStore();
  }
Ejemplo n.º 18
0
  public void add_subscribers(String event_name, ArrayList<String> entry, Context context) {
    int row = get_row(event_name, context);
    for (int i = 0; i < entry.size(); i++) {
      Log.d("ADD SUBSCRIBER DATABASE", entry.get(i));
    }
    Event e = get_event(event_name, context);
    SQLiteDatabase db = getInstance(context).getWritableDatabase();
    ContentValues initialValues = new ContentValues();
    initialValues.put(COLUMN_EVENT_ID, e.getEvent_id());
    initialValues.put(COLUMN_NAME, e.getName());
    initialValues.put(COLUMN_TIME_STAMP, e.getTime_stamp());
    initialValues.put(COLUMN_PUBLISHER, e.getPublisher());
    String new_list = convertArrayListToString(entry);
    initialValues.put(COLUMN_SUBSCRIBERS, new_list);

    db.delete(TABLE_EVENT, COLUMN_NO + "=" + row, null);
    db.insert(TABLE_EVENT, null, initialValues);
    db.close();

    // db.update(TABLE_EVENT, initialValues,COLUMN_NAME + "=" + event_name, null);
  }
  private void populateItems() {
    //  create the form
    form = new Form("form");
    // create elements and add them to the form
    form.add(new Label("eventName", event.getName()));
    form.add(new Label("location", event.getLocation()));
    form.add(new Label("description", event.getDescription()));
    form.add(new Label("positions", event.getNumPositions()));
    form.add(new Label("positionsLeft", event.getNumPositionsRemaining()));

    form.add(
        new Button("apply") {
          @Override
          public void onSubmit() {
            EventDao ed = new EventDao();
            ed.insertUserSignsUpForEvent(CustomSession.get().getUser(), event);
            if (returnTo.equals("partnerHomeView")) setResponsePage(PartnerHomeView.class);
            else if (returnTo.equals("partnerEventView")) setResponsePage(PartnerEventView.class);
            else if (returnTo.equals("volunteerHomeView")) setResponsePage(VolunteerHomeView.class);
            else if (returnTo.equals("volunteerSearchPage"))
              setResponsePage(VolunteerSearchView.class);
          }
        });

    form.add(
        new Button("save") {
          @Override
          public void onSubmit() {
            if (returnTo.equals("partnerHomeView")) setResponsePage(PartnerHomeView.class);
            else if (returnTo.equals("partnerEventView")) setResponsePage(PartnerEventView.class);
            else if (returnTo.equals("volunteerHomeView")) setResponsePage(VolunteerHomeView.class);
            else if (returnTo.equals("volunteerSearchPage"))
              setResponsePage(VolunteerSearchView.class);
          }
        });

    // add the form to the page
    add(form);
  }
  @Override
  public boolean perform(Game game, Event event, Map<Parameter, MagicSet> parameters) {
    Event damageEvent =
        createEvent(game, event.getName(), EventType.DEAL_DAMAGE_EVENLY, parameters);
    boolean ret = damageEvent.perform(event, false);

    SetPattern affectedCreatures =
        new SimpleSetPattern(
            Intersect.instance(
                TakerOfDamage.instance(EventDamage.instance(Identity.instance(event))),
                CreaturePermanents.instance()));

    SimpleEventPattern regenerate = new SimpleEventPattern(EventType.REGENERATE);
    regenerate.put(EventType.Parameter.OBJECT, affectedCreatures);

    EventReplacementEffectStopper stopRegen =
        new EventReplacementEffectStopper(
            parameters.get(Parameter.SOURCE).getOne(GameObject.class), null, regenerate);
    ContinuousEffect.Part part =
        new ContinuousEffect.Part(ContinuousEffectType.STOP_REPLACEMENT_EFFECT);
    part.parameters.put(ContinuousEffectType.Parameter.PROHIBITION, Identity.instance(stopRegen));

    Map<EventType.Parameter, MagicSet> stopRegenParameters =
        new HashMap<EventType.Parameter, MagicSet>();
    stopRegenParameters.put(EventType.Parameter.CAUSE, parameters.get(Parameter.SOURCE));
    stopRegenParameters.put(EventType.Parameter.EFFECT, new MagicSet(part));
    Event regenStopper =
        createEvent(
            game,
            "A creature dealt damage this way can't be regenerated this turn.",
            EventType.CREATE_FLOATING_CONTINUOUS_EFFECT,
            stopRegenParameters);
    ret = regenStopper.perform(event, false) && ret;

    event.setResult(Empty.set);

    return ret;
  }
Ejemplo n.º 21
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      Event selectedEvent = getItem(position);

      // if we weren't given a view, inflate one
      if (null == convertView) {
        convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_event, null);
      }

      // TODO:set the event details here for all sub-views eventNameTextView
      ImageView imageButton = (ImageView) convertView.findViewById(R.id.eventImageView);
      // imageButton.setVisibility(View.GONE);
      Bitmap bitmap = imageCache.get(selectedEvent.getId());
      if (bitmap != null) {
        imageButton.setImageBitmap(bitmap);
        imageButton.setVisibility(View.VISIBLE);
      } else {
        // displayEventImage(selectedEvent, imageButton);

        //				TODO loadBitmap(selectedEvent, imageButton);
        if (true) { // selectedEvent.getCoverImage() != null) {
          //					new DownloadAndCacheImageTask(imageButton, mContext, true).execute(selectedEvent);

          Glide.with(mContext)
              .load(selectedEvent.getCoverImage())
              .fitCenter()
              .placeholder(R.drawable.ic_launcher)
              .crossFade()
              .into(imageButton);
        }
      }
      // TODO 10/1/14
      //            if(selectedEvent.getImageUri() != null || selectedEvent.getLocalFileUri() !=
      // null) {
      //            	displayEventImage(selectedEvent, imageButton);
      //            }
      //            else {
      //            	Log.d(TAG, "EventListFragment: getView() - hiding the ImageView until bitmap is
      // created");
      //            	imageButton.setMaxHeight(0);
      //            	imageButton.setVisibility(View.GONE);
      //            }
      TextView eventNameView = (TextView) convertView.findViewById(R.id.nameTextView);
      eventNameView.setText(selectedEvent.getName());
      TextView eventDayView = (TextView) convertView.findViewById(R.id.eventDay);
      eventDayView.setText(selectedEvent.getDay());
      TextView eventMonthView = (TextView) convertView.findViewById(R.id.eventMonth);
      eventMonthView.setText(selectedEvent.getMonth());
      TextView eventLocationView = (TextView) convertView.findViewById(R.id.eventLocation);
      if (selectedEvent.getLocation() != null) {
        eventLocationView.setText(selectedEvent.getLocation());
      }

      TextView eventStartTime = (TextView) convertView.findViewById(R.id.eventStartTime);

      if (selectedEvent.getStartTime() != null) {
        eventStartTime.setText(selectedEvent.getStartTime().getTime().toString());
      } else {
        eventStartTime.setText(selectedEvent.getTime());
      }
      //            ImageButton rsvpButton = (ImageButton)
      // convertView.findViewById(R.id.rsvp_status);
      //            rsvpButton.setOnClickListener(new View.OnClickListener() {
      //    			@Override
      //    			public void onClick(View v) {
      //    				Log.d(TAG, "rsvpButton clicked by View: " + v.getId());
      //    				//showPopup(v);
      //    			}
      //
      //    		});

      mPreferences = mContext.getSharedPreferences("cyathen_references", mContext.MODE_PRIVATE);
      mIsFriend = (mSharedPrefs.getBoolean("isFriendEvent", false));

      TextView eventInviterView = (TextView) convertView.findViewById(R.id.eventHost);

      /*mHostProfilePictureView = (ProfilePictureView) convertView
      		.findViewById(R.id.hostProfilePicture);
      mHostProfilePictureView.setPresetSize(ProfilePictureView.SMALL);*/

      String rsvpText = "";
      String name = "";
      Friend friend = FriendInventory.get(mContext).getFriend(selectedEvent.getInvitedFriendId());
      if (mIsFriend && friend != null) {
        name = friend.getName();
        rsvpText = " is ";
        // Log.d(TAG, "EventListFragment isFriendEvent: " + mIsFriend + ", name: " + name);
      } else {
        name = "You";
        rsvpText = " are ";
        // Log.d(TAG, "EventListFragment isFriendEvent: " + mIsFriend);
      }
      String rsvpStatus = selectedEvent.getRSVP();
      if (rsvpStatus != null) {
        if (rsvpStatus.equalsIgnoreCase("not_replied")) {
          rsvpStatus = "invited by " + selectedEvent.getHost();
        } else {
          if (rsvpStatus.equalsIgnoreCase("unsure")) rsvpStatus = "maybe going";
          else if (rsvpStatus.equalsIgnoreCase("attending")) rsvpStatus = "going!";
          else if (rsvpStatus.equalsIgnoreCase("declined")) rsvpStatus = "not going";
        }
        // Log.d(TAG, "rsvpStatus: " + rsvpStatus);
      } else {
        rsvpStatus = "Invited by " + selectedEvent.getHost();
      }
      // If Mode = 0; then it's an event I'm invited to
      // Set eventInviterView to: my rsvp and mHostProfilePictureView to: FB image of inviter/host
      // If Mode = 1; then it's an event a FRIEND is invited to
      // Set eventInviterView to: friend name " is invited" and mHostProfilePictureView to: FB image
      // of friend
      // If Mode = 2; then this is a list of all events ONE friend is invited to
      // Set eventInviterView to: friend's rsvp and mHostProfilePictureView to: FB image of
      // inviter/host
      if (mListMode == 0) {
        eventInviterView.setText(name + rsvpText + rsvpStatus);
        // mHostProfilePictureView.setProfileId(selectedEvent.getHostId());
        // Log.d(TAG, selectedEvent.getName() + " is MY event ");
      } else if (mListMode == 1) {
        if (selectedEvent.getInvitedFriendId() != null) {
          // Log.d(TAG, selectedEvent.getName() + " is from friend: "
          // +selectedEvent.getInvitedFriendId() + ", name:" +
          // FriendInventory.get(mContext).getFriend(selectedEvent.getInvitedFriendId()).getName());

          if (friend != null) {
            eventInviterView.setText(friend.getName() + " is invited");
          } else {
            eventInviterView.setText(
                "Your friend " + selectedEvent.getInvitedFriendId() + " is invited");
          }
          // mHostProfilePictureView.setProfileId(selectedEvent.getInvitedFriendId());
        }
      } else if (mListMode == 2) {
        eventInviterView.setText(rsvpText + rsvpStatus);
        // mHostProfilePictureView.setProfileId(selectedEvent.getHostId());
      }
      return convertView;
    }
  public void processEvent(Event E) {
    if (E.getName().equals("logJoints")) {

      jointList.add(joints);
    }
  }
Ejemplo n.º 23
0
  @Override
  protected Builder buildEntry(Builder builder, Resource resource) {
    Event event = (Event) resource;

    builder =
        builder
            .withValue(Events.CALENDAR_ID, id)
            .withValue(entryColumnRemoteName(), event.getName())
            .withValue(entryColumnETag(), event.getETag())
            .withValue(entryColumnUID(), event.getUid())
            .withValue(Events.ALL_DAY, event.isAllDay() ? 1 : 0)
            .withValue(Events.DTSTART, event.getDtStartInMillis())
            .withValue(Events.EVENT_TIMEZONE, event.getDtStartTzID())
            .withValue(Events.HAS_ATTENDEE_DATA, event.getAttendees().isEmpty() ? 0 : 1)
            .withValue(Events.GUESTS_CAN_INVITE_OTHERS, 1)
            .withValue(Events.GUESTS_CAN_MODIFY, 1)
            .withValue(Events.GUESTS_CAN_SEE_GUESTS, 1);

    boolean recurring = false;
    if (event.getRrule() != null) {
      recurring = true;
      builder = builder.withValue(Events.RRULE, event.getRrule().getValue());
    }
    if (event.getRdate() != null) {
      recurring = true;
      builder = builder.withValue(Events.RDATE, event.getRdate().getValue());
    }
    if (event.getExrule() != null)
      builder = builder.withValue(Events.EXRULE, event.getExrule().getValue());
    if (event.getExdate() != null)
      builder = builder.withValue(Events.EXDATE, event.getExdate().getValue());

    // set either DTEND for single-time events or DURATION for recurring events
    // because that's the way Android likes it (see docs)
    if (recurring) {
      // calculate DURATION from start and end date
      Duration duration = new Duration(event.getDtStart().getDate(), event.getDtEnd().getDate());
      builder = builder.withValue(Events.DURATION, duration.getValue());
    } else {
      builder =
          builder
              .withValue(Events.DTEND, event.getDtEndInMillis())
              .withValue(Events.EVENT_END_TIMEZONE, event.getDtEndTzID());
    }

    if (event.getSummary() != null) builder = builder.withValue(Events.TITLE, event.getSummary());
    if (event.getLocation() != null)
      builder = builder.withValue(Events.EVENT_LOCATION, event.getLocation());
    if (event.getDescription() != null)
      builder = builder.withValue(Events.DESCRIPTION, event.getDescription());

    if (event.getOrganizer() != null && event.getOrganizer().getCalAddress() != null) {
      URI organizer = event.getOrganizer().getCalAddress();
      if (organizer.getScheme() != null && organizer.getScheme().equalsIgnoreCase("mailto"))
        builder = builder.withValue(Events.ORGANIZER, organizer.getSchemeSpecificPart());
    }

    Status status = event.getStatus();
    if (status != null) {
      int statusCode = Events.STATUS_TENTATIVE;
      if (status == Status.VEVENT_CONFIRMED) statusCode = Events.STATUS_CONFIRMED;
      else if (status == Status.VEVENT_CANCELLED) statusCode = Events.STATUS_CANCELED;
      builder = builder.withValue(Events.STATUS, statusCode);
    }

    builder =
        builder.withValue(
            Events.AVAILABILITY,
            event.isOpaque() ? Events.AVAILABILITY_BUSY : Events.AVAILABILITY_FREE);

    if (event.getForPublic() != null)
      builder =
          builder.withValue(
              Events.ACCESS_LEVEL,
              event.getForPublic() ? Events.ACCESS_PUBLIC : Events.ACCESS_PRIVATE);

    return builder;
  }
Ejemplo n.º 24
0
 public void processEvent(Event e) {
   String name = e.getName();
   if (name.equals("touch")) {
     which_changed.setValue(1 - which_changed.getValue());
   }
 }
  @RequestMapping(value = path + "details")
  @ResponseBody
  public Request viewVoteDetails(
      @RequestParam(value = phoneNumber) String inputNumber,
      @RequestParam(value = entityUidParam) String eventUid,
      @RequestParam(value = "back") String backMenu)
      throws URISyntaxException {
    // todo: decide whether to allow users to change the closing time (& permissions, of course)
    // todo: have some way of counting reminders and only allow once unless paid account
    // todo: reconsider whether to save URL here, might want to set back to null

    User user =
        userManager.findByInputNumber(
            inputNumber, saveVoteMenu("details", eventUid) + "&back=" + backMenu);
    Event vote = eventBroker.load(eventUid);
    boolean futureEvent = vote.getEventStartDateTime().isAfter(Instant.now());
    ResponseTotalsDTO voteResults = eventLogBroker.getResponseCountForEvent(vote);

    USSDMenu menu;

    if (futureEvent) {
      EventLog userResponse =
          eventLogRepository.findByEventAndUserAndEventLogType(vote, user, EventLogType.RSVP);

      String responseText;
      List<String> otherResponses;
      if (userResponse == null || !userResponse.hasValidResponse()) {
        responseText = "not voted yet";
        otherResponses = Arrays.asList("yes", "no", "abstain");
      } else {
        switch (userResponse.getResponse()) {
          case YES:
            responseText = "yes";
            otherResponses = Arrays.asList("no", "abstain");
            break;
          case NO:
            responseText = "no";
            otherResponses = Arrays.asList("yes", "abstain");
            break;
          case MAYBE:
            responseText = "abstain";
            otherResponses = Arrays.asList("yes", "no");
            break;
          default:
            responseText = "not voted yet";
            otherResponses = Arrays.asList("yes", "no", "abstain");
            break;
        }
      }

      final String suffix = entityUidUrlSuffix + eventUid;
      final String[] fields =
          new String[] {
            vote.getAncestorGroup().getName(""),
            vote.getName(),
            "" + (voteResults.getNumberOfUsers() - voteResults.getNumberNoRSVP()),
            responseText
          };

      menu = new USSDMenu(getMessage(thisSection, "details", "future." + promptKey, fields, user));
      for (String voteOption : otherResponses) {
        menu.addMenuOption(
            voteMenus + "change-vote" + suffix + "&response=" + voteOption,
            getMessage(thisSection, "details", optionsKey + "change", voteOption, user));
      }

    } else {
      String[] fields =
          new String[] {
            vote.getAncestorGroup().getName(""),
            vote.getName(),
            "" + voteResults.getYes(),
            "" + voteResults.getNo(),
            "" + voteResults.getMaybe(),
            "" + voteResults.getNumberNoRSVP()
          };
      menu = new USSDMenu(getMessage(thisSection, "details", promptKey, fields, user));
    }

    menu.addMenuOption(
        voteMenus + backMenu, getMessage(thisSection, "details", optionsKey + "back", user));

    return menuBuilder(menu);
  }
Ejemplo n.º 26
0
 static int zza(Event event)
 {
     return zzw.hashCode(new Object[] {
         event.getEventId(), event.getName(), event.getDescription(), event.getIconImageUri(), event.getIconImageUrl(), event.getPlayer(), Long.valueOf(event.getValue()), event.getFormattedValue(), Boolean.valueOf(event.isVisible())
     });
 }