use of com.thinkbiganalytics.nifi.rest.model.NifiProperty in project kylo by Teradata.
the class ImportTemplateArchive method create.
@Override
public NifiProcessGroup create(NiFiTemplateImport niFiTemplateImport, UploadProgressMessage importStatusMessage) {
log.info("Importing Zip file template {}, overwrite: {}, reusableFlow: {}", importTemplate.getFileName(), this.importTemplateOptions.isImportAndOverwrite(ImportComponent.TEMPLATE_DATA), importTemplateOptions.isImport(ImportComponent.REUSABLE_TEMPLATE));
if (importTemplate.isValid()) {
}
TemplateDTO dto = niFiTemplateImport.getDto();
String templateName = importTemplate.getTemplateName();
String fileName = importTemplate.getFileName();
importStatusMessage.update("Importing the NiFi flow, " + templateName);
log.info("Creating a template instance in Nifi. Template: {} for file {}", templateName, fileName);
Map<String, Object> configProperties = propertyExpressionResolver.getStaticConfigProperties();
List<NifiProperty> templateProperties = importTemplate.getTemplateToImport() != null ? importTemplate.getTemplateToImport().getProperties() : Collections.emptyList();
this.newTemplateInstance = nifiRestClient.createNewTemplateInstance(dto.getId(), templateProperties, configProperties, false, null, importTemplate.getVersionIdentifier());
importTemplate.setTemplateResults(newTemplateInstance);
if (newTemplateInstance.getVersionedProcessGroup() != null && StringUtils.isNotBlank(newTemplateInstance.getVersionedProcessGroup().getVersionedProcessGroupName())) {
uploadProgressService.addUploadStatus(importTemplateOptions.getUploadKey(), "Versioned off previous flow with the name: " + newTemplateInstance.getVersionedProcessGroup().getVersionedProcessGroupName(), true, true);
}
return newTemplateInstance;
}
use of com.thinkbiganalytics.nifi.rest.model.NifiProperty in project kylo by Teradata.
the class ValidateImportTemplatesArchive method validateTemplateProperties.
/**
* Validate the Template doesnt have any sensitive properties needing additional user input before importing
*
* @return true if valid, false if not
*/
private boolean validateTemplateProperties() {
RegisteredTemplate template = importTemplate.getTemplateToImport();
// detect any sensitive properties and prompt for input before proceeding
List<NifiProperty> sensitiveProperties = template.getSensitiveProperties();
ImportUtil.addToImportOptionsSensitiveProperties(importTemplateOptions, sensitiveProperties, ImportComponent.TEMPLATE_DATA);
boolean valid = ImportUtil.applyImportPropertiesToTemplate(template, importTemplate, ImportComponent.TEMPLATE_DATA);
if (!valid) {
importTemplate.getImportOptions().addErrorMessage(ImportComponent.TEMPLATE_DATA, "Additional properties are required for the Template");
}
this.importTemplateOptions.findImportComponentOption(ImportComponent.TEMPLATE_DATA).setAnalyzed(true);
return valid;
}
use of com.thinkbiganalytics.nifi.rest.model.NifiProperty 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.nifi.rest.model.NifiProperty 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.nifi.rest.model.NifiProperty in project kylo by Teradata.
the class PropertyExpressionResolverTest method testFeedMetadataProperties.
@Test
public void testFeedMetadataProperties() {
FeedMetadata metadata = new FeedMetadata();
metadata.setSystemFeedName("feedSystemName");
metadata.setCategory(new FeedCategory());
metadata.setTable(new TableSetup());
metadata.getTable().setSourceTableSchema(new DefaultTableSchema());
metadata.getTable().setTableSchema(new DefaultTableSchema());
metadata.getTable().getSourceTableSchema().setName("sourceTableName");
metadata.getTable().getTableSchema().setName("tableSchemaName");
final NifiProperty prop1 = createProperty("${metadata.table.sourceTableSchema.name}");
Assert.assertTrue(resolver.resolveExpression(metadata, prop1));
Assert.assertEquals("sourceTableName", prop1.getValue());
}
Aggregations