Search in sources :

Example 1 with DataSetDTO

use of io.hops.hopsworks.common.dao.dataset.DataSetDTO in project hopsworks by logicalclocks.

the class ProjectService method getDatasetInfo.

@GET
@Path("{projectId}/getInodeInfo/{inodeId}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.ANYONE })
public Response getDatasetInfo(@PathParam("projectId") Integer projectId, @PathParam("inodeId") Long inodeId, @Context SecurityContext sc) throws ProjectException, DatasetException {
    Inode inode = inodes.findById(inodeId);
    if (inode == null) {
        throw new DatasetException(RESTCodes.DatasetErrorCode.INODE_NOT_FOUND, Level.FINE, "inodeId: " + inodeId);
    }
    Project project = projectFacade.find(projectId);
    if (project == null) {
        throw new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_NOT_FOUND, Level.FINE, "projectId: " + projectId);
    }
    DataSetDTO dataset = new DataSetDTO(inode.getInodePK().getName(), inodeId, project);
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(dataset).build();
}
Also used : ProjectException(io.hops.hopsworks.exceptions.ProjectException) Project(io.hops.hopsworks.persistence.entity.project.Project) Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) DataSetDTO(io.hops.hopsworks.common.dao.dataset.DataSetDTO) DatasetException(io.hops.hopsworks.exceptions.DatasetException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 2 with DataSetDTO

use of io.hops.hopsworks.common.dao.dataset.DataSetDTO in project hopsworks by logicalclocks.

the class ProjectService method getDatasetInfo.

@GET
@Path("getDatasetInfo/{inodeId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getDatasetInfo(@PathParam("inodeId") Long inodeId, @Context SecurityContext sc) throws DatasetException {
    Inode inode = inodes.findById(inodeId);
    Project proj = datasetController.getOwningProject(inode);
    Dataset ds = datasetFacade.findByProjectAndInode(proj, inode);
    if (ds == null) {
        throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_NOT_FOUND, Level.FINE, "inodeId: " + inodeId);
    }
    Collection<DatasetSharedWith> projectsContainingInode = proj.getDatasetSharedWithCollection();
    List<String> sharedWith = new ArrayList<>();
    for (DatasetSharedWith d : projectsContainingInode) {
        if (!d.getProject().getId().equals(proj.getId())) {
            sharedWith.add(d.getProject().getName());
        }
    }
    DataSetDTO dataset = new DataSetDTO(ds, proj, sharedWith);
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(dataset).build();
}
Also used : Project(io.hops.hopsworks.persistence.entity.project.Project) Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) DatasetSharedWith(io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith) ArrayList(java.util.ArrayList) DataSetDTO(io.hops.hopsworks.common.dao.dataset.DataSetDTO) DatasetException(io.hops.hopsworks.exceptions.DatasetException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with DataSetDTO

use of io.hops.hopsworks.common.dao.dataset.DataSetDTO in project hopsworks by logicalclocks.

the class DelaClusterService method getPublicDatasets.

@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getPublicDatasets(@Context SecurityContext sc) {
    List<Dataset> clusterDatasets = clusterDatasetCtrl.getPublicDatasets();
    List<DataSetDTO> localDS = new LinkedList<>();
    for (Dataset ds : clusterDatasets) {
        localDS.add(new DataSetDTO(ds));
    }
    GenericEntity<List<DataSetDTO>> datasets = new GenericEntity<List<DataSetDTO>>(localDS) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(datasets).build();
}
Also used : Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) GenericEntity(javax.ws.rs.core.GenericEntity) List(java.util.List) LinkedList(java.util.LinkedList) DataSetDTO(io.hops.hopsworks.common.dao.dataset.DataSetDTO) LinkedList(java.util.LinkedList) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

DataSetDTO (io.hops.hopsworks.common.dao.dataset.DataSetDTO)3 GET (javax.ws.rs.GET)3 Produces (javax.ws.rs.Produces)3 DatasetException (io.hops.hopsworks.exceptions.DatasetException)2 Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)2 Inode (io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)2 Project (io.hops.hopsworks.persistence.entity.project.Project)2 Path (javax.ws.rs.Path)2 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)1 ProjectException (io.hops.hopsworks.exceptions.ProjectException)1 DatasetSharedWith (io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 GenericEntity (javax.ws.rs.core.GenericEntity)1