/** * Updates the task definition with the datasource properties. * @param taskDefinition the {@link TaskDefinition} to be updated. * @param dataSourceProperties the dataSource properties used by SCDF. * @return the updated {@link TaskDefinition} */ public static TaskDefinition updateTaskProperties(TaskDefinition taskDefinition, DataSourceProperties dataSourceProperties) { Assert.notNull(taskDefinition, "taskDefinition must not be null"); Assert.notNull(dataSourceProperties, "dataSourceProperties must not be null"); TaskDefinition.TaskDefinitionBuilder builder = TaskDefinition.TaskDefinitionBuilder.from(taskDefinition); builder.setProperty("spring.datasource.url", dataSourceProperties.getUrl()); builder.setProperty("spring.datasource.username", dataSourceProperties.getUsername()); // password may be empty if (StringUtils.hasText(dataSourceProperties.getPassword())) { builder.setProperty("spring.datasource.password", dataSourceProperties.getPassword()); } builder.setProperty("spring.datasource.driverClassName", dataSourceProperties.getDriverClassName()); return builder.build(); }
/** * Sets the contents of the provided map as the map of app properties. * * @param properties app properties * @return this builder object * @see AppDefinition#getProperties() */ public TaskDefinitionBuilder setProperties(Map<String, String> properties) { Assert.notNull(properties, "properties must not be null"); this.properties.clear(); this.addProperties(properties); return this; }
/** * Updates the task definition with the datasource properties. * @param taskDefinition the {@link TaskDefinition} to be updated. * @param dataSourceProperties the dataSource properties used by SCDF. * @return the updated {@link TaskDefinition} */ public static TaskDefinition updateTaskProperties(TaskDefinition taskDefinition, DataSourceProperties dataSourceProperties) { Assert.notNull(taskDefinition, "taskDefinition must not be null"); Assert.notNull(dataSourceProperties, "dataSourceProperties must not be null"); TaskDefinition.TaskDefinitionBuilder builder = TaskDefinition.TaskDefinitionBuilder.from(taskDefinition); builder.setProperty("spring.datasource.url", dataSourceProperties.getUrl()); builder.setProperty("spring.datasource.username", dataSourceProperties.getUsername()); // password may be empty if (StringUtils.hasText(dataSourceProperties.getPassword())) { builder.setProperty("spring.datasource.password", dataSourceProperties.getPassword()); } builder.setProperty("spring.datasource.driverClassName", dataSourceProperties.getDriverClassName()); return builder.build(); }
/** * Redacts sensitive property values in a task. * * @param taskDefinition the task definition to sanitize * @return Task definition text that has sensitive data redacted. */ public String sanitizeTaskDsl(TaskDefinition taskDefinition) { TaskDefinition sanitizedTaskDefinition = TaskDefinition.TaskDefinitionBuilder.from(taskDefinition) .setProperties(this.sanitizeProperties(taskDefinition.getProperties())) .build(); return this.taskDslConverter.toDsl(sanitizedTaskDefinition); }
/** * Create a new builder that is initialized with properties of the given * definition. Useful for "mutating" a definition by building a slightly different * copy. * * @param definition the DataFlowAppDefinition to use when creating the builder * @return a task definition builder */ public static TaskDefinitionBuilder from(DataFlowAppDefinition definition) { TaskDefinitionBuilder builder = new TaskDefinitionBuilder(); builder.setRegisteredAppName(definition.getRegisteredAppName()).setLabel(definition.getName()) .addProperties(definition.getProperties()); return builder; }
/** * Redacts sensitive property values in a task. * * @param taskDefinition the task definition to sanitize * @return Task definition text that has sensitive data redacted. */ public String sanitizeTaskDsl(TaskDefinition taskDefinition) { TaskDefinition sanitizedTaskDefinition = TaskDefinition.TaskDefinitionBuilder.from(taskDefinition) .setProperties(this.sanitizeProperties(taskDefinition.getProperties())) .build(); return this.taskDslConverter.toDsl(sanitizedTaskDefinition); }