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());
});
}
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);
}
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;
}
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;
}
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());
}
Aggregations