Skip to content

Commit

Permalink
fix(core/jdbc): add missing sort mapping for ServiceInstanceRepositor…
Browse files Browse the repository at this point in the history
…yInterface
  • Loading branch information
fhussonnois authored and loicmathieu committed Apr 25, 2024
1 parent 671ed5c commit fb4da35
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;

/**
* Repository service for storing service instance.
Expand Down Expand Up @@ -119,5 +120,12 @@ default ServiceStateTransition.Response mayTransitionServiceTo(final ServiceInst
}
}


/**
* Returns the function to be used for mapping column used to sort result.
*
* @return the mapping function.
*/
default Function<String, String> sortMapping(){
return Function.identity();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@

import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.jooq.impl.DSL.using;
Expand Down Expand Up @@ -297,4 +299,15 @@ private ImmutablePair<ServiceInstance, ServiceInstance> mayUpdateStatusById(fina
private Table<Record> table() {
return this.jdbcRepository.getTable();
}

/** {@inheritDoc} **/
@Override
public Function<String, String> sortMapping() {
Map<String, String> mapper = Map.of(
"createdAt", CREATED_AT.getName(),
"updatedAt", UPDATED_AT.getName(),
"serviceId", SERVICE_ID.getName()
);
return mapper::get;
}
}

0 comments on commit fb4da35

Please sign in to comment.