Query hibQuery = session.createQuery(" from SbiFunctions where funct_id = " + funct.getId());
List hibList = hibQuery.list();
if(!hibList.isEmpty()) {
return;
}
IDomainDAO domDAO = DAOFactory.getDomainDAO();
Domain functTypeDom = domDAO.loadDomainByCodeAndValue("FUNCT_TYPE", funct.getCodType());
SbiDomains hibFunctType = (SbiDomains)session.load(SbiDomains.class, functTypeDom.getValueId());
SbiFunctions hibFunct = new SbiFunctions(funct.getId());
hibFunct.setCode(funct.getCode());
hibFunct.setDescr(funct.getDescription());
hibFunct.setFunctTypeCd(funct.getCodType());
hibFunct.setFunctType(hibFunctType);
hibFunct.setName(funct.getName());
hibFunct.setPath(funct.getPath());
hibFunct.setProg(funct.getProg());
session.save(hibFunct);
tx.commit();
Role[] devRoles = funct.getDevRoles();
Domain devDom = domDAO.loadDomainByCodeAndValue(SpagoBIConstants.PERMISSION_ON_FOLDER,
SpagoBIConstants.PERMISSION_ON_FOLDER_TO_DEVELOP);
for(int i=0; i<devRoles.length; i++) {
Role devRole = devRoles[i];
insertRole(devRole, session);
insertFunctRole(devRole, funct, devDom.getValueId(), devDom.getValueCd(), session);
}
Role[] testRoles = funct.getTestRoles();
Domain testDom = domDAO.loadDomainByCodeAndValue(SpagoBIConstants.PERMISSION_ON_FOLDER,
SpagoBIConstants.PERMISSION_ON_FOLDER_TO_TEST);
for(int i=0; i<testRoles.length; i++) {
Role testRole = testRoles[i];
insertRole(testRole, session);
insertFunctRole(testRole, funct, testDom.getValueId(), testDom.getValueCd(), session);
}
Role[] execRoles = funct.getExecRoles();
Domain execDom = domDAO.loadDomainByCodeAndValue(SpagoBIConstants.PERMISSION_ON_FOLDER,
SpagoBIConstants.PERMISSION_ON_FOLDER_TO_EXECUTE);
for(int i=0; i<execRoles.length; i++) {
Role execRole = execRoles[i];
insertRole(execRole, session);
insertFunctRole(execRole, funct, execDom.getValueId(), execDom.getValueCd(), session);
}
Role[] createRoles = funct.getCreateRoles();
Domain createDom = domDAO.loadDomainByCodeAndValue(SpagoBIConstants.PERMISSION_ON_FOLDER,
SpagoBIConstants.PERMISSION_ON_FOLDER_TO_CREATE);
for(int i=0; i<createRoles.length; i++) {
Role createRole = createRoles[i];
insertRole(createRole, session);
insertFunctRole(createRole, funct, createDom.getValueId(), createDom.getValueCd(), session);