FOSSredder 0.5.0
Loading...
Searching...
No Matches
AnalysisPolicy.cpp
Go to the documentation of this file.
1
5
7
8#include <nlohmann/json.hpp>
9
10#include <utility>
11
13
14bool supportsResultType(const std::string& type) {
15 const auto normalized = core::domain::AnalysisType::normalize(type);
16 return !normalized.empty();
17}
18
22
23bool isChartLikeType(const std::string& type) {
24 const auto normalized = core::domain::AnalysisType::normalize(type);
27}
28
29bool isExportable(const std::string& type, const std::string& exportFormat) {
30 return !core::domain::AnalysisType::normalize(type).empty() && !core::domain::ExportFormat::normalize(exportFormat).empty();
31}
32
33std::string normalizeKey(std::string key) {
34 return core::domain::FilterSpec::normalize(std::move(key));
35}
36
37bool isConfigured(const std::string& type,
38 const std::string& configJson,
39 const std::string& filterSpec,
40 const std::string& exportFormat) {
41 return !core::domain::AnalysisType::normalize(type).empty() ||
42 !configJson.empty() ||
43 !core::domain::FilterSpec::normalize(filterSpec).empty() ||
44 !core::domain::ExportFormat::normalize(exportFormat).empty();
45}
46
47std::string resolveOutputType(const std::string& type, const std::string& configJson) {
48 const auto normalizedType = core::domain::AnalysisType::normalize(type);
50 return normalizedType;
51 }
52
53 if (configJson.empty()) {
55 }
56
57 try {
58 const auto config = nlohmann::json::parse(configJson);
60 return config[core::application::analysis::keys::kPlotTypeKey].get<std::string>();
61 }
62 } catch (...) {
63 }
64
66}
67
68std::string resolveExecutionType(const std::string& type) {
69 const auto normalizedType = core::domain::AnalysisType::normalize(type);
70 if (normalizedType.empty()) {
72 }
73 return normalizedType;
74}
75
76} // namespace core::domain::policies::analysis
Shared analysis validation and normalization helpers.
static std::string normalize(std::string value)
Trims leading and trailing whitespace from an analysis type.
static std::string normalize(std::string value)
Trims leading and trailing whitespace from an export format.
static std::string normalize(std::string value)
Trims leading and trailing whitespace from a filter specification.
constexpr std::string_view kTypePlot
constexpr std::string_view kPlotTypeKey
constexpr std::string_view kTypeTab
bool isConfigured(const std::string &type, const std::string &configJson, const std::string &filterSpec, const std::string &exportFormat)
Checks whether an analysis is sufficiently configured.
bool isExportable(const std::string &type, const std::string &exportFormat)
Checks whether an analysis type can be exported.
bool supportsResultType(const std::string &type)
Checks whether an analysis type is supported at all.
std::string resolveOutputType(const std::string &type, const std::string &configJson)
Resolves the effective output type for an analysis.
bool isChartLikeType(const std::string &type)
Checks whether an analysis type produces chart-like output.
bool isTabularType(const std::string &type)
Checks whether an analysis type produces tabular output.
std::string resolveExecutionType(const std::string &type)
Resolves the effective execution type for an analysis.
std::string normalizeKey(std::string key)
Normalizes filter keys used by analysis adjustments.