Java Code Examples for org.apache.nifi.web.api.dto.TemplateDTO#setTimestamp()

The following examples show how to use org.apache.nifi.web.api.dto.TemplateDTO#setTimestamp() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardNiFiServiceFacade.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: StandardNiFiServiceFacade.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public TemplateDTO createTemplate(final String name, final String description, final String snippetId, final String groupId, final Optional<String> idGenerationSeed) {
    // get the specified snippet
    final Snippet snippet = snippetDAO.getSnippet(snippetId);

    // create the template
    final TemplateDTO templateDTO = new TemplateDTO();
    templateDTO.setName(name);
    templateDTO.setDescription(description);
    templateDTO.setTimestamp(new Date());
    templateDTO.setSnippet(snippetUtils.populateFlowSnippet(snippet, true, true, true));
    templateDTO.setEncodingVersion(TemplateDTO.MAX_ENCODING_VERSION);

    // set the id based on the specified seed
    final String uuid = idGenerationSeed.isPresent() ? (UUID.nameUUIDFromBytes(idGenerationSeed.get().getBytes(StandardCharsets.UTF_8))).toString() : UUID.randomUUID().toString();
    templateDTO.setId(uuid);

    // create the template
    final Template template = templateDAO.createTemplate(templateDTO, groupId);

    // drop the snippet
    snippetDAO.dropSnippet(snippetId);

    // save the flow
    controllerFacade.save();

    return dtoFactory.createTemplateDTO(template);
}