Map categoriesByName = new HashMap();
for (Iterator iterator = commandService.getDefinedCategoryIds()
.iterator(); iterator.hasNext();) {
Category category = commandService
.getCategory((String) iterator.next());
try {
if (commandIdsByCategoryId.containsKey(category.getId())) {
String name = category.getName();
Collection categories = (Collection) categoriesByName
.get(name);
if (categories == null) {
categories = new HashSet();
categoriesByName.put(name, categories);
}
categories.add(category);
}
} catch (NotDefinedException eNotDefined) {
// Do nothing
}
}
Map schemesByName = new HashMap();
final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
for (int i = 0; i < definedSchemes.length; i++) {
final Scheme scheme = definedSchemes[i];
try {
String name = scheme.getName();
Collection schemes = (Collection) schemesByName.get(name);
if (schemes == null) {
schemes = new HashSet();
schemesByName.put(name, schemes);
}
schemes.add(scheme);
} catch (final NotDefinedException e) {
// Do nothing.
}
}
contextIdsByUniqueName = new HashMap();
contextUniqueNamesById = new HashMap();
for (Iterator iterator = contextsByName.entrySet().iterator(); iterator
.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String name = (String) entry.getKey();
Set contexts = (Set) entry.getValue();
Iterator iterator2 = contexts.iterator();
if (contexts.size() == 1) {
Context context = (Context) iterator2.next();
contextIdsByUniqueName.put(name, context.getId());
contextUniqueNamesById.put(context.getId(), name);
} else {
while (iterator2.hasNext()) {
Context context = (Context) iterator2.next();
String uniqueName = MessageFormat.format(
Util.translateString(RESOURCE_BUNDLE,
"uniqueName"), new Object[] { name, //$NON-NLS-1$
context.getId() });
contextIdsByUniqueName.put(uniqueName, context.getId());
contextUniqueNamesById.put(context.getId(), uniqueName);
}
}
}
categoryIdsByUniqueName = new HashMap();
categoryUniqueNamesById = new HashMap();
for (Iterator iterator = categoriesByName.entrySet().iterator(); iterator
.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String name = (String) entry.getKey();
Set categories = (Set) entry.getValue();
Iterator iterator2 = categories.iterator();
if (categories.size() == 1) {
Category category = (Category) iterator2.next();
categoryIdsByUniqueName.put(name, category.getId());
categoryUniqueNamesById.put(category.getId(), name);
} else {
while (iterator2.hasNext()) {
Category category = (Category) iterator2.next();
String uniqueName = MessageFormat.format(
Util.translateString(RESOURCE_BUNDLE,
"uniqueName"), new Object[] { name, //$NON-NLS-1$
category.getId() });
categoryIdsByUniqueName.put(uniqueName, category
.getId());
categoryUniqueNamesById.put(category.getId(),
uniqueName);
}
}
}