| 1077 | } |
| 1078 | |
| 1079 | Expression make_allAttributes(const std::string &function_name, const std::vector<Expression> &args) { |
| 1080 | if (args.size() < 1) { |
| 1081 | std::stringstream message_ss; |
| 1082 | message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 1 << " are required"; |
| 1083 | throw std::runtime_error(message_ss.str()); |
| 1084 | } |
| 1085 | |
| 1086 | auto result = make_dynamic([=](const Parameters ¶ms, const std::vector<Expression> &sub_exprs) -> Value { |
| 1087 | std::vector<Value> evaluated_args; |
| 1088 | |
| 1089 | bool all_true = true; |
| 1090 | |
| 1091 | for (const auto &sub_expr : sub_exprs) { |
| 1092 | all_true = all_true && sub_expr(params).asBoolean(); |
| 1093 | } |
| 1094 | |
| 1095 | return Value(all_true); |
| 1096 | }); |
| 1097 | |
| 1098 | result.make_multi([=](const Parameters& /*params*/) -> std::vector<Expression> { |
| 1099 | std::vector<Expression> out_exprs; |
| 1100 | |
| 1101 | for (const auto &arg : args) { |
| 1102 | out_exprs.emplace_back(make_dynamic([=](const Parameters ¶ms, |
| 1103 | const std::vector<Expression>& /*sub_exprs*/) -> Value { |
| 1104 | std::string attr_id; |
| 1105 | attr_id = arg(params).asString(); |
| 1106 | std::string attr_val; |
| 1107 | |
| 1108 | const auto cur_flow_file = params.flow_file.lock(); |
| 1109 | |
| 1110 | if (cur_flow_file && cur_flow_file->getAttribute(attr_id, attr_val)) { |
| 1111 | return Value(attr_val); |
| 1112 | } else { |
| 1113 | return Value(); |
| 1114 | } |
| 1115 | })); |
| 1116 | } |
| 1117 | |
| 1118 | return out_exprs; |
| 1119 | }); |
| 1120 | |
| 1121 | return result; |
| 1122 | } |
| 1123 | |
| 1124 | Expression make_anyAttribute(const std::string &function_name, const std::vector<Expression> &args) { |
| 1125 | if (args.size() < 1) { |
no test coverage detected