Package com.google.gdata.data

Examples of com.google.gdata.data.DateTime


          String desc = parser.analyse(formatting.getContentValue(), program);
          myEntry.setContent(new PlainTextConstruct(desc));

          Calendar c = CalendarToolbox.getStartAsCalendar(program);

          DateTime startTime = new DateTime(c.getTime(), c.getTimeZone());

          c = CalendarToolbox.getEndAsCalendar(program);

          DateTime endTime = new DateTime(c.getTime(), c.getTimeZone());

          When eventTimes = new When();

          eventTimes.setStartTime(startTime);
          eventTimes.setEndTime(endTime);
View Full Code Here


    return false;
  }

  private CalendarEventEntry findEntryForProgram(GoogleService myService, URL postUrl, String title, Program program) throws IOException, ServiceException {
    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;
      }
    }

    return null;
View Full Code Here

    ArrayList<Meeting> aMeetings = new ArrayList<Meeting>();
   
    URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/private/full");
 
    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);
View Full Code Here

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

      CalendarQuery myQuery = new CalendarQuery(feedUrl);

    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) {
        myQuery.setMinimumStartTime(new DateTime(oMeet.getDate(DB.dt_start)));
        myQuery.setMaximumStartTime(new DateTime(oMeet.getDate(DB.dt_end)));
      if (DebugFile.trace) DebugFile.writeln("CalendarQuery.query("+feedUrl.toString()+","+oMeet.getDateTime24(DB.dt_start)+","+oMeet.getDateTime24(DB.dt_end)+", without time zone)");
      } 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);
        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++) {
View Full Code Here

    return httpConn.getHeaderField(headerName);
  }

  public DateTime getResponseDateHeader(String headerName) {
    long dateValue = httpConn.getHeaderFieldDate(headerName, -1);
    return (dateValue >= 0) ? new DateTime(dateValue) : null;
  }
View Full Code Here

   *
   * The value of userList is never null after calling this method.
   */
  private void refetch() {
    Date newFetchDate = new Date();
    DateTime lastFetchDateTime = null;
    if (lastFetchDate != null) {
      lastFetchDateTime = new DateTime(lastFetchDate);
    }

    
    String urlString = USER_LIST_FEED_PATTERN
                        .replaceAll("\\{domain\\}", domain);
View Full Code Here

    } catch (MalformedURLException murle) {
      LOGGER.severe(murle.toString());
      throw new RepositoryException(murle);
    }
   
    DateTime ifModifiedSince = null;
    if (checkpoint != null) {
      String dateString = checkpoint.substring(0, checkpoint.indexOf("!"));
      try {
        ifModifiedSince = DateTime.parseDateTime(dateString);
      } catch (NumberFormatException nfe) {
        LOGGER.info("Got " + nfe.toString() + " while parsing date part of"
            + "checkpoint.  Continuing as if no date was specified.");
      }
    }
    // If ifModifiedSince is null at this point service.query() will treat it
    // as if no threshold was specified (equivalent to the 2-arg form).
   
    DateTime fetchTime = DateTime.now();
    Query query = new Query(feedUrl);
    query.setMaxResults(MAX_RESULTS);
    if (ifModifiedSince != null) {
      // The use of ifModifiedSince here filters out entries that were
      // modified before the given date.  Logically, we only care about those
      // entries that were modified recently.
      query.setUpdatedMin(ifModifiedSince);
    }
   
    Feed feed = null;
    try {
      feed = (Feed) service.query(query, Feed.class, ifModifiedSince);
    } catch (NotModifiedException nme) {
      // excellent! no work to do
      return new LinkedList();
    } catch (ServiceException se) {
      LOGGER.severe(se.toString());
      throw new RepositoryException(se);
    } catch (IOException ioe) {
      LOGGER.severe(ioe.toString());
      throw new RepositoryException(ioe);
    }
    List entries = feed.getEntries();
    Collections.sort(entries, comparator);
    Entry lastEntry = (Entry) entries.get(entries.size() - 1);
    lastEntryId = lastEntry.getId();
    lastEntryCheckpoint = fetchTime.toString() + "!" + lastEntryId;
   
   
    if (checkpoint != null && ifModifiedSince != null) {
      // All of these entries were modified during or after the checkpoint time
      // but we still need to skip over any that have been processed before
View Full Code Here

  throws RepositoryException, AuthenticationException {
    final int COUNT = 9;
    final int SKIP = 6;
   
    List entries = new LinkedList();
    DateTime sometime = DateTime.now();
    for (int idx = 0; idx < COUNT; idx++) {
      Entry entry = new Entry();
      entry.setUpdated(sometime);
      entry.setId("" + idx);
      entries.add(entry);
    }
   
    Feed riggedFeed = new Feed();
    riggedFeed.getEntries().addAll(entries);
    RiggedCalendarService service = new RiggedCalendarService(riggedFeed);
    CalendarEntryProvider provider =
      new CalendarEntryProvider(service, "admin@example.com", "secret");
   
    String checkpoint = sometime.toString() + "!" + (SKIP - 1);
    List results = provider.getOrderedEntriesForUser("loltapir", checkpoint);
    assertEquals(COUNT - SKIP, results.size());
  }
View Full Code Here

public class EntryDocumentizerTest extends TestCase {

  public void testMakeDocumentExtractsRequiredMetadata() {
    String id = "ID";
    String uri = "http://localhost";
    DateTime dt = DateTime.now();
    String contentNonce = "\u9762" + System.currentTimeMillis();
   
    Entry entry = new Entry();
    entry.setId(id);
    entry.setUpdated(dt);
    entry.addHtmlLink(uri, "en", "example");
    entry.setContent(
        TextConstruct.create(TextConstruct.Type.TEXT, contentNonce, null));
   
    Document doc = null;
    try {
      doc = EntryDocumentizer.makeDocument(entry);
    } catch (RepositoryException re) {
      fail(re.toString());
    }
   
    assertEquals(id,
        getFirstStringValue(doc, SpiConstants.PROPNAME_DOCID));
    assertEquals(uri,
        getFirstStringValue(doc, SpiConstants.PROPNAME_DISPLAYURL));
    assertEquals(dt.toStringRfc822(),
        getFirstStringValue(doc, SpiConstants.PROPNAME_LASTMODIFIED));
    assertTrue(getFirstStringValue(doc, SpiConstants.PROPNAME_CONTENT)
        .contains(contentNonce));
  }
View Full Code Here

TOP

Related Classes of com.google.gdata.data.DateTime

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.