Search in sources :

Example 1 with PositionDTO

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

the class AlignProcessGroupComponents method alignPorts.

private void alignPorts(Collection<PortDTO> ports, AbstractRenderer renderer) {
    ports.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().updateInputPort(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 2 with PositionDTO

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

the class ColumnRenderer method getNextPosition.

@Override
public PositionDTO getNextPosition(PositionDTO lastPosition) {
    Double yValue = getLastPosition() == null ? layoutGroup.getTopY() : getLastPosition().getY() + (getHeight() / itemCount);
    // force the last one to go the the bottom
    if (alignLastToBottom && getStoredPositionCounter() == (itemCount - 1)) {
        yValue = layoutGroup.getBottomY();
    }
    PositionDTO newPosition = new PositionDTO();
    newPosition.setX(xValue);
    newPosition.setY(yValue);
    storePosition(LOCATION_KEY, newPosition);
    return newPosition;
}
Also used : PositionDTO(org.apache.nifi.web.api.dto.PositionDTO)

Example 3 with PositionDTO

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

the class SingleRowRightRenderer method getNextPosition.

@Override
public PositionDTO getNextPosition(PositionDTO lastPosition) {
    if (this.xSpace == null) {
        this.xSpace = alignmentConfig.getProcessGroupWidth() + alignmentConfig.getProcessGroupPaddingLeftRight();
    }
    PositionDTO newPosition = new PositionDTO();
    newPosition.setX(alignmentConfig.getCenterX() - (alignmentConfig.getProcessGroupWidth() / 2));
    newPosition.setY(yValue);
    if (lastPosition == null) {
        storePosition(newPosition);
    } else {
        // place right
        PositionDTO rightPosition = getLastPosition();
        newPosition.setX((rightPosition != null ? rightPosition.getX() : 0) + xSpace);
        storePosition(newPosition);
    }
    return newPosition;
}
Also used : PositionDTO(org.apache.nifi.web.api.dto.PositionDTO)

Example 4 with PositionDTO

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

the class TopBottomRowsRenderer method getNextPosition.

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

Example 5 with PositionDTO

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

the class TopBottomRowsRenderer method getNextPosition.

@Override
public PositionDTO getNextPosition(PositionDTO lastPosition) {
    PositionDTO newPosition = null;
    Location currentLocation = null;
    Location lastLocation = getLastLocationKey() != null ? Location.valueOf(getLastLocationKey()) : null;
    if (lastLocation == null) {
        currentLocation = Location.TOP_LEFT;
    } else {
        currentLocation = lastLocation.getNext();
    }
    PositionDTO lastPositionAtLocation = getLastPosition(currentLocation);
    if (lastPositionAtLocation != null) {
        newPosition = getNextPosition(currentLocation, lastPositionAtLocation);
    } else {
        newPosition = getInitialPosition(currentLocation);
    }
    storePosition(currentLocation, newPosition);
    return newPosition;
}
Also used : PositionDTO(org.apache.nifi.web.api.dto.PositionDTO)

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