private void removeInstanceIdentifierIfNecessary(Set<? extends ComponentDTO> componentDtos) { if (this.newTemplate) { for (ComponentDTO componentDto : componentDtos) { UUID id = new UUID(this.generateMsb(componentDto.getId()), LSB); componentDto.setId(id.toString()); id = new UUID(this.generateMsb(componentDto.getParentGroupId()), LSB); componentDto.setParentGroupId(id.toString()); if (componentDto instanceof ControllerServiceDTO) { ControllerServiceDTO csDTO = (ControllerServiceDTO) componentDto;
/** * Builds a mapping of components to PositionDTO's. * * @param components components * @return component and position map */ private static Map<ComponentDTO, PositionDTO> getPositionLookup(Collection<ComponentDTO> components) { final Map<ComponentDTO, PositionDTO> positionLookup = new HashMap<>(); // determine the position for each component for (final ComponentDTO component : components) { positionLookup.put(component, new PositionDTO(component.getPosition().getX(), component.getPosition().getY())); } return positionLookup; }
/** * Applies the updated positions to the corresponding components. * * @param componentPositionLookup lookup * @param connectionPositionLookup lookup */ private static void applyUpdatedPositions(final Map<ComponentDTO, PositionDTO> componentPositionLookup, final Map<ConnectionDTO, List<PositionDTO>> connectionPositionLookup) { for (final Map.Entry<ComponentDTO, PositionDTO> entry : componentPositionLookup.entrySet()) { final ComponentDTO component = entry.getKey(); final PositionDTO position = entry.getValue(); component.setPosition(position); } for (final Map.Entry<ConnectionDTO, List<PositionDTO>> entry : connectionPositionLookup.entrySet()) { final ConnectionDTO connection = entry.getKey(); final List<PositionDTO> bends = entry.getValue(); connection.setBends(bends); } }
smallestX = Math.min(smallestX, component.getPosition().getX()); smallestY = Math.min(smallestY, component.getPosition().getY()); component.getPosition().setX(component.getPosition().getX() - smallestX); component.getPosition().setY(component.getPosition().getY() - smallestY);
@Override public String toString() { return this.getClass().getSimpleName() + ":" + this.getId(); } }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj.getClass() != getClass()) { return false; } return id.equals(((ComponentDTO) obj).getId()); }