Package com.google.gdata.data.calendar

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


        final String title = parser.analyse(formatting.getTitleValue(), program);

        // First step: search for event in calendar
        boolean createEvent = true;

        CalendarEventEntry entry = findEntryForProgram(myService, postUrl, title, program);

        if (entry != null) {
          int ret = JOptionPane.showConfirmDialog(null, mLocalizer.msg("alreadyAvailable", "already available", program.getTitle()), mLocalizer.msg("title", "Add event?"),  JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

          if (ret != JOptionPane.YES_OPTION) {
View Full Code Here


  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;
       
        oStmm.setString(1, sGuWorkArea);
        oStmm.setString(2, oEvnt.getIcalUID());
        oRSet = oStmm.executeQuery();
        if (oRSet.next())
          bAlreadyExists = oMeet.load(oConn, oRSet.getString(1));
        else
          oMeet.put(DB.gu_meeting, Gadgets.generateUUID());
    oRSet.close();
           
        oMeet.put(DB.id_domain, iIdDomain);
        oMeet.put(DB.gu_workarea, sGuWorkArea);
        oMeet.put(DB.gu_fellow, sGuUser);
        oMeet.put(DB.gu_writer, sGuUser);
        oMeet.put(DB.bo_private, (short) (oEvnt.getVisibility().getValue().equals(Visibility.PRIVATE_VALUE) || oEvnt.getVisibility().getValue().equals(Visibility.CONFIDENTIAL_VALUE) ? 1 : 0));
        oMeet.put(DB.id_icalendar, oEvnt.getIcalUID());
        oMeet.put(DB.dt_start, new Date(oTimes.get(0).getStartTime().getValue()));
        oMeet.put(DB.dt_end, new Date(oTimes.get(0).getEndTime().getValue()));
        if (oEvnt.getTitle()!=null) oMeet.put(DB.tx_meeting, oEvnt.getTitle().getPlainText());
        if (oEvnt.getPlainTextContent()!=null) oMeet.put(DB.de_meeting, oEvnt.getPlainTextContent());
    oMeet.store(oConn);
   
    DBSubset oFlws = bAlreadyExists ? oMeet.getFellows(oConn) : new DBSubset(DB.k_fellows, "'','','','',''", null, 1);
   
    for (EventWho oEwho : oEvnt.getParticipants()) {
      String sEMail = oEwho.getEmail();
      if (sEMail!=null) {
        int iFlw = oFlws.find(4, sEMail);
        if (iFlw<0) {
          oStmf.setString(1, sGuWorkArea);
View Full Code Here

  public void writeMeetingToGoogle(JDCConnection oConn, Meeting oMeet)
    throws IOException, SQLException, MalformedURLException, ServiceException {

  URL postUrl = new URL("https://www.google.com/calendar/feeds/"+sEMail+"/private/full");

  CalendarEventEntry oEvnt;

  if (oMeet.isNull(DB.id_icalendar)) {
    oEvnt = new CalendarEventEntry();
    oEvnt.setIcalUID(oMeet.getString(DB.gu_meeting)+"@hipergate.org");
    oEvnt.setTitle(new PlainTextConstruct(oMeet.getStringNull(DB.tx_meeting,"")));
      oEvnt.setContent(new PlainTextConstruct(oMeet.getStringNull(DB.de_meeting,"")));
   
    When oTimes = new When();
    String sTimeZone = DBCommand.queryStr(oConn, "SELECT "+DB.tx_timezone+" FROM "+DB.k_fellows+" WHERE "+DB.gu_fellow+"='"+oMeet.getString(DB.gu_fellow)+"'");
      if (null==sTimeZone) {
        oTimes.setStartTime(new DateTime(oMeet.getDate(DB.dt_start)));
      oTimes.setEndTime(new DateTime(oMeet.getDate(DB.dt_end)));
      } else {
        int lSign = sTimeZone.charAt(0)=='+' ? 1 : -1;
        String[] aTimeZone = Gadgets.split2(sTimeZone.substring(1),':');
        SimpleTimeZone oTmz = new SimpleTimeZone(lSign*(Integer.parseInt(aTimeZone[0])*3600000+Integer.parseInt(aTimeZone[1])*60000), sTimeZone);
        oTimes.setStartTime(new DateTime(oMeet.getDate(DB.dt_start),oTmz));
      oTimes.setEndTime(new DateTime(oMeet.getDate(DB.dt_end),oTmz));
      }
    oEvnt.addTime(oTimes);
    DBSubset oFlws = oMeet.getFellows(oConn);
    for (int f=0; f<oFlws.getRowCount(); f++) {
      if (!oFlws.isNull(4,f)) {
        EventWho oEwho = new EventWho();
        oEwho.setEmail(oFlws.getString(4,f));
        oEvnt.addParticipant(oEwho);
      } // fi
    } // next
    oEvnt = oCalSrv.insert(postUrl, oEvnt);

    if (!oMeet.isNull(DB.bo_private))
      oEvnt.getVisibility().setValue(oMeet.getShort(DB.bo_private)==0 ? Visibility.PUBLIC_VALUE : Visibility.PRIVATE_VALUE);     
   
    DBCommand.executeUpdate(oConn, "UPDATE "+DB.k_meetings+" SET "+DB.id_icalendar+"='"+oMeet.getString(DB.gu_meeting)+"@hipergate.org"+"' WHERE "+DB.gu_meeting+"='"+oMeet.getString(DB.gu_meeting)+"'");
  } else {
      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);
        else
          oEvnt.getVisibility().setValue(oMeet.getShort(DB.bo_private)==0 ? Visibility.PUBLIC_VALUE : Visibility.PRIVATE_VALUE);     
        When oTimes = new When();
          oTimes.setStartTime(new DateTime(oMeet.getDate(DB.dt_start)));
        oTimes.setEndTime(new DateTime(oMeet.getDate(DB.dt_end)));
        oEvnt.addTime(oTimes);
        DBSubset oFlws = oMeet.getFellows(oConn);
        for (int f=0; f<oFlws.getRowCount(); f++) {
          if (!oFlws.isNull(4,f)) {
            EventWho oEwho = new EventWho();
            oEwho.setEmail(oFlws.getString(4,f));
            oEvnt.addParticipant(oEwho);
          } // fi
        } // next
        if (DebugFile.trace)
          DebugFile.writeln("CalendarService.update("+new URL(oEvnt.getEditLink().getHref()).toString()+","+oEvnt.getIcalUID());
        oCalSrv.update(new URL(oEvnt.getEditLink().getHref()), oEvnt);
        break;
      } // fi
    } // next       
  } // fi
  } // writeMeetingToGoogle
View Full Code Here

      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()+",*)");
      oCalSrv.delete(new URL(oEvnt.getEditLink().getHref()),"*");
        break;
      } // fi
    } // next       
  } else {
    if (DebugFile.trace) DebugFile.writeln("meeting does not have an iCalendar unique identifier");
View Full Code Here

import java.util.TimeZone;

public class SmsUtil {
    public static void send(String title, String username, String password)
            throws SmsSendException {
        CalendarEventEntry entry = new CalendarEventEntry();
        CalendarService service = new CalendarService("GrayGoose-1.0");

        try {
            service.setUserCredentials(username, password);
        } catch (AuthenticationException e) {
            throw new SmsSendException("Illegal credentials.", e);
        }

        entry.setService(service);
        entry.setTitle(TextConstruct.plainText(title));
        entry.setContent(TextConstruct.plainText(""));

        setupWhen(entry);
        try {
            CalendarEventEntry insertedEntry = service.insert(
                    new URL("http://www.google.com/calendar/feeds/default/private/full"),
                    entry
            );
            setupReminder(insertedEntry);
            insertedEntry.update();
        } catch (IOException | ServiceException e) {
            throw new SmsSendException("Can't add calendar event.", e);
        }
    }
View Full Code Here

            List<CalendarEventEntry> entriesToInsert = new ArrayList<CalendarEventEntry>();
            for (Long id : adIds) {
              if (id != null) {
                Ad ad = DatastoreProxy.getAdById(id);
                if (ad != null) {
                  CalendarEventEntry eventEntry = new CalendarEventEntry();
                  String title, content, attendee;
                  title = ad.getProduct() + " (" + ad.getCompany() + ")";
                  eventEntry.setTitle(new PlainTextConstruct(title));
                  // EventWho who = new EventWho();
                  // who.setValueString(attendee);
                  // who.setEmail("casamind.avicena@gmail.com");
                  // eventEntry.getParticipants().add(who);
                  content = ad.getSlogan() + "\n" + ad.getText();
                  if (ad.getResourceURLs() != null) {
                    for (String resource : ad.getResourceURLs()) {
                      content += "\n" + resource;
                    }
                  }
                  eventEntry.setContent(new PlainTextConstruct(content));
                  DateTime startTime = DateTime.parseDateTime(calFormatter.format(ad.getStartTime()));
                  DateTime endTime = DateTime.parseDateTime(calFormatter.format(ad.getEndTime()));
                  When eventTimes = new When();
                  eventTimes.setStartTime(startTime);
                  eventTimes.setEndTime(endTime);
                  eventEntry.addTime(eventTimes);
                  entriesToInsert.add(eventEntry);
                  log.info("Added event: " + title + "\tFrom: " + startTime + "\tto: " + endTime);
                }
              }
            }
View Full Code Here

        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());
View Full Code Here

        User user = (User) req.getSession().getAttribute("user");
        if (user == null ) {
            resp.sendRedirect("login");
        } else {
            try {
                CalendarEventEntry entry = nextEvent(user.getEmail());
                req.setAttribute("nextEvent", entry);
            } catch (Exception e) {
                throw new ServletException("Unable to fetch next calendar event", e);
            }
            req.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").forward(req, resp);
View Full Code Here

        UserInfo user = (UserInfo) req.getSession().getAttribute("user");
        if (user == null ) {
            resp.sendRedirect("/");
        } else {
            try {
                CalendarEventEntry entry = nextEvent(user);
                req.setAttribute("nextEvent", entry);
            } catch (Exception e) {
                throw new ServletException("Unable to fetch next calendar event", e);
            }
            req.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").forward(req, resp);
View Full Code Here

   * @throws ServiceException
   */
  private void publishEventToCalendar(Event event)
  throws EPAuthenticationException, IOException, ServiceException {
    CalendarService calService = getCalService();
    CalendarEventEntry entry = null;
    if (event.getCalendarUrl() != null) {
      // updating event
      entry = calService.getEntry(event.getCalendarUrl(),
          CalendarEventEntry.class);
    } else {
      // publishing new event
      entry = new CalendarEventEntry();  
    }

    // set data on event
    entry.setTitle(new PlainTextConstruct(event.getTitle()));
    entry.setContent(new PlainTextConstruct(event.getDescription()));
    When when = new When();
    DateTime startDateTime = new DateTime(event.getStartDate());
    startDateTime.setDateOnly(true);

    // we must add 1 day to the event as the end-date is exclusive
    Calendar endDateCal = new GregorianCalendar();
    endDateCal.setTime(event.getEndDate());
    endDateCal.add(Calendar.DATE, 1);
    DateTime endDateTime = new DateTime(endDateCal.getTime());
    endDateTime.setDateOnly(true);

    when.setStartTime(startDateTime);
    when.setEndTime(endDateTime);
    entry.getTimes().add(when);
    if (event.getCalendarUrl() != null) {
      // updating event
      entry.update()
    } else {
      // insert event
      CalendarEventEntry resultEntry = calService.insert(calUrl, entry);
      updateSsEventEditUrl(event.getSsEditUrl(),
          resultEntry.getEditLink().getHref(),
          null);
    }
  }
View Full Code Here

TOP

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

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.