class ProductAvailabilityServiceImpl extends SalesManagerEntityServiceImpl<Long, ProductAvailability>
		implements ProductAvailabilityService {

	private ProductAvailabilityRepository productAvailabilityRepository;

	@Inject
	private PageableProductAvailabilityRepository pageableProductAvailabilityRepository;

	@Inject
	public ProductAvailabilityServiceImpl(ProductAvailabilityRepository productAvailabilityRepository) {
		super(productAvailabilityRepository);
		this.productAvailabilityRepository = productAvailabilityRepository;
	}

	@Override
	public ProductAvailability saveOrUpdate(ProductAvailability availability) throws ServiceException {
		if (isPositive(availability.getId())) {
			update(availability);
		} else {
			create(availability);
		}
		
		return availability;
	}

	private boolean isPositive(Long id) {
		return Objects.nonNull(id) && id > 0;
	}



	@Override
	public Page<ProductAvailability> listByProduct(Long productId, MerchantStore store, int page,
			int count) {<FILL_FUNCTION_BODY>}



	@Override
	public Optional<ProductAvailability> getById(Long availabilityId, MerchantStore store) {
		Validate.notNull(store, "Merchant must not be null");
		return Optional.ofNullable(productAvailabilityRepository.getById(availabilityId));
	}

	@Override
	public Page<ProductAvailability> getBySku(String sku, MerchantStore store, int page, int count) {
		Validate.notNull(store, "MerchantStore cannot be null");
		Pageable pageRequest = PageRequest.of(page, count);
		return pageableProductAvailabilityRepository.getBySku(sku, store.getCode(), pageRequest);
	}

	@Override
	public Page<ProductAvailability> getBySku(String sku, int page, int count) {
		Pageable pageRequest = PageRequest.of(page, count);
		return pageableProductAvailabilityRepository.getBySku(sku, pageRequest);
	}

	@Override
	public List<ProductAvailability> getBySku(String sku, MerchantStore store) {
		Validate.notNull(store, "MerchantStore cannot be null");
		return productAvailabilityRepository.getBySku(sku, store.getCode());
	}

}

		Validate.notNull(productId, "Product cannot be null");
		Validate.notNull(store, "MercantStore cannot be null");
		Pageable pageRequest = PageRequest.of(page, count);
		return pageableProductAvailabilityRepository.getByProductId(productId, store.getCode(), pageRequest);
	
<methods>public void <init>(JpaRepository<com.salesmanager.core.model.catalog.product.availability.ProductAvailability,java.lang.Long>) ,public java.lang.Long count() ,public void create(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) throws com.salesmanager.core.business.exception.ServiceException,public void delete(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) throws com.salesmanager.core.business.exception.ServiceException,public void flush() ,public com.salesmanager.core.model.catalog.product.availability.ProductAvailability getById(java.lang.Long) ,public List<com.salesmanager.core.model.catalog.product.availability.ProductAvailability> list() ,public void save(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) throws com.salesmanager.core.business.exception.ServiceException,public void saveAll(Iterable<com.salesmanager.core.model.catalog.product.availability.ProductAvailability>) throws com.salesmanager.core.business.exception.ServiceException,public void update(com.salesmanager.core.model.catalog.product.availability.ProductAvailability) throws com.salesmanager.core.business.exception.ServiceException<variables>private Class<com.salesmanager.core.model.catalog.product.availability.ProductAvailability> objectClass,private JpaRepository<com.salesmanager.core.model.catalog.product.availability.ProductAvailability,java.lang.Long> repository