Search in sources :

Example 1 with ProjectTypeResolution

use of org.eclipse.che.api.project.server.type.ProjectTypeResolution in project che by eclipse.

the class ProjectService method estimateProject.

@GET
@Path("/estimate/{path:.*}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Estimates if the folder supposed to be project of certain type", response = Map.class)
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "Project with specified path doesn't exist in workspace"), @ApiResponse(code = 403, message = "Access to requested project is forbidden"), @ApiResponse(code = 500, message = "Server error") })
public SourceEstimation estimateProject(@ApiParam(value = "Path to requested project", required = true) @PathParam("path") String path, @ApiParam(value = "Project Type ID to estimate against", required = true) @QueryParam("type") String projectType) throws NotFoundException, ForbiddenException, ServerException, ConflictException {
    final ProjectTypeResolution resolution = projectManager.estimateProject(path, projectType);
    final HashMap<String, List<String>> attributes = new HashMap<>();
    for (Map.Entry<String, Value> attr : resolution.getProvidedAttributes().entrySet()) {
        attributes.put(attr.getKey(), attr.getValue().getList());
    }
    return DtoFactory.newDto(SourceEstimation.class).withType(projectType).withMatched(resolution.matched()).withResolution(resolution.getResolution()).withAttributes(attributes);
}
Also used : ProjectTypeResolution(org.eclipse.che.api.project.server.type.ProjectTypeResolution) HashMap(java.util.HashMap) DefaultValue(javax.ws.rs.DefaultValue) Value(org.eclipse.che.api.core.model.project.type.Value) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with ProjectTypeResolution

use of org.eclipse.che.api.project.server.type.ProjectTypeResolution in project che by eclipse.

the class ProjectService method resolveSources.

@GET
@Path("/resolve/{path:.*}")
@Produces(MediaType.APPLICATION_JSON)
public List<SourceEstimation> resolveSources(@ApiParam(value = "Path to requested project", required = true) @PathParam("path") String path) throws NotFoundException, ForbiddenException, ServerException, ConflictException {
    List<SourceEstimation> estimations = new ArrayList<>();
    for (ProjectTypeResolution resolution : projectManager.resolveSources(path, false)) {
        if (resolution.matched()) {
            final HashMap<String, List<String>> attributes = new HashMap<>();
            for (Map.Entry<String, Value> attr : resolution.getProvidedAttributes().entrySet()) {
                attributes.put(attr.getKey(), attr.getValue().getList());
            }
            estimations.add(DtoFactory.newDto(SourceEstimation.class).withType(resolution.getType()).withMatched(resolution.matched()).withAttributes(attributes));
        }
    }
    return estimations;
}
Also used : ProjectTypeResolution(org.eclipse.che.api.project.server.type.ProjectTypeResolution) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SourceEstimation(org.eclipse.che.api.project.shared.dto.SourceEstimation) DefaultValue(javax.ws.rs.DefaultValue) Value(org.eclipse.che.api.core.model.project.type.Value) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 DefaultValue (javax.ws.rs.DefaultValue)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)2 Value (org.eclipse.che.api.core.model.project.type.Value)2 ProjectTypeResolution (org.eclipse.che.api.project.server.type.ProjectTypeResolution)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 SourceEstimation (org.eclipse.che.api.project.shared.dto.SourceEstimation)1