Commit a8509816 authored by Martin Lowe's avatar Martin Lowe

Add filter service, update Quarkus version

Signed-off-by: Martin Lowe's avatarMartin Lowe <martin.lowe@eclipse-foundation.org>
parent 1beff785
......@@ -29,7 +29,7 @@ public final class PersistenceUrlParameterNames implements UrlParameterNamespace
public static final UrlParameter SORT = new UrlParameter("sort");
public static final UrlParameter MANUAL_OFFSET = new UrlParameter("manual_offset");
private static final List<UrlParameter> params = Collections.unmodifiableList(Arrays.asList(SORT));
private static final List<UrlParameter> params = Collections.unmodifiableList(Arrays.asList(SORT, MANUAL_OFFSET));
@Override
public List<UrlParameter> getParameters() {
......
package org.eclipsefoundation.persistence.service;
import org.eclipsefoundation.persistence.dto.BareNode;
import org.eclipsefoundation.persistence.dto.filter.DtoFilter;
/**
* Provides filters for the passed class reference to reduce the number of injections that need to
* be handled by Graph endpoints.
*
* @author Martin Lowe
*/
public interface FilterService {
/**
* Returns a DTO filter if available for the given class.
*
* @param <T> the type of entity being filtered
* @param target class ref for the target entity type
* @return a filter instance for the given class if it exists, null otherwise
*/
<T extends BareNode> DtoFilter<T> get(Class<T> target);
}
package org.eclipsefoundation.persistence.service.impl;
import java.util.Optional;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import org.eclipsefoundation.persistence.dto.BareNode;
import org.eclipsefoundation.persistence.dto.filter.DtoFilter;
import org.eclipsefoundation.persistence.service.FilterService;
@ApplicationScoped
public class DefaultFilterService implements FilterService {
@Inject Instance<DtoFilter<?>> filters;
@SuppressWarnings("unchecked")
@Override
public <T extends BareNode> DtoFilter<T> get(Class<T> target) {
Optional<DtoFilter<?>> filter =
filters.stream().filter(f -> f.getType().equals(target)).findFirst();
if (filter.isPresent()) {
return (DtoFilter<T>) filter.get();
}
return null;
}
}
......@@ -10,7 +10,7 @@
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire-plugin.version>2.22.0</surefire-plugin.version>
<quarkus.version>1.7.0.Final</quarkus.version>
<quarkus.version>1.9.2.Final</quarkus.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment