using ms_namingservice.Mapping.ValuesMapping;
using ms_namingservice.Objects;
using ms_namingservice.Objects.SavedData;
using ms_namingservice.Objects.ServiceObjects;

namespace ms_namingservice.Mapping;

/// <summary>
/// A class that generates names for frameworks.
/// </summary>
public class GeneratingNames
{
    /// <summary>
    /// Method that maps all the generated names, categories, subcategories and references for all frameworks.
    /// </summary>
    /// <returns>A task containing an Output object that includes a list of Framework objects and a log source.</returns>
    public async static Task<Output> GetResult()
    {
        List<Framework> frameworks = new List<Framework>();
        
        // Create a new MITRE Framework object with its generated name, category, subcategory, and reference.
        Framework mitre = new Framework
        {
            Name = Const.Mitre, 
            GeneratedName = await GeneratedNameMapping.GetGeneratedName(Const.Mitre),
            Category = await CategoryMapping.GetCategory(Const.Mitre),
            Subcategory = await SubcategoryMapping.GetSubcategory(Const.Mitre),
            Reference = await ReferenceMapping.GetReference(Const.Mitre)
        };

        // Create a new ENISA Framework object with its generated name and category, but no subcategory or reference.
        Framework enisa = new Framework
        {
            Name = Const.Enisa,
            GeneratedName = await GeneratedNameMapping.GetGeneratedName(Const.Enisa),
            Category = await CategoryMapping.GetCategory(Const.Enisa),
            Subcategory = null, //Does not use subcategories
            Reference = null //Does not use references
        };

        // Add the Mitre and Enisa frameworks to the frameworks list.
        frameworks.Add(mitre);
        frameworks.Add(enisa);

        // Create a new Output object with the frameworks list and the log source from the InputData.
        Output output = new Output
        {
            Frameworks = frameworks,
            LogSource = InputData.Input.LogSource //Does not change
        };
    
        return output;
    }
}