Skip to content

Commit

Permalink
updated relevanceservice
Browse files Browse the repository at this point in the history
  • Loading branch information
jannik.lange committed Dec 3, 2024
1 parent 88eb352 commit 7d72349
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import de.muenchen.kobit.backend.decisiontree.relevance.view.RelevanceView;
import java.util.*;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
public class RelevanceService {

Expand Down Expand Up @@ -48,13 +51,21 @@ public Set<RelevanceCompetence> getAllRelevanceCompetencesByPathId(UUID pathId)
return new HashSet<>();
}

public List<UUID> getAllContactPointIdsByPathId(UUID pathId) {
return relevanceRepository.findAllByPathId(pathId).stream().map(Relevance::getContactPointId).collect(Collectors.toList());
}

public List<RelevanceOrder> getOrderOrNull(Set<Competence> competences) {
Path path = findExistingPathOrNull(competences);
if (path == null) {
log.debug("getOrderOrNull | path is null");
return null;
} else {
log.debug("getOrderOrNull | path is: {}", path.getId());

return relevanceRepository.findAllByPathId(path.getId()).stream()
.map(it -> new RelevanceOrder(it.getContactPointId(), it.getPosition()))
.map(relevance -> new RelevanceOrder(relevance.getContactPointId(), relevance.getPosition()))
.peek(relevanceOrder -> log.debug("getOrderOrNull | cpID: {}, position: {}", relevanceOrder.getContactPointId(), relevanceOrder.getPosition()))
.collect(Collectors.toList());
}
}
Expand Down Expand Up @@ -117,6 +128,9 @@ private Path findExistingPathOrNull(Set<Competence> selectedPath) {
existingPaths.stream()
.filter(it -> hasMatchingCompetences(it, selectedPath))
.collect(Collectors.toList());

log.debug("findExistingPathOrNull | found paths: {}", matchingPaths.size());

if (!matchingPaths.isEmpty()) {
return matchingPaths.stream()
.findFirst()
Expand Down

0 comments on commit 7d72349

Please sign in to comment.