Skip to content

Commit

Permalink
feat: update workspace external api
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed Feb 29, 2024
1 parent 7491d06 commit 1b08d63
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.tkit.onecx.announcement.bff.rs.controller;

import java.util.HashSet;
import java.util.Set;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
Expand All @@ -21,6 +21,8 @@
import gen.org.tkit.onecx.announcement.client.api.AnnouncementInternalApi;
import gen.org.tkit.onecx.announcement.client.model.*;
import gen.org.tkit.onecx.workspace.client.api.WorkspaceExternalApi;
import gen.org.tkit.onecx.workspace.client.model.WorkspacePageResult;
import gen.org.tkit.onecx.workspace.client.model.WorkspaceSearchCriteria;

@ApplicationScoped
@Transactional(value = Transactional.TxType.NOT_SUPPORTED)
Expand Down Expand Up @@ -71,9 +73,10 @@ public Response getAllAppsWithAnnouncements() {

@Override
public Response getAllWorkspaceNames() {
HashSet<String> workspaceNames = new HashSet<>();
try (Response response = workspaceClient.getAllWorkspaceNames()) {
workspaceNames = response.readEntity(HashSet.class);
Set<String> workspaceNames;
try (Response response = workspaceClient.searchWorkspaces(new WorkspaceSearchCriteria())) {
var result = response.readEntity(WorkspacePageResult.class);
workspaceNames = announcementMapper.workspaceNames(result);
}
return Response.status(Response.Status.OK).entity(workspaceNames).build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
package org.tkit.onecx.announcement.bff.rs.mappers;

import java.util.Set;
import java.util.stream.Collectors;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper;

import gen.org.tkit.onecx.announcement.bff.rs.internal.model.*;
import gen.org.tkit.onecx.announcement.client.model.*;
import gen.org.tkit.onecx.workspace.client.model.WorkspaceAbstract;
import gen.org.tkit.onecx.workspace.client.model.WorkspacePageResult;

@Mapper(uses = { OffsetDateTimeMapper.class })
public interface AnnouncementMapper {

default Set<String> workspaceNames(WorkspacePageResult result) {
if (result == null || result.getStream() == null) {
return Set.of();
}
return result.getStream().stream().map(WorkspaceAbstract::getName).collect(Collectors.toSet());
}

CreateAnnouncementRequest mapCreateAnnouncement(CreateAnnouncementRequestDTO createAnnouncementRequestDTO);

UpdateAnnouncementRequest mapUpdateAnnouncement(UpdateAnnouncementRequestDTO updateAnnouncementRequestDTO);
Expand Down

0 comments on commit 1b08d63

Please sign in to comment.