a800fde0
jcartign
First version, in...
|
1
2
3
4
5
|
package fr.plil.sio.persistence.jdbc;
import fr.plil.sio.persistence.api.Group;
import fr.plil.sio.persistence.api.GroupService;
import fr.plil.sio.persistence.api.Right;
|
31bdbe1b
msahmane
Version où les te...
|
6
|
import java.sql.SQLException;
|
7940aa22
jcartign
Finishing API jav...
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
a800fde0
jcartign
First version, in...
|
8
9
10
11
|
import org.springframework.stereotype.Service;
@Service
public class GroupServiceJdbc implements GroupService {
|
7940aa22
jcartign
Finishing API jav...
|
12
13
14
15
|
@Autowired
private GroupRepository groupRepository;
|
a800fde0
jcartign
First version, in...
|
16
17
|
@Override
public Group create(String name) {
|
7940aa22
jcartign
Finishing API jav...
|
18
19
20
21
22
23
24
25
26
27
28
|
if (name == null) {
throw new IllegalArgumentException("name cannot be null");
}
Group group = groupRepository.findByName(name);
if (group != null) {
throw new IllegalStateException("a group with the same name already exists");
}
group = new Group();
group.setName(name);
groupRepository.save(group);
return group;
|
a800fde0
jcartign
First version, in...
|
29
30
31
|
}
@Override
|
5418cb05
jcartign
Javadoc of API is...
|
32
|
public boolean delete(String name) {
|
31bdbe1b
msahmane
Version où les te...
|
33
34
35
36
37
38
39
40
41
42
43
|
//throw new IllegalStateException("not implemented !");
if (name == null) {
throw new IllegalArgumentException("name cannot be null");
}
Group group = groupRepository.findByName(name);
if(group!=null){
groupRepository.delete(group.getId());
return true;
}
return false;
|
a800fde0
jcartign
First version, in...
|
44
45
46
47
|
}
@Override
public Group findByName(String name) {
|
7940aa22
jcartign
Finishing API jav...
|
48
49
50
51
|
if (name == null) {
throw new IllegalArgumentException("name cannot be null");
}
return groupRepository.findByName(name);
|
a800fde0
jcartign
First version, in...
|
52
53
54
|
}
@Override
|
5418cb05
jcartign
Javadoc of API is...
|
55
|
public boolean addRight(String groupName, Right right) {
|
292aec6f
jcartign
First version bef...
|
56
|
throw new IllegalStateException("not implemented !");
|
a800fde0
jcartign
First version, in...
|
57
58
59
|
}
@Override
|
5418cb05
jcartign
Javadoc of API is...
|
60
|
public boolean removeRight(String groupName, Right right) {
|
292aec6f
jcartign
First version bef...
|
61
|
throw new IllegalStateException("not implemented !");
|
a800fde0
jcartign
First version, in...
|
62
63
|
}
}
|