}
private List<EntityGroup> createTopicGroups(Collection<INews> input) {
/* Default Group */
EntityGroup gDefault = new EntityGroup(Group.NO_TOPIC.ordinal(), GROUP_CATEGORY_ID, Group.NO_TOPIC.getName());
Map<String, EntityGroup> groupCache = new HashMap<String, EntityGroup>();
groupCache.put(Group.NO_TOPIC.getName(), gDefault);
/* Group Input */
int nextId = Group.NO_TOPIC.ordinal() + TITLE_ID_BEGIN;
for (Object object : input) {
if (object instanceof INews) {
INews news = (INews) object;
EntityGroup group = gDefault;
/* Normalize Title */
String normalizedTitle = CoreUtils.getHeadline(news, true);
normalizedTitle = CoreUtils.normalizeTitle(normalizedTitle);
/* Determine Group ID */
String groupId;
if (!SyncUtils.isSynchronized(news) && StringUtils.isSet(news.getInReplyTo()))
groupId = news.getInReplyTo();
else
groupId = normalizedTitle;
/* Add or Create Group */
if (StringUtils.isSet(groupId)) {
group = groupCache.get(groupId);
/* Create new Group */
if (group == null) {
group = new EntityGroup(nextId++, GROUP_CATEGORY_ID, normalizedTitle);
groupCache.put(groupId, group);
}
}
/* Add to Group */