use of com.thinkbiganalytics.feedmgr.rest.ImportComponent in project kylo by Teradata.
the class ImportUtil method addToImportOptionsSensitiveProperties.
public static void addToImportOptionsSensitiveProperties(ImportOptions importOptions, List<NifiProperty> sensitiveProperties, ImportComponent component) {
ImportComponentOption option = importOptions.findImportComponentOption(component);
if (option.getProperties().isEmpty()) {
option.setProperties(sensitiveProperties.stream().map(p -> new ImportProperty(p.getProcessorName(), p.getProcessorId(), p.getKey(), "", p.getProcessorType())).collect(Collectors.toList()));
} else {
// only add in those that are unique
Map<String, ImportProperty> propertyMap = option.getProperties().stream().collect(Collectors.toMap(p -> p.getProcessorNameTypeKey(), p -> p));
sensitiveProperties.stream().filter(nifiProperty -> !propertyMap.containsKey(nifiProperty.getProcessorNameTypeKey())).forEach(p -> {
option.getProperties().add(new ImportProperty(p.getProcessorName(), p.getProcessorId(), p.getKey(), "", p.getProcessorType()));
});
}
}
use of com.thinkbiganalytics.feedmgr.rest.ImportComponent in project kylo by Teradata.
the class ImportUtil method applyImportPropertiesToTemplate.
public static boolean applyImportPropertiesToTemplate(RegisteredTemplate template, ImportTemplate importTemplate, ImportComponent component) {
ImportComponentOption option = importTemplate.getImportOptions().findImportComponentOption(component);
if (!option.getProperties().isEmpty() && option.getProperties().stream().anyMatch(importProperty -> StringUtils.isBlank(importProperty.getPropertyValue()))) {
importTemplate.setSuccess(false);
importTemplate.setTemplateResults(new NifiProcessGroup());
String msg = "Unable to import Template. Additional properties to be supplied before importing.";
importTemplate.getTemplateResults().addError(NifiError.SEVERITY.WARN, msg, "");
option.getErrorMessages().add(msg);
return false;
} else {
template.getSensitiveProperties().forEach(nifiProperty -> {
ImportProperty userSuppliedValue = option.getProperties().stream().filter(importFeedProperty -> nifiProperty.getProcessorId().equalsIgnoreCase(importFeedProperty.getProcessorId()) && nifiProperty.getKey().equalsIgnoreCase(importFeedProperty.getPropertyKey())).findFirst().orElse(null);
// deal with nulls?
if (userSuppliedValue == null) {
// attempt to find it via the name
userSuppliedValue = option.getProperties().stream().filter(importFeedProperty -> nifiProperty.getProcessorName().equalsIgnoreCase(importFeedProperty.getProcessorName()) && nifiProperty.getKey().equalsIgnoreCase(importFeedProperty.getPropertyKey())).findFirst().orElse(null);
}
if (userSuppliedValue != null) {
nifiProperty.setValue(userSuppliedValue.getPropertyValue());
}
});
return true;
}
}
use of com.thinkbiganalytics.feedmgr.rest.ImportComponent in project kylo by Teradata.
the class ImportUtil method applyImportPropertiesToFeed.
public static boolean applyImportPropertiesToFeed(FeedMetadata metadata, ImportFeed importFeed, ImportComponent component) {
ImportComponentOption option = importFeed.getImportOptions().findImportComponentOption(component);
if (!option.getProperties().isEmpty() && option.getProperties().stream().anyMatch(importProperty -> StringUtils.isBlank(importProperty.getPropertyValue()))) {
importFeed.setSuccess(false);
if (importFeed.getTemplate() == null) {
ImportTemplate importTemplate = new ImportTemplate(importFeed.getFileName());
importFeed.setTemplate(importTemplate);
}
String feedCategory = importFeed.getImportOptions().getCategorySystemName() != null ? importFeed.getImportOptions().getCategorySystemName() : metadata.getSystemCategoryName();
String msg = "The feed " + FeedNameUtil.fullName(feedCategory, metadata.getSystemFeedName()) + " needs additional properties to be supplied before importing.";
importFeed.addErrorMessage(metadata, msg);
option.getErrorMessages().add(msg);
return false;
} else {
metadata.getSensitiveProperties().forEach(nifiProperty -> {
ImportProperty userSuppliedValue = importFeed.getImportOptions().getProperties(ImportComponent.FEED_DATA).stream().filter(importFeedProperty -> {
return nifiProperty.getProcessorId().equalsIgnoreCase(importFeedProperty.getProcessorId()) && nifiProperty.getKey().equalsIgnoreCase(importFeedProperty.getPropertyKey());
}).findFirst().orElse(null);
// deal with nulls?
if (userSuppliedValue != null) {
nifiProperty.setValue(userSuppliedValue.getPropertyValue());
}
});
return true;
}
}
Aggregations