Package com.motomapia

Source Code of com.motomapia.SyncPlaceTask

/*
*/

package com.motomapia;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import com.google.appengine.api.taskqueue.DeferredTask;
import com.googlecode.objectify.VoidWork;
import com.motomapia.entity.Place;
import com.motomapia.wikimapia.WikiPlace;

import static com.motomapia.OfyService.ofy;

/**
* Synchronizes one place
*
* @author Jeff Schnitzer
*/
@RequiredArgsConstructor
@Slf4j
public class SyncPlaceTask implements DeferredTask
{
  private static final long serialVersionUID = 1L;

  final WikiPlace wikiPlace;

  @Override
  public void run() {

    ofy().transact(new VoidWork() {
      @Override
      public void vrun() {
        log.debug("Syncing " + wikiPlace);

        Place place = ofy().load().type(Place.class).id(wikiPlace.getId()).now();

        if (place == null) {
          ofy().save().entity(new Place(wikiPlace));
        } else {
          place.updateFrom(wikiPlace);
        }
      }
    });
  }
}
TOP

Related Classes of com.motomapia.SyncPlaceTask

TOP
Copyright © 2018 www.massapi.com. 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.