Search in sources :

Example 1 with ProductMixBO

use of org.mifos.accounts.productsmix.business.ProductMixBO in project head by mifos.

the class TestObjectFactory method createAllowedProductsMix.

public static ProductMixBO createAllowedProductsMix(final SavingsOfferingBO saving1, final SavingsOfferingBO saving2) {
    ProductMixBO prdmix;
    try {
        prdmix = new ProductMixBO(saving1, saving2);
        testObjectPersistence.persist(prdmix);
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return prdmix;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductMixBO(org.mifos.accounts.productsmix.business.ProductMixBO) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException)

Example 2 with ProductMixBO

use of org.mifos.accounts.productsmix.business.ProductMixBO in project head by mifos.

the class TestObjectFactory method createNotAllowedProductForAProductOffering.

public static ProductMixBO createNotAllowedProductForAProductOffering(final PrdOfferingBO prdOffering, final PrdOfferingBO prdOfferingNotAllowedId) {
    ProductMixBO prdmix;
    try {
        prdmix = new ProductMixBO(prdOffering, prdOfferingNotAllowedId);
        prdmix.save();
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return prdmix;
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductMixBO(org.mifos.accounts.productsmix.business.ProductMixBO) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerException(org.mifos.customers.exceptions.CustomerException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) OfficeException(org.mifos.customers.office.exceptions.OfficeException)

Example 3 with ProductMixBO

use of org.mifos.accounts.productsmix.business.ProductMixBO in project head by mifos.

the class AdminServiceFacadeWebTier method createOrUpdateProductMix.

@Override
public void createOrUpdateProductMix(Integer productId, List<Integer> notAllowedProductIds) {
    try {
        PrdOfferingBO product = new PrdOfferingPersistence().getPrdOfferingByID(productId.shortValue());
        StaticHibernateUtil.startTransaction();
        product.setPrdMixFlag(YesNoFlag.YES.getValue());
        applicationConfigurationDao.save(product);
        StaticHibernateUtil.flushSession();
        List<PrdOfferingBO> newNotAllowedProducts = new ArrayList<PrdOfferingBO>();
        for (Integer notAllowedProductId : notAllowedProductIds) {
            PrdOfferingBO notAllowedProduct = new PrdOfferingPersistence().getPrdOfferingByID(notAllowedProductId.shortValue());
            newNotAllowedProducts.add(notAllowedProduct);
        }
        for (ProductMixBO oldNotAllowedProduct : product.getCollectionProductMix()) {
            ProductMixBO productMix = legacyProductMixDao.getPrdOfferingMixByPrdOfferingID(productId.shortValue(), oldNotAllowedProduct.getPrdOfferingNotAllowedId().getPrdOfferingId());
            if (null != productMix) {
                applicationConfigurationDao.delete(productMix);
                StaticHibernateUtil.flushSession();
            }
            ProductMixBO alternateproductmix = legacyProductMixDao.getPrdOfferingMixByPrdOfferingID(oldNotAllowedProduct.getPrdOfferingNotAllowedId().getPrdOfferingId(), productId.shortValue());
            if (null != alternateproductmix) {
                applicationConfigurationDao.delete(alternateproductmix);
                StaticHibernateUtil.flushSession();
            }
        }
        for (PrdOfferingBO notAllowedProduct : newNotAllowedProducts) {
            ProductMixBO productMix = new ProductMixBO(product, notAllowedProduct);
            productMix.setUpdatedDate(new DateTime().toDate());
            productMix.setUpdatedBy(Short.valueOf("1"));
            applicationConfigurationDao.save(productMix);
            StaticHibernateUtil.flushSession();
        }
        StaticHibernateUtil.commitTransaction();
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : PrdOfferingPersistence(org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence) PrdOfferingBO(org.mifos.accounts.productdefinition.business.PrdOfferingBO) ArrayList(java.util.ArrayList) ProductMixBO(org.mifos.accounts.productsmix.business.ProductMixBO) DateTime(org.joda.time.DateTime) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) BusinessRuleException(org.mifos.service.BusinessRuleException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ServiceException(org.mifos.framework.exceptions.ServiceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with ProductMixBO

use of org.mifos.accounts.productsmix.business.ProductMixBO in project head by mifos.

the class LegacyProductMixDao method getPrdOfferingMixByPrdOfferingID.

public ProductMixBO getPrdOfferingMixByPrdOfferingID(Short productID, Short notAllowedProductID) throws PersistenceException {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put(ProductDefinitionConstants.PRODUCTID, productID);
    queryParameters.put(ProductDefinitionConstants.NOTALLOWEDPRODUCTID, notAllowedProductID);
    ProductMixBO prdOffring = (ProductMixBO) execUniqueResultNamedQuery(NamedQueryConstants.PRD_MIX_BYID, queryParameters);
    return prdOffring;
}
Also used : HashMap(java.util.HashMap) ProductMixBO(org.mifos.accounts.productsmix.business.ProductMixBO)

Aggregations

ProductMixBO (org.mifos.accounts.productsmix.business.ProductMixBO)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 ApplicationException (org.mifos.framework.exceptions.ApplicationException)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 SystemException (org.mifos.framework.exceptions.SystemException)3 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)2 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)2 CustomerException (org.mifos.customers.exceptions.CustomerException)2 OfficeException (org.mifos.customers.office.exceptions.OfficeException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DateTime (org.joda.time.DateTime)1 PrdOfferingBO (org.mifos.accounts.productdefinition.business.PrdOfferingBO)1 PrdOfferingPersistence (org.mifos.accounts.productdefinition.persistence.PrdOfferingPersistence)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1