This is an automated email from the ASF dual-hosted git repository.

adebreceni pushed a commit to branch minifi-api-reduced
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit ff298550549ad3b864c5bd9efd97debc9e41dc6f
Author: Adam Debreceni <[email protected]>
AuthorDate: Thu Mar 20 08:39:42 2025 +0100

    Rebase fix
---
 .../include/utils/ProcessorConfigUtils.h           |  24 ++---
 extension-utils/src/utils/ProcessorConfigUtils.cpp | 108 ---------------------
 .../expression-language/ProcessContextExpr.cpp     |   6 +-
 .../tests/unit/FlowJsonTests.cpp                   |   2 +-
 .../tests/unit/YamlConfigurationTests.cpp          |   2 +-
 libminifi/src/core/ProcessContext.cpp              |   4 +-
 libminifi/test/libtest/unit/MockClasses.h          |   2 +-
 .../include/minifi-cpp/core/ProcessContext.h       |   4 +-
 8 files changed, 22 insertions(+), 130 deletions(-)

diff --git a/extension-utils/include/utils/ProcessorConfigUtils.h 
b/extension-utils/include/utils/ProcessorConfigUtils.h
index 29de57eec..5f0ca845f 100644
--- a/extension-utils/include/utils/ProcessorConfigUtils.h
+++ b/extension-utils/include/utils/ProcessorConfigUtils.h
@@ -32,27 +32,27 @@
 namespace org::apache::nifi::minifi::utils {
 
 inline std::string parseProperty(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file = nullptr) {
-  return ctx.getProperty(property.name, flow_file) | 
orThrow(fmt::format("Expected valid value from \"{}::{}\"", 
ctx.getProcessor().getName(), property.name));
+  return ctx.getProperty(property.name, flow_file) | 
orThrow(fmt::format("Expected valid value from \"{}::{}\"", 
ctx.getProcessorInfo().getName(), property.name));
 }
 
 inline bool parseBoolProperty(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file = nullptr) {
-  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseBool) | orThrow(fmt::format("Expected parsable bool from 
\"{}::{}\"", ctx.getProcessor().getName(), property.name));
+  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseBool) | orThrow(fmt::format("Expected parsable bool from 
\"{}::{}\"", ctx.getProcessorInfo().getName(), property.name));
 }
 
 inline uint64_t parseU64Property(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file = nullptr) {
-  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseIntegral<uint64_t>) | orThrow(fmt::format("Expected 
parsable uint64_t from \"{}::{}\"", ctx.getProcessor().getName(), 
property.name));
+  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseIntegral<uint64_t>) | orThrow(fmt::format("Expected 
parsable uint64_t from \"{}::{}\"", ctx.getProcessorInfo().getName(), 
property.name));
 }
 
 inline int64_t parseI64Property(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file = nullptr) {
-  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseIntegral<int64_t>) | orThrow(fmt::format("Expected 
parsable int64_t from \"{}::{}\"", ctx.getProcessor().getName(), 
property.name));
+  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseIntegral<int64_t>) | orThrow(fmt::format("Expected 
parsable int64_t from \"{}::{}\"", ctx.getProcessorInfo().getName(), 
property.name));
 }
 
 inline std::chrono::milliseconds parseDurationProperty(const 
core::ProcessContext& ctx, const core::PropertyReference& property, const 
core::FlowFile* flow_file = nullptr) {
-  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseDuration<std::chrono::milliseconds>) | 
orThrow(fmt::format("Expected parsable duration from \"{}::{}\"", 
ctx.getProcessor().getName(), property.name));
+  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseDuration<std::chrono::milliseconds>) | 
orThrow(fmt::format("Expected parsable duration from \"{}::{}\"", 
ctx.getProcessorInfo().getName(), property.name));
 }
 
 inline uint64_t parseDataSizeProperty(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file = nullptr) {
-  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseDataSize) | orThrow(fmt::format("Expected parsable data 
size from \"{}::{}\"", ctx.getProcessor().getName(), property.name));
+  return ctx.getProperty(property.name, flow_file) | 
andThen(parsing::parseDataSize) | orThrow(fmt::format("Expected parsable data 
size from \"{}::{}\"", ctx.getProcessorInfo().getName(), property.name));
 }
 
 inline std::optional<std::string> parseOptionalProperty(const 
core::ProcessContext& ctx, const core::PropertyReference& property, const 
core::FlowFile* flow_file = nullptr) {
@@ -61,7 +61,7 @@ inline std::optional<std::string> parseOptionalProperty(const 
core::ProcessConte
 
 inline std::optional<bool> parseOptionalBoolProperty(const 
core::ProcessContext& ctx, const core::PropertyReference& property, const 
core::FlowFile* flow_file = nullptr) {
   if (const auto property_str = ctx.getProperty(property.name, flow_file)) {
-    return parsing::parseBool(*property_str) | 
utils::orThrow(fmt::format("Expected parsable bool from \"{}::{}\"", 
ctx.getProcessor().getName(), property.name));
+    return parsing::parseBool(*property_str) | 
utils::orThrow(fmt::format("Expected parsable bool from \"{}::{}\"", 
ctx.getProcessorInfo().getName(), property.name));
   }
   return std::nullopt;
 }
@@ -71,7 +71,7 @@ inline std::optional<uint64_t> parseOptionalU64Property(const 
core::ProcessConte
     if (property_str->empty()) {
       return std::nullopt;
     }
-    return parsing::parseIntegral<uint64_t>(*property_str) | 
utils::orThrow(fmt::format("Expected parsable uint64_t from \"{}::{}\"", 
ctx.getProcessor().getName(), property.name));
+    return parsing::parseIntegral<uint64_t>(*property_str) | 
utils::orThrow(fmt::format("Expected parsable uint64_t from \"{}::{}\"", 
ctx.getProcessorInfo().getName(), property.name));
   }
 
   return std::nullopt;
@@ -82,7 +82,7 @@ inline std::optional<int64_t> parseOptionalI64Property(const 
core::ProcessContex
     if (property_str->empty()) {
       return std::nullopt;
     }
-    return parsing::parseIntegral<int64_t>(*property_str) | 
utils::orThrow(fmt::format("Expected parsable int64_t from \"{}::{}\"", 
ctx.getProcessor().getName(), property.name));
+    return parsing::parseIntegral<int64_t>(*property_str) | 
utils::orThrow(fmt::format("Expected parsable int64_t from \"{}::{}\"", 
ctx.getProcessorInfo().getName(), property.name));
   }
 
   return std::nullopt;
@@ -93,7 +93,7 @@ inline std::optional<std::chrono::milliseconds> 
parseOptionalDurationProperty(co
     if (property_str->empty()) {
       return std::nullopt;
     }
-    return parsing::parseDuration(*property_str) | 
utils::orThrow(fmt::format("Expected parsable duration from \"{}::{}\"", 
ctx.getProcessor().getName(), property.name));
+    return parsing::parseDuration(*property_str) | 
utils::orThrow(fmt::format("Expected parsable duration from \"{}::{}\"", 
ctx.getProcessorInfo().getName(), property.name));
   }
 
   return std::nullopt;
@@ -104,7 +104,7 @@ inline std::optional<uint64_t> 
parseOptionalDataSizeProperty(const core::Process
     if (property_str->empty()) {
       return std::nullopt;
     }
-    return parsing::parseDataSize(*property_str) | 
utils::orThrow(fmt::format("Expected parsable data size from \"{}::{}\"", 
ctx.getProcessor().getName(), property.name));
+    return parsing::parseDataSize(*property_str) | 
utils::orThrow(fmt::format("Expected parsable data size from \"{}::{}\"", 
ctx.getProcessorInfo().getName(), property.name));
   }
 
   return std::nullopt;
@@ -115,7 +115,7 @@ inline std::optional<float> 
parseOptionalFloatProperty(const core::ProcessContex
     if (property_str->empty()) {
       return std::nullopt;
     }
-    return parsing::parseFloat(*property_str) | 
utils::orThrow(fmt::format("Expected parsable float from {}::{}", 
ctx.getProcessor().getName(), property.name));
+    return parsing::parseFloat(*property_str) | 
utils::orThrow(fmt::format("Expected parsable float from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
   }
   return std::nullopt;
 }
diff --git a/extension-utils/src/utils/ProcessorConfigUtils.cpp 
b/extension-utils/src/utils/ProcessorConfigUtils.cpp
deleted file mode 100644
index 2ba8c73cb..000000000
--- a/extension-utils/src/utils/ProcessorConfigUtils.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "utils/ProcessorConfigUtils.h"
-
-#include <string>
-
-#include "utils/expected.h"
-
-namespace org::apache::nifi::minifi::utils {
-
-std::string parseProperty(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file) {
-  return ctx.getProperty(property, flow_file) | 
utils::expect(fmt::format("Expected valid value from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-}
-
-std::optional<std::string> parseOptionalProperty(const core::ProcessContext& 
ctx, const core::PropertyReference& property, const core::FlowFile* flow_file) {
-  if (const auto property_str = ctx.getProperty(property, flow_file)) {
-    return *property_str;
-  }
-  return std::nullopt;
-}
-
-std::optional<bool> parseOptionalBoolProperty(const core::ProcessContext& ctx, 
const core::PropertyReference& property, const core::FlowFile* flow_file) {
-  if (const auto property_str = ctx.getProperty(property, flow_file)) {
-    return parsing::parseBool(*property_str) | 
utils::expect(fmt::format("Expected parsable bool from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-  }
-  return std::nullopt;
-}
-
-bool parseBoolProperty(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file) {
-  return ctx.getProperty(property, flow_file) | 
utils::andThen(parsing::parseBool) | utils::expect(fmt::format("Expected 
parsable bool from {}::{}", ctx.getProcessorInfo().getName(), property.name));
-}
-
-std::optional<uint64_t> parseOptionalU64Property(const core::ProcessContext& 
ctx, const core::PropertyReference& property, const core::FlowFile* flow_file) {
-  if (const auto property_str = ctx.getProperty(property, flow_file)) {
-    if (property_str->empty()) {
-        return std::nullopt;
-    }
-    return parsing::parseIntegral<uint64_t>(*property_str) | 
utils::expect(fmt::format("Expected parsable uint64_t from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-  }
-
-  return std::nullopt;
-}
-
-uint64_t parseU64Property(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file) {
-  return ctx.getProperty(property, flow_file) | 
utils::andThen(parsing::parseIntegral<uint64_t>) | 
utils::expect(fmt::format("Expected parsable uint64_t from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-}
-
-std::optional<int64_t> parseOptionalI64Property(const core::ProcessContext& 
ctx, const core::PropertyReference& property, const core::FlowFile* flow_file) {
-  if (const auto property_str = ctx.getProperty(property, flow_file)) {
-    if (property_str->empty()) {
-      return std::nullopt;
-    }
-    return parsing::parseIntegral<int64_t>(*property_str) | 
utils::expect(fmt::format("Expected parsable int64_t from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-  }
-
-  return std::nullopt;
-}
-
-int64_t parseI64Property(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file) {
-  return ctx.getProperty(property, flow_file) | 
utils::andThen(parsing::parseIntegral<int64_t>) | 
utils::expect(fmt::format("Expected parsable int64_t from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-}
-
-std::optional<std::chrono::milliseconds> parseOptionalMsProperty(const 
core::ProcessContext& ctx, const core::PropertyReference& property, const 
core::FlowFile* flow_file) {
-  if (const auto property_str = ctx.getProperty(property, flow_file)) {
-    if (property_str->empty()) {
-      return std::nullopt;
-    }
-    return parsing::parseDuration(*property_str) | 
utils::expect(fmt::format("Expected parsable duration from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-  }
-
-  return std::nullopt;
-}
-
-std::chrono::milliseconds parseMsProperty(const core::ProcessContext& ctx, 
const core::PropertyReference& property, const core::FlowFile* flow_file) {
-  return ctx.getProperty(property, flow_file) | 
utils::andThen(parsing::parseDuration<std::chrono::milliseconds>) | 
utils::expect(fmt::format("Expected parsable duration from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-}
-
-std::optional<uint64_t> parseOptionalDataSizeProperty(const 
core::ProcessContext& ctx, const core::PropertyReference& property, const 
core::FlowFile* flow_file) {
-  if (const auto property_str = ctx.getProperty(property, flow_file)) {
-    if (property_str->empty()) {
-      return std::nullopt;
-    }
-    return parsing::parseDataSize(*property_str) | 
utils::expect(fmt::format("Expected parsable data size from {}::{}", 
ctx.getProcessorInfo().getName(), property.name));
-  }
-
-  return std::nullopt;
-}
-
-uint64_t parseDataSizeProperty(const core::ProcessContext& ctx, const 
core::PropertyReference& property, const core::FlowFile* flow_file) {
-  return ctx.getProperty(property, flow_file) | 
utils::andThen(parsing::parseDataSize) | utils::expect(fmt::format("Expected 
parsable data size from {}::{}", ctx.getProcessorInfo().getName(), 
property.name));
-}
-
-
-}  // namespace org::apache::nifi::minifi::utils
diff --git a/extensions/expression-language/ProcessContextExpr.cpp 
b/extensions/expression-language/ProcessContextExpr.cpp
index 04deec7f6..fb917045e 100644
--- a/extensions/expression-language/ProcessContextExpr.cpp
+++ b/extensions/expression-language/ProcessContextExpr.cpp
@@ -26,12 +26,12 @@
 namespace org::apache::nifi::minifi::core {
 
 nonstd::expected<std::string, std::error_code> 
ProcessContextExpr::getProperty(const std::string_view name, const FlowFile* 
flow_file) const {
-  const auto property = getProcessorInfo().getPropertyReference(name);
+  const auto property = getProcessorInfo().getSupportedProperty(name);
   if (!property) {
     return nonstd::make_unexpected(PropertyErrorCode::NotSupportedProperty);
   }
 
-  if (!property->supports_expression_language) {
+  if (!property->supportsExpressionLanguage()) {
     return ProcessContextImpl::getProperty(name, flow_file);
   }
   if (!cached_expressions_.contains(name)) {
@@ -41,7 +41,7 @@ nonstd::expected<std::string, std::error_code> 
ProcessContextExpr::getProperty(c
   }
   expression::Parameters p(this, flow_file);
   auto result = cached_expressions_[std::string{name}](p).asString();
-  if (!property->validator->validate(result)) {
+  if (!property->getValidator().validate(result)) {
     return nonstd::make_unexpected(PropertyErrorCode::ValidationFailed);
   }
   return result;
diff --git a/extensions/standard-processors/tests/unit/FlowJsonTests.cpp 
b/extensions/standard-processors/tests/unit/FlowJsonTests.cpp
index c36dc6664..05cccb361 100644
--- a/extensions/standard-processors/tests/unit/FlowJsonTests.cpp
+++ b/extensions/standard-processors/tests/unit/FlowJsonTests.cpp
@@ -1532,7 +1532,7 @@ TEST_CASE("Parameter providers can be used for parameter 
values") {
   std::unique_ptr<core::ProcessGroup> flow = 
config.getRootFromPayload(CONFIG_JSON);
   REQUIRE(flow);
 
-  auto* proc = 
dynamic_cast<core::ProcessorImpl*>(flow->findProcessorByName("MyProcessor"));
+  auto* proc = flow->findProcessorByName("MyProcessor");
   REQUIRE(proc);
   auto values = proc->getAllDynamicPropertyValues("My Dynamic Property 
Sequence");
   CHECK((*values)[0] == "value2");
diff --git 
a/extensions/standard-processors/tests/unit/YamlConfigurationTests.cpp 
b/extensions/standard-processors/tests/unit/YamlConfigurationTests.cpp
index 21137ad17..53c6118c3 100644
--- a/extensions/standard-processors/tests/unit/YamlConfigurationTests.cpp
+++ b/extensions/standard-processors/tests/unit/YamlConfigurationTests.cpp
@@ -2150,7 +2150,7 @@ Parameter Context Name: dummycontext
   std::unique_ptr<core::ProcessGroup> flow = 
yaml_config.getRootFromPayload(TEST_CONFIG_YAML);
   REQUIRE(flow);
 
-  auto* proc = 
dynamic_cast<core::ProcessorImpl*>(flow->findProcessorByName("DummyProcessor"));
+  auto* proc = flow->findProcessorByName("DummyProcessor");
   REQUIRE(proc);
   auto values = proc->getAllDynamicPropertyValues("My Dynamic Property 
Sequence");
   CHECK((*values)[0] == "value2");
diff --git a/libminifi/src/core/ProcessContext.cpp 
b/libminifi/src/core/ProcessContext.cpp
index 39e993108..dd9d55099 100644
--- a/libminifi/src/core/ProcessContext.cpp
+++ b/libminifi/src/core/ProcessContext.cpp
@@ -29,8 +29,8 @@ class StandardProcessorInfo : public ProcessorInfo {
   std::string getName() const override {return proc_.getName();}
   utils::Identifier getUUID() const override {return proc_.getUUID();}
   std::shared_ptr<state::FlowIdentifier> getFlowIdentifier() const override 
{return proc_.getFlowIdentifier();}
-  std::map<std::string, core::Property> getSupportedProperties() const 
override {return proc_.getSupportedProperties();}
-  nonstd::expected<PropertyReference, std::error_code> 
getPropertyReference(std::string_view name) const override {return 
proc_.getPropertyReference(name);}
+  std::map<std::string, core::Property, std::less<>> getSupportedProperties() 
const override {return proc_.getSupportedProperties();}
+  nonstd::expected<Property, std::error_code> 
getSupportedProperty(std::string_view name) const override {return 
proc_.getSupportedProperty(name);}
 
  private:
   Processor& proc_;
diff --git a/libminifi/test/libtest/unit/MockClasses.h 
b/libminifi/test/libtest/unit/MockClasses.h
index 77c63e5ba..bb55e7a30 100644
--- a/libminifi/test/libtest/unit/MockClasses.h
+++ b/libminifi/test/libtest/unit/MockClasses.h
@@ -125,7 +125,7 @@ class MockProcessor : public minifi::core::ProcessorImpl {
       // and verify that we can execute it.
     }
 
-    bool in_sub_process_group = context.getProperty("InSubProcessGroup") | 
minifi::utils::andThen(minifi::parsing::parseBool) | minifi::utils::expect("");
+    bool in_sub_process_group = context.getProperty("InSubProcessGroup") | 
minifi::utils::andThen(minifi::parsing::parseBool) | minifi::utils::orThrow("");
     auto sub_service = context.getControllerService("SubMockController", 
getUUID());
     if (in_sub_process_group) {
       REQUIRE(nullptr != sub_service);
diff --git a/minifi-api/include/minifi-cpp/core/ProcessContext.h 
b/minifi-api/include/minifi-cpp/core/ProcessContext.h
index 629d06c28..f4f963e1d 100644
--- a/minifi-api/include/minifi-cpp/core/ProcessContext.h
+++ b/minifi-api/include/minifi-cpp/core/ProcessContext.h
@@ -42,8 +42,8 @@ class ProcessorInfo {
   virtual std::string getName() const = 0;
   virtual utils::Identifier getUUID() const = 0;
   virtual std::shared_ptr<state::FlowIdentifier> getFlowIdentifier() const = 0;
-  virtual std::map<std::string, core::Property> getSupportedProperties() const 
= 0;
-  virtual nonstd::expected<PropertyReference, std::error_code> 
getPropertyReference(std::string_view name) const = 0;
+  virtual std::map<std::string, core::Property, std::less<>> 
getSupportedProperties() const = 0;
+  virtual nonstd::expected<Property, std::error_code> 
getSupportedProperty(std::string_view name) const = 0;
 
   virtual ~ProcessorInfo() = default;
 };

Reply via email to