Package fr.emn.nuitinfo.model.persistence.impl

Source Code of fr.emn.nuitinfo.model.persistence.impl.ChasseDatastoreDAO

package fr.emn.nuitinfo.model.persistence.impl;

import static com.googlecode.objectify.ObjectifyService.ofy;

import java.util.List;

import com.google.gson.Gson;

import fr.emn.nuitinfo.model.Chasse;
import fr.emn.nuitinfo.model.interfaces.IChasse;
import fr.emn.nuitinfo.model.persistence.IDAO;

public class ChasseDatastoreDAO implements IDAO<IChasse> {

  @Override
  public List<IChasse> retrieveAll() {
    return ofy().load().type(IChasse.class).list();
  }

  @Override
  public void create(String t) {
    Gson gson = new Gson();
    Chasse chasse = gson.fromJson(t, Chasse.class);
    ofy().save().entity(chasse);
  }

  @Override
  public IChasse retrieveByName(String name) {
    return ofy().load().type(Chasse.class).id(name).get();
  }

  @Override
  public void update(String name, String t) {
    Gson gson = new Gson();
    IChasse chasse = gson.fromJson(t, Chasse.class);
    ofy().delete().type(Chasse.class).id(chasse.getNom());
    ofy().save().entity(chasse);
  }

  @Override
  public void remove(String name) {
    ofy().delete().type(Chasse.class).id(name);
  }

}
TOP

Related Classes of fr.emn.nuitinfo.model.persistence.impl.ChasseDatastoreDAO

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.