Exemplo n.º 1
0
  @Post("/projects/{project.id}/servers")
  public void addServer(final Server server, final Project project) {

    validator.checking(
        new Validations() {
          {
            if (server != null) {
              that(server.getDescription(), is(notEmpty()), "description", "invalid_description");
              that(server.getIp(), is(notEmpty()), "ip", "invalid_ip");
            }
          }
        });

    validator.onErrorForwardTo(ProjectsController.class).addServer(server, project);

    Project p = projectDao.find(project.getId());

    server.setCreation(Calendar.getInstance());
    server.setOwner(userInfo.getUser());

    p.addServer(server);

    projectDao.add(p);

    result.include("notice", server.getDescription() + " server added");
    result.redirectTo(ProjectsController.class).view(project);
  }
Exemplo n.º 2
0
 public void validate(Validator validator) {
   validator.checking(
       new Validations() {
         {
           that(isNotBlank(nome), "warning", "fiel.nome.invalido");
           if (that(dataDeNascimento != null, "warning", "fiel.dataNascimeto.naoInfomada")) {
             that(
                 dataDeNascimento.isBeforeNow() || dataDeNascimento.isEqualNow(),
                 "warning",
                 "fiel.dataNascimeto.invalida");
           }
         }
       });
 }
Exemplo n.º 3
0
  /**
   * Valida se o ddd e o telefone são válidos
   *
   * @return true - se o ddd e o telefone forem válidos <br>
   *     false - se o ddd e o telefone forem inválidos
   */
  public void validate(Validator validator) {
    validator.checking(
        new Validations() {
          {
            if (this.that(isValidDDD(), "validation", "validation.invalid", i18n("phone.ddd"))) ;

            switch (getType()) {
              case CELL:
                if (this.that(
                    isValidCellNumber(), "validation", "validation.invalid", i18n("phone.number")))
                  ;
                break;
              default:
                if (this.that(
                    isValidNumber(), "validation", "validation.invalid", i18n("phone.number"))) ;
            }
          }
        });
  }
Exemplo n.º 4
0
  @Post("/projects")
  public void add(final Project project) {

    validator.checking(
        new Validations() {
          {
            if (project != null) {
              that(project.getDescription(), is(notEmpty()), "description", "invalid_description");
            }
          }
        });

    validator.onErrorForwardTo(ProjectsController.class).list();

    project.setCreation(Calendar.getInstance());
    project.setOwner(userInfo.getUser());

    projectDao.add(project);

    result.include("notice", project.getDescription() + " project added");
    result.redirectTo(ProjectsController.class).list();
  }