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

ASF GitHub Bot commented on MINIFICPP-269:
------------------------------------------

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

    https://github.com/apache/nifi-minifi-cpp/pull/157#discussion_r148581669
  
    --- Diff: extensions/bustache/ApplyTemplate.cpp ---
    @@ -0,0 +1,100 @@
    +/**
    + * @file ApplyTemplate.cpp
    + * ApplyTemplate class implementation
    + *
    + * 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 <string.h>
    +#include <iostream>
    +#include <fstream>
    +#include <memory>
    +#include <string>
    +#include <set>
    +
    +#include <boost/iostreams/device/mapped_file.hpp>
    +
    +#include <bustache/model.hpp>
    +#include <bustache/format.hpp>
    +
    +#include "ApplyTemplate.h"
    +#include "core/ProcessContext.h"
    +#include "core/ProcessSession.h"
    +
    +
    +namespace org {
    +namespace apache {
    +namespace nifi {
    +namespace minifi {
    +namespace processors {
    +
    +core::Property ApplyTemplate::Template("Template", "Path to the input 
mustache template file", "");
    +core::Relationship ApplyTemplate::Success("success", "success operational 
on the flow record");
    +
    +void ApplyTemplate::initialize() {
    +    //! Set the supported properties
    +    std::set<core::Property> properties;
    +    properties.insert(Template);
    +    setSupportedProperties(properties);
    +    //! Set the supported relationships
    +    std::set<core::Relationship> relationships;
    +    relationships.insert(Success);
    +    setSupportedRelationships(relationships);
    +}
    +
    +void ApplyTemplate::onTrigger(core::ProcessContext *context, 
core::ProcessSession *session) {
    +    auto flowFile = session->get();
    +
    +    if (!flowFile) {
    +        return;
    +    }
    +
    +    std::string templateFile;
    +    context->getProperty(Template.getName(), templateFile);
    +    WriteCallback cb(templateFile, flowFile);
    +    session->write(flowFile, &cb);
    +    session->transfer(flowFile, Success);
    +}
    +
    +ApplyTemplate::WriteCallback::WriteCallback(const std::string& path, 
std::shared_ptr<core::FlowFile> flowFile) {
    +    logger_ = 
logging::LoggerFactory<ApplyTemplate::WriteCallback>::getLogger();
    +    templateFile_ = path;
    +    flowFile_ = flowFile;
    +}
    +
    +int64_t 
ApplyTemplate::WriteCallback::process(std::shared_ptr<io::BaseStream> stream) {
    --- End diff --
    
    It won't let me declare a different prototype than the virtual one in 
OutputStreamCallback
    ```
    [ 85%] Building CXX object 
extensions/bustache/CMakeFiles/minifi-bustache-extensions.dir/ApplyTemplate.cpp.o
    /home/ubuntu/workspace/extensions/bustache/ApplyTemplate.cpp: In member 
function ‘virtual void 
org::apache::nifi::minifi::processors::ApplyTemplate::onTrigger(const 
std::shared_ptr<org::apache::nifi::minifi::core::ProcessContext>&, const 
std::shared_ptr<org::apache::nifi::minifi::core::ProcessSession>&)’:
    /home/ubuntu/workspace/extensions/bustache/ApplyTemplate.cpp:66:19: error: 
cannot declare variable ‘cb’ to be of abstract type 
‘org::apache::nifi::minifi::processors::ApplyTemplate::WriteCallback’
         WriteCallback cb(templateFile, 
std::shared_ptr<core::FlowFile>(flowFile));
                       ^
    In file included from 
/home/ubuntu/workspace/extensions/bustache/ApplyTemplate.cpp:32:0:
    /home/ubuntu/workspace/extensions/bustache/ApplyTemplate.h:61:11: note:   
because the following virtual functions are pure within 
‘org::apache::nifi::minifi::processors::ApplyTemplate::WriteCallback’:
         class WriteCallback : public OutputStreamCallback {
               ^
    In file included from 
/home/ubuntu/workspace/extensions/bustache/../../libminifi/include/core/ProcessSession.h:31:0,
                     from 
/home/ubuntu/workspace/extensions/bustache/../../libminifi/include/core/Processor.h:42,
                     from 
/home/ubuntu/workspace/extensions/bustache/ApplyTemplate.h:25,
                     from 
/home/ubuntu/workspace/extensions/bustache/ApplyTemplate.cpp:32:
    
/home/ubuntu/workspace/extensions/bustache/../../libminifi/include/FlowFileRecord.h:97:19:
 note:        virtual int64_t 
org::apache::nifi::minifi::OutputStreamCallback::process(std::shared_ptr<org::apache::nifi::minifi::io::BaseStream>)
       virtual int64_t process(std::shared_ptr<io::BaseStream> stream) = 0;
                       ^
    make[2]: *** 
[extensions/bustache/CMakeFiles/minifi-bustache-extensions.dir/ApplyTemplate.cpp.o]
 Error 1
    make[1]: *** 
[extensions/bustache/CMakeFiles/minifi-bustache-extensions.dir/all] Error 2
    make: *** [all] Error 2
    ```


> Implement ApplyTemplate processor
> ---------------------------------
>
>                 Key: MINIFICPP-269
>                 URL: https://issues.apache.org/jira/browse/MINIFICPP-269
>             Project: NiFi MiNiFi C++
>          Issue Type: New Feature
>            Reporter: Caleb Johnson
>            Priority: Minor
>              Labels: mustache, processor, template, templates
>
> The ApplyTemplate processor is fairly straightforward: it reads a 
> [mustache|https://mustache.github.io/] template from a provided path on disk 
> and maps flowfile attributes to template values.
> Dynamic properties (MINIFI-171) would go a long way towards making these 
> templates more flexible by using the union of input flowfile attributes and 
> (possibly evaluated?) properties as the value map.
> Due to its dependency on [bustache|https://github.com/jamboree/bustache] and 
> boost, it has been made into an optional extension, much like the libarchive 
> processors have.
> It may also be desirable to load the template from the input flowfile's 
> contents instead of a configurable path.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to