This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 5591bec44b NIFI-9742: Use dependent property Display Names in
documentation
5591bec44b is described below
commit 5591bec44b6b69d9a4581de055041fe8cd88d1e1
Author: Matthew Burgess <[email protected]>
AuthorDate: Tue Mar 1 12:40:06 2022 -0500
NIFI-9742: Use dependent property Display Names in documentation
This closes #5820
Signed-off-by: David Handermann <[email protected]>
---
.../html/HtmlDocumentationWriter.java | 47 +++++++++++++++++-----
1 file changed, 36 insertions(+), 11 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
index 7ae0eea21d..d78f2899de 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
@@ -609,23 +609,48 @@ public class HtmlDocumentationWriter implements
DocumentationWriter {
for (final PropertyDependency dependency : dependencies) {
final Set<String> dependentValues =
dependency.getDependentValues();
final String prefix = (capitalizeThe ? "The" : "the")
+ " <" + dependency.getPropertyDisplayName() + "> Property ";
- final String suffix;
+ String suffix = "";
if (dependentValues == null) {
suffix = "has a value specified.";
- } else if (dependentValues.size() == 1) {
- final String requiredValue =
dependentValues.iterator().next();
- suffix = "has a value of \"" + requiredValue +
"\".";
} else {
- final StringBuilder sb = new StringBuilder("is set
to one of the following values: ");
-
- for (final String dependentValue :
dependentValues) {
-
sb.append("\"").append(dependentValue).append("\", ");
+ PropertyDescriptor dependencyProperty = null;
+ for (PropertyDescriptor prop : properties) {
+ if
(prop.getName().equals(dependency.getPropertyName())) {
+ dependencyProperty = prop;
+ break;
+ }
+ }
+ if (null == dependencyProperty) {
+ throw new XMLStreamException("No property was
found matching the name '" + dependency.getPropertyName() + "'");
}
+ if (dependentValues.size() == 1) {
+ final String requiredValue =
dependentValues.iterator().next();
+ final List<AllowableValue> allowableValues =
dependencyProperty.getAllowableValues();
+ if (allowableValues != null) {
+ for (AllowableValue av : allowableValues) {
+ if
(requiredValue.equals(av.getValue())) {
+ suffix = "has a value of \"" +
av.getDisplayName() + "\".";
+ break;
+ }
+ }
+ }
+ } else {
+ final StringBuilder sb = new StringBuilder("is
set to one of the following values: ");
- // Delete the trailing ", "
- sb.setLength(sb.length() - 2);
+ for (final String dependentValue :
dependentValues) {
+ for (AllowableValue av :
dependencyProperty.getAllowableValues()) {
+ if
(dependentValue.equals(av.getValue())) {
+
sb.append("\"").append(av.getDisplayName()).append("\", ");
+ break;
+ }
+ }
+ }
- suffix = sb.toString();
+ // Delete the trailing ", "
+ sb.setLength(sb.length() - 2);
+
+ suffix = sb.toString();
+ }
}
final String elementName = dependencies.size() > 1 ?
"li" : "strong";