Skip to content

Commit 29462ec

Browse files
saviosoaresUFCrlimapro
authored andcommitted
Implementing Ci-CD (#21)
1 parent 07d3c1f commit 29462ec

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

.github/workflows/build_mvn.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Echo Secrets and Build JavaFX Project
2+
3+
on:
4+
push:
5+
branches:
6+
- develop # Aciona a ação ao enviar mudanças para a branch "develop"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
MY_VARIABLE: "This is my public variable" # Variável de ambiente pública
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: '21' # Versão do Java usada no projeto
23+
distribution: temurin
24+
25+
- name: Setup Maven
26+
run: mvn -version # Verifica a versão do Maven
27+
28+
- name: Echo environment variable
29+
run: echo "My environment variable is $MY_VARIABLE" # Exibe a variável pública
30+
31+
- name: Echo GitHub secret
32+
run: echo "My GitHub secret is ${{ secrets.MY_GITHUB_SECRET }}" # Exibe o valor da chave secreta
33+
34+
- name: Run Tests
35+
run: mvn test
36+
37+
- name: Build with Maven
38+
run: mvn clean package # Compila o projeto

src/main/java/com/carvalhotechsolutions/mundoanimal/controllers/modals/ModalCriarAgendamentoController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ private void carregarClientes() {
237237
Cliente clienteSelecionado = create_agendamento_client_field.getValue();
238238
if (clienteSelecionado != null) {
239239
carregarPetsPorCliente(clienteSelecionado);
240+
241+
// Limpar o valor selecionado no ComboBox de pets
242+
create_agendamento_pet_field.setValue(null);
240243
}
241244
});
242245
}
@@ -313,7 +316,10 @@ public void configurarParaEdicao(Agendamento agendamento) {
313316
agendamento.getHorarioAgendamento().format(DateTimeFormatter.ofPattern("HH:mm"))
314317
);
315318
create_agendamento_servico_field.setValue(agendamento.getServico());
319+
320+
// Populando os ComboBoxes de cliente e pet
316321
create_agendamento_client_field.setValue(agendamento.getCliente());
322+
carregarPetsPorCliente(agendamento.getCliente()); // Carregar pets do cliente atual
317323
create_agendamento_pet_field.setValue(agendamento.getAnimal());
318324
}
319325

src/main/java/com/carvalhotechsolutions/mundoanimal/controllers/modals/ModalCriarClienteController.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,34 @@ public void configurarParaEdicao(Cliente cliente) {
111111
private boolean validarInputs(String nome, String telefone) {
112112

113113
nome = nome.trim();
114-
telefone = telefone.trim(); // trim() usado para remover espaços desnecessários
114+
telefone = telefone.trim(); // Remove espaços desnecessários
115115

116+
// Validação de campos vazios
116117
if (nome.isEmpty() || telefone.isEmpty()) {
117118
mostrarAlerta("Erro", "Campo(s) obrigatório(s) vazio(s)!", Alert.AlertType.ERROR);
118119
return false;
119120
}
121+
122+
// Extrair apenas os números do telefone para validação
123+
String telefoneNumerico = telefone.replaceAll("\\D", ""); // Remove tudo que não for número
124+
125+
// Validação do comprimento do telefone (apenas números)
126+
if (telefoneNumerico.length() != 11) {
127+
mostrarAlerta("Erro", "O telefone deve conter exatamente 11 dígitos numéricos.", Alert.AlertType.ERROR);
128+
return false;
129+
}
130+
131+
// Verificar se o telefone já está cadastrado
120132
String finalTelefone = telefone;
121133
boolean telefoneJaCadastrado = clienteRepository.findAll().stream()
122134
.anyMatch(cliente -> cliente.getTelefone().equals(finalTelefone) &&
123135
(clienteAtual == null || !cliente.getId().equals(clienteAtual.getId())));
124-
if (telefoneJaCadastrado){
136+
if (telefoneJaCadastrado) {
125137
mostrarAlerta("Erro", "O telefone informado já está cadastrado no sistema.", Alert.AlertType.ERROR);
126138
return false;
127139
}
140+
141+
// Verificar se o nome já está cadastrado
128142
String finalNome = nome;
129143
boolean nomeJaCadastrado = clienteRepository.findAll().stream()
130144
.anyMatch(cliente -> cliente.getNome().equalsIgnoreCase(finalNome) &&
@@ -135,7 +149,8 @@ private boolean validarInputs(String nome, String telefone) {
135149
return false;
136150
}
137151

138-
if(nome.equalsIgnoreCase("admin")) {
152+
// Impedir o cadastro de "admin"
153+
if (nome.equalsIgnoreCase("admin")) {
139154
mostrarAlerta("Erro", "Não é possível cadastrar um admin.", Alert.AlertType.ERROR);
140155
return false;
141156
}

0 commit comments

Comments
 (0)