Skip to content

Commit 86b80a5

Browse files
authored
add region and nice type to artifact api (#179)
1 parent be248e9 commit 86b80a5

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

src/main/java/com/redhat/labs/lodestar/model/Artifact.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Artifact extends EngagementAttribute {
1818
private String title;
1919
private String description;
2020
private String type;
21+
private String prettyType;
2122
private String linkAddress;
2223

2324
}

src/main/java/com/redhat/labs/lodestar/model/EngagementArtifact.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ public class EngagementArtifact extends Artifact {
2323

2424
private String projectName;
2525
private String customerName;
26+
private String region;
2627

2728
}

src/main/java/com/redhat/labs/lodestar/service/ArtifactService.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.redhat.labs.lodestar.service;
22

33
import java.util.List;
4+
import java.util.Map;
45
import java.util.Optional;
56
import java.util.Set;
67

@@ -35,6 +36,9 @@ public class ArtifactService {
3536
@Inject
3637
EngagementService engagementService;
3738

39+
@Inject
40+
ConfigService configService;
41+
3842
public List<Artifact> getArtifacts(String engagementUuid) {
3943
ArtifactOptions options = ArtifactOptions.builder().page(0).pageSize(1000)
4044
.engagementUuid(engagementUuid).build();
@@ -60,15 +64,18 @@ public Response getArtifacts(ListFilterOptions filterOptions, String engagementU
6064
int totalArtifacts = Integer.parseInt(response.getHeaderString("x-total-artifacts"));
6165
int totalPages = totalArtifacts / pageSize + 1;
6266
List<EngagementArtifact> artifacts = response.readEntity(new GenericType<>(){});
63-
64-
//if(dashboardView) { //enrich data with customer and engagement name
65-
for(EngagementArtifact artifact : artifacts) {
66-
Engagement e = engagementService.getByUuid(artifact.getEngagementUuid());
67-
artifact.setCustomerName(e.getCustomerName());
68-
artifact.setProjectName(e.getProjectName());
69-
70-
}
71-
// }
67+
68+
Map<String, String> artifactOptions = configService.getArtifactOptions();
69+
70+
for(EngagementArtifact artifact : artifacts) {
71+
Engagement e = engagementService.getByUuid(artifact.getEngagementUuid());
72+
artifact.setCustomerName(e.getCustomerName());
73+
artifact.setProjectName(e.getProjectName());
74+
artifact.setRegion(e.getRegion());
75+
76+
artifact.setPrettyType(artifactOptions.get(artifact.getType()));
77+
78+
}
7279

7380
return Response.ok(artifacts).header("x-current-page", currentPage).header("x-per-page", pageSize)
7481
.header("x-total-artifacts", totalArtifacts).header("x-next-page", currentPage + 1)

src/test/java/com/redhat/labs/lodestar/service/ArtifactServiceTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,12 @@ void testSendUpdateWebError() {
7272

7373
Mockito.verify(artifactClient, Mockito.never()).updateArtifacts("uuid3", "na", artifacts, "Mitch", "[email protected]");
7474
}
75+
76+
@Test
77+
void testArtifactTypeCount() {
78+
79+
artifactService.getTypesCount(Collections.emptyList());
80+
81+
Mockito.verify(artifactClient).getTypesCount(Collections.emptyList());
82+
}
7583
}

0 commit comments

Comments
 (0)