use of io.hops.hopsworks.persistence.entity.hdfs.inode.InodeView in project hopsworks by logicalclocks.
the class ProjectController method getProjectByName.
/**
* Project info as data transfer object that can be sent to the user.
*
* @param name
* @return project DTO that contains team members and services
*/
public ProjectDTO getProjectByName(String name) throws ProjectException {
// find the project entity from hopsworks database
Project project = projectFacade.findByName(name);
if (project == null) {
throw new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_NOT_FOUND, Level.FINE, "project: " + name);
}
// find the project as an inode from hops database
Inode inode = inodeController.getInodeAtPath(Utils.getProjectPath(name));
List<ProjectTeam> projectTeam = projectTeamFacade.findMembersByProject(project);
List<ProjectServiceEnum> projectServices = projectServicesFacade.findEnabledServicesForProject(project);
List<String> services = new ArrayList<>();
for (ProjectServiceEnum s : projectServices) {
services.add(s.toString());
}
Inode parent;
List<InodeView> kids = new ArrayList<>();
Collection<Dataset> dsInProject = project.getDatasetCollection();
Collection<DatasetSharedWith> dsSharedWithProject = project.getDatasetSharedWithCollection();
for (Dataset ds : dsInProject) {
parent = inodes.findParent(ds.getInode());
kids.add(new InodeView(parent, ds, inodeController.getPath(ds.getInode())));
}
for (DatasetSharedWith ds : dsSharedWithProject) {
parent = inodes.findParent(ds.getDataset().getInode());
kids.add(new InodeView(parent, ds, inodeController.getPath(ds.getDataset().getInode())));
}
// send the project back to client
return new ProjectDTO(project, inode.getId(), services, projectTeam, kids, projectUtils.dockerImageIsPreinstalled(project.getDockerImage()), projectUtils.isOldDockerImage(project.getDockerImage()));
}
Aggregations