Search in sources :

Example 1 with SousFamille

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

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

the class SousFamilleServiceImpl method sousFamilleList.

@Override
public Page<SousFamille> sousFamilleList(Pageable pageable, String search) {
    log.info("Service- SousFamilleServiceImpl Calling sousFamilleList with params :" + pageable + ", " + search);
    try {
        if (search.isEmpty()) {
            log.debug("fetching sousFamille page");
            return sousFamilleRepo.findAll(pageable);
        } else {
            log.debug("Searching by :" + search);
            // creating example
            SousFamille sousFamille = new SousFamille();
            sousFamille.setNom(search);
            if (marqueRepo.findByNom(search).isPresent()) {
                sousFamille.setMarque(marqueRepo.findByNom(search).get());
            }
            if (familleRepo.findByNom(search).isPresent()) {
                sousFamille.setFamille(familleRepo.findByNom(search).get());
            }
            // creating matcher
            ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
            Example<SousFamille> example = Example.of(sousFamille, matcher);
            log.debug("getting search results");
            return sousFamilleRepo.findAll(example, pageable);
        }
    } catch (Exception e) {
        log.debug("Failed retrieving list of SousFamilles");
        throw new OperationFailedException("Operation échouée", e);
    }
}
Also used : SousFamille(me.kadarh.mecaworks.domain.others.SousFamille) 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 SousFamille

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

the class SousFamilleController method add.

@GetMapping("/add")
public String add(Model model, Pageable pageable, @RequestParam(defaultValue = "") String search) {
    model.addAttribute("sousFamille", new SousFamille());
    model.addAttribute("page", sousFamilleService.sousFamilleList(pageable, search));
    model.addAttribute("familles", familleService.list());
    model.addAttribute("marques", marqueService.list());
    model.addAttribute("typesCompteur", TypeCompteur.values());
    model.addAttribute("search", search);
    return "admin/sousFamilles/add";
}
Also used : SousFamille(me.kadarh.mecaworks.domain.others.SousFamille)

Aggregations

SousFamille (me.kadarh.mecaworks.domain.others.SousFamille)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 Marque (me.kadarh.mecaworks.domain.others.Marque)1