import fr.norsys.mapper.console.utils.URLEncoderUtil;
public class MenuServiceImpl implements MenuService {
public MenuRepository buildMenu(MenuRepository oldRepository,
Collection applications, Collection connexions, String isAppliModified, String currentAppli) {
MenuRepository repository = new MenuRepository();
repository.setDisplayers(oldRepository.getDisplayers());
MenuComponent conMenu = new MenuComponent();
conMenu.setName("Connections");
conMenu.setTitle("Connections");
conMenu.setLocation("javascript:saveBeforeLoad('"+isAppliModified+"','"+currentAppli+"','connection.do?method=init')");
repository.addMenu(conMenu);
for(Iterator it=connexions.iterator();it.hasNext();) {
MenuComponent mc = new MenuComponent();
Connection connection = (Connection) it.next();
String name = connection.getName();
mc.setName(name);
mc.setTitle(name);
mc.setLocation("javascript:saveBeforeLoad('"+isAppliModified+"','"+currentAppli+"','connection.do?method=edit&forward=connection&id="+URLEncoderUtil.escape(connection.getId())+"')");
mc.setParent(conMenu);
}
MenuComponent appliMenu = new MenuComponent();
appliMenu.setName("Applications");
appliMenu.setTitle("Applications");
appliMenu.setLocation("javascript:saveBeforeLoad('"+isAppliModified+"','"+currentAppli+"','application.do?method=init')");
repository.addMenu(appliMenu);
for(Iterator it=applications.iterator();it.hasNext();) {
MenuComponent mc = new MenuComponent();
Application application = (Application) it.next();
String name = application.getName();
mc.setName(name);