#' @title Generate provenance for SUNSET's Anomalies module execution
#' @description Generate provenance information for the execution of SUNSET's Anomalies module.
#' @param recipe Configuration file specifying parameters.
#' @param data s2dv_cube object generated by SUNSET's Anomalies.R function.
#' @return s2dv_cube object with updated graph provenance information.
#' @details This function generates provenance information for the execution of SUNSET's Anomalies module.
#' @references https://earth.bsc.es/gitlab/es/sunset/-/tree/dev-test-provenance?ref_type=heads Documentation for SUNSET's provenance generation.
#' @references This function is based on the semantics outlined in the Calibration ontology within the Metaclip Framework (available at \url{http://www.metaclip.org/}).

SunsetProv.Anomalies <- function(recipe, graph){

  #hcst definition (Dataset+Datasubset)
  graph_hcst <- Prov.Anomalies(recipe, data,graph , type = "hcst")

  #obs definition (Dataset+Datasubset)
  graph_obs <- Prov.Anomalies(recipe, data, graph, type = "obs")

  #fcst definition (Dataset+Datasubset)
  if (!is.null(data$fcst)) {
    graph_fcst <- Prov.Anomalies(recipe, data, graph, type="fcst")
  }

  #Command Call and output definition
  if (!is.null(data$fcst)) {
    graph <- my_union_graph(graph_fcst$graph, graph_hcst$graph, graph_obs$graph)
    graph <- list("graph" = graph,
                  "parentnodename"
                  = list("parentnodename_fcst"
                         = graph_fcst$parentnodename,
                         "parentnodename_hcst"
                         = graph_hcst$parentnodename,
                         "parentnodename_obs"
                         = graph_obs$parentnodename))
  } else {
    graph <- my_union_graph(graph_hcst$graph, graph_obs$graph)
    graph <- list("graph" = graph,
                  "parentnodename"
                  = list("parentnodename_hcst"=graph_hcst$parentnodename,
                         "parentnodename_obs"=graph_obs$parentnodename))
  }

  return(graph)
 
}