use of org.eclipse.che.api.workspace.shared.stack.StackSource in project che by eclipse.
the class DtoConverter method asDto.
/** Convert {@link StackImpl} to {@link StackDto}. */
public static StackDto asDto(Stack stack) {
WorkspaceConfigDto workspaceConfigDto = null;
if (stack.getWorkspaceConfig() != null) {
workspaceConfigDto = asDto(stack.getWorkspaceConfig());
}
StackSourceDto stackSourceDto = null;
StackSource source = stack.getSource();
if (source != null) {
stackSourceDto = newDto(StackSourceDto.class).withType(source.getType()).withOrigin(source.getOrigin());
}
List<StackComponentDto> componentsDto = null;
if (stack.getComponents() != null) {
componentsDto = stack.getComponents().stream().map(component -> newDto(StackComponentDto.class).withName(component.getName()).withVersion(component.getVersion())).collect(toList());
}
return newDto(StackDto.class).withId(stack.getId()).withName(stack.getName()).withDescription(stack.getDescription()).withCreator(stack.getCreator()).withScope(stack.getScope()).withTags(stack.getTags()).withComponents(componentsDto).withWorkspaceConfig(workspaceConfigDto).withSource(stackSourceDto);
}
Aggregations