[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-12-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719485#comment-16719485
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

Github user phrocker commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241199779
  
--- Diff: libminifi/include/core/state/Value.h ---
@@ -74,94 +157,215 @@ class BoolValue : public Value {
   explicit BoolValue(bool value)
   : Value(value ? "true" : "false"),
 value(value) {
+setTypeId();
+  }
 
+  explicit BoolValue(const std::string )
+  : Value(strvalue) {
+bool l;
+std::istringstream(strvalue) >> std::boolalpha >> l;
+value = l;  // avoid warnings
   }
-  bool getValue() {
+
+  bool getValue() const {
 return value;
   }
  protected:
+
+  virtual bool getValue(int ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(int64_t ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(uint64_t ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(bool ) {
+ref = value;
+return true;
+  }
+
   bool value;
 };
 
-class Int64Value : public Value {
+class UInt64Value : public Value {
  public:
-  explicit Int64Value(uint64_t value)
+  explicit UInt64Value(uint64_t value)
   : Value(std::to_string(value)),
 value(value) {
+setTypeId();
+  }
 
+  explicit UInt64Value(const std::string )
+  : Value(strvalue),
+value(std::stoull(strvalue)) {
+setTypeId();
   }
-  uint64_t getValue() {
+
+  uint64_t getValue() const {
 return value;
   }
  protected:
+
+  virtual bool getValue(int ) {
+return false;
+  }
+
+  virtual bool getValue(int64_t ) {
+if (value < std::numeric_limits::max()) {
+  ref = value;
+  return true;
+}
+return false;
+  }
+
+  virtual bool getValue(uint64_t ) {
+ref = value;
+return true;
+  }
+
+  virtual bool getValue(bool ) {
+return false;
+  }
+
   uint64_t value;
 };
 
+class Int64Value : public Value {
+ public:
+  explicit Int64Value(int64_t value)
+  : Value(std::to_string(value)),
+value(value) {
+setTypeId();
+  }
+  explicit Int64Value(const std::string )
+  : Value(strvalue),
+value(std::stoll(strvalue)) {
+setTypeId();
+  }
+
+  int64_t getValue() {
+return value;
+  }
+ protected:
+
+  virtual bool getValue(int ) {
+return false;
+  }
+
+  virtual bool getValue(int64_t ) {
+ref = value;
+return true;
+  }
+
+  virtual bool getValue(uint64_t ) {
+if (value >= 0) {
+  ref = value;
+  return true;
+}
+return true;
+  }
+
+  virtual bool getValue(bool ) {
+return false;
+  }
 
-static inline std::shared_ptr createValue(
-const bool ) {
+  int64_t value;
+};
+
+static inline std::shared_ptr createValue(const bool ) {
   return std::make_shared(object);
 }
 
-static inline std::shared_ptr createValue(
-const char *object) {
+static inline std::shared_ptr createValue(const char *object) {
   return std::make_shared(object);
 }
 
-static inline std::shared_ptr createValue(
-char *object) {
+static inline std::shared_ptr createValue(char *object) {
   return std::make_shared(std::string(object));
 }
 
-static inline std::shared_ptr createValue(
-const std::string ) {
+static inline std::shared_ptr createValue(const std::string 
) {
   return std::make_shared(object);
 }
 
-
-static inline std::shared_ptr createValue(
-const uint32_t ) {
-  return std::make_shared(object);
+static inline std::shared_ptr createValue(const uint32_t ) {
+  return std::make_shared(object);
+}
+#if ( defined(__APPLE__) || defined(__MACH__) || defined(DARWIN) )
+static inline std::shared_ptr createValue(const size_t ) {
+  return 

[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-12-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719469#comment-16719469
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

Github user phrocker commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241193264
  
--- Diff: libminifi/include/core/PropertyValidation.h ---
@@ -0,0 +1,347 @@
+/**
+ *
+ * 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.
+ */
+#ifndef LIBMINIFI_INCLUDE_CORE_PROPERTYVALIDATION_H_
+#define LIBMINIFI_INCLUDE_CORE_PROPERTYVALIDATION_H_
+
+#include "core/Core.h"
+#include "core/state/Value.h"
+#include "TypedValues.h"
+#include "utils/StringUtils.h"
+#include 
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+
+class ValidationResult;
+
+class ValidationResult {
+ public:
+  bool valid() const {
+return valid_;
+  }
+
+  class Builder {
+   public:
+static Builder createBuilder() {
+  return Builder();
+}
+Builder (bool valid) {
+  valid_ = valid;
+  return *this;
+}
+Builder (const std::string ) {
+  subject_ = subject;
+  return *this;
+}
+Builder (const std::string ) {
+  input_ = input;
+  return *this;
+}
+
+ValidationResult build() {
+  return ValidationResult(*this);
+}
+
+   protected:
+bool valid_;
+std::string subject_;
+std::string input_;
+friend class ValidationResult;
+  };
+ private:
+
+  bool valid_;
+  std::string subject_;
+  std::string input_;
+
+  ValidationResult(const Builder )
+  : valid_(builder.valid_),
+subject_(builder.subject_),
+input_(builder.input_) {
+  }
+
+  friend class Builder;
+};
+
+class PropertyValidator {
+ public:
+
+  PropertyValidator(const std::string )
+  : name_(name) {
+  }
+  virtual ~PropertyValidator() {
+
+  }
+
+  std::string getName() const {
+return name_;
+  }
+
+  virtual ValidationResult validate(const std::string , const 
std::shared_ptr ) const = 0;
+
+  virtual ValidationResult validate(const std::string , const 
std::string ) const = 0;
+
+ protected:
+  template
+  ValidationResult _validate_internal(const std::string , const 
std::shared_ptr ) const {
+if (std::dynamic_pointer_cast(input) != nullptr) {
+  return 
ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input->getStringValue()).isValid(true).build();
+} else {
+  state::response::ValueNode vn;
+  vn = input->getStringValue();
+  return validate(subject, input->getStringValue());
+}
+
+  }
+
+  std::string name_;
+};
+
+class AlwaysValid : public PropertyValidator {
+  bool always_valid_;
+ public:
+  AlwaysValid(bool isalwaysvalid, const std::string )
+  : always_valid_(isalwaysvalid),
+PropertyValidator(name) {
+
+  }
+  virtual ~AlwaysValid() {
+  }
+  ValidationResult validate(const std::string , const 
std::shared_ptr ) const {
+return 
ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input->getStringValue()).isValid(always_valid_).build();
+  }
+
+  ValidationResult validate(const std::string , const std::string 
) const {
+return 
ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input).isValid(always_valid_).build();
+  }
+
+};
+
+class BooleanValidator : public PropertyValidator {
+ public:
+  BooleanValidator(const std::string )
+  : PropertyValidator(name) {
+  }
+  virtual ~BooleanValidator() {
+
+  }
+
+  ValidationResult validate(const std::string , const 

[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-12-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719467#comment-16719467
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

Github user phrocker commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241192961
  
--- Diff: libminifi/include/core/state/Value.h ---
@@ -74,94 +157,215 @@ class BoolValue : public Value {
   explicit BoolValue(bool value)
   : Value(value ? "true" : "false"),
 value(value) {
+setTypeId();
+  }
 
+  explicit BoolValue(const std::string )
+  : Value(strvalue) {
+bool l;
+std::istringstream(strvalue) >> std::boolalpha >> l;
+value = l;  // avoid warnings
   }
-  bool getValue() {
+
+  bool getValue() const {
 return value;
   }
  protected:
+
+  virtual bool getValue(int ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(int64_t ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(uint64_t ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(bool ) {
+ref = value;
+return true;
+  }
+
   bool value;
 };
 
-class Int64Value : public Value {
+class UInt64Value : public Value {
  public:
-  explicit Int64Value(uint64_t value)
+  explicit UInt64Value(uint64_t value)
   : Value(std::to_string(value)),
 value(value) {
+setTypeId();
+  }
 
+  explicit UInt64Value(const std::string )
+  : Value(strvalue),
+value(std::stoull(strvalue)) {
+setTypeId();
   }
-  uint64_t getValue() {
+
+  uint64_t getValue() const {
 return value;
   }
  protected:
+
+  virtual bool getValue(int ) {
+return false;
+  }
+
+  virtual bool getValue(int64_t ) {
+if (value < std::numeric_limits::max()) {
+  ref = value;
+  return true;
+}
+return false;
+  }
+
+  virtual bool getValue(uint64_t ) {
+ref = value;
+return true;
+  }
+
+  virtual bool getValue(bool ) {
+return false;
+  }
+
   uint64_t value;
 };
 
+class Int64Value : public Value {
+ public:
+  explicit Int64Value(int64_t value)
+  : Value(std::to_string(value)),
+value(value) {
+setTypeId();
+  }
+  explicit Int64Value(const std::string )
+  : Value(strvalue),
+value(std::stoll(strvalue)) {
+setTypeId();
+  }
+
+  int64_t getValue() {
+return value;
+  }
+ protected:
+
+  virtual bool getValue(int ) {
+return false;
+  }
+
+  virtual bool getValue(int64_t ) {
+ref = value;
+return true;
+  }
+
+  virtual bool getValue(uint64_t ) {
+if (value >= 0) {
+  ref = value;
+  return true;
+}
+return true;
+  }
+
+  virtual bool getValue(bool ) {
+return false;
+  }
 
-static inline std::shared_ptr createValue(
-const bool ) {
+  int64_t value;
--- End diff --

I think that's probably a differing opinion of style. I don't like using 
"using" directives and don't think the duplication is enough to warrant its 
usage. I have and do use "using" but very sparingly. 


> Incorporate property validation information into manifest
> -
>
> Key: MINIFICPP-479
> URL: https://issues.apache.org/jira/browse/MINIFICPP-479
> Project: NiFi MiNiFi C++
>  Issue Type: Improvement
>Reporter: Andrew Christianson
>Assignee: Mr TheSegfault
>Priority: Major
>
> High-level intent is to avoid round-trip to c2 to know that flow is valid 
> (or, invalid in common/trivial ways).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-12-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719106#comment-16719106
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

Github user arpadboda commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241048908
  
--- Diff: libminifi/include/core/state/Value.h ---
@@ -74,94 +157,215 @@ class BoolValue : public Value {
   explicit BoolValue(bool value)
   : Value(value ? "true" : "false"),
 value(value) {
+setTypeId();
+  }
 
+  explicit BoolValue(const std::string )
+  : Value(strvalue) {
+bool l;
+std::istringstream(strvalue) >> std::boolalpha >> l;
+value = l;  // avoid warnings
   }
-  bool getValue() {
+
+  bool getValue() const {
 return value;
   }
  protected:
+
+  virtual bool getValue(int ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(int64_t ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(uint64_t ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(bool ) {
+ref = value;
+return true;
+  }
+
   bool value;
 };
 
-class Int64Value : public Value {
+class UInt64Value : public Value {
  public:
-  explicit Int64Value(uint64_t value)
+  explicit UInt64Value(uint64_t value)
   : Value(std::to_string(value)),
 value(value) {
+setTypeId();
+  }
 
+  explicit UInt64Value(const std::string )
+  : Value(strvalue),
+value(std::stoull(strvalue)) {
+setTypeId();
   }
-  uint64_t getValue() {
+
+  uint64_t getValue() const {
 return value;
   }
  protected:
+
+  virtual bool getValue(int ) {
+return false;
+  }
+
+  virtual bool getValue(int64_t ) {
+if (value < std::numeric_limits::max()) {
+  ref = value;
+  return true;
+}
+return false;
+  }
+
+  virtual bool getValue(uint64_t ) {
+ref = value;
+return true;
+  }
+
+  virtual bool getValue(bool ) {
+return false;
+  }
+
   uint64_t value;
 };
 
+class Int64Value : public Value {
+ public:
+  explicit Int64Value(int64_t value)
+  : Value(std::to_string(value)),
+value(value) {
+setTypeId();
+  }
+  explicit Int64Value(const std::string )
+  : Value(strvalue),
+value(std::stoll(strvalue)) {
+setTypeId();
+  }
+
+  int64_t getValue() {
+return value;
+  }
+ protected:
+
+  virtual bool getValue(int ) {
+return false;
+  }
+
+  virtual bool getValue(int64_t ) {
+ref = value;
+return true;
+  }
+
+  virtual bool getValue(uint64_t ) {
+if (value >= 0) {
+  ref = value;
+  return true;
+}
+return true;
+  }
+
+  virtual bool getValue(bool ) {
+return false;
+  }
 
-static inline std::shared_ptr createValue(
-const bool ) {
+  int64_t value;
--- End diff --

Honestly I don't really like to hanem a member with different type but same 
name in each derived type. 
Why don't simply create value as a template class and use "using" directive 
to create Int64Value as value ? 
In my opinion it would require less code duplication. 


> Incorporate property validation information into manifest
> -
>
> Key: MINIFICPP-479
> URL: https://issues.apache.org/jira/browse/MINIFICPP-479
> Project: NiFi MiNiFi C++
>  Issue Type: Improvement
>Reporter: Andrew Christianson
>Assignee: Mr TheSegfault
>Priority: Major
>
> High-level intent is to avoid round-trip to c2 to know that flow is valid 
> (or, invalid in common/trivial ways).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-12-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719107#comment-16719107
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

Github user arpadboda commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241051202
  
--- Diff: libminifi/src/processors/LogAttribute.cpp ---
@@ -38,13 +38,23 @@ namespace apache {
 namespace nifi {
 namespace minifi {
 namespace processors {
-core::Property LogAttribute::LogLevel("Log Level", "The Log Level to use 
when logging the Attributes", "info");
-core::Property LogAttribute::AttributesToLog("Attributes to Log", "A 
comma-separated list of Attributes to Log. If not specified, all attributes 
will be logged.", "");
-core::Property LogAttribute::AttributesToIgnore("Attributes to Ignore", "A 
comma-separated list of Attributes to ignore. If not specified, no attributes 
will be ignored.", "");
-core::Property LogAttribute::LogPayload("Log Payload", "If true, the 
FlowFile's payload will be logged, in addition to its attributes;"
-"otherwise, just the Attributes 
will be logged.",
-"false");
-core::Property LogAttribute::LogPrefix("Log prefix", "Log prefix appended 
to the log lines. It helps to distinguish the output of multiple LogAttribute 
processors.", "");
+
+core::Property LogAttribute::LogLevel(
+core::PropertyBuilder::createProperty("Log 
Level")->withDescription("The Log Level to use when logging the 
Attributes")->withAllowedValue("info")->withAllowedValue("trace")
+
->withAllowedValue("error")->withAllowedValue("warn")->withAllowedValue("debug")->withDefaultValue("info")->build());
--- End diff --

I don't like this, withAllowedValue should be implemented as 
```
template
withAllowedValue(std::set) {
  ...
}
```

This way it can be done as:
```
withAllowedValue({"Red", "Green", "Blue"))
```


> Incorporate property validation information into manifest
> -
>
> Key: MINIFICPP-479
> URL: https://issues.apache.org/jira/browse/MINIFICPP-479
> Project: NiFi MiNiFi C++
>  Issue Type: Improvement
>Reporter: Andrew Christianson
>Assignee: Mr TheSegfault
>Priority: Major
>
> High-level intent is to avoid round-trip to c2 to know that flow is valid 
> (or, invalid in common/trivial ways).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-12-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719105#comment-16719105
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

Github user arpadboda commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241052650
  
--- Diff: libminifi/include/core/PropertyValidation.h ---
@@ -0,0 +1,347 @@
+/**
+ *
+ * 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.
+ */
+#ifndef LIBMINIFI_INCLUDE_CORE_PROPERTYVALIDATION_H_
+#define LIBMINIFI_INCLUDE_CORE_PROPERTYVALIDATION_H_
+
+#include "core/Core.h"
+#include "core/state/Value.h"
+#include "TypedValues.h"
+#include "utils/StringUtils.h"
+#include 
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace core {
+
+class ValidationResult;
+
+class ValidationResult {
+ public:
+  bool valid() const {
+return valid_;
+  }
+
+  class Builder {
+   public:
+static Builder createBuilder() {
+  return Builder();
+}
+Builder (bool valid) {
+  valid_ = valid;
+  return *this;
+}
+Builder (const std::string ) {
+  subject_ = subject;
+  return *this;
+}
+Builder (const std::string ) {
+  input_ = input;
+  return *this;
+}
+
+ValidationResult build() {
+  return ValidationResult(*this);
+}
+
+   protected:
+bool valid_;
+std::string subject_;
+std::string input_;
+friend class ValidationResult;
+  };
+ private:
+
+  bool valid_;
+  std::string subject_;
+  std::string input_;
+
+  ValidationResult(const Builder )
+  : valid_(builder.valid_),
+subject_(builder.subject_),
+input_(builder.input_) {
+  }
+
+  friend class Builder;
+};
+
+class PropertyValidator {
+ public:
+
+  PropertyValidator(const std::string )
+  : name_(name) {
+  }
+  virtual ~PropertyValidator() {
+
+  }
+
+  std::string getName() const {
+return name_;
+  }
+
+  virtual ValidationResult validate(const std::string , const 
std::shared_ptr ) const = 0;
+
+  virtual ValidationResult validate(const std::string , const 
std::string ) const = 0;
+
+ protected:
+  template
+  ValidationResult _validate_internal(const std::string , const 
std::shared_ptr ) const {
+if (std::dynamic_pointer_cast(input) != nullptr) {
+  return 
ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input->getStringValue()).isValid(true).build();
+} else {
+  state::response::ValueNode vn;
+  vn = input->getStringValue();
+  return validate(subject, input->getStringValue());
+}
+
+  }
+
+  std::string name_;
+};
+
+class AlwaysValid : public PropertyValidator {
+  bool always_valid_;
+ public:
+  AlwaysValid(bool isalwaysvalid, const std::string )
+  : always_valid_(isalwaysvalid),
+PropertyValidator(name) {
+
+  }
+  virtual ~AlwaysValid() {
+  }
+  ValidationResult validate(const std::string , const 
std::shared_ptr ) const {
+return 
ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input->getStringValue()).isValid(always_valid_).build();
+  }
+
+  ValidationResult validate(const std::string , const std::string 
) const {
+return 
ValidationResult::Builder::createBuilder().withSubject(subject).withInput(input).isValid(always_valid_).build();
+  }
+
+};
+
+class BooleanValidator : public PropertyValidator {
+ public:
+  BooleanValidator(const std::string )
+  : PropertyValidator(name) {
+  }
+  virtual ~BooleanValidator() {
+
+  }
+
+  ValidationResult validate(const std::string , const 

[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-12-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16719104#comment-16719104
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

Github user arpadboda commented on a diff in the pull request:

https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241048231
  
--- Diff: libminifi/include/core/state/Value.h ---
@@ -74,94 +157,215 @@ class BoolValue : public Value {
   explicit BoolValue(bool value)
   : Value(value ? "true" : "false"),
 value(value) {
+setTypeId();
+  }
 
+  explicit BoolValue(const std::string )
+  : Value(strvalue) {
+bool l;
+std::istringstream(strvalue) >> std::boolalpha >> l;
+value = l;  // avoid warnings
   }
-  bool getValue() {
+
+  bool getValue() const {
 return value;
   }
  protected:
+
+  virtual bool getValue(int ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(int64_t ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(uint64_t ) {
+if (ref == 1) {
+  ref = true;
+  return true;
+} else if (ref == 0) {
+  ref = false;
+  return true;
+} else {
+  return false;
+}
+  }
+
+  virtual bool getValue(bool ) {
+ref = value;
+return true;
+  }
+
   bool value;
 };
 
-class Int64Value : public Value {
+class UInt64Value : public Value {
  public:
-  explicit Int64Value(uint64_t value)
+  explicit UInt64Value(uint64_t value)
   : Value(std::to_string(value)),
 value(value) {
+setTypeId();
+  }
 
+  explicit UInt64Value(const std::string )
+  : Value(strvalue),
+value(std::stoull(strvalue)) {
+setTypeId();
   }
-  uint64_t getValue() {
+
+  uint64_t getValue() const {
 return value;
   }
  protected:
+
+  virtual bool getValue(int ) {
+return false;
+  }
+
+  virtual bool getValue(int64_t ) {
+if (value < std::numeric_limits::max()) {
+  ref = value;
+  return true;
+}
+return false;
+  }
+
+  virtual bool getValue(uint64_t ) {
+ref = value;
+return true;
+  }
+
+  virtual bool getValue(bool ) {
+return false;
+  }
+
   uint64_t value;
 };
 
+class Int64Value : public Value {
+ public:
+  explicit Int64Value(int64_t value)
+  : Value(std::to_string(value)),
+value(value) {
+setTypeId();
+  }
+  explicit Int64Value(const std::string )
+  : Value(strvalue),
+value(std::stoll(strvalue)) {
+setTypeId();
+  }
+
+  int64_t getValue() {
+return value;
+  }
+ protected:
+
+  virtual bool getValue(int ) {
+return false;
+  }
+
+  virtual bool getValue(int64_t ) {
+ref = value;
+return true;
+  }
+
+  virtual bool getValue(uint64_t ) {
+if (value >= 0) {
+  ref = value;
+  return true;
+}
+return true;
+  }
+
+  virtual bool getValue(bool ) {
+return false;
+  }
 
-static inline std::shared_ptr createValue(
-const bool ) {
+  int64_t value;
+};
+
+static inline std::shared_ptr createValue(const bool ) {
   return std::make_shared(object);
 }
 
-static inline std::shared_ptr createValue(
-const char *object) {
+static inline std::shared_ptr createValue(const char *object) {
   return std::make_shared(object);
 }
 
-static inline std::shared_ptr createValue(
-char *object) {
+static inline std::shared_ptr createValue(char *object) {
   return std::make_shared(std::string(object));
 }
 
-static inline std::shared_ptr createValue(
-const std::string ) {
+static inline std::shared_ptr createValue(const std::string 
) {
   return std::make_shared(object);
 }
 
-
-static inline std::shared_ptr createValue(
-const uint32_t ) {
-  return std::make_shared(object);
+static inline std::shared_ptr createValue(const uint32_t ) {
+  return std::make_shared(object);
+}
+#if ( defined(__APPLE__) || defined(__MACH__) || defined(DARWIN) )
+static inline std::shared_ptr createValue(const size_t ) {
+  

[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-12-11 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16718326#comment-16718326
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

GitHub user phrocker opened a pull request:

https://github.com/apache/nifi-minifi-cpp/pull/460

MINIFICPP-479: Add processor property descriptor updates. WIP

Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
 in the commit message?

- [ ] Does your PR title start with MINIFICPP- where  is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.

- [ ] Has your PR been rebased against the latest commit within the target 
branch (typically master)?

- [ ] Is your initial contribution a single, squashed commit?

### For code changes:
- [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?

### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in 
which it is rendered?

### Note:
Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/phrocker/nifi-minifi-cpp MINIFICPP-479

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi-minifi-cpp/pull/460.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #460


commit 371ab8cf0cbcd25c4924696ffe1c7215da2c2977
Author: Marc Parisi 
Date:   2018-08-12T17:22:00Z

MINIFICPP-479 and others: commit initial stuff

get back on track

MINIFICPP-479: begin incorporating validators

MINIFICPP-479: Adding code found on laptop

Found more code in stashed repos

commit ce89c4dfc6839ef071a8488af61abbefd0038027
Author: Marc Parisi 
Date:   2018-08-19T16:00:00Z

MINIFICPP-479: inc commit .. does not work fully

commit 72df0111bb5c6ae03be38c0471578178e7945365
Author: Marc Parisi 
Date:   2018-12-11T01:03:34Z

MINIFICPP-479: Make updates to how values can be used

MINIFICPP-479: Add comments

commit 54fc1f36cea1f7bb30e208acf95487c29b0fe2af
Author: Marc Parisi 
Date:   2018-12-12T01:12:58Z

MINIFICPP-479: Update processors




> Incorporate property validation information into manifest
> -
>
> Key: MINIFICPP-479
> URL: https://issues.apache.org/jira/browse/MINIFICPP-479
> Project: NiFi MiNiFi C++
>  Issue Type: Improvement
>Reporter: Andrew Christianson
>Assignee: Mr TheSegfault
>Priority: Major
>
> High-level intent is to avoid round-trip to c2 to know that flow is valid 
> (or, invalid in common/trivial ways).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-11-29 Thread Mr TheSegfault (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16703214#comment-16703214
 ] 

Mr TheSegfault commented on MINIFICPP-479:
--

As I mentioned to [~aboda] there is work that can better inform the servers 
what validators to use. Since the servers follow an open standard, we should 
provide some guarantees regarding validators that follow those of NiFi . I've 
taken the ticket as I previously did some work on this in June and can work 
with Arpad to merge those ideas. 

> Incorporate property validation information into manifest
> -
>
> Key: MINIFICPP-479
> URL: https://issues.apache.org/jira/browse/MINIFICPP-479
> Project: NiFi MiNiFi C++
>  Issue Type: Improvement
>Reporter: Andrew Christianson
>Assignee: Mr TheSegfault
>Priority: Major
>
> High-level intent is to avoid round-trip to c2 to know that flow is valid 
> (or, invalid in common/trivial ways).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-11-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16703210#comment-16703210
 ] 

ASF GitHub Bot commented on MINIFICPP-479:
--

Github user phrocker commented on the issue:

https://github.com/apache/nifi-minifi-cpp/pull/453
  
Thanks for submitting this. I think there is definite overlap between work 
I previously had with MINIFICPP-479 
(https://github.com/apache/nifi-minifi-cpp/compare/master...phrocker:MINIFICPP-479?expand=1)
 I collected commits from across computers and squashed them, but has the side 
effect that it does validation at flow file load time ( something we've 
desperately needed) -- giving us a much earlier failure. a bit different 
implementation -- and it informs c2 of java validators to be used.

what is the motivation of this PR beyond that work that we discussed 
offline? I think the same "pros" exist for both works. That work has been 
around since June -- so it's probably stale in its ideas, so I'll take a look 
at this at some point. Thanks again. 


> Incorporate property validation information into manifest
> -
>
> Key: MINIFICPP-479
> URL: https://issues.apache.org/jira/browse/MINIFICPP-479
> Project: NiFi MiNiFi C++
>  Issue Type: Improvement
>Reporter: Andrew Christianson
>Assignee: Andrew Christianson
>Priority: Major
>
> High-level intent is to avoid round-trip to c2 to know that flow is valid 
> (or, invalid in common/trivial ways).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MINIFICPP-479) Incorporate property validation information into manifest

2018-05-02 Thread Andrew Christianson (JIRA)

[ 
https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16461417#comment-16461417
 ] 

Andrew Christianson commented on MINIFICPP-479:
---

[https://github.com/phrocker/nifi-minifi-cpp/blob/7ea8364b2ae25dcece91bcd0646e1023391ef4d3/libminifi/include/core/state/nodes/AgentInformation.h#L250]

is where property descriptors are currently placed into the agent manifest

produces, e.g. (needs validation info):
{code:java}
org::apache::nifi::minifi::processors::AbstractMQTTProcessor": {
"buildInfo": {
"compiler": "/usr/bin/c++",
"flags": "  -std=c++11 -Wall",
"revision": 
"9edd5fbeecc39ec980cd596e7db06d528d028471",
"timestamp": 1525277805,
"version": "0.5.0"
},
"propertyDescriptors": {
"Broker URI": {
"description": "The URI to use to connect 
to the MQTT broker",
"name": "Broker URI"
},
"Client ID": {
"description": "MQTT client ID to use",
"name": "Client ID"
},
"Connection Timeout": {
"description": "Maximum time interval the 
client will wait for the network connection to the MQTT server",
"name": "Connection Timeout"
},
"Keep Alive Interval": {
"description": "Defines the maximum time 
interval between messages sent or received",
"name": "Keep Alive Interval"
},
"Password": {
"description": "Password to use when 
connecting to the broker",
"name": "Password"
},
"Quality of Service": {
"description": "The Quality of Service(QoS) 
to send the message with. Accepts three values '0', '1' and '2'",
"name": "Quality of Service"
},
"Session state": {
"description": "Whether to start afresh or 
resume previous flows. See the allowable value descriptions for more details",
"name": "Session state"
},
"Topic": {
"description": "The topic to publish the 
message to",
"name": "Topic"
},
"Username": {
"description": "Username to use when 
connecting to the broker",
"name": "Username"
}
},
"artifact": 
"org::apache::nifi::minifi::processors::AbstractMQTTProcessor",
"group": "org::apache::nifi::minifi",
"supportsDynamicProperties": false,
"version": "0.5.0"
},

{code}

> Incorporate property validation information into manifest
> -
>
> Key: MINIFICPP-479
> URL: https://issues.apache.org/jira/browse/MINIFICPP-479
> Project: NiFi MiNiFi C++
>  Issue Type: Improvement
>Reporter: Andrew Christianson
>Assignee: Andrew Christianson
>Priority: Major
>
> High-level intent is to avoid round-trip to c2 to know that flow is valid 
> (or, invalid in common/trivial ways).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)