commit 03cab3089523618c1363b79f6e48f00257a63815
Author: Jiri Trefil <badjokke@gmail.com>
Date:   Sat Dec 2 22:00:45 2023 +0100

    https://kivprogrammers.atlassian.net/browse/TSP2-63
    
    implementace filtrování work unit pres aktivity.

diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/managment/WorkUnitRepository.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/managment/WorkUnitRepository.java
index f6f6ac7..80bc718 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/managment/WorkUnitRepository.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/managment/WorkUnitRepository.java
@@ -43,14 +43,21 @@ public interface WorkUnitRepository extends JpaRepository<WorkUnit, Long> {
     @Query("SELECT unit from WorkUnit unit WHERE unit.project.id = ?1")
     List<WorkUnit> fetchAllProjectWorkUnits(Long projectId);
 
-    @Query("SELECT unit from WorkUnit unit WHERE unit.project.id = ?1 and ?2 IN (SELECT cat.name from unit.categories cat)")
-    List<WorkUnit> fetchActivityWorkUnitsFilteredByCategory(Long projectId, String category);
-
-    @Query("SELECT unit from WorkUnit unit WHERE unit.project.id = ?1 and unit.type.name = ?2")
-    List<WorkUnit> fetchActivityWorkUnitsFilteredByType(Long projectId, String type);
-    @Query("SELECT unit from WorkUnit unit WHERE unit.project.id = ?1 AND ?2 MEMBER OF unit.categories AND unit.type.name = ?3")
-    List<WorkUnit> fetchActivityWorkUnitsFilteredByTypeAndCategory(Long projectId,String category, String type);
+    @Query("SELECT unit FROM WorkUnit unit " +
+            "INNER JOIN Category cat " +
+            "ON cat member OF unit.categories " +
+            "WHERE unit.project.id = :projectId AND cat.name = :categoryName")
+    List<WorkUnit> fetchActivityWorkUnitsFilteredByCategory(@Param("projectId") Long projectId, @Param("categoryName") String category);
 
+    @Query("SELECT unit from WorkUnit unit WHERE unit.project.id = :projectId and unit.type.name in :typeNames")
+    List<WorkUnit> fetchActivityWorkUnitsFilteredByType(@Param("projectId") Long projectId, @Param("typeNames") List<String> wuTypes);
+    @Query("SELECT unit from WorkUnit unit " +
+            "INNER JOIN Category cat " +
+            "ON cat MEMBER OF unit.categories " +
+            "WHERE unit.project.id = :projectId AND cat.name = :categoryName AND unit.type.name in :typeNames")
+    List<WorkUnit> fetchActivityWorkUnitsFilteredByTypeAndCategory(@Param("projectId")Long projectId,@Param("categoryName") String category,@Param("typeNames")  List <String> type);
+    @Query("SELECT unit from WorkUnit unit ")
+    List<String> fetchCategoryNames(Long projectId);
     @Query("UPDATE WorkUnit unit SET unit.activity.id = :activityId WHERE unit.id in :wuIds")
     @Modifying
     @Transactional
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/management/WorkUnitController.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/management/WorkUnitController.java
index 66b0d40..34c1201 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/management/WorkUnitController.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/management/WorkUnitController.java
@@ -12,10 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Nullable;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -28,7 +25,7 @@ public class WorkUnitController {
     WorkUnitServiceV2 workUnitService;
 
     @GetMapping("/activity_work_units")
-    public ResponseEntity<String> getActivityWorkUnits(Long projectId, @Nullable String category, @Nullable String type) {
+    public ResponseEntity<String> getActivityWorkUnits(Long projectId, @Nullable @RequestParam String category, @Nullable @RequestParam List <String> type) {
         if(projectId == null) {
             return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
         }
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/workUnit/WorkUnitServiceV2.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/workUnit/WorkUnitServiceV2.java
index abe0bad..de0d55e 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/workUnit/WorkUnitServiceV2.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/workUnit/WorkUnitServiceV2.java
@@ -7,7 +7,7 @@ import java.util.List;
 import java.util.Set;
 
 public interface WorkUnitServiceV2 {
-    List<WorkUnit> fetchProjectWorkUnits(long activityId, String category, String type);
+    List<WorkUnit> fetchProjectWorkUnits(long activityId, String category, List <String> type);
     boolean updateWorkUnitsActivity(long activityId, List<Long> wuIds);
     Set<String> parseWorkUnitCategories(@NotNull List<WorkUnit> workUnits);
     Set<String> parseWorkUnitTypes(@NotNull List<WorkUnit> workUnits);
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/workUnit/WorkUnitServiceV2Impl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/workUnit/WorkUnitServiceV2Impl.java
index b490fc3..c7c7d5f 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/workUnit/WorkUnitServiceV2Impl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/workUnit/WorkUnitServiceV2Impl.java
@@ -21,7 +21,7 @@ public class WorkUnitServiceV2Impl implements WorkUnitServiceV2 {
     WorkUnitService workUnitService;
 
     @Override
-    public List<WorkUnit> fetchProjectWorkUnits(long projectId, String category, String type) {
+    public List<WorkUnit> fetchProjectWorkUnits(long projectId, String category, List <String> type) {
         //List<WorkUnit> units = this.workUnitRepository.fetchActivityWorkUnits(activityId);
         //no filter applied - return everything
         if(category == null && type == null)
