mirror of
https://github.com/apache/nifi.git
synced 2025-02-07 18:48:51 +00:00
NIFI-1121: Added an additional check for hidden properties to account for transitive dependent properties.
- Added a 'dependent' attribute to determine whether or not to save dependent property values Co-authored-by: Scott Aslan <scottyaslan@gmail.com> Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
parent
e2e901b6b9
commit
535cab3167
@ -75,8 +75,8 @@ public class PropertyDependency {
|
||||
}
|
||||
|
||||
final PropertyDependency that = (PropertyDependency) o;
|
||||
return Objects.equals(getPropertyName(), that.getPropertyName()) &&
|
||||
Objects.equals(getDependentValues(), that.getDependentValues());
|
||||
return Objects.equals(getPropertyName(), that.getPropertyName())
|
||||
&& Objects.equals(getDependentValues(), that.getDependentValues());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,6 @@ import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.nifi.annotation.lifecycle.OnScheduled;
|
||||
import org.apache.nifi.annotation.lifecycle.OnStopped;
|
||||
import org.apache.nifi.components.PropertyDescriptor;
|
||||
@ -51,7 +50,7 @@ public abstract class BinFiles extends AbstractSessionFactoryProcessor {
|
||||
|
||||
public static final PropertyDescriptor MIN_SIZE = new PropertyDescriptor.Builder()
|
||||
.name("Minimum Group Size")
|
||||
.description("The minimum size of for the bundle")
|
||||
.description("The minimum size for the bundle")
|
||||
.required(true)
|
||||
.defaultValue("0 B")
|
||||
.addValidator(StandardValidators.DATA_SIZE_VALIDATOR)
|
||||
|
@ -1674,6 +1674,7 @@
|
||||
// Get the property descriptor object
|
||||
var descriptor = descriptors[item.property];
|
||||
var hidden = false;
|
||||
var dependent = false;
|
||||
|
||||
// Check for dependencies
|
||||
if (descriptor.dependencies.length > 0) {
|
||||
@ -1687,12 +1688,17 @@
|
||||
// Check the row's dependent values against all other row's current values to determine hidden state
|
||||
$.each(items, function (k, property) {
|
||||
if (property.property === dependency.propertyName) {
|
||||
// Get the current property value to compare with the dependent value
|
||||
var propertyValue = property.value;
|
||||
dependent = true;
|
||||
if (property.hidden === false) {
|
||||
// Get the current property value to compare with the dependent value
|
||||
var propertyValue = property.value;
|
||||
|
||||
// Test the dependentValues array against the current value of the property
|
||||
// If not, then mark the current property hidden attribute is true
|
||||
hidden = !dependency.dependentValues.includes(propertyValue);
|
||||
// Test the dependentValues array against the current value of the property
|
||||
// If not, then mark the current property hidden attribute is true
|
||||
hidden = !dependency.dependentValues.includes(propertyValue);
|
||||
} else {
|
||||
hidden = true;
|
||||
}
|
||||
if (hidden) {
|
||||
// It is sufficient to have found a single instance of not meeting the
|
||||
// requirement for a dependent value in order to hide a property
|
||||
@ -1705,7 +1711,8 @@
|
||||
|
||||
propertyData.beginUpdate();
|
||||
propertyData.updateItem(id, $.extend(item, {
|
||||
hidden: hidden
|
||||
hidden: hidden,
|
||||
dependent: dependent
|
||||
}));
|
||||
propertyData.endUpdate();
|
||||
|
||||
@ -1826,18 +1833,38 @@
|
||||
}
|
||||
|
||||
var hidden = false;
|
||||
var dependent = false;
|
||||
|
||||
// Check for dependencies
|
||||
if (descriptor.dependencies.length > 0) {
|
||||
$.each(descriptor.dependencies, function (i, dependency) {
|
||||
// Get the property value by propertyName
|
||||
var propertyValue = properties[dependency.propertyName];
|
||||
// Test the dependentValues against the current value of the property
|
||||
// If not, then mark the current property hidden attribute is true
|
||||
hidden = !dependency.dependentValues.includes(propertyValue);
|
||||
// It is sufficient to have found a single instance of not meeting the
|
||||
// requirement for a dependent value in order to hide a property
|
||||
if (hidden) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the rows from the table
|
||||
var items = propertyData.getItems();
|
||||
|
||||
// Get the item's hidden attribute to compare. If item.hidden=true, hidden = true.
|
||||
$.each(items, function (k, property) {
|
||||
if (property.property === dependency.propertyName) {
|
||||
dependent = true;
|
||||
if (property.hidden === false) {
|
||||
// Get the property value by propertyName
|
||||
var propertyValue = properties[dependency.propertyName];
|
||||
// Test the dependentValues against the current value of the property
|
||||
// If not, then mark the current property hidden attribute is true
|
||||
hidden = !dependency.dependentValues.includes(propertyValue);
|
||||
} else {
|
||||
hidden = true;
|
||||
}
|
||||
if (hidden) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@ -1845,6 +1872,7 @@
|
||||
propertyData.addItem({
|
||||
id: i++,
|
||||
hidden: hidden,
|
||||
dependent: dependent,
|
||||
property: name,
|
||||
displayName: displayName,
|
||||
previousValue: value,
|
||||
@ -2221,7 +2249,7 @@
|
||||
var propertyGrid = table.data('gridInstance');
|
||||
var propertyData = propertyGrid.getData();
|
||||
$.each(propertyData.getItems(), function () {
|
||||
if (this.hidden === true) {
|
||||
if (this.hidden === true && !(this.dependent === true)) {
|
||||
// hidden properties were removed by the user, clear the value
|
||||
properties[this.property] = null;
|
||||
} else if (this.value !== this.previousValue) {
|
||||
|
@ -43,7 +43,6 @@ import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.file.CodecFactory;
|
||||
import org.apache.avro.file.DataFileConstants;
|
||||
@ -55,13 +54,13 @@ import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.nifi.annotation.behavior.SystemResourceConsideration;
|
||||
import org.apache.nifi.annotation.behavior.InputRequirement;
|
||||
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
|
||||
import org.apache.nifi.annotation.behavior.ReadsAttribute;
|
||||
import org.apache.nifi.annotation.behavior.ReadsAttributes;
|
||||
import org.apache.nifi.annotation.behavior.SideEffectFree;
|
||||
import org.apache.nifi.annotation.behavior.SystemResource;
|
||||
import org.apache.nifi.annotation.behavior.SystemResourceConsideration;
|
||||
import org.apache.nifi.annotation.behavior.TriggerWhenEmpty;
|
||||
import org.apache.nifi.annotation.behavior.WritesAttribute;
|
||||
import org.apache.nifi.annotation.behavior.WritesAttributes;
|
||||
@ -284,7 +283,7 @@ public class MergeContent extends BinFiles {
|
||||
+ "the values of the properties should be used as the content.")
|
||||
.allowableValues(DELIMITER_STRATEGY_NONE, DELIMITER_STRATEGY_FILENAME, DELIMITER_STRATEGY_TEXT)
|
||||
.defaultValue(DELIMITER_STRATEGY_NONE.getValue())
|
||||
.dependsOn(MERGE_STRATEGY, MERGE_STRATEGY_BIN_PACK)
|
||||
.dependsOn(MERGE_FORMAT, MERGE_FORMAT_CONCAT_VALUE)
|
||||
.build();
|
||||
public static final PropertyDescriptor HEADER = new PropertyDescriptor.Builder()
|
||||
.name("Header File")
|
||||
|
Loading…
x
Reference in New Issue
Block a user