Prov.Dataset<-function(recipe, data, type){
  #First metadata definitions
  Horizon<-tolower(recipe$Analysis$Horizon) #Either seasonal or decadal
  System.name<- recipe$Analysis$Datasets$System$name #System name
  Reference.name <- recipe$Analysis$Datasets$Reference$name #Reference name
  
  #Dataset setting
  if (Horizon=="seasonal") {
      archive<-read_yaml("conf/archive.yml")
      if(System.name %in% names(archive$esarchive$System) & (Reference.name %in% names(archive$esarchive$Reference))) {
        archive_system<- archive$esarchive$System[[System.name]]
        archive_reference<- archive$esarchive$Reference[[Reference.name]]
      }

      else if(System.name %in% names(archive$mars$System)) {
        archive_system<- archive$mars$System[[System.name]]
        archive_reference<- archive$mars$Reference[[Reference.name]]
    }

  } else if (Horizon=="decadal") {
    archive<-read_yaml("conf/archive_decadal.yml")
        if(System.name %in% names(archive$esarchive$System) & (Reference.name %in% names(archive$esarchive$Reference))) {
            archive_system<- archive$esarchive$System[[System.name]]
            archive_reference<- archive$esarchive$Reference[[Reference.name]]
            }
    else{
        print("The System or Reference datasource is not registered")
    }       
  }

  #Have to review this
  if(type=="fcst"){ 
    Dataset.name=archive_system$name
    Dataset.subclass="SeasonalOperationalForecast"
    DataProvider=archive_system$institution
    ModellingCenter=archive_system$institution
  }else if(type=="hcst"){
    Dataset.name=archive_system$name
    Dataset.subclass="SeasonalHindcast"
    DataProvider=archive_system$institution
    ModellingCenter=archive_system$institution
  }else if(type=="obs"){
    Dataset.name=archive_reference$name
    Dataset.subclass="ObservationalDataset"
    DataProvider=archive_reference$institution
    ModellingCenter=archive_reference$institution
  }
  Project<-"C3S"
  #"MultiDecadalSimulation can be included in the future"

  #Create the main graph
  graph<-make_empty_graph(0)
  #Dataset node
  Dataset.nodename<-paste0("Dataset_",type)
  graph <- my_add_vertices(graph,
                            nv = 1,
                            name = Dataset.nodename,
                            label = Dataset.name,
                            className = paste0("ds:", Dataset.subclass))
  #Data Provider
  if (is.character(DataProvider)) {
    if (length(DataProvider) > 1) stop("Only one DataProvider per Dataset is allowed", call. = FALSE)
    DataProvider.nodename<-paste0("DataProvider_", type)
    graph <- my_add_vertices(graph,
                                 name = DataProvider.nodename,
                                 label = DataProvider,
                                 className = "ds:DataProvider"
                                 )
    graph <- add_edges(graph, 
                       c(getNodeIndexbyName(graph, Dataset.nodename),
                       getNodeIndexbyName(graph, DataProvider.nodename)),
                       label = "ds:hadDataProvider")
  }
  #Modelling Center
  if (is.character(ModellingCenter)) {
    ModellingCenter.nodename<-paste0("ModellingCenter_",type)
    graph <- my_add_vertices(graph,
                             nv = 1,
                             name = ModellingCenter.nodename,
                             label = ModellingCenter,
                             className = "ds:ModellingCenter"
                             )
    
    graph <- add_edges(graph, 
                       c(getNodeIndexbyName(graph, Dataset.nodename),
                         getNodeIndexbyName(graph, ModellingCenter.nodename)),
                       label = "ds:hadModellingCenter" )
  }                    
  #Project
  if(is.character(Project)){
    Project.nodename<-paste0("Project_",type)
    graph <- my_add_vertices(graph,
                                   nv = 1,
                                   name = Project.nodename,
                                   label = Project,
                                   className = "ds:Project")
    graph <- add_edges(graph, 
                       c(getNodeIndexbyName(graph, Dataset.nodename),
                         getNodeIndexbyName(graph, Project.nodename)),
                       label = "ds:hadProject")
  } 
  
  return(list("graph"=graph, "parentnodename"=Dataset.nodename))
}
