package devopsdistilled.operp.server.data.service.items.impl;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import devopsdistilled.operp.server.data.entity.items.Category;
import devopsdistilled.operp.server.data.repo.items.CategoryRepository;
import devopsdistilled.operp.server.data.service.impl.AbstractEntityService;
import devopsdistilled.operp.server.data.service.items.CategoryService;

@Service
public class CategoryServiceImpl extends
		AbstractEntityService<Category, Long, CategoryRepository> implements
		CategoryService {

	private static final long serialVersionUID = 7024824459392415034L;

	@Inject
	private CategoryRepository repo;

	@Override
	protected CategoryRepository getRepo() {
		return repo;
	}

	@Override
	public boolean isCategoryNameExists(String categoryName) {
		Category category = repo.findByCategoryName(categoryName);
		if (category != null)
			return true;

		return false;
	}

	@Override
	public boolean isCategoryNameValidForCategory(Long categoryId,
			String categoryName) {

		Category category = repo.findByCategoryName(categoryName);

		if (category == null)
			return true;

		if (category.getCategoryId() != categoryId)
			return false;

		return true;
	}

}

@@ -1174,20 +1174,24 @@
 goryId()
- != 
+.equals(
 category
@@ -1193,16 +1193,17 @@
 egoryId)
+)
 %0A%09%09%09retu
@@ -1205,20 +1205,19 @@
 %09return 
-fals
+tru
 e;%0A%0A%09%09re
@@ -1221,19 +1221,20 @@
 %09return 
-tru
+fals
 e;%0A%09%7D%0A%0A%7D

Correct logic for is isCategoryNameValidForCategory()