Skip to content

Commit b966b45

Browse files
committed
add legacy values for categories, artifacts, participants
1 parent dfd2f9d commit b966b45

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.redhat.labs.lodestar.model;
22

33
import java.time.Instant;
4+
import java.util.ArrayList;
5+
import java.util.HashSet;
46
import java.util.List;
57
import java.util.Set;
68

@@ -92,6 +94,9 @@ public class Engagement {
9294
private String region;
9395
private String type;
9496

97+
@JsonbProperty("categories")
98+
List<String> categoriesV2;
99+
95100
@JsonbProperty("engagement_categories")
96101
@DiffIgnore
97102
private List<Category> categories;
@@ -116,6 +121,10 @@ public class Engagement {
116121
@DiffIgnore
117122
private int participantCount;
118123

124+
@JsonbProperty("artifact_count")
125+
@DiffIgnore
126+
private int artifactCount;
127+
119128
//Legacy - front end should switch to region
120129
@JsonbProperty("engagement_region")
121130
private String engagementRegion;
@@ -128,26 +137,63 @@ public class Engagement {
128137
@JsonbProperty("engagement_type")
129138
private String engagementType;
130139

140+
//Legacy
131141
public void setEngagementRegion(String engagementRegion) {
132142
this.engagementRegion = engagementRegion;
133143
this.region = engagementRegion;
134144
}
135145

146+
//Legacy
147+
public void setRegion(String region) {
148+
this.region = region;
149+
this.engagementRegion = region;
150+
}
151+
152+
//Legacy
136153
public void setProjectName(String projectName) {
137154
this.projectName = projectName;
138155
this.name = projectName;
139156
}
140157

158+
//Legacy
141159
public void setName(String projectName) {
142160
this.projectName = projectName;
143161
this.name = projectName;
144162
}
145163

164+
//Legacy
146165
public void setEngagementType(String engagementType) {
147166
this.engagementType = engagementType;
148167
this.type = engagementType;
149168
}
150169

170+
//Legacy
171+
public void addArtifact(Artifact a) {
172+
if(artifacts == null) {
173+
artifacts = new ArrayList<>();
174+
}
175+
176+
artifacts.add(a);
177+
}
178+
179+
//Legacy
180+
public void addParticipant(EngagementUser p) {
181+
if(engagementUsers == null) {
182+
engagementUsers = new HashSet<>();
183+
}
184+
185+
engagementUsers.add(p);
186+
}
187+
188+
//Legacy
189+
public void addCategory(String cat) {
190+
if(categories == null) {
191+
categories = new ArrayList<>();
192+
}
193+
194+
categories.add(Category.builder().name(cat).build());
195+
}
196+
151197
/**
152198
* The value return here is relative to the time entered. If the time entered was
153199
* (currentDate) Jan 1 2020 and this engagement started on Feb 1 and ended Feb 28

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,21 @@ public Response getEngagementsPaged(ListFilterOptions listFilterOptions) {
336336

337337
Response response = engagementApiClient.getEngagements(page, pageSize, listFilterOptions.getV2Regions());
338338
List<Engagement> engagements = response.readEntity(new GenericType<>(){});
339-
//engagements.forEach(e ->LOGGER.debug(" {} --- {} ", e.getProjectName(), e.getName() ));
339+
//TODO this loop is to allow frontend to change after v2 deployment.
340+
// FE should use participant, artifact count field, and categories (string version)
341+
for(Engagement e : engagements) {
342+
for(int i=0; i<e.getParticipantCount(); i++) {
343+
e.addParticipant(new EngagementUser());
344+
}
345+
346+
for(int i=0; i<e.getArtifactCount(); i++) {
347+
e.addArtifact(Artifact.builder().type("temp").build());
348+
}
349+
350+
for(String cat : e.getCategoriesV2()) {
351+
e.addCategory(cat);
352+
}
353+
}
340354
return Response.ok(engagements).header("x-total-engagements", response.getHeaderString("x-total-engagements")).build();
341355
}
342356

0 commit comments

Comments
 (0)