Search in sources :

Example 1 with Marque

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

the class EnginServiceImpl method enginList.

@Override
public Page<Engin> enginList(Pageable pageable, String search) {
    log.info("Service- EnginServiceImpl Calling enginList with params :" + pageable + ", " + search);
    try {
        if (search.isEmpty()) {
            log.debug("fetching engin page");
            return enginRepo.findAll(pageable);
        } else {
            log.debug("Searching by :" + search);
            // creating example
            Engin engin = new Engin();
            engin.setNumeroSerie(search);
            engin.setCode(search);
            // sousfamille
            SousFamille sousFamille = new SousFamille();
            sousFamille.setNom(search);
            // groupe
            Groupe groupe = new Groupe();
            groupe.setNom(search);
            // marque
            Marque marque = new Marque();
            marque.setNom(search);
            // setting groupe , marque , soufamille to engin
            engin.setGroupe(groupe);
            engin.setSousFamille(sousFamille);
            // creating matcher
            ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
            Example<Engin> example = Example.of(engin, matcher);
            log.debug("getting search results");
            return enginRepo.findAll(example, pageable);
        }
    } catch (Exception e) {
        log.debug("Failed retrieving list of engins");
        throw new OperationFailedException("Operation échouée, problème de saisi", e);
    }
}
Also used : Marque(me.kadarh.mecaworks.domain.others.Marque) SousFamille(me.kadarh.mecaworks.domain.others.SousFamille) Groupe(me.kadarh.mecaworks.domain.others.Groupe) ExampleMatcher(org.springframework.data.domain.ExampleMatcher) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) Engin(me.kadarh.mecaworks.domain.others.Engin) ResourceNotFoundException(me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with Marque

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

the class MarqueServiceImpl method marqueList.

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

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

the class MarqueController method add.

@GetMapping("/add")
public String add(Model model, Pageable pageable, @RequestParam(defaultValue = "") String search) {
    model.addAttribute("marque", new Marque());
    model.addAttribute("page", marqueService.marqueList(pageable, search));
    model.addAttribute("search", search);
    return "admin/marques/add";
}
Also used : Marque(me.kadarh.mecaworks.domain.others.Marque)

Aggregations

Marque (me.kadarh.mecaworks.domain.others.Marque)3 NoSuchElementException (java.util.NoSuchElementException)2 OperationFailedException (me.kadarh.mecaworks.service.exceptions.OperationFailedException)2 ResourceNotFoundException (me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException)2 ExampleMatcher (org.springframework.data.domain.ExampleMatcher)2 Engin (me.kadarh.mecaworks.domain.others.Engin)1 Groupe (me.kadarh.mecaworks.domain.others.Groupe)1 SousFamille (me.kadarh.mecaworks.domain.others.SousFamille)1