Search in sources :

Example 31 with PositionDTO

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

the class AlignProcessGroupComponents method alignOutputPorts.

private void alignOutputPorts(ProcessGroupToOutputPort layoutGroup, AbstractRenderer renderer) {
    layoutGroup.getPorts().values().stream().forEach(port -> {
        PortDTO positionPort = new PortDTO();
        positionPort.setId(port.getId());
        PositionDTO lastPosition = renderer.getLastPosition();
        PositionDTO newPosition = renderer.getNextPosition(lastPosition);
        positionPort.setPosition(newPosition);
        niFiRestClient.ports().updateOutputPort(parentProcessGroupId, positionPort);
        log.debug("Aligned Port {} at {},{}", port.getName(), positionPort.getPosition().getX(), positionPort.getPosition().getY());
    });
}
Also used : PortDTO(org.apache.nifi.web.api.dto.PortDTO) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO)

Example 32 with PositionDTO

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

the class ColumnRenderer method storePosition.

public void storePosition(Double x, Double y) {
    PositionDTO positionDTO = getLastLocationPositions().get(LOCATION_KEY);
    if (positionDTO == null) {
        positionDTO = new PositionDTO();
    }
    positionDTO.setX(x);
    positionDTO.setY(y);
    storePosition(positionDTO);
}
Also used : PositionDTO(org.apache.nifi.web.api.dto.PositionDTO)

Example 33 with PositionDTO

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

the class SingleRowRenderer method getNextPosition.

@Override
public PositionDTO getNextPosition(PositionDTO lastPosition) {
    PositionDTO newPosition = new PositionDTO();
    newPosition.setX(alignmentConfig.getCenterX() - (alignmentConfig.getProcessGroupWidth() / 2));
    newPosition.setY(yValue);
    Location currentLocation = null;
    Location lastLocation = getLastLocationKey() != null ? Location.valueOf(getLastLocationKey()) : null;
    if (lastLocation == null) {
        currentLocation = Location.CENTER;
        storePosition(currentLocation, newPosition);
        // newPosition.setX(alignmentConfig.getCenterX());
        storePosition(Location.CENTER, newPosition);
    } else {
        if (lastLocation.equals(Location.LEFT)) {
            currentLocation = Location.RIGHT;
            // place right
            PositionDTO rightPosition = getLastPosition(Location.RIGHT);
            if (rightPosition == null) {
                rightPosition = getLastPosition(Location.CENTER);
            }
            newPosition.setX((rightPosition != null ? rightPosition.getX() : 0) + alignmentConfig.getProcessGroupWidth() + alignmentConfig.getProcessGroupPaddingLeftRight());
            storePosition(Location.RIGHT, newPosition);
        } else {
            currentLocation = Location.LEFT;
            // place left
            PositionDTO leftPosition = getLastPosition(Location.LEFT);
            if (leftPosition == null) {
                leftPosition = getLastPosition(Location.CENTER);
            }
            newPosition.setX((leftPosition != null ? leftPosition.getX() : 0) - (alignmentConfig.getProcessGroupWidth() + alignmentConfig.getProcessGroupPaddingLeftRight()));
            storePosition(Location.LEFT, newPosition);
        }
    }
    return newPosition;
}
Also used : PositionDTO(org.apache.nifi.web.api.dto.PositionDTO)

Example 34 with PositionDTO

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

the class TopBottomRowsRenderer method getInitialPosition.

private PositionDTO getInitialPosition(Location location) {
    Double groupPlusPadding = new Double(alignmentConfig.getProcessGroupWidth() + alignmentConfig.getProcessGroupPaddingLeftRight());
    PositionDTO dto = new PositionDTO();
    dto.setX(centerX + groupPlusPadding);
    dto.setY(layoutGroup.getBottomY());
    switch(location) {
        case BOTTOM_RIGHT:
            dto.setX(centerX + groupPlusPadding);
            dto.setY(layoutGroup.getBottomY());
            break;
        case BOTTOM_LEFT:
            dto.setX(centerX - groupPlusPadding);
            dto.setY(layoutGroup.getBottomY());
            break;
        case TOP_RIGHT:
            dto.setX(centerX + groupPlusPadding);
            dto.setY(layoutGroup.getTopY());
            break;
        case TOP_LEFT:
            dto.setX(centerX - groupPlusPadding);
            dto.setY(layoutGroup.getTopY());
            break;
        default:
            break;
    }
    return dto;
}
Also used : PositionDTO(org.apache.nifi.web.api.dto.PositionDTO)

Example 35 with PositionDTO

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

the class TestFlowController method testInstantiateSnippetWithProcessor.

@Test
public void testInstantiateSnippetWithProcessor() throws ProcessorInstantiationException {
    final String id = UUID.randomUUID().toString();
    final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
    final ProcessorNode processorNode = controller.createProcessor(DummyProcessor.class.getName(), id, coordinate);
    // create a processor dto
    final ProcessorDTO processorDTO = new ProcessorDTO();
    // use a different id here
    processorDTO.setId(UUID.randomUUID().toString());
    processorDTO.setPosition(new PositionDTO(new Double(0), new Double(0)));
    processorDTO.setStyle(processorNode.getStyle());
    processorDTO.setParentGroupId("1234");
    processorDTO.setInputRequirement(processorNode.getInputRequirement().name());
    processorDTO.setPersistsState(processorNode.getProcessor().getClass().isAnnotationPresent(Stateful.class));
    processorDTO.setRestricted(processorNode.isRestricted());
    processorDTO.setExtensionMissing(processorNode.isExtensionMissing());
    processorDTO.setType(processorNode.getCanonicalClassName());
    processorDTO.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion()));
    processorDTO.setName(processorNode.getName());
    processorDTO.setState(processorNode.getScheduledState().toString());
    processorDTO.setRelationships(new ArrayList<>());
    processorDTO.setDescription("description");
    processorDTO.setSupportsParallelProcessing(!processorNode.isTriggeredSerially());
    processorDTO.setSupportsEventDriven(processorNode.isEventDrivenSupported());
    processorDTO.setSupportsBatching(processorNode.isSessionBatchingSupported());
    ProcessorConfigDTO configDTO = new ProcessorConfigDTO();
    configDTO.setSchedulingPeriod(processorNode.getSchedulingPeriod());
    configDTO.setPenaltyDuration(processorNode.getPenalizationPeriod());
    configDTO.setYieldDuration(processorNode.getYieldPeriod());
    configDTO.setRunDurationMillis(processorNode.getRunDuration(TimeUnit.MILLISECONDS));
    configDTO.setConcurrentlySchedulableTaskCount(processorNode.getMaxConcurrentTasks());
    configDTO.setLossTolerant(processorNode.isLossTolerant());
    configDTO.setComments(processorNode.getComments());
    configDTO.setBulletinLevel(processorNode.getBulletinLevel().name());
    configDTO.setSchedulingStrategy(processorNode.getSchedulingStrategy().name());
    configDTO.setExecutionNode(processorNode.getExecutionNode().name());
    configDTO.setAnnotationData(processorNode.getAnnotationData());
    processorDTO.setConfig(configDTO);
    // create the snippet with the processor
    final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO();
    flowSnippetDTO.setProcessors(Collections.singleton(processorDTO));
    // instantiate the snippet
    assertEquals(0, controller.getRootGroup().getProcessors().size());
    controller.instantiateSnippet(controller.getRootGroup(), flowSnippetDTO);
    assertEquals(1, controller.getRootGroup().getProcessors().size());
}
Also used : Stateful(org.apache.nifi.annotation.behavior.Stateful) ProcessorConfigDTO(org.apache.nifi.web.api.dto.ProcessorConfigDTO) FlowSnippetDTO(org.apache.nifi.web.api.dto.FlowSnippetDTO) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) DummyProcessor(org.apache.nifi.controller.service.mock.DummyProcessor) BundleDTO(org.apache.nifi.web.api.dto.BundleDTO) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO) Test(org.junit.Test)

Aggregations

PositionDTO (org.apache.nifi.web.api.dto.PositionDTO)48 ApiOperation (io.swagger.annotations.ApiOperation)16 ApiResponses (io.swagger.annotations.ApiResponses)16 Consumes (javax.ws.rs.Consumes)16 Path (javax.ws.rs.Path)16 Produces (javax.ws.rs.Produces)16 Revision (org.apache.nifi.web.Revision)16 Authorizable (org.apache.nifi.authorization.resource.Authorizable)15 ArrayList (java.util.ArrayList)10 ComponentAuthorizable (org.apache.nifi.authorization.ComponentAuthorizable)10 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)10 ProcessGroupAuthorizable (org.apache.nifi.authorization.ProcessGroupAuthorizable)9 SnippetAuthorizable (org.apache.nifi.authorization.SnippetAuthorizable)9 TemplateContentsAuthorizable (org.apache.nifi.authorization.TemplateContentsAuthorizable)9 POST (javax.ws.rs.POST)8 PUT (javax.ws.rs.PUT)8 PortDTO (org.apache.nifi.web.api.dto.PortDTO)8 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)8 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)7 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)7