Skip to content

Commit

Permalink
1680 - updated ape/terms api. Added updated_at field and start/end da…
Browse files Browse the repository at this point in the history
…te query params
  • Loading branch information
Vladysl committed Jun 5, 2024
1 parent 78905ff commit 7d5cc1b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.opendatadiscovery.oddplatform.controller;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.opendatadiscovery.oddplatform.api.contract.api.TermApi;
Expand Down Expand Up @@ -51,8 +51,8 @@ public class TermController implements TermApi {
@Override
public Mono<ResponseEntity<TermRefList>> getTermsList(final Integer page, final Integer size,
final String query,
final LocalDate updatedAtRangeStartDateTime,
final LocalDate updatedAtRangeEndDateTime,
final OffsetDateTime updatedAtRangeStartDateTime,
final OffsetDateTime updatedAtRangeEndDateTime,
final ServerWebExchange exchange) {
return termService.getTerms(page, size, query, updatedAtRangeStartDateTime, updatedAtRangeEndDateTime)
.map(ResponseEntity::ok);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.opendatadiscovery.oddplatform.repository.reactive;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.List;
import org.opendatadiscovery.oddplatform.dto.FacetStateDto;
import org.opendatadiscovery.oddplatform.dto.term.LinkedTermDto;
Expand All @@ -16,8 +16,8 @@
public interface ReactiveTermRepository extends ReactiveCRUDRepository<TermPojo> {

Mono<Page<TermRefDto>> listTermRefDtos(final int page, final int size, final String query,
final LocalDate updatedAtRangeStartDateTime,
final LocalDate updatedAtRangeEndDateTime);
final OffsetDateTime updatedAtRangeStartDateTime,
final OffsetDateTime updatedAtRangeEndDateTime);

Mono<Boolean> existsByNamespace(final Long namespaceId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.opendatadiscovery.oddplatform.repository.reactive;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -45,6 +45,7 @@
import org.opendatadiscovery.oddplatform.repository.util.JooqReactiveOperations;
import org.opendatadiscovery.oddplatform.repository.util.JooqRecordHelper;
import org.opendatadiscovery.oddplatform.repository.util.OrderByField;
import org.opendatadiscovery.oddplatform.service.ingestion.util.DateTimeUtil;
import org.opendatadiscovery.oddplatform.utils.Page;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
Expand Down Expand Up @@ -106,8 +107,8 @@ public ReactiveTermRepositoryImpl(final JooqReactiveOperations jooqReactiveOpera

@Override
public Mono<Page<TermRefDto>> listTermRefDtos(final int page, final int size, final String nameQuery,
final LocalDate updatedAtRangeStartDateTime,
final LocalDate updatedAtRangeEndDateTime) {
final OffsetDateTime updatedAtRangeStartDateTime,
final OffsetDateTime updatedAtRangeEndDateTime) {
final Select<TermRecord> homogeneousQuery = DSL.selectFrom(TERM)
.where(ListUtils.union(listCondition(nameQuery),
dateConditions(updatedAtRangeStartDateTime, updatedAtRangeEndDateTime)));
Expand Down Expand Up @@ -634,20 +635,20 @@ private List<LinkedTermDto> extractTerms(final Record record) {
.toList();
}

private List<Condition> dateConditions(final LocalDate updatedAtRangeStartDateTime,
final LocalDate updatedAtRangeEndDateTime) {
private List<Condition> dateConditions(final OffsetDateTime updatedAtRangeStartDateTime,
final OffsetDateTime updatedAtRangeEndDateTime) {
if (updatedAtRangeStartDateTime == null && updatedAtRangeEndDateTime == null) {
return Collections.emptyList();
}

final List<Condition> conditions = new ArrayList<>();

if (updatedAtRangeStartDateTime != null) {
conditions.add(TERM.UPDATED_AT.greaterOrEqual(updatedAtRangeStartDateTime.atStartOfDay()));
conditions.add(TERM.UPDATED_AT.greaterOrEqual(DateTimeUtil.mapUTCDateTime(updatedAtRangeStartDateTime)));
}

if (updatedAtRangeEndDateTime != null) {
conditions.add(TERM.UPDATED_AT.lessThan(updatedAtRangeEndDateTime.atStartOfDay()));
conditions.add(TERM.UPDATED_AT.lessThan(DateTimeUtil.mapUTCDateTime(updatedAtRangeEndDateTime)));
}

return conditions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.opendatadiscovery.oddplatform.service.term;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.List;
import org.opendatadiscovery.oddplatform.api.contract.model.LinkedTerm;
import org.opendatadiscovery.oddplatform.api.contract.model.LinkedTermList;
Expand All @@ -16,7 +16,8 @@

public interface TermService {
Mono<TermRefList> getTerms(final Integer page, final Integer size, final String query,
final LocalDate updatedAtRangeStartDateTime, final LocalDate updatedAtRangeEndDateTime);
final OffsetDateTime updatedAtRangeStartDateTime,
final OffsetDateTime updatedAtRangeEndDateTime);

Mono<TermRef> getTermByNamespaceAndName(final String namespaceName, final String name);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.opendatadiscovery.oddplatform.service.term;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -82,8 +82,8 @@ public class TermServiceImpl implements TermService {

@Override
public Mono<TermRefList> getTerms(final Integer page, final Integer size, final String query,
final LocalDate updatedAtRangeStartDateTime,
final LocalDate updatedAtRangeEndDateTime) {
final OffsetDateTime updatedAtRangeStartDateTime,
final OffsetDateTime updatedAtRangeEndDateTime) {
return termRepository.listTermRefDtos(page, size, query, updatedAtRangeStartDateTime, updatedAtRangeEndDateTime)
.map(termMapper::mapToRefPage);
}
Expand Down
4 changes: 2 additions & 2 deletions odd-platform-specification/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2730,13 +2730,13 @@ paths:
required: false
schema:
type: string
format: date
format: date-time
- name: updated_at_range_end_date_time
in: query
required: false
schema:
type: string
format: date
format: date-time
responses:
'200':
description: OK
Expand Down

0 comments on commit 7d5cc1b

Please sign in to comment.