use of com.thinkbiganalytics.feedmgr.service.template.TemplateModelTransform.TEMPLATE_TRANSFORMATION_TYPE in project kylo by Teradata.
the class RegisteredTemplateService method findRegisteredTemplate.
/**
* Gets a Registered Template or returns null if not found by various means passed in via the request object
*
* @param registeredTemplateRequest a request to get a registered template
* @return the RegisteredTemplate or null if not found
*/
public RegisteredTemplate findRegisteredTemplate(RegisteredTemplateRequest registeredTemplateRequest) {
String templateId = registeredTemplateRequest.getTemplateId();
String templateName = registeredTemplateRequest.getTemplateName();
// if we are looking for a given template as a request from a Feed, we need to query and access it via a service account.
// otherwise we will access it as the user
Principal[] principals = null;
if (registeredTemplateRequest.isFeedEdit()) {
principals = new Principal[1];
principals[0] = MetadataAccess.SERVICE;
} else {
principals = new Principal[0];
}
// The default transformation type will not include sensitive property values.
// if requested as a template or feed edit, it will include the encrypted sensitive property values
TEMPLATE_TRANSFORMATION_TYPE transformationType = TEMPLATE_TRANSFORMATION_TYPE.WITH_FEED_NAMES;
if (registeredTemplateRequest.isTemplateEdit() || registeredTemplateRequest.isFeedEdit() || registeredTemplateRequest.isIncludeSensitiveProperties()) {
transformationType = TEMPLATE_TRANSFORMATION_TYPE.WITH_SENSITIVE_DATA;
}
RegisteredTemplate registeredTemplate = findRegisteredTemplateById(templateId, transformationType, principals);
// if it is null check to see if the template exists in nifi and is already registered
if (registeredTemplate == null) {
// log.info("Attempt to get Template with id {}, returned null. This id must be one registed in Nifi... attempt to query Nifi for this template ", templateId);
registeredTemplate = findRegisteredTemplateByNiFiIdentifier(templateId, transformationType, principals);
}
if (registeredTemplate == null) {
// attempt to look by name
registeredTemplate = findRegisteredTemplateByName(templateName, transformationType, principals);
}
if (registeredTemplate != null) {
if (registeredTemplateRequest.isIncludeAllProperties()) {
registeredTemplate = mergeRegisteredTemplateProperties(registeredTemplate, registeredTemplateRequest);
registeredTemplate.initializeProcessors();
ensureRegisteredTemplateInputProcessors(registeredTemplate);
}
if (NifiPropertyUtil.containsPropertiesForProcessorMatchingType(registeredTemplate.getProperties(), NifiFeedConstants.TRIGGER_FEED_PROCESSOR_CLASS)) {
registeredTemplate.setAllowPreconditions(true);
} else {
registeredTemplate.setAllowPreconditions(false);
}
}
return registeredTemplate;
}
Aggregations