{
logger.info("We want to create a list of categories if not existing under the parent category " + parentCategory);
Iterator categoryIterator = categories.iterator();
while(categoryIterator.hasNext())
{
CategoryVO categoryVO = (CategoryVO)categoryIterator.next();
CategoryVO newParentCategory = null;
List<CategoryVO> existingCategories = null;
if(parentCategory != null)
existingCategories = CategoryController.getController().getActiveCategoryVOListByParent(parentCategory.getCategoryId(), db);
//existingCategories = CategoryController.getController().findByParent(parentCategory.getCategoryId(), db);
else
existingCategories = CategoryController.getController().findRootCategoryVOList(db);
Iterator<CategoryVO> existingCategoriesIterator = existingCategories.iterator();
while(existingCategoriesIterator.hasNext())
{
CategoryVO existingCategory = existingCategoriesIterator.next();
logger.info("existingCategory:" + existingCategory.getName());
if(existingCategory.getName().equals(categoryVO.getName()))
{
logger.info("Existed... setting " + existingCategory.getName() + " to new parent category.");
newParentCategory = existingCategory;
break;
}
}