protected void addPermissions(/*not final*/ CnATreeElement element) { HashSet<Permission> newperms = new HashSet<Permission>(); newperms.add(Permission.createPermission(element, authService.getUsername(), true, true)); element.setPermissions(newperms); for (CnATreeElement child : element.getChildren()) { addPermissions(child); } }
public void execute() { IBaseDao<T, Serializable> dao; if (clazz == null) { clazz = CnATypeMapper.getClassFromTypeId(typeId); } dao = (IBaseDao<T, Serializable>) getDaoFactory().getDAO(clazz); IBaseDao<CnATreeElement, Serializable> containerDAO = getDaoFactory().getDAOforTypedElement(container); try { if (!skipReload && !containerDAO.contains(container)) { containerDAO.reload(container, container.getDbId()); } // get constructor with parent-parameter and create new object: if (isOrganization()) { child = (T) Organization.class .getConstructor(CnATreeElement.class, boolean.class) .newInstance(container, createChildren); } else if (isAudit()) { child = (T) Audit.class .getConstructor(CnATreeElement.class, boolean.class) .newInstance(container, createChildren); } else { child = (T) clazz.getConstructor(CnATreeElement.class).newInstance(container); } if (title != null) { // override the default title child.setTitel(title); } if (authService.isPermissionHandlingNeeded()) { addPermissions(containerDAO); } child = dao.merge(child, false); container.addChild(child); child.setParentAndScope(container); if (isOrganization()) { setScope((Organization) child); } // initialize UUID, used to find container in display in views: container.getUuid(); } catch (Exception e) { getLogger().error("Error while creating element", e); throw new RuntimeCommandException(e); } }
/* * (non-Javadoc) * * @see sernet.gs.ui.rcp.main.service.commands.ICommand#execute() */ @Override public void execute() { FinishedRiskAnalysis riskAnalysis = getDaoFactory().getDAO(FinishedRiskAnalysis.class).findById(riskAnalysisDbId); finishedRiskLists = getDaoFactory().getDAO(FinishedRiskAnalysisLists.class).findById(listDbId); gefaehrdungsUmsetzung = GefaehrdungsUmsetzungFactory.build(null, currentGefaehrdung, language); getDaoFactory().getDAO(GefaehrdungsUmsetzung.class).saveOrUpdate(gefaehrdungsUmsetzung); if (authService.isPermissionHandlingNeeded()) { gefaehrdungsUmsetzung.setPermissions( Permission.clonePermissionSet(gefaehrdungsUmsetzung, riskAnalysis.getPermissions())); } finishedRiskLists.getAssociatedGefaehrdungen().add(gefaehrdungsUmsetzung); }