Examples of Objectify


Examples of com.googlecode.objectify.Objectify

  public <T> Result<Void> delete(final Class<T> clazz, final long id) {

    return new ResultHelper<Void>() {

      public Void get() {
        Objectify sync = base.sync();
        T object = sync.get(clazz, id);
        new Deleter(sync, factory).delete(object);
        return null;
      }

    };
View Full Code Here

Examples of com.googlecode.objectify.Objectify

  public <T> Result<Void> delete(final Class<T> clazz, final String name) {

    return new ResultHelper<Void>() {

      public Void get() {
        Objectify sync = base.sync();
        T object = sync.get(clazz, name);
        new Deleter(sync, factory).delete(object);
        return null;
      }

    };
View Full Code Here

Examples of com.googlecode.objectify.Objectify

    return new ResultHelper<Void>() {

      public Void get() {

        Objectify sync = base.sync();
        Deleter deleter = new Deleter(sync, factory);

        for (Object object : keysOrEntities) {

          if (isKey(object)) {
            sync.delete(object);
          } else {
            deleter.delete(object);
          }

        }
View Full Code Here

Examples of com.googlecode.objectify.Objectify

  }

  @Test
  public void testGetcObjectify() {

    Objectify objectify = persiter.getObjectify();

    assertNotNull(objectify);

  }
View Full Code Here

Examples of com.googlecode.objectify.Objectify

    String ip = this.getThreadLocalRequest().getRemoteAddr();
   
    // The Objectify service for the entity must be registered before any
    // operations can be executed
    ObjectifyService.register(Note.class);
    Objectify ofy = ObjectifyService.begin();

    Note note = a;
    // Use setters to populate the object
    // the Key will be auto generated and does not need to be set
    ofy.put(note);
  }
View Full Code Here

Examples of com.googlecode.objectify.Objectify

    // + SessionListener.getActiveSessions());

    searchString = searchString.toLowerCase();

    ObjectifyService.register(Note.class);
    Objectify ofy = ObjectifyService.begin();

    Query<Note> q = ofy.query(Note.class).filter("parent", searchString)
        .order("-date");

    ArrayList<Note> notes = new ArrayList<Note>();

    // Loop the query results and add to the array
View Full Code Here

Examples of com.googlecode.objectify.Objectify

      final User updatedUser) throws ObjectNotFoundException, InvalidEditException {

    // TODO Validate that the current user has the required privileges!
    long userId = updatedUser.getId();

    Objectify ofyTxn = newOfyTransaction();
    try {
      UserImpl user = ofyTxn.get(UserImpl.class, userId);
      user.editFrom(updatedUser);
      ofyTxn.put(user);
      ofyTxn.getTxn().commit();
    } catch (NotFoundException e) {
      throw new ObjectNotFoundException("User not found, can't modify. Id = " + userId);
    } finally {
      if (ofyTxn.getTxn().isActive()) {
        ofyTxn.getTxn().rollback();
      }
    }
  }
View Full Code Here

Examples of com.googlecode.objectify.Objectify

    if (emailQuery == null) {
      return null;
    }

    Objectify ofyTxn = newOfyTransaction();

    UserImpl user = null;
    int retry = 0;
    while (user == null && retry < MAX_RETRIES) {
      try {
        EmailToUser emailToUser = ofyTxn.get(EmailToUser.class, emailQuery);
        ofyTxn.getTxn().commit();
        user = ofy().get(emailToUser.getUserKey());
      } catch (NotFoundException e) {
        user = new UserImpl(emailQuery);
        user.setLocale(locale);
        ofy().put(user);
        EmailToUser emailToUser = new EmailToUser(emailQuery, user.createKey());
        ofyTxn.put(emailToUser);
        ofyTxn.getTxn().commit();
      } finally {
        if (ofyTxn.getTxn().isActive()) {
          ofyTxn.getTxn().rollback();
          if (user != null) {
            ofy().delete(user);
          }
          user = null;
        }
View Full Code Here

Examples of com.googlecode.objectify.Objectify

    if (puzzleInfo.getId() != null) {
      throw new ObjectAlreadyCreatedException("Puzzle info already has an id: " + puzzleInfo.getId());
    }

    Objectify ofyTxn = newOfyTransaction();

    try {
      ofyTxn.put(puzzleInfo);
      puzzleDetails.attachToPuzzleInfo(puzzleInfo);
      ofyTxn.put(puzzleDetails);
      puzzleInfo.setPuzzleDetailsId(puzzleDetails.getId());
      ofyTxn.put(puzzleInfo);
      puzzle.attachToPuzzleDetails(puzzleDetails);
      ofyTxn.put(puzzle);
      puzzleDetails.setPuzzleId(puzzle.getId());
      ofyTxn.put(puzzleDetails);
      ofyTxn.getTxn().commit();
    } finally {
      if (ofyTxn.getTxn().isActive()) {
        ofyTxn.getTxn().rollback();
        throw new TransactionFailedException("Cannot create puzzle, title = \"" + puzzleInfo.getTitle() + "\"");
      }
    }
  }
View Full Code Here

Examples of com.googlecode.objectify.Objectify

import com.googlecode.objectify.Query;

public class AuthorityService {

  public static AuthorityEntity save(AuthorityEntity page) {
    Objectify ofy = OS.begin();
    ofy.put(page);
    return page;
  }
View Full Code Here
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.