Search in sources :

Example 1 with Fournisseur

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

the class FournisseurServiceImpl method fournisseurList.

/**
 * search with nom
 *
 * @param pageable page description
 * @param search   keyword
 * @return Page
 */
@Override
public Page<Fournisseur> fournisseurList(Pageable pageable, String search) {
    log.info("Service- FournisseurServiceImpl Calling FournisseurList with params :" + pageable + ", " + search);
    try {
        if (search.isEmpty()) {
            log.debug("fetching Fournisseur page");
            return fournisseurRepo.findAll(pageable);
        } else {
            log.debug("Searching by :" + search);
            // creating example
            Fournisseur fournisseur = new Fournisseur();
            fournisseur.setNom(search);
            // creating matcher
            ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
            Example<Fournisseur> example = Example.of(fournisseur, matcher);
            log.debug("getting search results");
            return fournisseurRepo.findAll(example, pageable);
        }
    } catch (Exception e) {
        log.debug("Failed retrieving list of Fournisseurs");
        throw new OperationFailedException("Operation échouée", e);
    }
}
Also used : Fournisseur(me.kadarh.mecaworks.domain.others.Fournisseur) 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)

Example 2 with Fournisseur

use of me.kadarh.mecaworks.domain.others.Fournisseur 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)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)2 Fournisseur (me.kadarh.mecaworks.domain.others.Fournisseur)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 Chantier (me.kadarh.mecaworks.domain.others.Chantier)1 ExampleMatcher (org.springframework.data.domain.ExampleMatcher)1