Skip to content

Commit

Permalink
Add new shapes and a SHAPES constant
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovicc committed May 1, 2018
1 parent 9429895 commit 6e8daa9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
18 changes: 17 additions & 1 deletion R/r-mip-adaptor.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,20 @@
#' @aliases r-mip-adaptor package-r-mip-adaptor
#' @title HBP - Database connections
#' @name rmipadaptor
NULL

SHAPES <- list(
ERROR = "text/plain+error",
PFA = "application/pfa+json",
PFA_YAML = "application/pfa+yaml",
TABULAR_DATA_RESOURCE = "application/vnd.dataresource+json",
HTML = "text/html",
SVG = "image/svg+xml",
PNG = "image/png;base64",
HIGHCHARTS = "application/vnd.highcharts+json",
VISJS = "application/vnd.visjs+javascript",
PLOTLY = "application/vnd.plotly.v1+json",
VEGA = "application/vnd.vega+json",
VEGALITE = "application/vnd.vegalite+json",
JSON = "application/json",
TEXT = "text/plain"
)
2 changes: 1 addition & 1 deletion R/saveError.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ saveError <- function(
conn <- out_conn;
}
}
shape <- "error";
shape <- "text/plain+error";
data <- "";

if (file.exists(outputFile)) {
Expand Down
13 changes: 13 additions & 0 deletions R/saveResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,25 @@ saveResults <- function(

serialized_results <- switch(shape,
string = results,
"text/plain" = results,
pfa_json = results,
"application/pfa+json" = results,
pfa_yaml = results,
"application/pfa+yaml" = results,
"application/vnd.dataresource+json" = results,
svg = results,
"image/svg+xml" = results,
"image/png;base64" = results,
plotly = results,
"application/vnd.plotly.v1+json" = results,
highcharts = results,
"application/vnd.highcharts+json" = results,
"application/vnd.visjs+javascript" = results,
"application/vnd.vega+json" = results,
"application/vnd.vegalite+json" = results,
html = results,
"text/html" = results,
"application/json" = results,
r_dataframe_intermediate = toJSON(results, auto_unbox=TRUE, digits=8, Date = "ISO8601"),
r_dataframe_columns = toJSON(results, dataframe="columns", digits=8, Date = "ISO8601"),
r_matrix = toJSON(results, matrix="rowmajor", digits=8, Date = "ISO8601"),
Expand Down

0 comments on commit 6e8daa9

Please sign in to comment.