use of me.kadarh.mecaworks.service.exceptions.OperationFailedException 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);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class BonEnginServiceImpl method getPage.
/**
* Search by Pompiste, Chauffeur, code, engin and date
*
* @param pageable
* @param search
* @return
*/
@Override
public Page<BonEngin> getPage(Pageable pageable, String search) {
log.info("Service- BonEnginServiceImpl Calling bonEnginList with params :" + pageable + ", " + search);
try {
if (search.isEmpty()) {
log.debug("fetching bonEngins page");
return bonEnginRepo.findAll(pageable);
} else {
log.debug("Searching by :" + search);
// creating example by pompiste / chauffeur / code bon / code engin
BonEngin bonEngin = new BonEngin();
bonEngin.setCode(search);
bonEngin.setCompteurAbsoluKm(null);
bonEngin.setCompteurKm(null);
bonEngin.setCompteurH(null);
bonEngin.setCompteurAbsoluH(null);
bonEngin.setConsommationH(null);
bonEngin.setConsommationKm(null);
bonEngin.setQuantite(null);
bonEngin.setCarburant(null);
bonEngin.setCompteurPompe(null);
bonEngin.setCompteurHenPanne(null);
bonEngin.setCompteurKmenPanne(null);
bonEngin.setNbrHeures(null);
bonEngin.setNbrKm(null);
bonEngin.setConsommationPrevu(null);
bonEngin.setChargeHoraire(null);
Employe employe = new Employe();
employe.setNom(search);
Engin engin = new Engin();
engin.setCode(search);
engin.setNumeroSerie(search);
engin.setNumeroSerie(null);
engin.setConsommationMoyenne(null);
engin.setObjectif(null);
Chantier chantier = new Chantier();
chantier.setStock(null);
chantier.setNom(search);
bonEngin.setChantierGazoil(chantier);
bonEngin.setPompiste(employe);
bonEngin.setChauffeur(employe);
bonEngin.setEngin(engin);
try {
bonEngin.setDate(LocalDate.parse(search, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
} catch (Exception e) {
log.debug("Cannot search by date : keyword doesn't match date pattern");
}
// creating matcher
ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
Example<BonEngin> example = Example.of(bonEngin, matcher);
log.debug("getting search results");
return bonEnginRepo.findAll(example, pageable);
}
} catch (Exception e) {
log.debug("Failed retrieving list of bons");
throw new OperationFailedException("Operation échouée", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class BonEnginServiceImpl method delete.
@Override
public void delete(Long id) {
log.info("Service= BonEnginServiceImpl - calling methode delete");
try {
BonEngin bonEngin = bonEnginRepo.getOne(id);
log.info("Suppression du dernier bon");
Long idChantier = bonEngin.getChantierTravail().getId();
Long idGasoil = bonEngin.getChantierGazoil().getId();
stockManagerService.deleteStock(idGasoil, idChantier, id, TypeBon.BE);
alerteRepo.deleteAllByBonEngin_Id(id);
bonEnginRepo.deleteById(id);
miseAjourBonsService.doMiseAjour(bonEngin);
alerteRepo.findAllByIdBonEngin(bonEngin.getId()).forEach(alerteRepo::delete);
} catch (Exception e) {
throw new OperationFailedException("Probleme lors de la suppression du bon, ce bon ne peut pas être supprimer", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class BonFournisseurServiceImpl method delete.
@Override
public void delete(Long id) {
log.info("Service- BonFournisseurServiceImpl Calling delete with param id = " + id);
try {
BonFournisseur bonFournisseur = bonFournisseurRepo.getOne(id);
Long idChantier = bonFournisseur.getChantier().getId();
stockManagerService.deleteStock(null, idChantier, id, TypeBon.BF);
bonFournisseurRepo.delete(bonFournisseur);
} catch (NoSuchElementException e) {
throw new ResourceNotFoundException("opération échouée , l'élement est introuvable", e);
} catch (Exception e) {
throw new OperationFailedException("opération echouée , la suppression du bon a echouée", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class BonFournisseurServiceImpl method bonList.
/**
* Search by code, date, fournisseur and chantier
*
* @param pageable
* @param search
* @return
*/
@Override
public Page<BonFournisseur> bonList(Pageable pageable, String search) {
log.info("Service- BonFournisseurServiceImpl Calling bonList with params :" + pageable + ", " + search);
try {
if (search.isEmpty()) {
log.debug("fetching bonEngins page");
return bonFournisseurRepo.findAll(pageable);
} else {
log.debug("Searching by :" + search);
// creating example
BonFournisseur bonFournisseur = new BonFournisseur();
Chantier chantier = new Chantier();
chantier.setNom(search);
Fournisseur fournisseur = new Fournisseur();
fournisseur.setNom(search);
bonFournisseur.setChantier(chantier);
bonFournisseur.setFournisseur(fournisseur);
bonFournisseur.setCode(search);
try {
bonFournisseur.setDate(LocalDate.parse(search, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
} catch (Exception e) {
log.debug("Cannot search by date : keyword doesn't match date pattern");
}
// creating matcher
ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
Example<BonFournisseur> example = Example.of(bonFournisseur, matcher);
log.debug("getting search results");
return bonFournisseurRepo.findAll(example, pageable);
}
} catch (Exception e) {
log.debug("Failed retrieving list of employes");
throw new OperationFailedException("Operation échouée", e);
}
}
Aggregations