@Test public void testAssignWarehouse() { createShopAndWareHouse("TESTSHOP", "TESTWAREHOUSE"); List<Warehouse> shopWarehouses = warehouseService.getByShopId(shop.getShopId(), false); assertNotNull(shopWarehouses); assertTrue(shopWarehouses.isEmpty()); warehouseService.assignWarehouse(warehouse.getWarehouseId(), shop.getShopId(), false); shopWarehouses = warehouseService.getByShopId(shop.getShopId(), false); assertNotNull(shopWarehouses); assertFalse(shopWarehouses.isEmpty()); assertEquals(warehouse.getWarehouseId(), shopWarehouses.get(0).getWarehouseId()); warehouseService.unassignWarehouse(warehouse.getWarehouseId(), shop.getShopId(), false); List<Warehouse> shopWarehousesAfter = warehouseService.getByShopId(shop.getShopId(), false); assertNotNull(shopWarehousesAfter); assertTrue(shopWarehousesAfter.isEmpty()); }
@Override public void assignWarehouse(final long warehouseId, final long shopId, final boolean soft) { final Warehouse warehouse = findById(warehouseId); final Collection<ShopWarehouse> assigned = warehouse.getWarehouseShop(); for (final ShopWarehouse shop : assigned) { if (shop.getShop().getShopId() == shopId) { if (shop.isDisabled() && !soft) { shop.setDisabled(false); update(warehouse); } return; } } final Shop shop = shopDao.findById(shopId); if (shop != null) { final ShopWarehouse shopWarehouse = shopWarehouseDao.getEntityFactory().getByIface(ShopWarehouse.class); shopWarehouse.setWarehouse(warehouse); shopWarehouse.setShop(shop); shopWarehouse.setRank(DEFAULT_USAGE_RANK); shopWarehouse.setDisabled(soft); assigned.add(shopWarehouse); } update(warehouse); }
WarehouseServiceImpl extends BaseGenericServiceImpl<Warehouse> implements WarehouseService { @Override public void assignWarehouse(final long warehouseId, final long shopId, final boolean soft) { final Warehouse warehouse = findById(warehouseId); final Collection<ShopWarehouse> assigned = warehouse.getWarehouseShop(); for (final ShopWarehouse shop : assigned) { if (shop.getShop().getShopId() == shopId) { if (shop.isDisabled() && !soft) { shop.setDisabled(false); update(warehouse); } return; } } final Shop shop = shopDao.findById(shopId); if (shop != null) { final ShopWarehouse shopWarehouse = shopWarehouseDao.getEntityFactory().getByIface(ShopWarehouse.class); shopWarehouse.setWarehouse(warehouse); shopWarehouse.setShop(shop); shopWarehouse.setRank(DEFAULT_USAGE_RANK); shopWarehouse.setDisabled(soft); assigned.add(shopWarehouse); } update(warehouse); } }
WarehouseServiceImpl extends BaseGenericServiceImpl<Warehouse> implements WarehouseService { @Override public void assignWarehouse(final long warehouseId, final long shopId, final boolean soft) { final Warehouse warehouse = findById(warehouseId); final Collection<ShopWarehouse> assigned = warehouse.getWarehouseShop(); for (final ShopWarehouse shop : assigned) { if (shop.getShop().getShopId() == shopId) { if (shop.isDisabled() && !soft) { shop.setDisabled(false); update(warehouse); } return; } } final Shop shop = shopDao.findById(shopId); if (shop != null) { final ShopWarehouse shopWarehouse = shopWarehouseDao.getEntityFactory().getByIface(ShopWarehouse.class); shopWarehouse.setWarehouse(warehouse); shopWarehouse.setShop(shop); shopWarehouse.setRank(DEFAULT_USAGE_RANK); shopWarehouse.setDisabled(soft); assigned.add(shopWarehouse); } update(warehouse); } WarehouseServiceImpl(
            final GenericDAO<Warehouse, Long> genericDao,
            final GenericDAO<Shop, Long> shopDao,
            final GenericDAO<ShopWarehouse, Long> shopWarehouseDao); }
WarehouseServiceImpl extends BaseGenericServiceImpl<Warehouse> implements WarehouseService { @Override public void assignWarehouse(final long warehouseId, final long shopId, final boolean soft) { final Warehouse warehouse = findById(warehouseId); final Collection<ShopWarehouse> assigned = warehouse.getWarehouseShop(); for (final ShopWarehouse shop : assigned) { if (shop.getShop().getShopId() == shopId) { if (shop.isDisabled() && !soft) { shop.setDisabled(false); update(warehouse); } return; } } final Shop shop = shopDao.findById(shopId); if (shop != null) { final ShopWarehouse shopWarehouse = shopWarehouseDao.getEntityFactory().getByIface(ShopWarehouse.class); shopWarehouse.setWarehouse(warehouse); shopWarehouse.setShop(shop); shopWarehouse.setRank(DEFAULT_USAGE_RANK); shopWarehouse.setDisabled(soft); assigned.add(shopWarehouse); } update(warehouse); } WarehouseServiceImpl(
            final GenericDAO<Warehouse, Long> genericDao,
            final GenericDAO<Shop, Long> shopDao,
            final GenericDAO<ShopWarehouse, Long> shopWarehouseDao); @Override List<Warehouse> findByShopId(final long shopId, boolean includeDisabled); @Override List<Warehouse> getByShopId(final long shopId, boolean includeDisabled); @Override Map<String, Warehouse> getByShopIdMapped(final long shopId, final boolean includeDisabled); @Override void updateShopWarehouseRank(final long shopWarehouseId, final int newRank); @Override ShopWarehouse findShopWarehouseById(final long shopWarehouseId); @Override void assignWarehouse(final long warehouseId, final long shopId, final boolean soft); @Override void unassignWarehouse(final long warehouseId, final long shopId, final boolean soft); @Override List<Warehouse> findWarehouses(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findWarehouseCount(final Map<String, List> filter); }
WarehouseServiceImpl extends BaseGenericServiceImpl<Warehouse> implements WarehouseService { @Override public void assignWarehouse(final long warehouseId, final long shopId, final boolean soft) { final Warehouse warehouse = findById(warehouseId); final Collection<ShopWarehouse> assigned = warehouse.getWarehouseShop(); for (final ShopWarehouse shop : assigned) { if (shop.getShop().getShopId() == shopId) { if (shop.isDisabled() && !soft) { shop.setDisabled(false); update(warehouse); } return; } } final Shop shop = shopDao.findById(shopId); if (shop != null) { final ShopWarehouse shopWarehouse = shopWarehouseDao.getEntityFactory().getByIface(ShopWarehouse.class); shopWarehouse.setWarehouse(warehouse); shopWarehouse.setShop(shop); shopWarehouse.setRank(DEFAULT_USAGE_RANK); shopWarehouse.setDisabled(soft); assigned.add(shopWarehouse); } update(warehouse); } WarehouseServiceImpl(
            final GenericDAO<Warehouse, Long> genericDao,
            final GenericDAO<Shop, Long> shopDao,
            final GenericDAO<ShopWarehouse, Long> shopWarehouseDao); @Override List<Warehouse> findByShopId(final long shopId, boolean includeDisabled); @Override List<Warehouse> getByShopId(final long shopId, boolean includeDisabled); @Override Map<String, Warehouse> getByShopIdMapped(final long shopId, final boolean includeDisabled); @Override void updateShopWarehouseRank(final long shopWarehouseId, final int newRank); @Override ShopWarehouse findShopWarehouseById(final long shopWarehouseId); @Override void assignWarehouse(final long warehouseId, final long shopId, final boolean soft); @Override void unassignWarehouse(final long warehouseId, final long shopId, final boolean soft); @Override List<Warehouse> findWarehouses(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findWarehouseCount(final Map<String, List> filter);  }