Search in sources :

Example 1 with Employe

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

the class EmployeController method add.

@GetMapping("/add")
public String add(Model model) {
    model.addAttribute("employe", new Employe());
    model.addAttribute("metiers", Metier.values());
    return "admin/employes/add";
}
Also used : Employe(me.kadarh.mecaworks.domain.others.Employe)

Example 2 with Employe

use of me.kadarh.mecaworks.domain.others.Employe 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);
    }
}
Also used : ExampleMatcher(org.springframework.data.domain.ExampleMatcher) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) Employe(me.kadarh.mecaworks.domain.others.Employe) ResourceNotFoundException(me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

Employe (me.kadarh.mecaworks.domain.others.Employe)2 NoSuchElementException (java.util.NoSuchElementException)1 OperationFailedException (me.kadarh.mecaworks.service.exceptions.OperationFailedException)1 ResourceNotFoundException (me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException)1 ExampleMatcher (org.springframework.data.domain.ExampleMatcher)1