class CustomerOptionValueServiceImpl extends
		SalesManagerEntityServiceImpl<Long, CustomerOptionValue> implements
		CustomerOptionValueService {

	@Inject
	private CustomerAttributeService customerAttributeService;
	
	private CustomerOptionValueRepository customerOptionValueRepository;
	
	@Inject
	private CustomerOptionSetService customerOptionSetService;
	
	@Inject
	public CustomerOptionValueServiceImpl(
			CustomerOptionValueRepository customerOptionValueRepository) {
			super(customerOptionValueRepository);
			this.customerOptionValueRepository = customerOptionValueRepository;
	}
	
	
	@Override
	public List<CustomerOptionValue> listByStore(MerchantStore store, Language language) throws ServiceException {
		
		return customerOptionValueRepository.findByStore(store.getId(), language.getId());
	}
	


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

			super.update(entity);
			
		} else {
			
			super.save(entity);
			
		}
		
	}
	
	
	public void delete(CustomerOptionValue customerOptionValue) throws ServiceException {<FILL_FUNCTION_BODY>}
	
	@Override
	public CustomerOptionValue getByCode(MerchantStore store, String optionValueCode) {
		return customerOptionValueRepository.findByCode(store.getId(), optionValueCode);
	}



}

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