* Builds a hierarchy of {@link CssMenuItem}s, following the provided map of {@link LogicalServiceAction}s (keyed by their service Name).
*/
private List<CssMenuItem> buildMenuItems(final List<String> serviceNamesInOrder, final Map<String, List<LogicalServiceAction>> serviceActionsByName) {
final List<CssMenuItem> menuItems = Lists.newArrayList();
for (String serviceName : serviceNamesInOrder) {
final CssMenuItem serviceMenuItem = CssMenuItem.newMenuItem(serviceName).build();
final List<LogicalServiceAction> serviceActionsForName = serviceActionsByName.get(serviceName);
for (LogicalServiceAction logicalServiceAction : serviceActionsForName) {
final ObjectAdapter serviceAdapter = logicalServiceAction.serviceAdapter;
final ObjectSpecification serviceSpec = serviceAdapter.getSpecification();
if (serviceSpec.isHidden()) {
continue;
}
final ObjectAdapterMemento serviceAdapterMemento = logicalServiceAction.serviceAdapterMemento;
final ObjectAction objectAction = logicalServiceAction.objectAction;
final Builder subMenuItemBuilder = serviceMenuItem.newSubMenuItem(serviceAdapterMemento, objectAction, cssMenuLinkFactory);
if (subMenuItemBuilder == null) {
// not visible
continue;
}
subMenuItemBuilder.build();
}
if (serviceMenuItem.hasSubMenuItems()) {
menuItems.add(serviceMenuItem);
}
}
return menuItems;
}