Skip to content
Snippets Groups Projects
Commit a37f8670 authored by ThanKarab's avatar ThanKarab
Browse files

Get workflow refactored.

parent 94ed19fe
No related branches found
No related tags found
1 merge request!8Dev merge middleware
This diff is collapsed.
......@@ -10,7 +10,7 @@ import com.google.gson.*;
import eu.hbp.mip.controllers.retrofit.RetroFitGalaxyClients;
import eu.hbp.mip.controllers.retrofit.RetrofitClientInstance;
import eu.hbp.mip.dto.ErrorResponse;
import eu.hbp.mip.dto.GetWorkflowResultsFromGalaxyDtoResponse;
import eu.hbp.mip.dto.GalaxyWorkflowResult;
import eu.hbp.mip.dto.PostWorkflowToGalaxyDtoResponse;
import eu.hbp.mip.dto.StringDtoResponse;
import eu.hbp.mip.helpers.LogHelper;
......@@ -368,22 +368,22 @@ class GalaxyAPI {
logger.info(LogHelper.logUser(userDetails) + "Get workflow results called");
RetroFitGalaxyClients service = RetrofitClientInstance.getRetrofitInstance().create(RetroFitGalaxyClients.class);
Call<List<GetWorkflowResultsFromGalaxyDtoResponse>> call = service.getWorkflowResultsFromGalaxy(id,apiKey);
Call<List<GalaxyWorkflowResult>> call = service.getWorkflowResultsFromGalaxy(id,apiKey);
List<GetWorkflowResultsFromGalaxyDtoResponse> getWorkflowResultsFromGalaxyDtoResponsesList = null;
List<GalaxyWorkflowResult> workflowGalaxyDtoResponsesList = null;
try {
Response<List<GetWorkflowResultsFromGalaxyDtoResponse>> response = call.execute();
Response<List<GalaxyWorkflowResult>> response = call.execute();
if(response.code() >= 400){
logger.error(LogHelper.logUser(userDetails) + "Resonse code: " + response.code() + "" + " with body: " + response.errorBody().string());
return ResponseEntity.badRequest().build();
}
getWorkflowResultsFromGalaxyDtoResponsesList = response.body();
workflowGalaxyDtoResponsesList = response.body();
} catch (IOException e) {
logger.error(LogHelper.logUser(userDetails) + "Cannot make the call to Galaxy API", e);
}
logger.info(LogHelper.logUser(userDetails) + "Get workflow results completed");
return ResponseEntity.ok(getWorkflowResultsFromGalaxyDtoResponsesList);
return ResponseEntity.ok(workflowGalaxyDtoResponsesList);
}
/**
......@@ -418,39 +418,6 @@ class GalaxyAPI {
return ResponseEntity.ok(jsonString);
}
/**
* Get the result body of a specific workflow with details.
*
* @param id : The id as @{@link String} of the workflow.
* @param contentId : The content id as @{@link String}.
* @return Return a @{@link ResponseEntity}.
*/
@RequestMapping(method = RequestMethod.GET, value = "/getWorkflowResultsDetails/{id}/contents/{contentId}", produces = "application/json")
@ResponseStatus(value = HttpStatus.OK)
public ResponseEntity getWorkflowResultsDetails(@AuthenticationPrincipal UserDetails userDetails, @PathVariable String id, @PathVariable String contentId) {
logger.info(LogHelper.logUser(userDetails) + "Get workflow results details called");
RetroFitGalaxyClients service = RetrofitClientInstance.getRetrofitInstance().create(RetroFitGalaxyClients.class);
Call<Object> call = service.getWorkflowResultsDetailsFromGalaxy(id,contentId,apiKey);
String jsonString = null;
try {
Response<Object> response = call.execute();
if(response.code() >= 400){
logger.error(LogHelper.logUser(userDetails) + "Resonse code: " + response.code() + "" + " with body: " + response.errorBody().string());
return ResponseEntity.badRequest().build();
}
jsonString = new Gson().toJson(response.body());
System.out.println(jsonString);
logger.info(LogHelper.logUser(userDetails) + "----" + response.body() + "----" + response.code());
} catch (IOException e) {
logger.error(LogHelper.logUser(userDetails) + "Cannot make the call to Galaxy API", e);
}
logger.info(LogHelper.logUser(userDetails) + "Get workflow results details completed");
return ResponseEntity.ok(jsonString);
}
@RequestMapping(method = RequestMethod.GET, value = "getErrorMessageOfWorkflow/{id}", produces = "application/json")
@ResponseStatus(value = HttpStatus.OK)
public ResponseEntity getErrorMessageOfWorkflow(@AuthenticationPrincipal UserDetails userDetails, @PathVariable String id) {
......
package eu.hbp.mip.controllers.retrofit;
import com.google.gson.JsonObject;
import eu.hbp.mip.dto.GetWorkflowResultsFromGalaxyDtoResponse;
import eu.hbp.mip.dto.GalaxyWorkflowResult;
import eu.hbp.mip.dto.PostWorkflowToGalaxyDtoResponse;
import retrofit2.Call;
import retrofit2.http.*;
......@@ -17,14 +17,11 @@ public interface RetroFitGalaxyClients {
Call<Object> getWorkflowStatusFromGalaxy(@Path("historyId") String historyId, @Query("key") String key);
@GET("histories/{historyId}/contents")
Call<List<GetWorkflowResultsFromGalaxyDtoResponse>> getWorkflowResultsFromGalaxy(@Path("historyId") String historyId, @Query("key") String key);
Call<List<GalaxyWorkflowResult>> getWorkflowResultsFromGalaxy(@Path("historyId") String historyId, @Query("key") String key);
@GET("histories/{historyId}/contents/{contentId}/display")
Call<Object> getWorkflowResultsBodyFromGalaxy(@Path("historyId") String historyId, @Path("contentId") String contentId, @Query("key") String key);
@GET("histories/{historyId}/contents/{contentId}")
Call<Object> getWorkflowResultsDetailsFromGalaxy(@Path("historyId") String historyId, @Path("contentId") String contentId, @Query("key") String key);
@GET("jobs/{jobId}?full=true")
Call<Object> getErrorMessageOfWorkflowFromGalaxy(@Path("jobId") String historyId, @Query("key") String key);
Call<Object> getErrorMessageOfWorkflowFromGalaxy(@Path("jobId") String jobId, @Query("key") String key);
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
public class GetWorkflowResultsFromGalaxyDtoResponse {
public class GalaxyWorkflowResult {
@SerializedName("history_content_type")
private String historyContentType;
......@@ -46,10 +46,10 @@ public class GetWorkflowResultsFromGalaxyDtoResponse {
@SerializedName("purged")
private Boolean purged;
public GetWorkflowResultsFromGalaxyDtoResponse() {
public GalaxyWorkflowResult() {
}
public GetWorkflowResultsFromGalaxyDtoResponse(String historyContentType, String updateTime, String name, String extension, String typeId, Boolean deleted, String historyId, List<Object> tags, String id, Boolean visible, String state, String createTime, Integer hid, String url, String datasetId, String type, Boolean purged) {
public GalaxyWorkflowResult(String historyContentType, String updateTime, String name, String extension, String typeId, Boolean deleted, String historyId, List<Object> tags, String id, Boolean visible, String state, String createTime, Integer hid, String url, String datasetId, String type, Boolean purged) {
this.historyContentType = historyContentType;
this.updateTime = updateTime;
this.name = name;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment