Search in sources :

Example 1 with ComponentHistoryDTO

use of org.apache.nifi.web.api.dto.ComponentHistoryDTO in project nifi by apache.

the class StandardNiFiServiceFacade method getComponentHistory.

@Override
public ComponentHistoryDTO getComponentHistory(final String componentId) {
    final Map<String, PropertyHistoryDTO> propertyHistoryDtos = new LinkedHashMap<>();
    final Map<String, List<PreviousValue>> propertyHistory = auditService.getPreviousValues(componentId);
    for (final Map.Entry<String, List<PreviousValue>> entry : propertyHistory.entrySet()) {
        final List<PreviousValueDTO> previousValueDtos = new ArrayList<>();
        for (final PreviousValue previousValue : entry.getValue()) {
            final PreviousValueDTO dto = new PreviousValueDTO();
            dto.setPreviousValue(previousValue.getPreviousValue());
            dto.setTimestamp(previousValue.getTimestamp());
            dto.setUserIdentity(previousValue.getUserIdentity());
            previousValueDtos.add(dto);
        }
        if (!previousValueDtos.isEmpty()) {
            final PropertyHistoryDTO propertyHistoryDto = new PropertyHistoryDTO();
            propertyHistoryDto.setPreviousValues(previousValueDtos);
            propertyHistoryDtos.put(entry.getKey(), propertyHistoryDto);
        }
    }
    final ComponentHistoryDTO history = new ComponentHistoryDTO();
    history.setComponentId(componentId);
    history.setPropertyHistory(propertyHistoryDtos);
    return history;
}
Also used : PropertyHistoryDTO(org.apache.nifi.web.api.dto.PropertyHistoryDTO) ArrayList(java.util.ArrayList) PreviousValue(org.apache.nifi.history.PreviousValue) LinkedHashMap(java.util.LinkedHashMap) PreviousValueDTO(org.apache.nifi.web.api.dto.PreviousValueDTO) ComponentHistoryDTO(org.apache.nifi.web.api.dto.ComponentHistoryDTO) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) StateMap(org.apache.nifi.components.state.StateMap) HashMap(java.util.HashMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 StateMap (org.apache.nifi.components.state.StateMap)1 PreviousValue (org.apache.nifi.history.PreviousValue)1 ComponentHistoryDTO (org.apache.nifi.web.api.dto.ComponentHistoryDTO)1 PreviousValueDTO (org.apache.nifi.web.api.dto.PreviousValueDTO)1 PropertyHistoryDTO (org.apache.nifi.web.api.dto.PropertyHistoryDTO)1