use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class ClasseServiceImpl method classeList.
/**
* search with nom
*
* @param pageable page description
* @param search keyword
* @return Page
*/
@Override
public Page<Classe> classeList(Pageable pageable, String search) {
log.info("Service- ClasseServiceImpl Calling ClasseList with params :" + pageable + ", " + search);
try {
if (search.isEmpty()) {
log.debug("fetching Classe page");
return classeRepo.findAll(pageable);
} else {
log.debug("Searching by :" + search);
// creating example
Classe classe = new Classe();
classe.setNom(search);
// creating matcher
ExampleMatcher matcher = ExampleMatcher.matchingAny().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase().withIgnoreNullValues();
Example<Classe> example = Example.of(classe, matcher);
log.debug("getting search results");
return classeRepo.findAll(example, pageable);
}
} catch (Exception e) {
log.debug("Failed retrieving list of Classes");
throw new OperationFailedException("Operation échouée", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class EnginServiceImpl method add.
/**
* @param engin to add
* @return the engin
*/
@Override
public Engin add(Engin engin) {
log.info("Service = EnginServiceImpl - calling methode add");
try {
engin.setGroupe(groupeService.get(engin.getGroupe().getId()));
engin.setSousFamille(sousFamilleService.get(engin.getSousFamille().getId()));
return enginRepo.save(engin);
} catch (ResourceNotFoundException e) {
log.debug("cannot find group or sousFamille , failed operation");
throw new OperationFailedException("L'ajout de l'engin a echouée,sous famille ou groupe introuvable ", e);
} catch (Exception e) {
log.debug("cannot add engin , failed operation");
throw new OperationFailedException("L'ajout de l'engin a echouée ", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException 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);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class ChantierServiceImpl method update.
/**
* updating the chantier
*
* @param chantier
* @return
*/
@Override
public Chantier update(Chantier chantier) {
log.info("Service= ChantierServiceImpl - calling methode update");
try {
Chantier old = get(chantier.getId());
if (chantier.getNom() != null) {
old.setNom(chantier.getNom());
}
if (chantier.getAdresse() != null) {
old.setAdresse(chantier.getAdresse());
}
if (chantier.getStock() != null) {
if (!chantier.getStock().equals(old.getStock())) {
Stock stock = new Stock();
stock.setDate(LocalDate.now());
stock.setStockC(chantier.getStock());
stock.setStockReel(chantier.getStock());
stock.setChantier(old);
Stock stockC = stockService.getLastStock(chantier);
if (stockC != null) {
if (stockC.getStockC() < chantier.getStock())
stock.setEcart_plus(chantier.getStock() - stockC.getStockC());
else if (stockC.getStockC() > chantier.getStock())
stock.setEcart_moins(stockC.getStockC() - chantier.getStock());
} else {
stock.setEcart_moins(0);
stock.setEcart_plus(0);
}
stockService.add(stock);
}
old.setStock(chantier.getStock());
}
return chantierRepo.save(old);
} catch (Exception e) {
log.debug("cannot update Chantier , failed operation");
throw new OperationFailedException("La modification du Chantier a echouée ", e);
}
}
use of me.kadarh.mecaworks.service.exceptions.OperationFailedException in project mecaworks by KadarH.
the class ChantierServiceImpl method add.
/**
* @param chantier to add
* @return the chantier
*/
@Override
public Chantier add(Chantier chantier) {
log.info("Service= ChantierServiceImpl - calling methode add");
try {
Stock stock = new Stock();
stock.setDate(LocalDate.now());
stock.setStockC(chantier.getStock());
stock.setStockReel(chantier.getStock());
stock.setChantier(chantier);
stock.setEcart_plus(0);
stock.setEcart_moins(0);
stockService.add(stock);
return chantierRepo.save(chantier);
} catch (Exception e) {
log.debug("cannot add chantier , failed operation");
throw new OperationFailedException("L'ajout du Chantier a echouée ", e);
}
}
Aggregations