Package com.google.api.gbase.client

Examples of com.google.api.gbase.client.GoogleBaseEntry


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


    this(null, null, null, null, null, null, null);
  }

  public GoogleBaseEntry toGoogleBaseEntry(String idUrl)
  {
    GoogleBaseEntry entry = new GoogleBaseEntry();
    entry.getGoogleBaseAttributes().setItemType(RECIPE_ITEMTYPE);
    if (idUrl != null) {
      entry.setId(idUrl);
    }
    entry.setTitle(TextConstruct.create(TextConstruct.Type.TEXT, title, null));
    if (url != null) {
      entry.addHtmlLink(url, null, null);
    }
    if (description != null) {
      // If the original content was not TEXT, the formatting is lost
      entry.setContent(
          TextConstruct.create(TextConstruct.Type.TEXT, description, null));
    }
    for (String ingredient : mainIngredient) {
      entry.getGoogleBaseAttributes().addTextAttribute(
          MAIN_INGREDIENT_ATTRIBUTE, ingredient);
    }
    for (String cuisineItem : cuisine) {
      entry.getGoogleBaseAttributes().addTextAttribute(
          CUISINE_ATTRIBUTE, cuisineItem);
    }
    if (cookingTime != null) {
      entry.getGoogleBaseAttributes().addIntUnitAttribute(
          COOKING_TIME_ATTRIBUTE, cookingTime);
    }
    return entry;
  }
View Full Code Here

    // Display the URL generated by the API
    System.out.println("Sending request to: " + url);

    try {
      GoogleBaseEntry entry = service.getEntry(url);
      // Print the item type
      printItemTypeEntry(entry);
    } catch (ServiceException e) {
      printServiceException(e);
    }
View Full Code Here

  private void recipeDisplay(HttpServletRequest request,
                         HttpServletResponse response,
                         GoogleBaseService service,
                         String id)
      throws ServletException, IOException {
    GoogleBaseEntry entry;
    try {
      URL feedUrl = urlFactory.getSnippetsEntryURL(id);
      entry = service.getEntry(feedUrl, GoogleBaseEntry.class);
    } catch (ServiceException e) {
      RecipeUtil.logServiceException(this, e);
View Full Code Here

   */
  protected void recipeAdd(GoogleBaseService service,
                           Recipe recipe)
    throws IOException, ServiceException {
    URL feedUrl = urlFactory.getItemsFeedURL();
    GoogleBaseEntry entry = recipe.toGoogleBaseEntry(null);
    service.insert(feedUrl, entry);
  }
View Full Code Here

   */
  protected void recipeUpdate(GoogleBaseService service,
                              Recipe recipe)
      throws ServiceException, IOException {
    URL feedUrl = urlFactory.getItemsEntryURL(recipe.getId());
    GoogleBaseEntry entry = recipe.toGoogleBaseEntry(feedUrl.toString());
    service.update(feedUrl, entry);
  }
View Full Code Here

        Recipe recipe = null;
        if (isAdd()) {
          recipe = new Recipe();
        } else if (isUpdate()) {
          URL entryUrl = urlFactory.getItemsEntryURL(id);
          GoogleBaseEntry entry = service.getEntry(entryUrl);
          recipe = new Recipe(entry);
        }
        if (recipe != null) {
          // Ready to add or update
          editRecipe(request, response, recipe, null);
View Full Code Here

TOP

Related Classes of com.google.api.gbase.client.GoogleBaseEntry

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.