SONAR-25960 Update the project search action to return the project UUID
This commit is contained in:
parent
4684df7ada
commit
b92a8abb56
|
|
@ -230,18 +230,33 @@ public class SearchAction implements ProjectsWsAction {
|
|||
.build();
|
||||
|
||||
components.stream()
|
||||
.map(dto -> dtoToProject(dto, snapshotsByComponentUuid.get(dto.uuid()), lastAnalysisDateByComponentUuid.get(projectUuidByComponentUuid.get(dto.uuid())),
|
||||
PROJECT.equals(dto.qualifier()) ? componentUuidToManaged.get(dto.uuid()) : null))
|
||||
.map(dto -> {
|
||||
var projectUuid = projectUuidByComponentUuid.get(dto.uuid());
|
||||
return dtoToProject(
|
||||
dto,
|
||||
snapshotsByComponentUuid.get(dto.uuid()),
|
||||
lastAnalysisDateByComponentUuid.get(projectUuid),
|
||||
PROJECT.equals(dto.qualifier()) ? componentUuidToManaged.get(dto.uuid()) : null,
|
||||
projectUuid
|
||||
);
|
||||
})
|
||||
.forEach(responseBuilder::addComponents);
|
||||
return responseBuilder.build();
|
||||
}
|
||||
|
||||
private static Component dtoToProject(ComponentDto dto, @Nullable SnapshotDto snapshot, @Nullable Long lastAnalysisDate, @Nullable Boolean isManaged) {
|
||||
Component.Builder builder = Component.newBuilder()
|
||||
private static Component dtoToProject(
|
||||
ComponentDto dto,
|
||||
@Nullable SnapshotDto snapshot,
|
||||
@Nullable Long lastAnalysisDate,
|
||||
@Nullable Boolean isManaged,
|
||||
@Nullable String projectUuid) {
|
||||
var builder = Component.newBuilder()
|
||||
.setKey(dto.getKey())
|
||||
.setName(dto.name())
|
||||
.setQualifier(dto.qualifier())
|
||||
.setVisibility(dto.isPrivate() ? PRIVATE.getLabel() : PUBLIC.getLabel());
|
||||
|
||||
ofNullable(projectUuid).ifPresent(builder::setProjectUuid);
|
||||
ofNullable(snapshot).map(SnapshotDto::getRevision).ifPresent(builder::setRevision);
|
||||
ofNullable(lastAnalysisDate).ifPresent(d -> builder.setLastAnalysisDate(formatDateTime(d)));
|
||||
ofNullable(isManaged).ifPresent(builder::setManaged);
|
||||
|
|
|
|||
|
|
@ -1,27 +1,26 @@
|
|||
{
|
||||
"paging": {
|
||||
"pageIndex": 1,
|
||||
"pageSize": 100,
|
||||
"total": 2
|
||||
"paging" : {
|
||||
"pageIndex" : 1,
|
||||
"pageSize" : 100,
|
||||
"total" : 2
|
||||
},
|
||||
"components": [
|
||||
{
|
||||
"key": "project-key-1",
|
||||
"name": "Project Name 1",
|
||||
"qualifier": "TRK",
|
||||
"visibility": "public",
|
||||
"lastAnalysisDate": "2017-03-01T11:39:03+0300",
|
||||
"revision": "cfb82f55c6ef32e61828c4cb3db2da12795fd767",
|
||||
"managed": false
|
||||
},
|
||||
{
|
||||
"key": "project-key-2",
|
||||
"name": "Project Name 2",
|
||||
"qualifier": "TRK",
|
||||
"visibility": "private",
|
||||
"lastAnalysisDate": "2017-03-02T15:21:47+0300",
|
||||
"revision": "7be96a94ac0c95a61ee6ee0ef9c6f808d386a355",
|
||||
"managed": false
|
||||
}
|
||||
]
|
||||
"components" : [ {
|
||||
"key" : "project-key-1",
|
||||
"name" : "Project Name 1",
|
||||
"qualifier" : "TRK",
|
||||
"visibility" : "public",
|
||||
"lastAnalysisDate" : "2017-03-01T09:39:03+0100",
|
||||
"revision" : "cfb82f55c6ef32e61828c4cb3db2da12795fd767",
|
||||
"managed" : false,
|
||||
"projectUuid" : "project-uuid-1"
|
||||
}, {
|
||||
"key" : "project-key-2",
|
||||
"name" : "Project Name 2",
|
||||
"qualifier" : "TRK",
|
||||
"visibility" : "private",
|
||||
"lastAnalysisDate" : "2017-03-02T13:21:47+0100",
|
||||
"revision" : "7be96a94ac0c95a61ee6ee0ef9c6f808d386a355",
|
||||
"managed" : false,
|
||||
"projectUuid" : "project-uuid-2"
|
||||
} ]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ message SearchWsResponse {
|
|||
optional string lastAnalysisDate = 7;
|
||||
optional string revision = 8;
|
||||
optional bool managed = 9;
|
||||
optional string projectUuid = 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue