class CustomerOptionServiceImpl extends
		SalesManagerEntityServiceImpl<Long, CustomerOption> implements CustomerOptionService {

	
	private CustomerOptionRepository customerOptionRepository;
	
	@Inject
	private CustomerAttributeService customerAttributeService;
	
	@Inject
	private CustomerOptionSetService customerOptionSetService;
	

	@Inject
	public CustomerOptionServiceImpl(
			CustomerOptionRepository customerOptionRepository) {
			super(customerOptionRepository);
			this.customerOptionRepository = customerOptionRepository;
	}
	
	@Override
	public List<CustomerOption> listByStore(MerchantStore store, Language language) throws ServiceException {

		return customerOptionRepository.findByStore(store.getId(), language.getId());

	}
	

	@Override
	public void saveOrUpdate(CustomerOption entity) throws ServiceException {
		
		
		//save or update (persist and attach entities
		if(entity.getId()!=null && entity.getId()>0) {
			super.update(entity);
		} else {
			super.save(entity);
		}
		
	}


	@Override
	public void delete(CustomerOption customerOption) throws ServiceException {<FILL_FUNCTION_BODY>}
	
	@Override
	public CustomerOption getByCode(MerchantStore store, String optionCode) {
		return customerOptionRepository.findByCode(store.getId(), optionCode);
	}
	

	




}

		
		//remove all attributes having this option
		List<CustomerAttribute> attributes = customerAttributeService.getByOptionId(customerOption.getMerchantStore(), customerOption.getId());
		
		for(CustomerAttribute attribute : attributes) {
			customerAttributeService.delete(attribute);
		}
		
		CustomerOption option = this.getById(customerOption.getId());
		
		List<CustomerOptionSet> optionSets = customerOptionSetService.listByOption(customerOption, customerOption.getMerchantStore());
		
		for(CustomerOptionSet optionSet : optionSets) {
			customerOptionSetService.delete(optionSet);
		}
		
		//remove option
		super.delete(option);
		
	
<methods>public void <init>(JpaRepository<com.salesmanager.core.model.customer.attribute.CustomerOption,java.lang.Long>) ,public java.lang.Long count() ,public void create(com.salesmanager.core.model.customer.attribute.CustomerOption) throws com.salesmanager.core.business.exception.ServiceException,public void delete(com.salesmanager.core.model.customer.attribute.CustomerOption) throws com.salesmanager.core.business.exception.ServiceException,public void flush() ,public com.salesmanager.core.model.customer.attribute.CustomerOption getById(java.lang.Long) ,public List<com.salesmanager.core.model.customer.attribute.CustomerOption> list() ,public void save(com.salesmanager.core.model.customer.attribute.CustomerOption) throws com.salesmanager.core.business.exception.ServiceException,public void saveAll(Iterable<com.salesmanager.core.model.customer.attribute.CustomerOption>) throws com.salesmanager.core.business.exception.ServiceException,public void update(com.salesmanager.core.model.customer.attribute.CustomerOption) throws com.salesmanager.core.business.exception.ServiceException<variables>private Class<com.salesmanager.core.model.customer.attribute.CustomerOption> objectClass,private JpaRepository<com.salesmanager.core.model.customer.attribute.CustomerOption,java.lang.Long> repository