use of org.apache.nifi.components.PropertyDescriptor in project nifi by apache.
the class StandardProcessContext method getProperty.
/**
* <p>
* Returns the currently configured value for the property with the given name.
* </p>
*/
@Override
public PropertyValue getProperty(final String propertyName) {
verifyTaskActive();
final Processor processor = procNode.getProcessor();
final PropertyDescriptor descriptor = processor.getPropertyDescriptor(propertyName);
if (descriptor == null) {
return null;
}
final String setPropertyValue = procNode.getProperty(descriptor);
final String propValue = (setPropertyValue == null) ? descriptor.getDefaultValue() : setPropertyValue;
return new StandardPropertyValue(propValue, this, preparedQueries.get(descriptor), procNode.getVariableRegistry());
}
use of org.apache.nifi.components.PropertyDescriptor in project nifi by apache.
the class StandardFlowSynchronizer method updateReportingTaskControllerServices.
private void updateReportingTaskControllerServices(final Set<ReportingTaskNode> reportingTasks, final Map<String, ControllerServiceNode> controllerServiceMapping) {
for (ReportingTaskNode reportingTask : reportingTasks) {
if (reportingTask.getProperties() != null) {
final Set<Map.Entry<PropertyDescriptor, String>> propertyDescriptors = reportingTask.getProperties().entrySet().stream().filter(e -> e.getKey().getControllerServiceDefinition() != null).filter(e -> controllerServiceMapping.containsKey(e.getValue())).collect(Collectors.toSet());
final Map<String, String> controllerServiceProps = new HashMap<>();
for (Map.Entry<PropertyDescriptor, String> propEntry : propertyDescriptors) {
final PropertyDescriptor propertyDescriptor = propEntry.getKey();
final ControllerServiceNode clone = controllerServiceMapping.get(propEntry.getValue());
controllerServiceProps.put(propertyDescriptor.getName(), clone.getIdentifier());
}
reportingTask.setProperties(controllerServiceProps);
}
}
}
use of org.apache.nifi.components.PropertyDescriptor in project nifi by apache.
the class StandardReportingContext method getProperty.
@Override
public PropertyValue getProperty(final PropertyDescriptor property) {
final PropertyDescriptor descriptor = reportingTask.getPropertyDescriptor(property.getName());
if (descriptor == null) {
return null;
}
final String configuredValue = properties.get(property);
return new StandardPropertyValue(configuredValue == null ? descriptor.getDefaultValue() : configuredValue, this, preparedQueries.get(property), variableRegistry);
}
use of org.apache.nifi.components.PropertyDescriptor in project nifi by apache.
the class StandardFlowSerializer method addConfiguration.
private static void addConfiguration(final Element element, final Map<PropertyDescriptor, String> properties, final String annotationData, final StringEncryptor encryptor) {
final Document doc = element.getOwnerDocument();
for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) {
final PropertyDescriptor descriptor = entry.getKey();
String value = entry.getValue();
if (value != null && descriptor.isSensitive()) {
value = ENC_PREFIX + encryptor.encrypt(value) + ENC_SUFFIX;
}
if (value == null) {
value = descriptor.getDefaultValue();
}
final Element propElement = doc.createElement("property");
addTextElement(propElement, "name", descriptor.getName());
if (value != null) {
addTextElement(propElement, "value", value);
}
element.appendChild(propElement);
}
if (annotationData != null) {
addTextElement(element, "annotationData", annotationData);
}
}
use of org.apache.nifi.components.PropertyDescriptor in project nifi by apache.
the class StandardControllerServiceNode method getRequiredControllerServices.
@Override
public List<ControllerServiceNode> getRequiredControllerServices() {
Set<ControllerServiceNode> requiredServices = new HashSet<>();
for (Entry<PropertyDescriptor, String> entry : getProperties().entrySet()) {
PropertyDescriptor descriptor = entry.getKey();
if (descriptor.getControllerServiceDefinition() != null && entry.getValue() != null) {
ControllerServiceNode requiredNode = serviceProvider.getControllerServiceNode(entry.getValue());
requiredServices.add(requiredNode);
requiredServices.addAll(requiredNode.getRequiredControllerServices());
}
}
return new ArrayList<>(requiredServices);
}
Aggregations