Search in sources :

Example 6 with NiFiPropertyDescriptor

use of com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor in project kylo by Teradata.

the class NifiRemoteProcessGroupUtil method remoteProcessGroupProperties.

public static List<NifiProperty> remoteProcessGroupProperties(RemoteProcessGroupDTO remoteProcessGroupDTO) {
    List<NifiProperty> list = Arrays.stream(BeanUtils.getPropertyDescriptors(RemoteProcessGroupDTO.class)).filter(propertyDescriptor -> remoteProcessGroupPropertiesMap.containsKey(propertyDescriptor.getName())).map(propertyDescriptor -> {
        NifiProperty property = new NifiProperty(remoteProcessGroupDTO.getParentGroupId(), remoteProcessGroupDTO.getId(), propertyDescriptor.getName(), getPropertyAsString(remoteProcessGroupDTO, propertyDescriptor));
        property.setProcessorType(NifiConstants.NIFI_COMPONENT_TYPE.REMOTE_PROCESS_GROUP.name());
        property.setProcessGroupId(remoteProcessGroupDTO.getParentGroupId());
        property.setProcessorName(remoteProcessGroupDTO.getName() != null ? remoteProcessGroupDTO.getName() : remoteProcessGroupDTO.getTargetUri());
        property.setProcessGroupName(NifiConstants.NIFI_COMPONENT_TYPE.REMOTE_PROCESS_GROUP.name());
        NiFiPropertyDescriptor propertyDescriptorDTO = remoteProcessGroupPropertiesMap.get(propertyDescriptor.getName());
        property.setPropertyDescriptor(propertyDescriptorDTO);
        return property;
    }).collect(Collectors.toList());
    // add in the connected input port name as a hidden descriptor
    if (remoteProcessGroupDTO.getContents() != null) {
        NifiProperty connectedRemoteInputPort = remoteProcessGroupDTO.getContents().getInputPorts().stream().filter(port -> port.isConnected()).map(port -> {
            NifiProperty property = new NifiProperty(remoteProcessGroupDTO.getParentGroupId(), remoteProcessGroupDTO.getId(), "Remote Input Port", port.getName());
            property.setProcessorType(NifiConstants.NIFI_COMPONENT_TYPE.REMOTE_PROCESS_GROUP.name());
            property.setProcessGroupId(remoteProcessGroupDTO.getParentGroupId());
            property.setProcessorName(remoteProcessGroupDTO.getName() != null ? remoteProcessGroupDTO.getName() : remoteProcessGroupDTO.getTargetUri());
            property.setProcessGroupName(NifiConstants.NIFI_COMPONENT_TYPE.REMOTE_PROCESS_GROUP.name());
            property.setPropertyDescriptor(hiddenOnlyPropertyDescriptor("Remote Input Port", port.getName()));
            property.setHidden(true);
            return property;
        }).findFirst().orElse(null);
        if (connectedRemoteInputPort != null) {
            list.add(connectedRemoteInputPort);
        }
    }
    return list;
}
Also used : RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) Arrays(java.util.Arrays) PropertyUtils(org.apache.commons.beanutils.PropertyUtils) WordUtils(org.apache.commons.lang3.text.WordUtils) NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty) CaseFormat(com.google.common.base.CaseFormat) NiFiPropertyDescriptor(com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) NiFiRemoteProcessGroup(com.thinkbiganalytics.nifi.rest.model.NiFiRemoteProcessGroup) List(java.util.List) Lists(com.google.common.collect.Lists) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) TemplateDTO(org.apache.nifi.web.api.dto.TemplateDTO) PropertyDescriptor(java.beans.PropertyDescriptor) Map(java.util.Map) Collector(java.util.stream.Collector) Nullable(javax.annotation.Nullable) BeanUtils(org.springframework.beans.BeanUtils) NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty) NiFiPropertyDescriptor(com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor)

Aggregations

NiFiPropertyDescriptor (com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor)6 NifiProperty (com.thinkbiganalytics.nifi.rest.model.NifiProperty)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 CaseFormat (com.google.common.base.CaseFormat)1 Lists (com.google.common.collect.Lists)1 NiFiAllowableValue (com.thinkbiganalytics.nifi.rest.model.NiFiAllowableValue)1 NiFiRemoteProcessGroup (com.thinkbiganalytics.nifi.rest.model.NiFiRemoteProcessGroup)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Function (java.util.function.Function)1 Collector (java.util.stream.Collector)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 PropertyUtils (org.apache.commons.beanutils.PropertyUtils)1 WordUtils (org.apache.commons.lang3.text.WordUtils)1 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)1