use of com.thinkbiganalytics.nifi.rest.model.NifiProperty in project kylo by Teradata.
the class RegisteredTemplateService method mergeTemplatePropertiesWithFeed.
public FeedMetadata mergeTemplatePropertiesWithFeed(FeedMetadata feedMetadata) {
// gets the feed data and then gets the latest template associated with that feed and merges the properties into the feed
RegisteredTemplate registeredTemplate = findRegisteredTemplate(new RegisteredTemplateRequest.Builder().templateId(feedMetadata.getTemplateId()).isFeedEdit(true).nifiTemplateId(feedMetadata.getTemplateId()).includeAllProperties(true).build());
if (registeredTemplate != null) {
feedMetadata.setTemplateId(registeredTemplate.getId());
List<NifiProperty> templateProperties = registeredTemplate.getProperties().stream().map(nifiProperty -> new NifiProperty(nifiProperty)).collect(Collectors.toList());
NifiPropertyUtil.matchAndSetPropertyByProcessorName(templateProperties, feedMetadata.getProperties(), NifiPropertyUtil.PROPERTY_MATCH_AND_UPDATE_MODE.FEED_DETAILS_MATCH_TEMPLATE);
// detect template properties that dont match the feed.properties from the registeredtemplate
ensureFeedPropertiesExistInTemplate(feedMetadata, templateProperties);
feedMetadata.setProperties(templateProperties);
registeredTemplate.setProperties(templateProperties);
registeredTemplate.initializeProcessors();
feedMetadata.setRegisteredTemplate(registeredTemplate);
}
return feedMetadata;
}
use of com.thinkbiganalytics.nifi.rest.model.NifiProperty in project kylo by Teradata.
the class ImportFeedTemplateXml method create.
@Override
public NifiProcessGroup create(NiFiTemplateImport niFiTemplateImport, UploadProgressMessage importStatusMessage) {
TemplateDTO dto = niFiTemplateImport.getDto();
String templateName = importTemplate.getTemplateName();
String fileName = importTemplate.getFileName();
importStatusMessage.update("Importing the NiFi flow, " + templateName);
log.info("validate NiFi Flow by 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();
NifiProcessGroup newTemplateInstance = nifiRestClient.createNewTemplateInstance(dto.getId(), templateProperties, configProperties, false, null, importTemplate.getVersionIdentifier());
importTemplate.setTemplateResults(newTemplateInstance);
return newTemplateInstance;
}
use of com.thinkbiganalytics.nifi.rest.model.NifiProperty 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;
}
}
use of com.thinkbiganalytics.nifi.rest.model.NifiProperty in project kylo by Teradata.
the class PropertyExpressionResolverTest method newProperty.
private NifiProperty newProperty(String key, String value) {
NifiProperty p = new NifiProperty();
p.setKey(key);
p.setValue(value);
return p;
}
use of com.thinkbiganalytics.nifi.rest.model.NifiProperty in project kylo by Teradata.
the class PropertyExpressionResolverTest method resolveExpressionInvalid.
/**
* Verifies invalid expressions are resolved properly.
*/
@Test
public void resolveExpressionInvalid() {
final FeedMetadata metadata = new FeedMetadata();
// Verify missing config variable
final NifiProperty prop1 = createProperty("${config.test.invalid}");
Assert.assertFalse(resolver.resolveExpression(metadata, prop1));
Assert.assertEquals("${config.test.invalid}", prop1.getValue());
// Verify missing metadata variable
final NifiProperty prop2 = createProperty("${metadata.invalid}");
Assert.assertFalse(resolver.resolveExpression(metadata, prop2));
Assert.assertEquals("${metadata.invalid}", prop2.getValue());
// Verify empty variable
final NifiProperty prop3 = createProperty("${}");
Assert.assertFalse(resolver.resolveExpression(metadata, prop3));
Assert.assertEquals("${}", prop3.getValue());
}
Aggregations