/** * Scrubs the template prior to persisting in order to remove fields that shouldn't be included or are unnecessary. * * @param templateDto template */ public static void scrubTemplate(final TemplateDTO templateDto) { scrubSnippet(templateDto.getSnippet()); }
@Override public TemplateDTO importTemplate(final TemplateDTO templateDTO, final String groupId, final Optional<String> idGenerationSeed) { // ensure id is set final String uuid = idGenerationSeed.isPresent() ? (UUID.nameUUIDFromBytes(idGenerationSeed.get().getBytes(StandardCharsets.UTF_8))).toString() : UUID.randomUUID().toString(); templateDTO.setId(uuid); // mark the timestamp templateDTO.setTimestamp(new Date()); // ensure default values are populated ensureDefaultPropertyValuesArePopulated(templateDTO.getSnippet()); // import the template final Template template = templateDAO.importTemplate(templateDTO, groupId); // save the flow controllerFacade.save(); // return the template dto return dtoFactory.createTemplateDTO(template); }
@Override public TemplateDTO exportTemplate(final String id) { final Template template = templateDAO.getTemplate(id); final TemplateDTO templateDetails = template.getDetails(); final TemplateDTO templateDTO = dtoFactory.createTemplateDTO(template); templateDTO.setSnippet(dtoFactory.copySnippetContents(templateDetails.getSnippet())); return templateDTO; }
if (requestTemplateEntity == null || requestTemplateEntity.getTemplate() == null || requestTemplateEntity.getTemplate().getSnippet() == null) { throw new IllegalArgumentException("Template details must be specified.");
final FlowSnippetDTO requestTemplateContents = requestedTemplate.getSnippet();
public static ConfigSchema transformTemplateToSchema(InputStream source) throws JAXBException, IOException { try { TemplateDTO templateDTO = (TemplateDTO) JAXBContext.newInstance(TemplateDTO.class).createUnmarshaller().unmarshal(source); FlowSnippetDTOEnricher enricher = new FlowSnippetDTOEnricher(); enricher.enrich(templateDTO.getSnippet(), templateDTO.getEncodingVersion()); ConfigSchema configSchema = new ConfigSchemaFunction().apply(templateDTO); return configSchema; } finally { source.close(); } }
public static ConfigSchema transformTemplateToSchema(InputStream source) throws JAXBException, IOException { try { TemplateDTO templateDTO = (TemplateDTO) JAXBContext.newInstance(TemplateDTO.class).createUnmarshaller().unmarshal(source); FlowSnippetDTOEnricher enricher = new FlowSnippetDTOEnricher(); enricher.enrich(templateDTO.getSnippet(), templateDTO.getEncodingVersion()); ConfigSchema configSchema = new ConfigSchemaFunction().apply(templateDTO); return configSchema; } finally { source.close(); } }
@Override public ConfigSchema apply(TemplateDTO templateDTO) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY, flowControllerSchemaFunction.apply(templateDTO).toMap()); FlowSnippetDTO snippet = templateDTO.getSnippet(); addSnippet(map, snippet); return new ConfigSchema(map); }
@Override public ConfigSchema apply(TemplateDTO templateDTO) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.FLOW_CONTROLLER_PROPS_KEY, flowControllerSchemaFunction.apply(templateDTO).toMap()); FlowSnippetDTO snippet = templateDTO.getSnippet(); addSnippet(map, snippet); return new ConfigSchema(map); }