{-| Module : ModuleLevelAnalysis Description : Facade to the MetaModel module level analysis functions Copyright : Copyright (C) 2019 S. Kamps License : -- This file is distributed under the terms of the Apache License 2.0. For more information, see the file "LICENSE", which is included in the distribution. Stability : experimental -} module ModuleLevelAnalysis (extractMetricData) where import qualified Data.Set as Set import MetaHS.EDSL import qualified MetaHS.DataModel.MetaModel as MetaModel import CsvData -- | Extracts all metric values associated with supplied Relation key. extractMetricData :: String -- ^ The identifier associated with this analysis. -> RelationKey -- ^ The MetaModel Relation Key (E.g., LCOM). -> MetaModel.MetaModel -- ^ The MetaModel Containing the associated key. -> [MetricInfo] -- ^ List of metric values of supplied key extractMetricData id key mm = map (generateMetricInfo id key) $ Set.toList $getRelation key mm -- | Generates a MetricInfoModule data-structure holding the metric value of supplied Element Pair. generateMetricInfo :: String -- ^ The identifier associated with this analysis. -> RelationKey -- ^ The MetaModel metric key -> MetaModel.Pair -- ^ The Module Element to analyze. -> MetricInfo -- ^ The metric information for the given (Element) Pair. generateMetricInfo id metricKey elementPair = MetricInfo { identifier = id ++ "," ++ mn -- hash + module name ,relationKey = metricKey ,value = v } where mn = MetaModel.name $ fst elementPair v = fromIntegral $ MetaModel.intValue $ snd elementPair