use of me.kadarh.mecaworks.service.exceptions.OperationFailedException 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);
Famille famille = new Famille();
famille.setNom(search);
Marque marque = new Marque();
marque.setNom(search);
sousFamille.setFamille(famille);
sousFamille.setMarque(marque);
// 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.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class SousFamilleServiceImpl method add.
@Override
public SousFamille add(SousFamille sousFamille) {
log.info("Service= SousFamilleServiceImpl - calling methode add");
try {
sousFamille.setFamille(familleService.get(sousFamille.getFamille().getId()));
sousFamille.setMarque(marqueService.get(sousFamille.getMarque().getId()));
return sousFamilleRepo.save(sousFamille);
} catch (ResourceNotFoundException e) {
log.debug("cannot find famille or marque , failed operation");
throw new OperationFailedException("L'ajout de la Sous-famille a echouée,famille ou marque introuvable ", e);
} catch (Exception e) {
log.debug("cannot add SousFamille , failed operation");
throw new OperationFailedException("L'ajout de la Sous-famille a echouée ", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class BonEnginServiceImpl method add.
/*--------------------------------------------------------------------------- */
/* ------------ CRUD METHODES -------------------------------------------------- */
/* ---------------------------------------------------------------------------- */
@Override
public BonEngin add(BonEngin bonEngin) {
log.info("Service= BonEnginServiceImpl - calling methode add");
bonEngin = calculAbsoluService.fillBon(bonEngin);
try {
if (bonEngin.getPlein())
bonEngin = calculService.calculConsommation(bonEngin);
if (bonEngin.getChantierGazoil() != bonEngin.getChantierTravail()) {
log.info("Service= BonEnginServiceImpl - Il faut inserer un bon de livraison virtuel");
bonLivraisonService.insertBonLivraison(bonEngin);
}
bonEngin = bonEnginRepo.save(bonEngin);
miseAjourBonsService.doMiseAjour(bonEngin);
persistService.insertAlertes(bonEngin);
log.info("Alertes Bon Engin inserted");
persistService.insertStock(bonEngin);
log.info("Stock Bon Engin inserted");
persistService.insertAlerteConsommation(bonEngin);
log.info("Alertes Bon Engin Consomation inserted");
return bonEngin;
} catch (DataIntegrityViolationException e) {
log.debug("cannot add bonEngin , failed operation");
throw new OperationFailedException("L'ajout du bonEngin a echouée , le code engin existe déjà", e);
} catch (Exception e) {
log.debug("cannot add bonEngin , failed operation");
throw new OperationFailedException("L'ajout du bonEngin a echouée ", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class BonFournisseurServiceImpl method add.
@Override
public BonFournisseur add(BonFournisseur bonFournisseur) {
log.info("Service- BonFournisseurServiceImpl Calling add ");
try {
bonFournisseurRepo.save(fill(bonFournisseur));
insertStock_Fournisseur(bonFournisseur);
return bonFournisseur;
} catch (Exception e) {
throw new OperationFailedException("l'ajout du bon a été suspendu, opération echouée", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class AlerteServiceImpl method hideAlert.
@Override
public void hideAlert(Long id) {
log.info("Service- BonEnginServiceImpl Calling hideAlert with params :" + id);
try {
Alerte alerte = alerteRepo.getOne(id);
alerte.setEtat(false);
alerteRepo.save(alerte);
} catch (Exception e) {
log.debug("Failed hiding alert id:" + id);
throw new OperationFailedException("Alerte introuvable", e);
}
}
Aggregations