Mercurial > repos > ecology > aquainfra
annotate aquainfra_ogc_api_processes.R @ 0:3073e68373a5 draft default tip
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
author | ecology |
---|---|
date | Thu, 10 Oct 2024 09:56:27 +0000 |
parents | |
children |
rev | line source |
---|---|
0
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
1 library("httr2") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
2 library("jsonlite") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
3 library("getopt") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
4 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
5 cat("start generic wrapper service \n") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
6 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
7 remove_null_values <- function(x) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
8 # Check if the input is a list |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
9 if (is.list(x)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
10 # Remove NULL values and apply the function recursively to sublists |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
11 x <- lapply(x, remove_null_values) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
12 x <- x[!sapply(x, is.null)] |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
13 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
14 return(x) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
15 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
16 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
17 getParameters <- function() { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
18 con <- file("inputs.json", "r") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
19 lines <- readLines(con) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
20 close(con) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
21 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
22 json_string <- paste(lines, collapse = "\n") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
23 json_data <- fromJSON(json_string) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
24 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
25 # Remove NULL values from json_data |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
26 cleaned_json_data <- remove_null_values(json_data) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
27 return(cleaned_json_data$conditional_process) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
28 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
29 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
30 parseResponseBody <- function(body) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
31 hex <- c(body) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
32 intValues <- as.integer(hex) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
33 rawVector <- as.raw(intValues) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
34 readableOutput <- rawToChar(rawVector) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
35 jsonObject <- jsonlite::fromJSON(readableOutput) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
36 return(jsonObject) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
37 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
38 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
39 getOutputs <- function(inputs, output, server) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
40 url <- |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
41 paste(paste(server, "/processes/", sep = ""), |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
42 inputs$select_process, |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
43 sep = "") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
44 request <- request(url) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
45 response <- req_perform(request) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
46 responseBody <- parseResponseBody(response$body) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
47 outputs <- list() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
48 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
49 for (x in 1:length(responseBody$outputs)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
50 outputformatName <- |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
51 paste(names(responseBody$outputs[x]), "_outformat", sep = "") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
52 output_item <- list() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
53 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
54 for (p in names(inputs)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
55 if (p == outputformatName) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
56 format <- list("mediaType" = inputs[[outputformatName]]) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
57 output_item$format <- format |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
58 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
59 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
60 output_item$transmissionMode <- "reference" |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
61 outputs[[x]] <- output_item |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
62 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
63 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
64 names(outputs) <- names(responseBody$outputs) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
65 return(outputs) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
66 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
67 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
68 executeProcess <- function(url, process, requestBodyData) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
69 url <- |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
70 paste(paste(paste(url, "processes/", sep = ""), process, sep = ""), "/execution", sep = "") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
71 requestBodyData$inputs$select_process <- NULL |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
72 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
73 body <- list() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
74 body$inputs <- requestBodyData$inputs |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
75 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
76 response <- request(url) %>% |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
77 req_headers("Content-Type" = "application/json", |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
78 "Prefer" = "respond-async") %>% |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
79 req_body_json(body) %>% |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
80 req_perform() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
81 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
82 cat("\n Process executed") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
83 cat("\n status: ", response$status_code) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
84 #if ( process == "barplot-trend-results") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
85 # process = "batplot-trend-results" |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
86 #} |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
87 #href <- parseResponseBody(response$body)$outputs[[gsub("-", "_", process)]]$href |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
88 jobId <- parseResponseBody(response$body)$jobID |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
89 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
90 return(jobId) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
91 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
92 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
93 checkJobStatus <- function(server, process, jobID) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
94 url <- paste0(server, "jobs/", jobID) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
95 response <- request(url) %>% |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
96 req_perform() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
97 jobStatus <- parseResponseBody(response$body)$status |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
98 jobProgress <- parseResponseBody(response$body)$progress |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
99 return(jobStatus) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
100 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
101 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
102 getStatusCode <- function(server, process, jobID) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
103 url <- paste0(server, "jobs/", jobID) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
104 print(url) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
105 response <- request(url) %>% |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
106 req_perform() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
107 status_code <- response$status_code |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
108 return(status_code) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
109 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
110 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
111 getResult <- function (server, process, jobID) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
112 response <- |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
113 request(paste0(server, "jobs/", jobID, "/results?f=json")) %>% |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
114 req_perform() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
115 return(response) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
116 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
117 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
118 # Recursive function to search for href in a nested list |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
119 findHref <- function(obj) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
120 hrefs <- c() # Initialize an empty vector to store hrefs |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
121 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
122 if (is.list(obj)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
123 # If the object is a list, loop through its elements |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
124 for (name in names(obj)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
125 element <- obj[[name]] |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
126 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
127 if (is.list(element)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
128 # Recursively search if the element is another list |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
129 hrefs <- c(hrefs, findHref(element)) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
130 } else if (name == "href") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
131 # If the element has a name "href", capture its value |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
132 hrefs <- c(hrefs, element) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
133 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
134 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
135 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
136 return(hrefs) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
137 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
138 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
139 retrieveResults <- function(server, process, jobID, outputData) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
140 status_code <- getStatusCode(server, process, jobID) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
141 print(status_code) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
142 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
143 if (status_code == 200) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
144 status <- "running" |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
145 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
146 while (status == "running") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
147 jobStatus <- checkJobStatus(server, process, jobID) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
148 print(jobStatus) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
149 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
150 if (jobStatus == "successful") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
151 status <- jobStatus |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
152 result <- getResult(server, process, jobID) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
153 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
154 if (result$status_code == 200) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
155 resultBody <- parseResponseBody(result$body) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
156 print(resultBody) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
157 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
158 # Call the recursive function to find all hrefs |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
159 hrefs <- findHref(resultBody) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
160 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
161 if (length(hrefs) > 0) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
162 # Collapse the URLs with a newline |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
163 urls_with_newline <- paste(hrefs, collapse = "\n") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
164 print(urls_with_newline) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
165 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
166 # Write the URLs to a file |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
167 con <- file(outputData, "w") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
168 writeLines(urls_with_newline, con = con) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
169 close(con) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
170 } else { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
171 print("No hrefs found.") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
172 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
173 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
174 } else if (jobStatus == "failed") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
175 status <- jobStatus |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
176 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
177 Sys.sleep(3) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
178 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
179 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
180 cat("\n done \n") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
181 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
182 } else if (status_code1 == 400) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
183 print("A query parameter has an invalid value.") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
184 } else if (status_code1 == 404) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
185 print("The requested URI was not found.") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
186 } else if (status_code1 == 500) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
187 print("The requested URI was not found.") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
188 } else { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
189 print(paste("HTTP", status_code1, "Error:", resp1$status_message)) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
190 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
191 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
192 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
193 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
194 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
195 saveResult <- function(href, outputData) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
196 con <- file(outputData, "w") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
197 writeLines(href, con = con) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
198 close(con) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
199 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
200 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
201 is_url <- function(x) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
202 grepl("^https?://", x) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
203 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
204 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
205 server <- "https://aqua.igb-berlin.de/pygeoapi-dev/" |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
206 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
207 print("--> Retrieve parameters") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
208 inputParameters <- getParameters() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
209 #print(inputParameters) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
210 print("--> Parameters retrieved") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
211 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
212 args <- commandArgs(trailingOnly = TRUE) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
213 outputLocation <- args[2] |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
214 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
215 print("--> Retrieve outputs") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
216 outputs <- getOutputs(inputParameters, outputLocation, server) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
217 print("--> Outputs retrieved") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
218 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
219 print("--> Parse inputs") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
220 convertedKeys <- c() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
221 for (key in names(inputParameters)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
222 if (is.character(inputParameters[[key]]) && |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
223 (endsWith(inputParameters[[key]], ".dat") || |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
224 endsWith(inputParameters[[key]], ".txt"))) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
225 con <- file(inputParameters[[key]], "r") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
226 url_list <- list() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
227 #while (length(line <- readLines(con, n = 1)) > 0) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
228 # if (is_url(line)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
229 # url_list <- c(url_list, list(list(href = trimws(line)))) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
230 # } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
231 #} |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
232 con <- file(inputParameters[[key]], "r") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
233 lines <- readLines(con) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
234 print("--------------------------------------------------------------------1") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
235 print(length(lines)) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
236 close(con) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
237 if (!length(lines) > 1 && endsWith(lines, ".jp2") && startsWith(lines, "https")) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
238 print("--------------------------------------------------------------------2") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
239 tmp <- list() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
240 tmp$href <- lines |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
241 tmp$type <- "image/jp2" |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
242 inputParameters[[key]] <- tmp |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
243 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
244 else if (!length(lines) > 1 && endsWith(lines, ".zip") && startsWith(lines, "https")) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
245 print("--------------------------------------------------------------------3") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
246 json_string <- paste(lines, collapse = "\n") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
247 inputParameters[[key]] <- json_string |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
248 } else if (!length(lines) > 1 && (endsWith(lines, ".xlsx") || endsWith(lines, ".csv") || grepl("f=csv", lines)) && startsWith(lines, "https")) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
249 print("--------------------------------------------------------------------4") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
250 json_string <- paste(lines, collapse = "\n") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
251 inputParameters[[key]] <- json_string |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
252 } else if (inputParameters$select_process == "plot-image" || |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
253 inputParameters$select_process == "reproject-image") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
254 print("--------------------------------------------------------------------5") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
255 tmp <- list() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
256 tmp$href <- lines |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
257 tmp$type <- "image/tiff; application=geotiff" |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
258 if (inputParameters$select_process == "reproject-image") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
259 tmp$type <- "image/tiff; subtype=geotiff" |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
260 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
261 inputParameters[[key]] <- tmp |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
262 } else { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
263 print("-----------------------------------6") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
264 json_string <- paste(lines, collapse = "\n") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
265 json_data <- fromJSON(json_string) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
266 inputParameters[[key]] <- json_data |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
267 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
268 convertedKeys <- append(convertedKeys, key) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
269 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
270 else if (grepl("_Array_", key)) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
271 keyParts <- strsplit(key, split = "_")[[1]] |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
272 type <- keyParts[length(keyParts)] |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
273 values <- inputParameters[[key]] |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
274 value_list <- strsplit(values, split = ",") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
275 convertedValues <- c() |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
276 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
277 for (value in value_list) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
278 if (type == "integer") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
279 value <- as.integer(value) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
280 } else if (type == "numeric") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
281 value <- as.numeric(value) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
282 } else if (type == "character") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
283 value <- as.character(value) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
284 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
285 convertedValues <- append(convertedValues, value) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
286 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
287 convertedKey <- "" |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
288 for (part in keyParts) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
289 if (part == "Array") { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
290 break |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
291 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
292 convertedKey <- |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
293 paste(convertedKey, paste(part, "_", sep = ""), sep = "") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
294 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
295 convertedKey <- substr(convertedKey, 1, nchar(convertedKey) - 1) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
296 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
297 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
298 inputParameters[[key]] <- convertedValues |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
299 print("-------------------------") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
300 print(convertedValues) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
301 print("-------------------------") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
302 convertedKeys <- append(convertedKeys, convertedKey) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
303 } else { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
304 print("-------------------------") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
305 print(key) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
306 print(inputParameters[[key]]) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
307 if (!is.null(inputParameters[[key]])) { |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
308 convertedKeys <- append(convertedKeys, key) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
309 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
310 print("-------------------------") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
311 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
312 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
313 } |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
314 print(inputParameters) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
315 names(inputParameters) <- convertedKeys |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
316 #print(inputParameters) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
317 print("--> Inputs parsed") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
318 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
319 print("--> Prepare process execution") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
320 jsonData <- list("inputs" = inputParameters, |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
321 "outputs" = outputs) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
322 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
323 print("--> Execute process") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
324 jobId <- executeProcess(server, inputParameters$select_process, jsonData) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
325 print("--> Process executed") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
326 |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
327 print("--> Retrieve results") |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
328 retrieveResults(server, inputParameters$select_process, jobId, outputLocation) |
3073e68373a5
planemo upload for repository https://github.com/AquaINFRA/tools-ecology/tree/master commit d07f89c8f6d6ee44c05de6b1b8047b387e76cad6
ecology
parents:
diff
changeset
|
329 print("--> Results retrieved") |