Ejemplo n.º 1
0
  @Override
  protected void initialize(
      TaskinatraServiceConfiguration taskinatraServiceConfiguration, Environment environment)
      throws Exception {

    final DatabaseFactory factory = new DatabaseFactory(environment);
    final Database db =
        factory.build(taskinatraServiceConfiguration.getDatabaseConfiguration(), "h2");
    final PeopleDAO peopleDAO = db.onDemand(PeopleDAO.class);

    environment.addResource(new PeopleResource(peopleDAO));
    environment.addResource(new PersonResource(peopleDAO));
  }
  @GET
  @ApiOperation(
      value = "List some apples",
      notes = "extra notes",
      responseClass = "ro.mbog.statistics.api.GridResult")
  @Timed
  public GridResult<Apple> listApples() {
    GridResult<Apple> appleGrid = new GridResult<Apple>();
    appleGrid.setPage(1);
    appleGrid.setRecords(43L);
    appleGrid.setTotal(4);

    AppleDao dao = database.onDemand(AppleDao.class);

    appleGrid.setRows(dao.findAll());

    return appleGrid;
  }