public LabelDTO copy(final LabelDTO original) { final LabelDTO copy = new LabelDTO(); copy.setId(original.getId()); copy.setParentGroupId(original.getParentGroupId()); copy.setLabel(original.getLabel()); copy.setStyle(copy(original.getStyle())); copy.setPosition(original.getPosition()); copy.setWidth(original.getWidth()); copy.setHeight(original.getHeight()); copy.setVersionedComponentId(original.getVersionedComponentId()); return copy; }
@Override public Label updateLabel(LabelDTO labelDTO) { // get the label being updated Label label = locateLabel(labelDTO.getId()); // update the label state if (labelDTO.getPosition() != null) { label.setPosition(new Position(labelDTO.getPosition().getX(), labelDTO.getPosition().getY())); } if (labelDTO.getStyle() != null) { label.setStyle(labelDTO.getStyle()); } if (labelDTO.getLabel() != null) { label.setValue(labelDTO.getLabel()); } if (labelDTO.getWidth() != null && labelDTO.getHeight() != null) { label.setSize(new Size(labelDTO.getWidth(), labelDTO.getHeight())); } label.getProcessGroup().onComponentModified(); return label; }
public static LabelDTO getLabel(final Element element) { final LabelDTO dto = new LabelDTO(); dto.setId(getString(element, "id")); dto.setVersionedComponentId(getString(element, "versionedComponentId")); dto.setLabel(getString(element, "value")); dto.setPosition(getPosition(DomUtils.getChild(element, "position"))); final Size size = getSize(DomUtils.getChild(element, "size")); dto.setWidth(size.getWidth()); dto.setHeight(size.getHeight()); dto.setStyle(getStyle(DomUtils.getChild(element, "styles"))); return dto; }
public LabelEntity createLabelEntity(final LabelDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) { final LabelEntity entity = new LabelEntity(); entity.setRevision(revision); if (dto != null) { entity.setPermissions(permissions); entity.setId(dto.getId()); entity.setPosition(dto.getPosition()); final DimensionsDTO dimensions = new DimensionsDTO(); dimensions.setHeight(dto.getHeight()); dimensions.setWidth(dto.getWidth()); entity.setDimensions(dimensions); if (permissions != null && permissions.getCanRead()) { entity.setComponent(dto); } } return entity; }
if (requestLabelEntity.getComponent().getId() != null) { throw new IllegalArgumentException("Label ID cannot be specified."); final PositionDTO proposedPosition = requestLabelEntity.getComponent().getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { if (requestLabelEntity.getComponent().getParentGroupId() != null && !groupId.equals(requestLabelEntity.getComponent().getParentGroupId())) { throw new IllegalArgumentException(String.format("If specified, the parent process group id %s must be the same as specified in the URI %s", requestLabelEntity.getComponent().getParentGroupId(), groupId)); requestLabelEntity.getComponent().setParentGroupId(groupId); labelEntity -> { labelEntity.getComponent().setId(generateUuid()); final Revision revision = getRevision(labelEntity, labelEntity.getComponent().getId()); final LabelEntity entity = serviceFacade.createLabel(revision, groupId, labelEntity.getComponent()); labelResource.populateRemainingLabelEntityContent(entity);
for (final LabelDTO labelDTO : snippetContents.getLabels()) { final LabelDTO label = dtoFactory.copy(labelDTO); label.setId(generateId(labelDTO.getId(), idGenerationSeed, isCopy)); label.setParentGroupId(groupId); labels.add(label); ResourceFactory.getComponentResource(ResourceType.Label, labelDTO.getId(), labelDTO.getLabel()), ResourceFactory.getComponentResource(ResourceType.Label, label.getId(), label.getLabel()), idGenerationSeed);
if (!id.equals(requestLabelDTO.getId())) { throw new IllegalArgumentException(String.format("The label id (%s) in the request body does not equal the " + "label id of the requested resource (%s).", requestLabelDTO.getId(), id)); final PositionDTO proposedPosition = requestLabelDTO.getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) {
.forEach(id -> identifiers.add(id)); snippet.getLabels().stream() .map(label -> label.getId()) .forEach(id -> identifiers.add(id));
@Override public Label createLabel(String groupId, LabelDTO labelDTO) { if (labelDTO.getParentGroupId() != null && !flowController.getFlowManager().areGroupsSame(groupId, labelDTO.getParentGroupId())) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Label is being added."); } // get the desired group ProcessGroup group = locateProcessGroup(flowController, groupId); // create the label Label label = flowController.getFlowManager().createLabel(labelDTO.getId(), labelDTO.getLabel()); if (labelDTO.getPosition() != null) { label.setPosition(new Position(labelDTO.getPosition().getX(), labelDTO.getPosition().getY())); } if (labelDTO.getWidth() != null && labelDTO.getHeight() != null) { label.setSize(new Size(labelDTO.getWidth(), labelDTO.getHeight())); } label.setStyle(labelDTO.getStyle()); // add the label group.addLabel(label); return label; }
/** * Creates a LabelDTO from the specified Label. * * @param label label * @return dto */ public LabelDTO createLabelDto(final Label label) { if (label == null) { return null; } final LabelDTO dto = new LabelDTO(); dto.setId(label.getIdentifier()); dto.setPosition(createPositionDto(label.getPosition())); dto.setStyle(label.getStyle()); dto.setHeight(label.getSize().getHeight()); dto.setWidth(label.getSize().getWidth()); dto.setLabel(label.getValue()); dto.setParentGroupId(label.getProcessGroup().getIdentifier()); dto.setVersionedComponentId(label.getVersionedComponentId().orElse(null)); return dto; }
@Override public LabelEntity createLabel(final Revision revision, final String groupId, final LabelDTO labelDTO) { final RevisionUpdate<LabelDTO> snapshot = createComponent( revision, labelDTO, () -> labelDAO.createLabel(groupId, labelDTO), label -> dtoFactory.createLabelDto(label)); final Label label = labelDAO.getLabel(labelDTO.getId()); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(label); return entityFactory.createLabelEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions); }
for (final Element labelElement : labelNodeList) { final LabelDTO labelDTO = FlowFromDOMFactory.getLabel(labelElement); final Label label = flowManager.createLabel(labelDTO.getId(), labelDTO.getLabel()); label.setStyle(labelDTO.getStyle()); label.setPosition(new Position(labelDTO.getPosition().getX(), labelDTO.getPosition().getY())); label.setVersionedComponentId(labelDTO.getVersionedComponentId()); if (labelDTO.getWidth() != null && labelDTO.getHeight() != null) { label.setSize(new Size(labelDTO.getWidth(), labelDTO.getHeight()));
@Override public LabelEntity updateLabel(final Revision revision, final LabelDTO labelDTO) { final Label labelNode = labelDAO.getLabel(labelDTO.getId()); final RevisionUpdate<LabelDTO> snapshot = updateComponent(revision, labelNode, () -> labelDAO.updateLabel(labelDTO), label -> dtoFactory.createLabelDto(label)); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(labelNode); return entityFactory.createLabelEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions); }
for (final Element labelElement : labelNodeList) { final LabelDTO labelDTO = FlowFromDOMFactory.getLabel(labelElement); final Label label = flowManager.createLabel(labelDTO.getId(), labelDTO.getLabel()); label.setVersionedComponentId(labelDTO.getVersionedComponentId()); label.setStyle(labelDTO.getStyle()); label.setPosition(toPosition(labelDTO.getPosition())); label.setSize(new Size(labelDTO.getWidth(), labelDTO.getHeight())); processGroup.addLabel(label);
final Label label = group.getLabel(snippetLabel.getId());
final Label label = flowManager.createLabel(labelDTO.getId(), labelDTO.getLabel()); label.setPosition(toPosition(labelDTO.getPosition())); if (labelDTO.getWidth() != null && labelDTO.getHeight() != null) { label.setSize(new Size(labelDTO.getWidth(), labelDTO.getHeight())); label.setStyle(labelDTO.getStyle()); if (!topLevel) { label.setVersionedComponentId(labelDTO.getVersionedComponentId());