Skip to content

Commit

Permalink
add region and nice type to artifact api (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanoy authored Feb 22, 2022
1 parent be248e9 commit 86b80a5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/redhat/labs/lodestar/model/Artifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Artifact extends EngagementAttribute {
private String title;
private String description;
private String type;
private String prettyType;
private String linkAddress;

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ public class EngagementArtifact extends Artifact {

private String projectName;
private String customerName;
private String region;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.redhat.labs.lodestar.service;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

Expand Down Expand Up @@ -35,6 +36,9 @@ public class ArtifactService {
@Inject
EngagementService engagementService;

@Inject
ConfigService configService;

public List<Artifact> getArtifacts(String engagementUuid) {
ArtifactOptions options = ArtifactOptions.builder().page(0).pageSize(1000)
.engagementUuid(engagementUuid).build();
Expand All @@ -60,15 +64,18 @@ public Response getArtifacts(ListFilterOptions filterOptions, String engagementU
int totalArtifacts = Integer.parseInt(response.getHeaderString("x-total-artifacts"));
int totalPages = totalArtifacts / pageSize + 1;
List<EngagementArtifact> artifacts = response.readEntity(new GenericType<>(){});

//if(dashboardView) { //enrich data with customer and engagement name
for(EngagementArtifact artifact : artifacts) {
Engagement e = engagementService.getByUuid(artifact.getEngagementUuid());
artifact.setCustomerName(e.getCustomerName());
artifact.setProjectName(e.getProjectName());

}
// }

Map<String, String> artifactOptions = configService.getArtifactOptions();

for(EngagementArtifact artifact : artifacts) {
Engagement e = engagementService.getByUuid(artifact.getEngagementUuid());
artifact.setCustomerName(e.getCustomerName());
artifact.setProjectName(e.getProjectName());
artifact.setRegion(e.getRegion());

artifact.setPrettyType(artifactOptions.get(artifact.getType()));

}

return Response.ok(artifacts).header("x-current-page", currentPage).header("x-per-page", pageSize)
.header("x-total-artifacts", totalArtifacts).header("x-next-page", currentPage + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ void testSendUpdateWebError() {

Mockito.verify(artifactClient, Mockito.never()).updateArtifacts("uuid3", "na", artifacts, "Mitch", "[email protected]");
}

@Test
void testArtifactTypeCount() {

artifactService.getTypesCount(Collections.emptyList());

Mockito.verify(artifactClient).getTypesCount(Collections.emptyList());
}
}

0 comments on commit 86b80a5

Please sign in to comment.