public Integer updSite(Site vo) { siteDAO.merge(vo); Site currSite = getCurSite(); if (currSite != null) { if (currSite.getId() == vo.getId()) { initSiteInContext(vo); } } return vo.getId(); }
public Integer addSite(Integer parentId, String siteName, Integer organId) { Site vo = new Site(); vo.setSiteName(siteName); if (parentId != null) vo.setParent(siteDAO.get(parentId)); Organ organVo = new Organ(); organVo.setId(organId); vo.setOrgan(organVo); siteDAO.persist(vo); return vo.getId(); }
/** 获取子站点. */ public List<TreeNode> getSiteChildren(Integer parentId, Integer organId) { List<TreeNode> tnList = new ArrayList<TreeNode>(); List<Site> siteList = siteDAO.getSiteChildren(parentId, organId); for (Site vo : siteList) { TreeNode tnVo = new TreeNode(); tnVo.setId(vo.getId().toString()); tnVo.setText(vo.getSiteName()); if (vo.hasChildren()) { tnVo.setState("closed"); } else { tnVo.setState("open"); } tnList.add(tnVo); } return tnList; }
public Integer saveSiteServer(Site vo) { Site oldvo = getSite(vo.getId()); SiteServer siteServer = vo.getSiteServer(); if (siteServer.getPassword() == null || siteServer.getPassword().length() == 0) { if (oldvo.getSiteServer() != null) { siteServer.setPassword(oldvo.getSiteServer().getPassword()); } } oldvo.setSiteServer(vo.getSiteServer()); updSite(oldvo); return oldvo.getSiteServer().getId(); }