Search in sources :

Example 16 with ExampleMatcher

use of org.springframework.data.domain.ExampleMatcher 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)

Example 17 with ExampleMatcher

use of org.springframework.data.domain.ExampleMatcher 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);
            if (classeService.findByNom(search).isPresent()) {
                famille.setClasse(classeService.findByNom(search).get());
            }
            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);
    }
}
Also used : Famille(me.kadarh.mecaworks.domain.others.Famille) ExampleMatcher(org.springframework.data.domain.ExampleMatcher) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) Classe(me.kadarh.mecaworks.domain.others.Classe) ResourceNotFoundException(me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException) OperationFailedException(me.kadarh.mecaworks.service.exceptions.OperationFailedException) NoSuchElementException(java.util.NoSuchElementException)

Example 18 with ExampleMatcher

use of org.springframework.data.domain.ExampleMatcher in project mecaworks by KadarH.

the class FournisseurServiceImpl method fournisseurList.

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

use of org.springframework.data.domain.ExampleMatcher in project mecaworks by KadarH.

the class GroupeServiceImpl method groupesList.

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

use of org.springframework.data.domain.ExampleMatcher in project mecaworks by KadarH.

the class ChantierServiceImpl method chantierList.

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

Aggregations

ExampleMatcher (org.springframework.data.domain.ExampleMatcher)33 Test (org.junit.jupiter.api.Test)20 Query (org.springframework.data.relational.core.query.Query)17 NoSuchElementException (java.util.NoSuchElementException)9 OperationFailedException (me.kadarh.mecaworks.service.exceptions.OperationFailedException)9 ResourceNotFoundException (me.kadarh.mecaworks.service.exceptions.ResourceNotFoundException)9 Objects (java.util.Objects)2 Classe (me.kadarh.mecaworks.domain.others.Classe)2 Marque (me.kadarh.mecaworks.domain.others.Marque)2 SousFamille (me.kadarh.mecaworks.domain.others.SousFamille)2 Assertions (org.assertj.core.api.Assertions)2 Test (org.junit.Test)2 Example (org.springframework.data.domain.Example)2 BaseEntity (com.google.cloud.datastore.BaseEntity)1 BaseKey (com.google.cloud.datastore.BaseKey)1 Cursor (com.google.cloud.datastore.Cursor)1 Datastore (com.google.cloud.datastore.Datastore)1 DatastoreReaderWriter (com.google.cloud.datastore.DatastoreReaderWriter)1 Entity (com.google.cloud.datastore.Entity)1 Builder (com.google.cloud.datastore.Entity.Builder)1