Search in sources :

Example 1 with Chantier

use of me.kadarh.mecaworks.domain.others.Chantier in project mecaworks by KadarH.

the class BonFournisseurServiceImpl method bonList.

@Override
public Page<BonFournisseur> bonList(Pageable pageable, String search) {
    log.info("Service- BonFournisseurServiceImpl Calling bonList with params :" + pageable + ", " + search);
    try {
        if (search.isEmpty()) {
            log.debug("fetching bonEngins page");
            return bonFournisseurRepo.findAll(pageable);
        } else {
            log.debug("Searching by :" + search);
            // creating example
            // Searching by code bon , nom chantier, nom fournisseur
            BonFournisseur bonFournisseur = new BonFournisseur();
            Chantier chantier = new Chantier();
            chantier.setNom(search);
            Fournisseur fournisseur = new Fournisseur();
            fournisseur.setNom(search);
            bonFournisseur.setChantier(chantier);
            bonFournisseur.setFournisseur(fournisseur);
            bonFournisseur.setCode(search);
            // creating matcher
            ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
            Example<BonFournisseur> example = Example.of(bonFournisseur, matcher);
            Pageable pageable1 = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by(Sort.Direction.DESC, bonFournisseur.getDate().toString()));
            log.debug("getting search results");
            return bonFournisseurRepo.findAll(example, pageable1);
        }
    } catch (Exception e) {
        log.debug("Failed retrieving list of employes");
        throw new OperationFailedException("Operation échouée", e);
    }
}
Also used : BonFournisseur(me.kadarh.mecaworks.domain.bons.BonFournisseur) Fournisseur(me.kadarh.mecaworks.domain.others.Fournisseur) BonFournisseur(me.kadarh.mecaworks.domain.bons.BonFournisseur) Chantier(me.kadarh.mecaworks.domain.others.Chantier) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) ResourceNotFoundException(me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with Chantier

use of me.kadarh.mecaworks.domain.others.Chantier in project mecaworks by KadarH.

the class ChantierServiceImpl method chantierList.

/**
 * search with nom and adresse
 *
 * @param pageable page description
 * @param search   keyword
 * @return Page
 */
@Override
public Page<Chantier> chantierList(Pageable pageable, String search) {
    log.info("Service- ChantierServiceImpl Calling chantierList with params :" + pageable + ", " + search);
    try {
        if (search.isEmpty()) {
            log.debug("fetching chantier page");
            return chantierRepo.findAll(pageable);
        } else {
            log.debug("Searching by :" + search);
            // creating example
            Chantier chantier = new Chantier();
            chantier.setNom(search);
            chantier.setAdresse(search);
            // creating matcher
            ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
            Example<Chantier> example = Example.of(chantier, matcher);
            log.debug("getting search results");
            return chantierRepo.findAll(example, pageable);
        }
    } catch (Exception e) {
        log.debug("Failed retrieving list of chantiers");
        throw new OperationFailedException("Operation échouée", e);
    }
}
Also used : Chantier(me.kadarh.mecaworks.domain.others.Chantier) ExampleMatcher(org.springframework.data.domain.ExampleMatcher) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) ResourceNotFoundException(me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)2 Chantier (me.kadarh.mecaworks.domain.others.Chantier)2 OperationFailedException (me.kadarh.mecaworks.service.exceptions.OperationFailedException)2 ResourceNotFoundException (me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException)2 BonFournisseur (me.kadarh.mecaworks.domain.bons.BonFournisseur)1 Fournisseur (me.kadarh.mecaworks.domain.others.Fournisseur)1 ExampleMatcher (org.springframework.data.domain.ExampleMatcher)1