Search in sources :

Example 41 with RemoteProcessGroupDTO

use of org.apache.nifi.web.api.dto.RemoteProcessGroupDTO in project kylo by Teradata.

the class NiFiRemoteProcessGroupsRestClientV1 method enable.

@Nonnull
@Override
public Optional<RemoteProcessGroupDTO> enable(String remoteProcessGroupId) {
    Optional<RemoteProcessGroupDTO> remoteProcessGroupDTO = findById(remoteProcessGroupId);
    if (remoteProcessGroupDTO.isPresent()) {
        if (!remoteProcessGroupDTO.get().isTransmitting()) {
            RemoteProcessGroupDTO updatedGroup = new RemoteProcessGroupDTO();
            updatedGroup.setTransmitting(true);
            updatedGroup.setId(remoteProcessGroupId);
            return Optional.of(update(updatedGroup));
        }
        return remoteProcessGroupDTO;
    } else {
        return Optional.empty();
    }
}
Also used : RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) Nonnull(javax.annotation.Nonnull)

Example 42 with RemoteProcessGroupDTO

use of org.apache.nifi.web.api.dto.RemoteProcessGroupDTO 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)

Example 43 with RemoteProcessGroupDTO

use of org.apache.nifi.web.api.dto.RemoteProcessGroupDTO in project nifi-minifi by apache.

the class RemoteProcessGroupSchemaTest method setup.

@Before
public void setup() {
    remoteInputPortSchemaTest.setup();
    dto = new RemoteProcessGroupDTO();
    dto.setId(testId);
    dto.setName(testName);
    dto.setTargetUri(testUrl);
    RemoteProcessGroupContentsDTO contents = new RemoteProcessGroupContentsDTO();
    contents.setInputPorts(Arrays.asList(remoteInputPortSchemaTest.dto).stream().collect(Collectors.toSet()));
    dto.setContents(contents);
    dto.setComments(testComment);
    dto.setCommunicationsTimeout(testTimeout);
    dto.setYieldDuration(testYieldPeriod);
    dto.setTransportProtocol(transportProtocol);
    map = new HashMap<>();
    map.put(CommonPropertyKeys.ID_KEY, testId);
    map.put(CommonPropertyKeys.NAME_KEY, testName);
    map.put(RemoteProcessGroupSchema.URL_KEY, testUrl);
    map.put(CommonPropertyKeys.INPUT_PORTS_KEY, new ArrayList<>(Arrays.asList(remoteInputPortSchemaTest.map)));
    map.put(CommonPropertyKeys.COMMENT_KEY, testComment);
    map.put(RemoteProcessGroupSchema.TIMEOUT_KEY, testTimeout);
    map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, testYieldPeriod);
    map.put(RemoteProcessGroupSchema.TRANSPORT_PROTOCOL_KEY, transportProtocol);
}
Also used : RemoteProcessGroupContentsDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) Before(org.junit.Before)

Aggregations

RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)43 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)22 Action (org.apache.nifi.action.Action)17 Test (org.junit.Test)15 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)13 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)12 HashSet (java.util.HashSet)11 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)11 PortDTO (org.apache.nifi.web.api.dto.PortDTO)11 Map (java.util.Map)10 RemoteProcessGroupPortDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)9 FunnelDTO (org.apache.nifi.web.api.dto.FunnelDTO)8 LabelDTO (org.apache.nifi.web.api.dto.LabelDTO)8 List (java.util.List)7 FlowSnippetDTO (org.apache.nifi.web.api.dto.FlowSnippetDTO)7 Collectors (java.util.stream.Collectors)6 ConnectableDTO (org.apache.nifi.web.api.dto.ConnectableDTO)6 ControllerServiceDTO (org.apache.nifi.web.api.dto.ControllerServiceDTO)6