• 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/StudySessionService.java
1
package com.sessionBuilder.core;
2

3
import java.time.LocalDate;
4
import java.util.List;
5

6
import com.google.inject.Inject;
7

8
public class StudySessionService implements StudySessionInterface {
×
9
        
10
        private static final String NULL_SESSION_MESSAGE = "la sessione passata è null";
11
        @Inject
12
        private TransactionManager tm;
13

14
        public StudySession getSessionById(long id) {
15
                return tm.doInSessionTransaction(sessionRepository -> {
×
16
                        StudySession session = sessionRepository.findById(id);
×
17
                        if(session == null) throw new IllegalArgumentException("la sessione cercata non esiste");
×
18
                        return session;
×
19
                });
20
        }
21
        
22
        @Override
23
        public List<StudySession> getAllSessions() {
NEW
24
                return tm.doInSessionTransaction(sessionRepository -> {
×
25
                        try {
NEW
26
                                return sessionRepository.findAll();
×
NEW
27
                        } catch(Exception e) {
×
NEW
28
                                throw new IllegalArgumentException("Errore durante il caricamento delle session");
×
29
                        }
30
                });
31
        }
32

33
        @Override
34
        public StudySession createSession(LocalDate date, int duration, String note, List<Topic> topicList) {
35
                return tm.doInSessionTransaction(sessionRepository -> {
×
36
                        StudySession session = new StudySession(date, duration, note, topicList);
×
37
                        if(sessionRepository.findByDateDurationAndNote(date, duration, note) != null) {
×
38
                                throw new IllegalArgumentException("esiste già una session con questi valori");
×
39
                        }
40
                        sessionRepository.save(session);
×
41
                        return session;
×
42
                });
43
        }
44
        
45
        @Override
46
        public StudySession completeSession(long sessionId) {
47
                return tm.doInSessionTransaction(sessionRepository ->{
×
48
                        StudySession session = sessionRepository.findById(sessionId);
×
49
                        if(session == null) throw new IllegalArgumentException(NULL_SESSION_MESSAGE);
×
50
                        session.complete();
×
51
                        sessionRepository.update(session);
×
52
                        return session;
×
53
                });
54
        }
55
        
56
        @Override
57
        public void addTopic(long sessionId, long topicId) {
58
                tm.doInMultiRepositoryTransaction(context -> {
×
59
                        StudySession session = context.getSessionRepository().findById(sessionId);
×
60
                        Topic topic = context.getTopicRepository().findById(topicId);
×
61
                        if(session == null) throw new IllegalArgumentException(NULL_SESSION_MESSAGE);
×
62
                        if(topic == null) throw new IllegalArgumentException("il topic passato è null");
×
63
                        session.addTopic(topic);
×
64
                        context.getSessionRepository().update(session);
×
65
                        return null;
×
66
                });
67
        }
×
68
        
69
        @Override
70
        public void removeTopic(long sessionId, long topicId) {
71
                tm.doInMultiRepositoryTransaction(context -> {
×
72
                        StudySession session = context.getSessionRepository().findById(sessionId);
×
73
                        Topic topic = context.getTopicRepository().findById(topicId);
×
74
                        if(session == null) throw new IllegalArgumentException(NULL_SESSION_MESSAGE);
×
75
                        if(topic == null) throw new IllegalArgumentException("il topic passato è null");
×
76
                        session.removeTopic(topic);
×
77
                        context.getSessionRepository().update(session);
×
78
                        return null;
×
79
                });
80
        }
×
81
        
82
        @Override
83
        public void deleteSession(long sessionId) {
84
                tm.doInSessionTransaction(sessionRepository -> {
×
85
                        StudySession session = sessionRepository.findById(sessionId);
×
86
                        if(session == null) throw new IllegalArgumentException("la sessione da rimuovere è null");
×
87
                        sessionRepository.delete(sessionId);
×
88
                        return null;
×
89
                });
90
                
91
        }
×
92

93
        
94
        
95
        
96
        
97
        
98
        
99
        
100
        
101
        
102

103
}
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