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);
}
}
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);
}
}
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";
}
Aggregations