当我尝试从postgreSQL转换为mySQL以及我登录应用程序时,问题就出现了。错误如下所示
uniqdrg <- unique(drgs, incomparables = FALSE )
uniqdrg$drg <- substr(uniqdrg$drg, 0, 3)
uniqdrg <- uniqdrg %>% arrange(drg)
uniqdrg<-uniqdrg[uniqdrg$drg %in% uniqdrg$drg[duplicated(uniqdrg$drg)],]
这是MenuBean的代码。我将数据库从postgresql转换为mysql后显示错误。我需要帮助。感谢。
package com.salam.his.bean;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.annotation.Resources;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.apache.commons.collections.CollectionUtils;
import org.primefaces.model.menu.DefaultMenuItem;
import org.primefaces.model.menu.DefaultSubMenu;
import org.primefaces.model.menu.DynamicMenuModel;
import org.primefaces.model.menu.MenuModel;
import com.salam.his.dao.CustomMenu;
import com.salam.his.dao.MenuDAO;
import com.salam.his.dao.MenuDAOImpl;
import com.salam.his.dao.RolesMenuDAO;
import com.salam.his.dao.RolesMenuDAOImpl;
import com.salam.his.dao.UsersMenuDAO;
import com.salam.his.dao.UsersMenuDAOImpl;
import com.salam.his.dao.UsersRolesDAO;
import com.salam.his.dao.UsersRolesDAOImpl;
import com.salam.his.entities.Menu;
import com.salam.his.entities.RolesMenu;
import com.salam.his.entities.UsersMenu;
import com.salam.his.entities.UsersRoles;
import com.salam.his.util.SessionUtils;
import com.sun.xml.internal.ws.util.StringUtils;
@ManagedBean(name = "menuBean")
@SessionScoped
public class MenuBean {
private MenuModel model;
private Collection<Menu> listOfParentMenu = null;
private Collection<Menu> listOfParentMenuForUsers = null;
private Menu listMenuById = null;
private List<RolesMenu> listOfRolesMenu = null;
private List<RolesMenu> listOfAllRolesMenuForUsers = null;
private List<UsersMenu> listOfUsersMenu = null;
private List<UsersMenu> listOfAllUserMenuForUsers = null;
private List<UsersRoles> listOfUsersRoles = null;
private MenuDAO menuDAO;
private RolesMenuDAO rolesMenuDAO;
private UsersMenuDAO usersMenuDAO;
private UsersRolesDAO usersRolesDAO;
UsersMenu userMenu = new UsersMenu();
int userId = SessionUtils.getUserId();
public MenuBean() {
// HttpSession session = SessionUtils.getUserId();
model = new DynamicMenuModel();
usersRolesDAO = new UsersRolesDAOImpl();
rolesMenuDAO = new RolesMenuDAOImpl();
usersMenuDAO = new UsersMenuDAOImpl();
menuDAO = new MenuDAOImpl();
DefaultSubMenu submenu = new DefaultSubMenu();
DefaultMenuItem item = new DefaultMenuItem();
listOfUsersRoles = usersRolesDAO.getListUsersRolesByUserId(userId);
listOfUsersMenu = usersMenuDAO.getUsersMenuById(userId);
if (CollectionUtils.isNotEmpty(listOfUsersRoles)) {
listOfParentMenu = new ArrayList<Menu>();
listOfAllRolesMenuForUsers = new ArrayList<RolesMenu>();
for (UsersRoles ur : listOfUsersRoles) {
int rolesId = ur.getRolesId();
listOfRolesMenu = rolesMenuDAO.getListRolesMenuByRoleId(rolesId);
if (CollectionUtils.isNotEmpty(listOfRolesMenu)) {
for (RolesMenu rm : listOfRolesMenu) {
int menuId = rm.getMenuId();
menuDAO = new MenuDAOImpl();
Menu m = menuDAO.getMenuById(menuId);
if (m.getParentId() == 0) {
listOfParentMenu.add(m);
}
listOfAllRolesMenuForUsers.add(rm);
}
}
}
}
if(CollectionUtils.isNotEmpty(listOfUsersMenu)){
listOfParentMenuForUsers = new ArrayList<Menu>();
listOfAllUserMenuForUsers = new ArrayList<UsersMenu>();
for(UsersMenu um : listOfUsersMenu){
int menuId = um.getMenuId();
menuDAO = new MenuDAOImpl();
Menu menu = menuDAO.getMenuById(menuId);
if(menu.getParentId() == 0){
listOfParentMenuForUsers.add(menu);
}
listOfAllUserMenuForUsers.add(um);
}
}
List<RolesMenu> rMenu = new ArrayList<RolesMenu>(listOfAllRolesMenuForUsers);
List<UsersMenu> uMenu = new ArrayList<UsersMenu>(listOfAllUserMenuForUsers);
List<CustomMenu> union2 = new ArrayList<CustomMenu>(rMenu);
List<CustomMenu> different = new ArrayList<CustomMenu>(uMenu);
different.removeAll(rMenu);
if(different.size() > 0){
union2.addAll(different);
}
if (CollectionUtils.isNotEmpty(listOfParentMenu)) {
for (Menu parentMenu : listOfParentMenu) {
submenu = new DefaultSubMenu();
int menuId = parentMenu.getMenuId();
submenu.setLabel(StringUtils.capitalize(parentMenu.getMenuName()));
List<Menu> listMenu = menuDAO.getListOfMenuByParent(menuId);
if (CollectionUtils.isNotEmpty(listMenu)) {
for (Menu childMenu : listMenu) {
for(CustomMenu rm : union2){
if(rm.getMenuId() == childMenu.getMenuId()){
item = new DefaultMenuItem();
item.setValue(StringUtils.capitalize(childMenu.getMenuName()));
item.setOutcome(childMenu.getUrl().substring(14));
submenu.addElement(item);
}
}
}
}
model.addElement(submenu);
}
}
List<Menu> roleMenu = new ArrayList<Menu>(listOfParentMenu);
List<Menu> usersMenu = new ArrayList<Menu>(listOfParentMenuForUsers);
List<Menu> union = new ArrayList<Menu>(usersMenu);
union.addAll(roleMenu);
List<Menu> intersection = new ArrayList<Menu>(usersMenu);
intersection.retainAll(roleMenu);
if(intersection.size() > 0){
union.removeAll(intersection);
}else{
union.removeAll(roleMenu);
}
if(CollectionUtils.isNotEmpty(union)){
for(Menu m : union){
submenu = new DefaultSubMenu();
int menuId = m.getMenuId();
submenu.setLabel(StringUtils.capitalize(m.getMenuName()));
List<Menu> listMenu = menuDAO.getListOfMenuByParent(menuId);
if (CollectionUtils.isNotEmpty(listMenu)) {
for (Menu childMenu : listMenu) {
for(UsersMenu rm : listOfAllUserMenuForUsers){
if(rm.getMenuId() == childMenu.getMenuId()){
item = new DefaultMenuItem();
item.setValue(StringUtils.capitalize(childMenu.getMenuName()));
item.setOutcome(childMenu.getUrl().substring(14));
submenu.addElement(item);
}
}
}
}
model.addElement(submenu);
}
}
}
public String getMenuById(int menuId) {
menuDAO = new MenuDAOImpl();
listMenuById = menuDAO.getMenuById(menuId);
String menuName = listMenuById.getMenuName();
return menuName;
}
public MenuModel getModel() {
return model;
}
}
显示的错误是Cant实例化类:com.salam.his.bean.MenuBean。