Search in sources :

Example 1 with InodeView

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()));
}
Also used : InodeView(io.hops.hopsworks.persistence.entity.hdfs.inode.InodeView) Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) DatasetSharedWith(io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith) ArrayList(java.util.ArrayList) ProjectServiceEnum(io.hops.hopsworks.persistence.entity.project.service.ProjectServiceEnum) ProjectException(io.hops.hopsworks.exceptions.ProjectException) JupyterProject(io.hops.hopsworks.persistence.entity.jupyter.JupyterProject) Project(io.hops.hopsworks.persistence.entity.project.Project) ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)

Aggregations

ProjectException (io.hops.hopsworks.exceptions.ProjectException)1 Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)1 DatasetSharedWith (io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith)1 Inode (io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)1 InodeView (io.hops.hopsworks.persistence.entity.hdfs.inode.InodeView)1 JupyterProject (io.hops.hopsworks.persistence.entity.jupyter.JupyterProject)1 Project (io.hops.hopsworks.persistence.entity.project.Project)1 ProjectServiceEnum (io.hops.hopsworks.persistence.entity.project.service.ProjectServiceEnum)1 ProjectTeam (io.hops.hopsworks.persistence.entity.project.team.ProjectTeam)1 ArrayList (java.util.ArrayList)1