diff --git a/owlplug-client/src/main/java/com/owlplug/explore/controllers/ExploreController.java b/owlplug-client/src/main/java/com/owlplug/explore/controllers/ExploreController.java index b366752d..1509c2ef 100644 --- a/owlplug-client/src/main/java/com/owlplug/explore/controllers/ExploreController.java +++ b/owlplug-client/src/main/java/com/owlplug/explore/controllers/ExploreController.java @@ -243,11 +243,15 @@ private void performPackageSearch() { } } + List formats = new ArrayList<>(); for (Entry entry : formatsFilterCheckBoxes.entrySet()) { if (entry.getValue().isSelected()) { - criteriaList.add(new StoreFilterCriteria(entry.getKey(), ExploreFilterCriteriaType.FORMAT)); + formats.add(entry.getKey()); } } + if (formats.size() > 0) { + criteriaList.add(new StoreFilterCriteria(formats, ExploreFilterCriteriaType.FORMAT_LIST)); + } Task> task = new Task>() { @Override diff --git a/owlplug-client/src/main/java/com/owlplug/explore/dao/RemotePackageDAO.java b/owlplug-client/src/main/java/com/owlplug/explore/dao/RemotePackageDAO.java index 7b25e70b..8f18f156 100644 --- a/owlplug-client/src/main/java/com/owlplug/explore/dao/RemotePackageDAO.java +++ b/owlplug-client/src/main/java/com/owlplug/explore/dao/RemotePackageDAO.java @@ -19,7 +19,9 @@ package com.owlplug.explore.dao; import com.owlplug.core.model.PluginType; +import com.owlplug.explore.model.PackageBundle; import com.owlplug.explore.model.RemotePackage; +import jakarta.persistence.criteria.Fetch; import jakarta.persistence.criteria.Join; import jakarta.persistence.criteria.JoinType; import jakarta.persistence.criteria.Predicate; @@ -70,8 +72,24 @@ static Specification hasCreator(String creator) { @SuppressWarnings("unchecked") static Specification hasFormat(String format) { return (remotePackage, cq, cb) -> { - Join bundles = (Join) remotePackage.fetch("bundles"); - return cb.isMember(format, bundles.get("formats")); + Join bundles = (Join) remotePackage.fetch("bundles", JoinType.INNER); + return bundles.join("formats").in(format); + }; + } + + /** + * Platform filtering JPA Specification Filter packages matching the given + * platformTag or packages without platform assignment. + * + * @param formatList - The compatible platformTagList to find + * @return The JPA Specification + */ + @SuppressWarnings("unchecked") + static Specification hasFormat(List formatList) { + return (remotePackage, cq, cb) -> { + Join bundles = (Join) remotePackage.fetch("bundles", JoinType.INNER); + return bundles.join("formats").in(formatList); + }; } @@ -84,8 +102,8 @@ static Specification hasFormat(String format) { @SuppressWarnings("unchecked") static Specification hasPlatformTag(String platformTag) { return (remotePackage, cq, cb) -> { - Join bundles = (Join) remotePackage.fetch("bundles"); - return cb.isMember(platformTag, bundles.get("targets")); + Join bundles = (Join) remotePackage.fetch("bundles", JoinType.INNER); + return bundles.join("targets").in(platformTag); }; } @@ -100,12 +118,8 @@ static Specification hasPlatformTag(String platformTag) { static Specification hasPlatformTag(List platformTagList) { return (remotePackage, cq, cb) -> { Join bundles = (Join) remotePackage.fetch("bundles", JoinType.INNER); - List predicates = new ArrayList<>(); - for (String platformTag : platformTagList) { - predicates.add(cb.or(cb.isMember(platformTag, bundles.get("targets")))); - } - cq.distinct(true); - return cb.or(predicates.toArray(new Predicate[predicates.size()])); + return bundles.join("targets").in(platformTagList); + }; } diff --git a/owlplug-client/src/main/java/com/owlplug/explore/model/search/ExploreFilterCriteriaType.java b/owlplug-client/src/main/java/com/owlplug/explore/model/search/ExploreFilterCriteriaType.java index 14e21604..d265da60 100644 --- a/owlplug-client/src/main/java/com/owlplug/explore/model/search/ExploreFilterCriteriaType.java +++ b/owlplug-client/src/main/java/com/owlplug/explore/model/search/ExploreFilterCriteriaType.java @@ -19,5 +19,5 @@ package com.owlplug.explore.model.search; public enum ExploreFilterCriteriaType { - NAME, TAG, TYPE, PLATFORM, CREATOR, FORMAT + NAME, TAG, TYPE, PLATFORM, CREATOR, FORMAT, FORMAT_LIST } \ No newline at end of file diff --git a/owlplug-client/src/main/java/com/owlplug/explore/model/search/StoreCriteriaAdapter.java b/owlplug-client/src/main/java/com/owlplug/explore/model/search/StoreCriteriaAdapter.java index 8b1fe2be..9cdd6ce4 100644 --- a/owlplug-client/src/main/java/com/owlplug/explore/model/search/StoreCriteriaAdapter.java +++ b/owlplug-client/src/main/java/com/owlplug/explore/model/search/StoreCriteriaAdapter.java @@ -56,6 +56,9 @@ public static Specification toSpecification(StoreFilterCriteria c if (criteria.getFilterType().equals(ExploreFilterCriteriaType.FORMAT)) { return RemotePackageDAO.hasFormat(String.valueOf(criteria.getValue())); } + if (criteria.getFilterType().equals(ExploreFilterCriteriaType.FORMAT_LIST)) { + return RemotePackageDAO.hasFormat((List) criteria.getValue()); + } return Specification.where(null); } diff --git a/owlplug-client/src/main/resources/application.properties b/owlplug-client/src/main/resources/application.properties index a1e5ffe2..10952ed6 100644 --- a/owlplug-client/src/main/resources/application.properties +++ b/owlplug-client/src/main/resources/application.properties @@ -36,5 +36,5 @@ spring.main.web-environment=false # Logger # Available levels are: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF -#logging.level.org.hibernate.SQL=DEBUG -#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE +logging.level.org.hibernate.SQL=DEBUG +logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE