use of me.kadarh.mecaworks.service.exceptions.OperationFailedException 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);
// setting groupe , soufamille to engin
engin.setGroupe(groupe);
engin.setSousFamille(sousFamille);
engin.setObjectif(null);
engin.setConsommationMoyenne(null);
// 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.service.exceptions.OperationFailedException 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);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class AdminUserController method addPost.
@PostMapping("/add")
public String addPost(Model model, Pageable pageable, @Valid User user, BindingResult result) {
if (result.hasErrors()) {
model.addAttribute("page", userRepo.findAll(pageable));
model.addAttribute("roles", AuthoritiesConstants.getRoles());
return "admin/users/add";
}
if (userRepo.findByUsername(user.getUsername()).isPresent())
throw new OperationFailedException("Nom d'utilisateur déja utilisé");
user.setPassword(encoder.encode(user.getPassword()));
userRepo.save(user);
return "redirect:/admin/users/add";
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class EmployeServiceImpl method employesList.
/**
* search with nom
*
* @param pageable page description
* @param search keyword
* @return Page
*/
@Override
public Page<Employe> employesList(Pageable pageable, String search) {
log.info("Service- employeServiceImpl Calling employeList with params :" + pageable + ", " + search);
try {
if (search.isEmpty()) {
log.debug("fetching employe page");
return employeRepo.findAll(pageable);
} else {
log.debug("Searching by :" + search);
// creating example
Employe employe = new Employe();
employe.setNom(search);
employe.setMetier(search);
// creating matcher
ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
Example<Employe> example = Example.of(employe, matcher);
log.debug("getting search results");
return employeRepo.findAll(example, pageable);
}
} catch (Exception e) {
log.debug("Failed retrieving list of employes");
throw new OperationFailedException("Operation échouée", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class FamilleServiceImpl method familleList.
/**
* search with nom
*
* @param pageable page description
* @param search keyword
* @return Page
*/
@Override
public Page<Famille> familleList(Pageable pageable, String search) {
log.info("Service- FamilleServiceImpl Calling familleList with params :" + pageable + ", " + search);
try {
if (search.isEmpty()) {
log.debug("fetching famille page");
return familleRepo.findAll(pageable);
} else {
log.debug("Searching by :" + search);
// creating example
Famille famille = new Famille();
famille.setNom(search);
Classe classe = new Classe();
classe.setNom(search);
famille.setClasse(classe);
// creating matcher
ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
Example<Famille> example = Example.of(famille, matcher);
log.debug("getting search results");
return familleRepo.findAll(example, pageable);
}
} catch (Exception e) {
log.debug("Failed retrieving list of familles");
throw new OperationFailedException("Operation échouée", e);
}
}
Aggregations