Package com.google.gdata.data.calendar

Examples of com.google.gdata.data.calendar.CalendarEventFeed


    Calendar c = CalendarToolbox.getStartAsCalendar(program);
    DateTime startTime = new DateTime(c.getTime(), c.getTimeZone());

    Query myQuery = new Query(postUrl);
    myQuery.setFullTextQuery(title);
    CalendarEventFeed myResultsFeed = myService.query(myQuery, CalendarEventFeed.class);

    for (CalendarEventEntry entry : myResultsFeed.getEntries()) {
      if ((entry.getTimes().size() > 0) && (entry.getTimes().get(0).getStartTime().getValue() == startTime.getValue())) {
        return entry;
      }
    }
View Full Code Here


 
    CalendarQuery myQuery = new CalendarQuery(feedUrl);
    myQuery.setMinimumStartTime(new DateTime(dtFrom));
    myQuery.setMaximumStartTime(new DateTime(dtTo));

  CalendarEventFeed oFeed = oCalSrv.query(myQuery, CalendarEventFeed.class);   

  ResultSet oRSet;
    PreparedStatement oStmm = oConn.prepareStatement("SELECT "+DB.gu_meeting+" FROM "+DB.k_meetings+" WHERE "+DB.gu_workarea+"=? AND "+DB.id_icalendar+"=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    PreparedStatement oStmf = oConn.prepareStatement("SELECT "+DB.gu_fellow+" FROM "+DB.k_fellows+" WHERE "+DB.gu_workarea+"=? AND "+DB.tx_email+"=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

  for (int i = 0; i < oFeed.getEntries().size(); i++) {
      CalendarEventEntry oEvnt = oFeed.getEntries().get(i);
      List<When> oTimes = oEvnt.getTimes();
      if (oTimes.size()>0) {
        Meeting oMeet = new Meeting();
        boolean bAlreadyExists = false;
       
View Full Code Here

      URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/private/full");
      CalendarQuery myQuery = new CalendarQuery(feedUrl);
      myQuery.setMinimumStartTime(new DateTime(oMeet.getDate(DB.dt_start)));
      myQuery.setMaximumStartTime(new DateTime(oMeet.getDate(DB.dt_end)));

    CalendarEventFeed oFeed = oCalSrv.query(myQuery, CalendarEventFeed.class);   
    for (int i = 0; i < oFeed.getEntries().size(); i++) {
        oEvnt = oFeed.getEntries().get(i);
      if (oEvnt.getIcalUID().equals(oMeet.getString(DB.id_icalendar))) {
        oEvnt.setTitle(new PlainTextConstruct(oMeet.getStringNull(DB.tx_meeting,"")));
          oEvnt.setContent(new PlainTextConstruct(oMeet.getStringNull(DB.de_meeting,"")));
        if (oMeet.isNull(DB.bo_private))
          oEvnt.getVisibility().setValue(Visibility.DEFAULT_VALUE);
View Full Code Here

        myQuery.setMinimumStartTime(new DateTime(oMeet.getDate(DB.dt_start),oTmz));
        myQuery.setMaximumStartTime(new DateTime(oMeet.getDate(DB.dt_end),oTmz));
      if (DebugFile.trace) DebugFile.writeln("CalendarQuery.query("+feedUrl.toString()+","+oMeet.getDateTime24(DB.dt_start)+","+oMeet.getDateTime24(DB.dt_end)+", GMT "+oTmz.getID()+")");
      }

    CalendarEventFeed oFeed = oCalSrv.query(myQuery, CalendarEventFeed.class);   
    for (int i = 0; i < oFeed.getEntries().size(); i++) {
        CalendarEventEntry oEvnt = oFeed.getEntries().get(i);
      if (oEvnt.getIcalUID().equals(oMeet.getString(DB.id_icalendar))) {
        if (DebugFile.trace)
          DebugFile.writeln("CalendarService.update("+new URL(oEvnt.getEditLink().getHref()).toString()+","+oEvnt.getIcalUID());
        oEvnt = oCalSrv.update(new URL(oEvnt.getEditLink().getHref()), oEvnt);
        if (DebugFile.trace) DebugFile.writeln("CalendarService.delete("+new URL(oEvnt.getEditLink().getHref()).toString()+",*)");
 
View Full Code Here

  public void batchEntries(List<CalendarEventEntry> entries, BatchOperationType batchOperationType) throws BatchInterruptedException, MalformedURLException, IOException, ServiceException {
    if (entries == null || entries.size() == 0) {
      return;
    }
    // Create an batch entry to delete an existing event.
    CalendarEventFeed batchRequest = new CalendarEventFeed();
    for (CalendarEventEntry entry : entries) {
      BatchUtils.setBatchId(entry, entry.getTitle().getPlainText());
      BatchUtils.setBatchOperationType(entry, batchOperationType);
      batchRequest.getEntries().add(entry);
    }

    // Get the batch link URL and send the batch request there.
    Link batchLink = batchFeed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM);
    CalendarEventFeed batchResponse = service.batch(new URL(batchLink.getHref()), batchRequest);

    // Ensure that all the operations were successful.
    boolean isSuccess = true;
    for (CalendarEventEntry entry : batchResponse.getEntries()) {
      String batchId = BatchUtils.getBatchId(entry);
      if (!BatchUtils.isSuccess(entry)) {
        isSuccess = false;
        BatchStatus status = BatchUtils.getBatchStatus(entry);
        log.warning("\n" + batchId + " failed (" + status.getReason() + ") " + status.getContent());
View Full Code Here

    log.info("Deleting calendar event entries for withdrawn slot with entityId: " + entityId);
    Slot slot = DatastoreProxy.getSlotById(entityId);
    if (slot != null) {
      log.info("Purging Google Calendar from '" + logFormatter.format(slot.getStartDate()) + "' to '" + logFormatter.format(slot.getEndDate()) + "'");
      try {
        CalendarEventFeed rangeFeed = proxy.getEventsRangeFeed(slot.getStartDate(), slot.getEndDate());
        List<CalendarEventEntry> entriesToDelete = new ArrayList<CalendarEventEntry>();
        entriesToDelete.addAll(rangeFeed.getEntries());
        int size = entriesToDelete.size();
        while (size > 0) {
          log.info("Adding " + size + " event entries to mass deletion batch...");
          proxy.batchEntries(entriesToDelete, BatchOperationType.DELETE);
          rangeFeed = proxy.getEventsRangeFeed(slot.getStartDate(), slot.getEndDate());
          entriesToDelete.clear();
          entriesToDelete.addAll(rangeFeed.getEntries());
          size = entriesToDelete.size();
        }
        log.info("Finshed mass deletion batch.");
      } catch (IOException e) {
        // TODO Auto-generated catch block
View Full Code Here

            Calendar calendar = Calendar.getInstance();
            calendar.setTime(schedule.getMinDate());
            calendar.add(Calendar.DAY_OF_YEAR, -2);
            Date minDate = calendar.getTime();
            CalendarEventFeed rangeFeed = proxy.getEventsRangeFeed(minDate, schedule.getMaxDate());
            List<CalendarEventEntry> entriesToDelete = new ArrayList<CalendarEventEntry>();
            entriesToDelete.addAll(rangeFeed.getEntries());
            int size = entriesToDelete.size();
            while (size > 0) {
              log.info("Adding " + size + " event entries to mass deletion batch...");
              proxy.batchEntries(entriesToDelete, BatchOperationType.DELETE);
              rangeFeed = proxy.getEventsRangeFeed(minDate, schedule.getMaxDate());
              entriesToDelete.clear();
              entriesToDelete.addAll(rangeFeed.getEntries());
              size = entriesToDelete.size();
            }
            log.info("Finshed mass deletion batch.");
            List<CalendarEventEntry> entriesToInsert = new ArrayList<CalendarEventEntry>();
            for (Long id : adIds) {
View Full Code Here

      URL eventUrl = new URL ( calEntry.getLink(Link.Rel.ALTERNATE, Link.Type.ATOM).getHref() );
     
      // Get Number of events 
      Query eventQuery = new Query(eventUrl);
      eventQuery.setMaxResults(1);    
      CalendarEventFeed eventFeed = calService.query(eventQuery, CalendarEventFeed.class)
      if (eventFeed.getTotalResults() == 0) {
        System.out.println("No Events");
      } else {
        // Set Number of events for query
        eventQuery.setMaxResults(eventFeed.getTotalResults());
        eventFeed = calService.query(eventQuery, CalendarEventFeed.class);       
      }

      Boolean exists = false;
      Boolean update = false;
      Integer batchid = 0;

        Method methodType = Method.ALERT; //Method.EMAIL;
        Reminder reminder = new Reminder();
        reminder.setDays( REMINDER_DAYS );
        reminder.setMethod(methodType);
      CalendarEventFeed batchRequest = new CalendarEventFeed();

      // Copy contacts with title and birthday and check if event exists
      for (ContactEntry contact : conFeed.getEntries()) {

        if ( (contact.hasName()) && (contact.hasBirthday()) ) {
         
          exists = false;
          update = false;
         
          CalendarEventEntry entry = new CalendarEventEntry();
         
          SimpleDateFormat sdf = new SimpleDateFormat( DATE_FORMAT_GCON_PARSE_YMD );
          Date date;
          String datePattern;
          try {
            sdf.applyPattern( DATE_FORMAT_GCON_PARSE_YMD );
            date = sdf.parse(contact.getBirthday().getWhen());
            datePattern = DATE_FORMAT_GCAL_TEXT_DMY;
          } catch (ParseException e) {
            sdf.applyPattern( DATE_FORMAT_GCON_PARSE_MD );
            date = sdf.parse(contact.getBirthday().getWhen());
            datePattern = DATE_FORMAT_GCAL_TEXT_DM;
          }         
         
          for ( CalendarEventEntry event : eventFeed.getEntries() ) {

            if ( event.getTitle().getPlainText().contains( contact.getName().getFullName().getValue() ) ) {
              // found event for given contact
              // check date
              sdf.applyPattern( DATE_FORMAT_GCAL_SET_EVENT );
              if ( event.getRecurrence().getValue().contains( sdf.format(date) )) {
              //if ( event.getRecurrence().getValue().contains( recurData.substring(0, 25) )) {
                // same date - nothing todo
                //DEBUG: System.out.println("\tcontact and event have same date: " + contact.getName().getFullName().getValue() + " " + event.getTitle().getPlainText() );
                System.out.println("\tcontact and event have same date: " + contact.getName().getFullName().getValue() + " " + event.getTitle().getPlainText() );
                exists = true;
              }
              else {
                // date not correct - update date
                //DEBUG: System.out.println("\tcontact and event have not the same date: " + contact.getName().getFullName().getValue() + " " + contact.getBirthday().getWhen() + " " + event.getTitle().getPlainText() /* + " " + event.getRecurrence().getValue() */ );
                System.out.println("\tcontact and event have not the same date: " + contact.getName().getFullName().getValue() + " " + contact.getBirthday().getWhen() );
                update = true;
                entry = event;
              }
            }
          }
          if ( exists == false ) {
            // no event for given contact - add event
            sdf.applyPattern( datePattern );
            entry.setTitle( new PlainTextConstruct( contact.getName().getFullName().getValue() + " " + sdf.format(date) ) );
            entry.setContent( new PlainTextConstruct( "Birthday Celebration " + contact.getName().getFullName().getValue() + " (" + sdf.format(date) + ")") );
              sdf.applyPattern( DATE_FORMAT_GCAL_SET_EVENT );
            String recurData = "DTSTART;VALUE=DATE:" + sdf.format(date) + "\n"
                       + "DTEND;VALUE=DATE:" + sdf.format(date) + "\n"
                       + "RRULE:FREQ=YEARLY";
              Recurrence recur = new Recurrence();
              recur.setValue(recurData);
              entry.setRecurrence(recur);

              entry.getReminder().add(reminder);

            batchid++;
            BatchUtils.setBatchId(entry, batchid.toString());
            if ( update == true ) {
              System.out.println("\tUpd contact: " + contact.getName().getFullName().getValue());
              BatchUtils.setBatchOperationType(entry, BatchOperationType.UPDATE);
            } else {
              System.out.println("\tAdd contact: " + contact.getName().getFullName().getValue());
              BatchUtils.setBatchOperationType(entry, BatchOperationType.INSERT)
            }
            batchRequest.getEntries().add(entry);
          }
        }
      }

     
      // Get the batch link URL and send the batch request there.
      if ( batchRequest.getEntries().isEmpty() ) {
        System.out.println("No Batch Request");
      }else {
            System.out.println("Send Calendar Batch Request");
        Link batchLink = eventFeed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM);
        //CalendarEventFeed batchResponse =
View Full Code Here

        query.addCustomParameter(new Query.CustomParameter("orderby", "starttime"));
        query.addCustomParameter(new Query.CustomParameter("sortorder","a"));
        query.addCustomParameter(new Query.CustomParameter("singleevents","true"));
        query.addCustomParameter(new Query.CustomParameter("xoauth_requestor_id", userEmail));

        CalendarEventFeed results = calendarService.query(query, CalendarEventFeed.class);
        if (!results.getEntries().isEmpty()) {
            return results.getEntries().get(0);
        } else {
            return null;
        }
    }
View Full Code Here

        query.addCustomParameter(new Query.CustomParameter("orderby", "starttime"));
        query.addCustomParameter(new Query.CustomParameter("sortorder","a"));
        query.addCustomParameter(new Query.CustomParameter("singleevents","true"));
        query.addCustomParameter(new Query.CustomParameter("xoauth_requestor_id", user.getEmail()));

        CalendarEventFeed results = calendarService.query(query, CalendarEventFeed.class);
        if (!results.getEntries().isEmpty()) {
            return results.getEntries().get(0);
        } else {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of com.google.gdata.data.calendar.CalendarEventFeed

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.