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;
}
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;
}
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();
}
}
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;
}
Aggregations