adamdebreceni commented on code in PR #1692:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1692#discussion_r1453365651


##########
extensions/standard-processors/processors/JoltTransformJSON.h:
##########
@@ -0,0 +1,91 @@
+/**
+ * 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.
+ */
+
+#pragma once
+
+#include <string>
+
+#include "core/Processor.h"
+#include "core/ProcessSession.h"
+#include "core/PropertyDefinition.h"
+#include "core/PropertyDefinitionBuilder.h"
+#include "utils/Enum.h"
+#include "utils/Searcher.h"
+#include "../utils/JoltUtils.h"
+
+namespace org::apache::nifi::minifi::processors::jolt_transform_json {
+enum class JoltTransform {
+  Shift
+};
+}  // namespace org::apache::nifi::minifi::processors::jolt_transform_json
+
+namespace org::apache::nifi::minifi::processors {
+
+class JoltTransformJSON : public core::Processor {
+ public:
+  explicit JoltTransformJSON(std::string_view name, const utils::Identifier& 
uuid = {})
+      : Processor(name, uuid) {}
+
+
+  EXTENSIONAPI static constexpr const char* Description = "Applies a list of 
Jolt specifications to the flowfile JSON payload. A new FlowFile is created "
+      "with transformed content and is routed to the 'success' relationship. 
If the JSON transform "
+      "fails, the original FlowFile is routed to the 'failure' relationship.";
+
+  EXTENSIONAPI static constexpr auto JoltTransform = 
core::PropertyDefinitionBuilder<magic_enum::enum_count<jolt_transform_json::JoltTransform>()>::createProperty("Jolt
 Transformation DSL")
+      .withDescription("Specifies the Jolt Transformation that should be used 
with the provided specification.")
+      
.withDefaultValue(magic_enum::enum_name(jolt_transform_json::JoltTransform::Shift))
+      
.withAllowedValues(magic_enum::enum_names<jolt_transform_json::JoltTransform>())
+      .isRequired(true)
+      .build();
+
+  EXTENSIONAPI static constexpr auto JoltSpecification = 
core::PropertyDefinitionBuilder<>::createProperty("Jolt Specification")
+      .withDescription("Jolt Specification for transformation of JSON data. 
The value for this property may be the text of a Jolt specification "
+          "or the path to a file containing a Jolt specification. 'Jolt 
Specification' must be set, or "
+          "the value is ignored if the Jolt Sort Transformation is selected.")
+      .supportsExpressionLanguage(true)

Review Comment:
   removed



##########
extensions/standard-processors/utils/JoltUtils.h:
##########
@@ -0,0 +1,205 @@
+/**
+ * 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.
+ */
+
+#pragma once
+
+#include <string>
+#include <string_view>
+#include <vector>
+#include <functional>
+#include <map>
+#include <unordered_map>
+#include <memory>
+#include <compare>
+
+#include "logging/Logger.h"
+#include "utils/gsl.h"
+#include "rapidjson/document.h"
+#include "utils/expected.h"
+#include "utils/StringUtils.h"
+
+namespace org::apache::nifi::minifi::utils::jolt {
+
+class Spec {
+ public:
+  using It = std::string_view::const_iterator;
+
+  struct Context {
+   public:
+    const Context* parent{nullptr};
+
+    std::string path() const {
+      std::string res;
+      if (parent) {
+        res = parent->path();
+      }
+      res.append("/").append(matches.at(0));
+      return res;
+    }
+
+    const Context* find(size_t idx) const {
+      if (idx == 0) return this;
+      if (parent) return parent->find(idx - 1);
+      return nullptr;
+    }
+
+    ::gsl::final_action<std::function<void()>> 
log(std::function<void(std::shared_ptr<core::logging::Logger>)> on_enter, 
std::function<void(std::shared_ptr<core::logging::Logger>)> on_exit) const {

Review Comment:
   changed it to template



-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to