{
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);//.getActiveByParent(parentCategory.getCategoryId(), db);
//existingCategories = CategoryController.getController().findByParent(parentCategory.getCategoryId(), db);
logger.info("existingCategories 1:" + existingCategories);
}
else
{
existingCategories = CategoryController.getController().findRootCategoryVOList(db);
logger.info("existingCategories 2:" + existingCategories);
}
Iterator<CategoryVO> existingCategoriesIterator = existingCategories.iterator();
while(existingCategoriesIterator.hasNext())
{
Object candidate = existingCategoriesIterator.next();
logger.info("candidate:" + candidate.getClass().getName() + ":" + candidate);
CategoryVO existingCategory = (CategoryVO)candidate; //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;
}
}