Search in sources :

Example 1 with NiFiPropertyDescriptor

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

the class NifiRemoteProcessGroupUtil method hiddenOnlyPropertyDescriptor.

private static NiFiPropertyDescriptor hiddenOnlyPropertyDescriptor(String key, String label) {
    NiFiPropertyDescriptor descriptorDTO = new NiFiPropertyDescriptor();
    descriptorDTO.setName(key);
    descriptorDTO.setDisplayName(label);
    descriptorDTO.setHidden(true);
    return descriptorDTO;
}
Also used : NiFiPropertyDescriptor(com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor)

Example 2 with NiFiPropertyDescriptor

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

the class NifiRemoteProcessGroupUtil method propertyDescriptorDTO.

private static NiFiPropertyDescriptor propertyDescriptorDTO(String key, String label, boolean required, boolean sensitive) {
    NiFiPropertyDescriptor descriptorDTO = new NiFiPropertyDescriptor();
    descriptorDTO.setName(key);
    descriptorDTO.setDisplayName(label);
    descriptorDTO.setRequired(required);
    descriptorDTO.setSensitive(sensitive);
    return descriptorDTO;
}
Also used : NiFiPropertyDescriptor(com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor)

Example 3 with NiFiPropertyDescriptor

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

the class NifiPropertyUtil method getPropertiesForProcessor.

/**
 * Return a list of properties on a gi en processor
 *
 * @param processGroup                the processors group
 * @param processor                   the processor
 * @param propertyDescriptorTransform the transform utility
 * @return the list of properties on the processor
 */
public static List<NifiProperty> getPropertiesForProcessor(ProcessGroupDTO processGroup, ProcessorDTO processor, NiFiPropertyDescriptorTransform propertyDescriptorTransform) {
    List<NifiProperty> properties = new ArrayList<>();
    for (Map.Entry<String, String> entry : processor.getConfig().getProperties().entrySet()) {
        PropertyDescriptorDTO descriptorDTO = processor.getConfig().getDescriptors().get(entry.getKey());
        if (descriptorDTO != null) {
            final NiFiPropertyDescriptor propertyDescriptor = propertyDescriptorTransform.toNiFiPropertyDescriptor(processor.getConfig().getDescriptors().get(entry.getKey()));
            final NifiProperty property = new NifiProperty(processor.getParentGroupId(), processor.getId(), entry.getKey(), entry.getValue(), propertyDescriptor);
            property.setProcessGroupName(processGroup.getName());
            property.setProcessorName(processor.getName());
            property.setProcessorType(processor.getType());
            properties.add(property);
        }
    }
    return properties;
}
Also used : ArrayList(java.util.ArrayList) NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty) HashMap(java.util.HashMap) Map(java.util.Map) NiFiPropertyDescriptor(com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor) PropertyDescriptorDTO(org.apache.nifi.web.api.dto.PropertyDescriptorDTO)

Example 4 with NiFiPropertyDescriptor

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

the class NiFiPropertyDescriptorTransformV1 method toNiFiPropertyDescriptor.

@Nonnull
@Override
public NiFiPropertyDescriptor toNiFiPropertyDescriptor(@Nonnull final PropertyDescriptorDTO dto) {
    final NiFiPropertyDescriptor nifi = new NiFiPropertyDescriptor();
    nifi.setName(dto.getName());
    nifi.setDisplayName(dto.getDisplayName());
    nifi.setDescription(dto.getDescription());
    nifi.setDefaultValue(dto.getDefaultValue());
    nifi.setRequired(dto.isRequired());
    nifi.setSensitive(dto.isSensitive());
    nifi.setDynamic(dto.isDynamic());
    nifi.setSupportsEl(dto.getSupportsEl());
    nifi.setIdentifiesControllerService(dto.getIdentifiesControllerService());
    final List<AllowableValueEntity> allowableValues = dto.getAllowableValues();
    if (allowableValues != null) {
        nifi.setAllowableValues(allowableValues.stream().filter(allowableValueEntity -> allowableValueEntity.getAllowableValue() != null && allowableValueEntity.getAllowableValue().getValue() != null).map(AllowableValueEntity::getAllowableValue).map(this::toNiFiAllowableValue).collect(Collectors.toList()));
    }
    return nifi;
}
Also used : AllowableValueEntity(org.apache.nifi.web.api.entity.AllowableValueEntity) NiFiPropertyDescriptor(com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor) Nonnull(javax.annotation.Nonnull)

Example 5 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