• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

edoardof01 / sessionBuilder / 142

23 Jun 2025 03:53PM UTC coverage: 0.0%. Remained the same
142

push

github

edoardof01
modifica al codice per popolare i models della UI coi records del db

0 of 282 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 45 new or added lines in 7 files covered. (0.0%)

1 existing line in 1 file now uncovered.

0 of 930 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/sessionBuilder/sessionBuilder-core/src/main/java/com/sessionBuilder/core/TopicRepository.java
1
package com.sessionBuilder.core;
2

3
import java.util.List;
4

5
import com.google.inject.Inject;
6

7
import jakarta.persistence.NoResultException;
8

9

10
public class TopicRepository implements TopicRepositoryInterface{
11
        
12
        
13
        private TransactionManager tm;
14
        
15
        @Inject
16
        public TopicRepository(TransactionManager tm) {
×
17
                this.tm = tm;
×
18
        }
×
19

20
        @Override
21
        public Topic findById(long id) {
22
                return tm.doInTransaction(em -> {
×
23
                        try {
24
                                return em.createQuery(
×
25
                                        "SELECT t FROM Topic t LEFT JOIN FETCH t.sessionList WHERE t.id = :id", 
26
                                        Topic.class)
27
                                        .setParameter("id", id)
×
28
                                        .getSingleResult();
×
29
                        } catch (NoResultException e) {
×
30
                                throw new IllegalArgumentException("non esiste un topic con tale id");
×
31
                        }
32
                });
33
        }
34
        
35
        @Override
36
        public Topic findByNameDescriptionAndDifficulty(String name, String description, int difficulty) {
NEW
37
                return tm.doInTransaction(em ->{
×
38
                        try {
NEW
39
                        return em.createQuery(
×
40
                                "SELECT t FROM Topic t WHERE t.name = :name AND t.description = :description AND t.difficulty = :difficulty",
41
                                Topic.class)
NEW
42
                                .setParameter("name", name)
×
NEW
43
                                .setParameter("description", description)
×
NEW
44
                                .setParameter("difficulty", difficulty)
×
NEW
45
                                .getSingleResult();
×
NEW
46
                        } catch (RuntimeException e) {
×
NEW
47
                                throw new IllegalArgumentException("non esiste un topic con tali valori");
×
48
                        }
49
                });
50
        }
51
        
52
        @Override
53
        public List<Topic> findAll() {
NEW
54
                return tm.doInTransaction(em -> {
×
55
                        try {
NEW
56
                                return em.createQuery("SELECT t FROM Topic t", Topic.class).getResultList();
×
NEW
57
                        } catch(Exception e) {
×
NEW
58
                                throw new IllegalArgumentException("erorre nell'estrazione dei topic");
×
59
                        }
60
                });
61
        }
62

63
        @Override
64
        public void save(Topic topic) {
65
                tm.doInTransaction(em -> {
×
66
                        if(topic == null) throw new IllegalArgumentException("il topic da persistere è null");
×
67
                        em.persist(topic);
×
68
                        return null;
×
69
                });
70
        }
×
71

72
        @Override
73
        public void update(Topic topic) {
74
                tm.doInTransaction(em -> {
×
75
                        if(topic == null) throw new IllegalArgumentException("il topic da aggiornare è null");
×
76
                        em.merge(topic);
×
77
                        return null;
×
78
                });
79
        }
×
80
        
81
        @Override
82
        public void delete(long id) {
83
                tm.doInTransaction(em -> {
×
84
                        Topic result = em.find(Topic.class, id);
×
85
                        if(result == null) throw new IllegalArgumentException("il topic da rimuovere è null");
×
86
                        em.remove(result);
×
87
                        return null;
×
88
                });
89
        }
×
90

91
        
92

93
        
94

95

96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc