Search in sources :

Example 26 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project sic by belluccifranco.

the class FacturaServiceImpl method calcularIvaCompra.

@Override
public double calcularIvaCompra(BusquedaFacturaCompraCriteria criteria) {
    //Empresa
    if (criteria.getEmpresa() == null) {
        throw new EntityNotFoundException(ResourceBundle.getBundle("Mensajes").getString("mensaje_empresa_no_existente"));
    }
    //Fecha de Factura        
    if (criteria.isBuscaPorFecha() == true & (criteria.getFechaDesde() == null | criteria.getFechaHasta() == null)) {
        throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_fechas_busqueda_invalidas"));
    }
    if (criteria.isBuscaPorFecha() == true) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(criteria.getFechaDesde());
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        criteria.setFechaDesde(cal.getTime());
        cal.setTime(criteria.getFechaHasta());
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        criteria.setFechaHasta(cal.getTime());
    }
    //Proveedor
    if (criteria.isBuscaPorProveedor() == true && criteria.getProveedor() == null) {
        throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_proveedor_vacio"));
    }
    TipoDeComprobante[] tipoFactura = { TipoDeComprobante.FACTURA_A };
    return facturaRepository.calcularIVA_Compra(criteria, tipoFactura);
}
Also used : BusinessServiceException(sic.service.BusinessServiceException) TipoDeComprobante(sic.modelo.TipoDeComprobante) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 27 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project sic by belluccifranco.

the class FacturaServiceImpl method calcularTotalFacturadoCompra.

@Override
public double calcularTotalFacturadoCompra(BusquedaFacturaCompraCriteria criteria) {
    //Empresa
    if (criteria.getEmpresa() == null) {
        throw new EntityNotFoundException(ResourceBundle.getBundle("Mensajes").getString("mensaje_empresa_no_existente"));
    }
    //Fecha de Factura        
    if (criteria.isBuscaPorFecha() == true & (criteria.getFechaDesde() == null | criteria.getFechaHasta() == null)) {
        throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_fechas_busqueda_invalidas"));
    }
    if (criteria.isBuscaPorFecha() == true) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(criteria.getFechaDesde());
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        criteria.setFechaDesde(cal.getTime());
        cal.setTime(criteria.getFechaHasta());
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        criteria.setFechaHasta(cal.getTime());
    }
    //Proveedor
    if (criteria.isBuscaPorProveedor() == true && criteria.getProveedor() == null) {
        throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_proveedor_vacio"));
    }
    return facturaRepository.calcularTotalFacturadoCompra(criteria);
}
Also used : BusinessServiceException(sic.service.BusinessServiceException) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 28 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project sic by belluccifranco.

the class FacturaServiceImpl method calcularGananciaTotal.

@Override
public double calcularGananciaTotal(BusquedaFacturaVentaCriteria criteria) {
    //Empresa
    if (criteria.getEmpresa() == null) {
        throw new EntityNotFoundException(ResourceBundle.getBundle("Mensajes").getString("mensaje_empresa_no_existente"));
    }
    //Fecha de Factura        
    if (criteria.isBuscaPorFecha() == true && (criteria.getFechaDesde() == null || criteria.getFechaHasta() == null)) {
        throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_fechas_busqueda_invalidas"));
    }
    if (criteria.isBuscaPorFecha() == true) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(criteria.getFechaDesde());
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        criteria.setFechaDesde(cal.getTime());
        cal.setTime(criteria.getFechaHasta());
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        criteria.setFechaHasta(cal.getTime());
    }
    //Cliente
    if (criteria.isBuscaCliente() == true && criteria.getCliente() == null) {
        throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_cliente_vacio"));
    }
    //Usuario
    if (criteria.isBuscaUsuario() == true && criteria.getUsuario() == null) {
        throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_usuario_vacio"));
    }
    if (criteria.isBuscaViajante() == true && criteria.getViajante() == null) {
        throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_factura_viajante_vacio"));
    }
    return facturaRepository.calcularGananciaTotal(criteria);
}
Also used : BusinessServiceException(sic.service.BusinessServiceException) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 29 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project API by ca-cwds.

the class CrossReportService method update.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
   *      gov.ca.cwds.rest.api.Request)
   */
@Override
public gov.ca.cwds.rest.api.domain.cms.CrossReport update(Serializable primaryKey, Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.CrossReport;
    gov.ca.cwds.rest.api.domain.cms.CrossReport crossReport = (gov.ca.cwds.rest.api.domain.cms.CrossReport) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        CrossReport managed = new CrossReport(crossReport.getThirdId(), crossReport, lastUpdatedId);
        managed = crossReportDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.CrossReport(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("CrossReport not found : {}", crossReport);
        throw new ServiceException(e);
    }
}
Also used : CrossReport(gov.ca.cwds.data.persistence.cms.CrossReport) ServiceException(gov.ca.cwds.rest.services.ServiceException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 30 with EntityNotFoundException

use of javax.persistence.EntityNotFoundException in project API by ca-cwds.

the class LongTextService method update.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
   *      gov.ca.cwds.rest.api.Request)
   */
@Override
public gov.ca.cwds.rest.api.domain.cms.LongText update(Serializable primaryKey, Request request) {
    assert primaryKey instanceof String;
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.LongText;
    gov.ca.cwds.rest.api.domain.cms.LongText longText = (gov.ca.cwds.rest.api.domain.cms.LongText) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        LongText managed = new LongText((String) primaryKey, longText, lastUpdatedId);
        managed = longTextDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.LongText(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("LongText not found : {}", longText);
        throw new ServiceException(e);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) EntityNotFoundException(javax.persistence.EntityNotFoundException) PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) LongText(gov.ca.cwds.data.persistence.cms.LongText)

Aggregations

EntityNotFoundException (javax.persistence.EntityNotFoundException)73 EntityManager (javax.persistence.EntityManager)20 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)18 ServiceException (gov.ca.cwds.rest.services.ServiceException)15 Transactional (org.springframework.transaction.annotation.Transactional)14 BusinessServiceException (sic.service.BusinessServiceException)11 Test (org.junit.Test)10 Calendar (java.util.Calendar)9 GregorianCalendar (java.util.GregorianCalendar)9 BooleanBuilder (com.querydsl.core.BooleanBuilder)6 TblMle (com.intel.mtwilson.as.data.TblMle)5 ArrayList (java.util.ArrayList)5 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)4 TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)4 PersistenceException (javax.persistence.PersistenceException)4 Sort (org.springframework.data.domain.Sort)4 TblHosts (com.intel.mtwilson.as.data.TblHosts)3 OptimisticLockException (javax.persistence.OptimisticLockException)3 TblEventType (com.intel.mtwilson.as.data.TblEventType)2 TblHostSpecificManifest (com.intel.mtwilson.as.data.TblHostSpecificManifest)2