use of com.cloud.projects.ProjectAccountVO in project cloudstack by apache.
the class ProjectJoinDaoImpl method newProjectResponse.
@Override
public ProjectResponse newProjectResponse(EnumSet<DomainDetails> details, ProjectJoinVO proj) {
ProjectResponse response = new ProjectResponse();
response.setId(proj.getUuid());
response.setName(proj.getName());
response.setDisplaytext(proj.getDisplayText());
if (proj.getState() != null) {
response.setState(proj.getState().toString());
}
response.setDomainId(proj.getDomainUuid());
response.setDomain(proj.getDomainName());
List<ProjectAccountVO> projectAccounts = projectAccountDao.listByProjectId(proj.getId());
projectAccounts = projectAccounts.stream().filter(projectAccount -> projectAccount.getAccountRole() == ProjectAccount.Role.Admin).collect(Collectors.toList());
List<Map<String, String>> ownersList = new ArrayList<>();
for (ProjectAccount projectAccount : projectAccounts) {
Map<String, String> ownerDetails = new HashMap<>();
if (projectAccount.getUserId() != null) {
User user = userDao.findById(projectAccount.getUserId());
ownerDetails.put("account", _accountDao.findById(projectAccount.getAccountId()).getAccountName());
ownerDetails.put("user", user.getUsername());
ownerDetails.put("userid", user.getUuid());
} else {
ownerDetails.put("account", _accountDao.findById(projectAccount.getAccountId()).getAccountName());
}
ownersList.add(ownerDetails);
}
response.setOwners(ownersList);
response.setCreated(proj.getCreated());
// update tag information
List<ResourceTagJoinVO> tags = ApiDBUtils.listResourceTagViewByResourceUUID(proj.getUuid(), ResourceObjectType.Project);
for (ResourceTagJoinVO vtag : tags) {
response.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
}
// set resource limit/count information for the project (by getting the info of the project's account)
Account account = _accountDao.findByIdIncludingRemoved(proj.getProjectAccountId());
if (details.contains(DomainDetails.all) || details.contains(DomainDetails.resource)) {
AccountJoinVO accountJn = ApiDBUtils.newAccountView(account);
_accountJoinDao.setResourceLimits(accountJn, false, response);
}
response.setProjectAccountName(account.getAccountName());
response.setObjectName("project");
return response;
}
use of com.cloud.projects.ProjectAccountVO in project cloudstack by apache.
the class ProjectAccountDaoImpl method listByProjectId.
@Override
public List<ProjectAccountVO> listByProjectId(long projectId) {
SearchCriteria<ProjectAccountVO> sc = AllFieldsSearch.create();
sc.setParameters("projectId", projectId);
Filter filter = new Filter(ProjectAccountVO.class, "id", Boolean.TRUE, null, null);
return listBy(sc, filter);
}
Aggregations