Skip to content

Commit

Permalink
Merge pull request #40 from ClementGib/task#76
Browse files Browse the repository at this point in the history
task#76: Message formatter and all log and message revision
  • Loading branch information
ClementGib authored Nov 7, 2024
2 parents 212fb33 + f9f8185 commit 2ebe52c
Show file tree
Hide file tree
Showing 40 changed files with 585 additions and 469 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ quarkus dev -e
./mvnw clean package
```

*Pour voir les logs*
```bash
./mvnw quarkus:dev -Dquarkus.log.level=DEBUG
```

3. (Optionel) Lancer les tests Junit 5

*A la racine du projet*
Expand Down
94 changes: 0 additions & 94 deletions application/src/main/docker/Dockerfile.jvm

This file was deleted.

90 changes: 0 additions & 90 deletions application/src/main/docker/Dockerfile.legacy-jar

This file was deleted.

27 changes: 0 additions & 27 deletions application/src/main/docker/Dockerfile.native

This file was deleted.

30 changes: 0 additions & 30 deletions application/src/main/docker/Dockerfile.native-micro

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public BankAccount toDto(BankAccountEntity entity) {

dto.setIssuedTransactions(entity.getIssuedTransactions().stream()
.map(transactionMapper::toDto)
// .collect(Collectors.toSet(ArrayList::new)));
.collect(Collectors.toSet()));

return dto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,32 @@
import com.cdx.bas.domain.bank.account.BankAccount;
import com.cdx.bas.domain.bank.account.BankAccountException;
import com.cdx.bas.domain.bank.account.BankAccountPersistencePort;
import com.cdx.bas.domain.message.MessageFormatter;
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import io.quarkus.panache.common.Sort;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;
import jakarta.transaction.TransactionManager;
import jakarta.transaction.Transactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import static com.cdx.bas.domain.text.MessageConstants.BANK_ACCOUNT_START;
import static jakarta.transaction.Transactional.TxType.REQUIRED;
import static com.cdx.bas.domain.message.CommonMessages.*;

/***
* persistence implementation for BankAccount entities
*
*
* @author Clément Gibert
*
*/
@ApplicationScoped
public class BankAccountRepository implements BankAccountPersistencePort, PanacheRepositoryBase<BankAccountEntity, Long> {

private static final Logger logger = LoggerFactory.getLogger(BankAccountRepository.class);
public static final String ID_FIELD = "id";

BankAccountMapper bankAccountMapper;

Expand All @@ -48,20 +47,20 @@ public BankAccountRepository(BankAccountMapper bankAccountMapper,

@Override
public List<BankAccount> getAll() {
return findAll(Sort.by("id")).stream()
.map(bankAccountEntity -> bankAccountMapper.toDto(bankAccountEntity))
.collect(Collectors.toList());
return findAll(Sort.by(ID_FIELD)).stream()
.map(bankAccountMapper::toDto)
.toList();
}

@Override
public Optional<BankAccount> findById(long id) {
return findByIdOptional(id).map(bankAccountMapper::toDto);
}

@Override
public BankAccount create(BankAccount bankAccount) {
entityManager.persist(bankAccountMapper.toEntity(bankAccount));
logger.info(BANK_ACCOUNT_START + bankAccount.getId() + " created");
logger.debug(MessageFormatter.format(BANK_ACCOUNT_CONTEXT, CREATION_ACTION, SUCCESS_STATUS));
return bankAccount;
}

Expand All @@ -72,20 +71,20 @@ public BankAccount update(BankAccount bankAccount) {
getEntityManager();
BankAccountEntity merge = entityManager.merge(entity);
bankAccount = bankAccountMapper.toDto(merge);
logger.info(BANK_ACCOUNT_START + bankAccount.getId() + " updated");
logger.debug(MessageFormatter.format(BANK_ACCOUNT_CONTEXT, UPDATE_ACTION, SUCCESS_STATUS));
return bankAccount;
} catch (UnsupportedOperationException exception) {
throw new BankAccountException("invalid", exception);
throw new BankAccountException(MessageFormatter.format(BANK_ACCOUNT_CONTEXT, UPDATE_ACTION, FAILED_STATUS));
}
}

@Override
public Optional<BankAccount> deleteById(long id) {
Optional<BankAccountEntity> entityOptional = findByIdOptional(id);
if (entityOptional.isPresent()) {
BankAccountEntity entity = entityOptional.get();
delete(entity);
logger.info("BankAccount " + entity.getId() + " deleted");
logger.debug(MessageFormatter.format(BANK_ACCOUNT_CONTEXT, DELETION_ACTION, SUCCESS_STATUS));
return Optional.of(bankAccountMapper.toDto(entity));
}
return Optional.empty();
Expand Down
Loading

0 comments on commit 2ebe52c

Please sign in to comment.