adamdebreceni commented on code in PR #2231:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2231#discussion_r4562914258
##########
libminifi/src/core/flow/StructuredConfiguration.cpp:
##########
@@ -1134,4 +1064,83 @@ std::string StructuredConfiguration::serialize(const
core::ProcessGroup& process
return flow_serializer_->serialize(process_group, schema_,
sensitive_values_encryptor_, {}, parameter_contexts_);
}
+void StructuredConfiguration::parseReportingTasks(const Node&
reporting_tasks_node, core::ProcessGroup* parent_group) {
+ if (!reporting_tasks_node || !reporting_tasks_node.isSequence()) {
+ return;
+ }
+ for (const auto& reporting_task_node : reporting_tasks_node) {
+ checkRequiredField(reporting_task_node, schema_.name);
+ auto name = reporting_task_node[schema_.name].getString().value();
+ utils::Identifier id;
+ id = getOrGenerateId(reporting_task_node);
+
+ checkRequiredField(reporting_task_node, schema_.type);
+ auto type = reporting_task_node[schema_.type].getString().value();
+
+ auto reporting_task =
createProcessor(utils::string::partAfterLastOccurrenceOf(type, '.'), type,
name, id);
+ if (!reporting_task) {
+ logger_->log_error("Could not create a processor {} with id {}", name,
id.to_string());
+ throw std::invalid_argument("Could not create processor " + name);
+ }
+
+ reporting_task->setFlowIdentifier(flow_version_->getFlowIdentifier());
+
+ auto scheduling_strategy = getOptionalField(reporting_task_node,
schema_.scheduling_strategy, DEFAULT_SCHEDULING_STRATEGY);
+ if (scheduling_strategy == "TIMER_DRIVEN") {
+ reporting_task->setSchedulingStrategy(core::TIMER_DRIVEN);
+ } else {
+ reporting_task->setSchedulingStrategy(core::CRON_DRIVEN);
+ }
+ auto scheduling_period_str = getOptionalField(reporting_task_node,
schema_.scheduling_period, DEFAULT_SCHEDULING_PERIOD_STR);
+ if (scheduling_strategy == "TIMER_DRIVEN") {
+ if (auto scheduling_period =
utils::timeutils::StringToDuration<std::chrono::nanoseconds>(scheduling_period_str))
{
+ reporting_task->setSchedulingPeriod(*scheduling_period);
+ }
+ } else {
+ reporting_task->setCronPeriod(scheduling_period_str);
+ }
Review Comment:
added checks, and test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]