FOSSredder 0.5.0
Loading...
Searching...
No Matches
AnnualWorkflow.cpp
Go to the documentation of this file.
1
5
7
13
14#include <utility>
15
16namespace ui {
17
19 StateSnapshotProvider stateSnapshotProvider,
20 std::shared_ptr<ui::adapters::AnnualAdapter> annualAdapter, QObject* parent)
21 : QObject(parent), stateSnapshotProvider_(std::move(stateSnapshotProvider)),
22 annualAdapter_(std::move(annualAdapter)) {}
23
24QVariantMap AnnualWorkflow::computeAnnualPreview(const QString& annualId,
25 const QStringList& analysisIds,
26 int year) const {
27 if (!annualAdapter_) {
28 return {};
29 }
32 "Annual preview compute submitted",
33 {{"annualId", annualId.trimmed().toStdString()},
34 {observability::context::kCount, std::to_string(analysisIds.size())}});
35 try {
37 request.annualId = strings::toStdString(annualId.trimmed());
38 request.previewYear = year;
39 request.previewAnalysisIds.reserve(analysisIds.size());
40 for (const auto& id : analysisIds) {
41 request.previewAnalysisIds.push_back(strings::toStdString(id));
42 }
43 return annualAdapter_->mapAnnualResult(
44 annualAdapter_->runAnnual(stateSnapshot(), request));
45 } catch (...) {
46 return {};
47 }
48}
49
51AnnualWorkflow::stateSnapshot() const {
52 return stateSnapshotProvider_ ? stateSnapshotProvider_()
53 : core::ports::workspace::WorkspaceSnapshot{};
54}
55
56} // namespace ui
Declares the annual adapter used by UI workflows.
Declares the annual query request port contract.
Declares the UI workflow for annual result computation.
Declarations for the UI Origins component.
Declares lightweight conversions between common Qt string types and standard strings.
Declarations for the UI Trace component.
AnnualWorkflow(StateSnapshotProvider stateSnapshotProvider, std::shared_ptr< ui::adapters::AnnualAdapter > annualAdapter, QObject *parent=nullptr)
Creates an annual workflow.
QVariantMap computeAnnualPreview(const QString &annualId, const QStringList &analysisIds, int year) const
Computes an annual preview through the core runner.
std::function< core::ports::workspace::WorkspaceSnapshot()> StateSnapshotProvider
constexpr auto kCount
Definition Trace.h:23
void traceWorkflow(const char *origin, std::string message, core::errors::ErrorContext context={})
Emits a workflow trace event.
Definition Trace.h:108
std::string toStdString(const QString &value)
Converts a QString to a UTF-8 encoded std::string.
std::vector< std::string > previewAnalysisIds