@Override public boolean unassignAccountFromProject(long projectId, long accountId) { ProjectAccountVO projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, accountId); if (projectAccount == null) { s_logger.debug("Account id=" + accountId + " is not assigned to project id=" + projectId + " so no need to unassign"); return true; } if (_projectAccountDao.remove(projectAccount.getId())) { return true; } else { s_logger.warn("Failed to unassign account id=" + accountId + " from the project id=" + projectId); return false; } }
@Override public Boolean doInTransaction(TransactionStatus status) { boolean success = true; //remove account ProjectAccountVO projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, accountId); success = _projectAccountDao.remove(projectAccount.getId()); //remove all invitations for account if (success) { s_logger.debug("Removed account " + accountId + " from project " + projectId + " , cleaning up old invitations for account/project..."); ProjectInvitation invite = _projectInvitationDao.findByAccountIdProjectId(accountId, projectId); if (invite != null) { success = success && _projectInvitationDao.remove(invite.getId()); } } return success; } });
_projectAccountDao.update(currentOwner.getId(), currentOwner); _resourceLimitMgr.decrementResourceCount(currentOwnerAccount.getId(), ResourceType.project); _projectAccountDao.update(futureOwner.getId(), futureOwner); _resourceLimitMgr.incrementResourceCount(futureOwnerAccount.getId(), ResourceType.project);
protected ProjectAccountDaoImpl() { AllFieldsSearch = createSearchBuilder(); AllFieldsSearch.and("role", AllFieldsSearch.entity().getAccountRole(), SearchCriteria.Op.EQ); AllFieldsSearch.and("projectId", AllFieldsSearch.entity().getProjectId(), SearchCriteria.Op.EQ); AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ); AllFieldsSearch.and("projectAccountId", AllFieldsSearch.entity().getProjectAccountId(), SearchCriteria.Op.EQ); AllFieldsSearch.done(); AdminSearch = createSearchBuilder(Long.class); AdminSearch.selectFields(AdminSearch.entity().getProjectId()); AdminSearch.and("role", AdminSearch.entity().getAccountRole(), Op.EQ); AdminSearch.and("accountId", AdminSearch.entity().getAccountId(), Op.EQ); AdminSearch.done(); ProjectAccountSearch = createSearchBuilder(Long.class); ProjectAccountSearch.selectFields(ProjectAccountSearch.entity().getProjectAccountId()); ProjectAccountSearch.and("accountId", ProjectAccountSearch.entity().getAccountId(), Op.EQ); ProjectAccountSearch.done(); CountByRoleSearch = createSearchBuilder(Long.class); CountByRoleSearch.select(null, Func.COUNT, CountByRoleSearch.entity().getId()); CountByRoleSearch.and("accountId", CountByRoleSearch.entity().getAccountId(), Op.EQ); CountByRoleSearch.and("role", CountByRoleSearch.entity().getAccountRole(), Op.EQ); CountByRoleSearch.done(); }