Skip to content

Commit

Permalink
1657 - activity "User" filter should accept usernames instead of owne…
Browse files Browse the repository at this point in the history
…r_ids.
  • Loading branch information
Vladysl committed Apr 17, 2024
1 parent 9c13c99 commit e23bb88
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.opendatadiscovery.oddplatform.api.contract.model.ActivityCountInfo;
import org.opendatadiscovery.oddplatform.api.contract.model.ActivityEventType;
import org.opendatadiscovery.oddplatform.api.contract.model.ActivityType;
import org.opendatadiscovery.oddplatform.api.contract.model.ActivityUserList;
import org.opendatadiscovery.oddplatform.service.activity.ActivityService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -28,15 +29,15 @@ public Mono<ResponseEntity<Flux<Activity>>> getActivity(final OffsetDateTime beg
final Long namespaceId,
final List<Long> tagIds,
final List<Long> ownerIds,
final List<Long> userIds,
final List<String> usernames,
final ActivityType type,
final ActivityEventType eventType,
final Long lasEventId,
final OffsetDateTime lastEventDateTime,
final ServerWebExchange exchange) {
return Mono.just(
activityService.getActivityList(beginDate, endDate, size, datasourceId, namespaceId, tagIds, ownerIds,
userIds, type, eventType, lasEventId, lastEventDateTime))
usernames, type, eventType, lasEventId, lastEventDateTime))
.map(ResponseEntity::ok);
}

Expand All @@ -47,11 +48,20 @@ public Mono<ResponseEntity<ActivityCountInfo>> getActivityCounts(final OffsetDat
final Long namespaceId,
final List<Long> tagIds,
final List<Long> ownerIds,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventType eventType,
final ServerWebExchange exchange) {
return activityService.getActivityCounts(beginDate, endDate, datasourceId, namespaceId,
tagIds, ownerIds, userIds, eventType)
tagIds, ownerIds, usernames, eventType)
.map(ResponseEntity::ok);
}

@Override
public Mono<ResponseEntity<ActivityUserList>> getUsersList(final Integer page,
final Integer size,
final String query,
final ServerWebExchange exchange) {
return activityService.getUsersList(page, size, query)
.map(ResponseEntity::ok);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@ public Mono<ResponseEntity<Flux<Activity>>> getDataEntityActivity(final Long dat
final OffsetDateTime beginDate,
final OffsetDateTime endDate,
final Integer size,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventType eventType,
final Long lastEventId,
final OffsetDateTime lastEventDateTime,
final ServerWebExchange exchange) {
return Mono.just(
activityService.getDataEntityActivityList(beginDate, endDate, size, dataEntityId, userIds, eventType,
activityService.getDataEntityActivityList(beginDate, endDate, size, dataEntityId, usernames, eventType,
lastEventId, lastEventDateTime)
).map(ResponseEntity::ok);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.opendatadiscovery.oddplatform.dto.activity;

import org.opendatadiscovery.oddplatform.model.tables.pojos.OwnerPojo;

public record UsernameDto(String username, OwnerPojo ownerPojo) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.jooq.JSONB;
import org.mapstruct.Mapper;
Expand All @@ -12,6 +13,8 @@
import org.mapstruct.NullValueCheckStrategy;
import org.opendatadiscovery.oddplatform.api.contract.model.Activity;
import org.opendatadiscovery.oddplatform.api.contract.model.ActivityState;
import org.opendatadiscovery.oddplatform.api.contract.model.ActivityUser;
import org.opendatadiscovery.oddplatform.api.contract.model.ActivityUserList;
import org.opendatadiscovery.oddplatform.api.contract.model.AlertHaltConfigActivityState;
import org.opendatadiscovery.oddplatform.api.contract.model.AlertReceivedActivityState;
import org.opendatadiscovery.oddplatform.api.contract.model.AlertStatusUpdatedActivityState;
Expand All @@ -31,6 +34,7 @@
import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldValuesActivityState;
import org.opendatadiscovery.oddplatform.api.contract.model.DescriptionActivityState;
import org.opendatadiscovery.oddplatform.api.contract.model.OwnershipActivityState;
import org.opendatadiscovery.oddplatform.api.contract.model.PageInfo;
import org.opendatadiscovery.oddplatform.api.contract.model.TagActivityState;
import org.opendatadiscovery.oddplatform.api.contract.model.TermActivityState;
import org.opendatadiscovery.oddplatform.dto.AssociatedOwnerDto;
Expand All @@ -53,10 +57,12 @@
import org.opendatadiscovery.oddplatform.dto.activity.OwnershipActivityStateDto;
import org.opendatadiscovery.oddplatform.dto.activity.TagActivityStateDto;
import org.opendatadiscovery.oddplatform.dto.activity.TermActivityStateDto;
import org.opendatadiscovery.oddplatform.dto.activity.UsernameDto;
import org.opendatadiscovery.oddplatform.model.tables.pojos.ActivityPojo;
import org.opendatadiscovery.oddplatform.model.tables.pojos.DataEntityPojo;
import org.opendatadiscovery.oddplatform.service.ingestion.util.DateTimeUtil;
import org.opendatadiscovery.oddplatform.utils.JSONSerDeUtils;
import org.opendatadiscovery.oddplatform.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;

@Mapper(config = MapperConfig.class, uses = {DateTimeMapper.class})
Expand Down Expand Up @@ -309,4 +315,17 @@ AssociatedOwner mapUser(final ActivityDto activityDto) {
return associatedOwnerMapper.mapAssociatedOwner(
new AssociatedOwnerDto(activityDto.activity().getCreatedBy(), activityDto.user(), null));
}

public ActivityUserList mapToActivityUserList(final Page<UsernameDto> usernameDtos) {
return new ActivityUserList()
.items(mapActivityUsers(usernameDtos.getData()))
.pageInfo(new PageInfo().total(usernameDtos.getTotal()));
}

private List<ActivityUser> mapActivityUsers(final List<UsernameDto> dtos) {
return dtos.stream().map(this::mapToActivityUser).collect(Collectors.toList());
}

@Mapping(source = "ownerPojo.id", target = "ownerId")
abstract ActivityUser mapToActivityUser(final UsernameDto dto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import java.util.List;
import org.opendatadiscovery.oddplatform.dto.activity.ActivityDto;
import org.opendatadiscovery.oddplatform.dto.activity.ActivityEventTypeDto;
import org.opendatadiscovery.oddplatform.dto.activity.UsernameDto;
import org.opendatadiscovery.oddplatform.model.tables.pojos.ActivityPojo;
import org.opendatadiscovery.oddplatform.utils.Page;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand All @@ -20,7 +22,7 @@ Flux<ActivityDto> findAllActivities(final OffsetDateTime beginDate,
final Long namespaceId,
final List<Long> tagIds,
final List<Long> ownerIds,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventTypeDto eventType,
final Long lastEventId,
final OffsetDateTime lastEventDateTime);
Expand All @@ -31,7 +33,7 @@ Flux<ActivityDto> findMyActivities(final OffsetDateTime beginDate,
final Long datasourceId,
final Long namespaceId,
final List<Long> tagIds,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventTypeDto eventType,
final Long currentOwnerId,
final Long lastEventId,
Expand All @@ -43,7 +45,7 @@ Flux<ActivityDto> findDependentActivities(final OffsetDateTime beginDate,
final Long datasourceId,
final Long namespaceId,
final List<Long> tagIds,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventTypeDto eventType,
final List<String> oddrns,
final Long lastEventId,
Expand All @@ -53,7 +55,7 @@ Flux<ActivityDto> findDataEntityActivities(final OffsetDateTime beginDate,
final OffsetDateTime endDate,
final Integer size,
final Long dataEntityId,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventTypeDto eventType,
final Long lastEventId,
final OffsetDateTime lastEventDateTime);
Expand All @@ -64,15 +66,15 @@ Mono<Long> getTotalActivitiesCount(final OffsetDateTime beginDate,
final Long namespaceId,
final List<Long> tagIds,
final List<Long> ownerIds,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventTypeDto eventType);

Mono<Long> getMyObjectsActivitiesCount(final OffsetDateTime beginDate,
final OffsetDateTime endDate,
final Long datasourceId,
final Long namespaceId,
final List<Long> tagIds,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventTypeDto eventType,
final Long currentOwnerId);

Expand All @@ -81,7 +83,9 @@ Mono<Long> getDependentActivitiesCount(final OffsetDateTime beginDate,
final Long datasourceId,
final Long namespaceId,
final List<Long> tagIds,
final List<Long> userIds,
final List<String> usernames,
final ActivityEventTypeDto eventType,
final List<String> oddrns);

Mono<Page<UsernameDto>> getUsersList(final Integer page, final Integer size, final String query);
}
Loading

0 comments on commit e23bb88

Please sign in to comment.