2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
18 package org.onap.dcae.genprocessor;
20 import java.util.List;
23 import org.apache.nifi.components.PropertyDescriptor;
24 import org.apache.nifi.processor.AbstractProcessor;
25 import org.apache.nifi.processor.ProcessContext;
26 import org.apache.nifi.processor.ProcessSession;
27 import org.apache.nifi.processor.Relationship;
28 import org.apache.nifi.processor.exception.ProcessException;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
34 public abstract class DCAEProcessor extends AbstractProcessor {
36 static final Logger LOG = LoggerFactory.getLogger(DCAEProcessor.class);
38 // These are properties of the DCAE component that may be useful in the future..
39 abstract public String getName();
40 abstract public String getVersion();
41 abstract public String getComponentId();
42 abstract public String getComponentUrl();
49 public void onTrigger(ProcessContext arg0, ProcessSession arg1) throws ProcessException {
50 LOG.info("Bang you triggered DCAEProcessor!");
55 * This function gets implemented by the ProcessorBuilder magic to build a new custom list of
56 * PropertyDescriptor every time. This is to be used by getSupportedPropertyDescriptors() which
57 * *should* only call this method once to initially fill the cache.
59 * @return list of PropertyDescriptor
61 abstract protected List<PropertyDescriptor> buildSupportedPropertyDescriptors();
63 // Cache of PropertyDescriptors which should be static
64 private List<PropertyDescriptor> properties;
67 * This is the critical Nifi function that is used to populate the configuration parameters
68 * in the UI and drive all the other configuration related functions in the ConfigurableComponent
72 protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
73 if (this.properties == null) {
74 this.properties = buildSupportedPropertyDescriptors();
76 return this.properties;
79 abstract protected Set<Relationship> buildRelationships();
81 // Cache of Relationships which should be static
82 private Set<Relationship> relationships;
85 public Set<Relationship> getRelationships() {
86 if (this.relationships == null) {
87 this.relationships = buildRelationships();
89 return this.relationships;