-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathActiveUserDeleteCommand.java
More file actions
82 lines (63 loc) · 2.28 KB
/
ActiveUserDeleteCommand.java
File metadata and controls
82 lines (63 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*package edu.uark.registerapp.commands.activeUsers;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.pringframework.transaction.annotation.Transactional;
import edu.uark.registerapp.commands.VoidCommandInterface;
import edu.uark.registerapp.nodels.entities.ActiveUserEntity;
import edu.uark.registerapp.models.repositories.ActiveUserRepository;
@Service
public class ActiveUserDeleteCommand implements VoidCommandInterface{
@Override
@Transactional
public void execute(){
final Optional<ActiveUserEntity> activeUserEntity=
this.activeUserRepository.findBySessionKey(this.sessionKey);
if(!activeUserEntity.isPresent()){
this.activeUserRepository.delete(activeUserEntity.get());
}
}
private String sessionKey;
public String getSessionKey(){
return this.sessionKey;
}
public ActiveUserDeleteCommand setSessionKey(final String sessionKey){
this.sessionKey = sessionKey;
return this;
}
@Autowired
private ActiveUserRepository activeUserRepository;
}
*/
package edu.uark.registerapp.commands.activeUsers;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import edu.uark.registerapp.commands.VoidCommandInterface;
import edu.uark.registerapp.models.entities.ActiveUserEntity;
import edu.uark.registerapp.models.repositories.ActiveUserRepository;
@Service
public class ActiveUserDeleteCommand implements VoidCommandInterface {
@Transactional
@Override
public void execute() {
final Optional<ActiveUserEntity> activeUserEntity =
this.activeUserRepository.findBySessionKey(this.sessionKey);
if (activeUserEntity.isPresent()) {
this.activeUserRepository.delete(activeUserEntity.get());
}
}
// Properties
private String sessionKey;
public String getSessionKey() {
return this.sessionKey;
}
public ActiveUserDeleteCommand setSessionKey(final String sessionKey) {
this.sessionKey = sessionKey;
return this;
}
@Autowired
private ActiveUserRepository activeUserRepository;
}