com.google.api.gbase.client.GoogleBaseAttributesExtension

Here are the examples of the java api class com.google.api.gbase.client.GoogleBaseAttributesExtension taken from open source projects.

1. EventPublisher#publishEventToBase()

View license
/**
   * Publishes an individual event to Base 
   *
   * @param event The <code>Event</code> to publish
   * @throws EPAuthenticationException 
   * @throws IOException 
   * @throws ServiceException
   */
private void publishEventToBase(Event event) throws EPAuthenticationException, IOException, ServiceException {
    GoogleBaseService baseService = getBaseService();
    GoogleBaseEntry entry = null;
    if (event.getBaseUrl() != null) {
        // updating base entry
        entry = baseService.getEntry(event.getBaseUrl(), GoogleBaseEntry.class);
        entry = new GoogleBaseEntry();
    } else {
        // publishing new entry
        entry = new GoogleBaseEntry();
    }
    // prepare an 'events and activities' item for publishing
    GoogleBaseAttributesExtension gbaseAttributes = entry.getGoogleBaseAttributes();
    entry.setTitle(new PlainTextConstruct(event.getTitle()));
    entry.setContent(new PlainTextConstruct(event.getDescription()));
    gbaseAttributes.setItemType("events and activities");
    // this sample currently only demonstrates publishing all-day events
    // an event in Google Base must have a start-time and end-time, so
    // this simulates that by adding 1 day to the end-date specified, if the
    // start and end times are identical
    DateTime startDateTime = new DateTime(event.getStartDate());
    startDateTime.setDateOnly(true);
    DateTime endDateTime = null;
    if (event.getStartDate().equals(event.getEndDate())) {
        Calendar endDateCal = new GregorianCalendar();
        endDateCal.setTime(event.getEndDate());
        endDateCal.add(Calendar.DATE, 1);
        endDateTime = new DateTime(endDateCal.getTime());
    } else {
        endDateTime = new DateTime(event.getEndDate());
    }
    endDateTime.setDateOnly(true);
    gbaseAttributes.addDateTimeRangeAttribute("event date range", new DateTimeRange(startDateTime, endDateTime));
    gbaseAttributes.addTextAttribute("event performer", "Google mashup test");
    gbaseAttributes.addUrlAttribute("performer url", "http://code.google.com/apis/gdata.html");
    if (event.getBaseUrl() != null) {
        // updating event
        baseService.update(event.getBaseUrl(), entry);
    } else {
        // insert event
        GoogleBaseEntry resultEntry = baseService.insert(FeedURLFactory.getDefault().getItemsFeedURL(), entry);
        updateSsEventEditUrl(event.getSsEditUrl(), null, resultEntry.getEditLink().getHref());
    }
}