Clover icon

sunshower-core

  1. Project Clover database Fri Apr 6 2018 03:27:42 UTC
  2. Package io.sunshower.service.signup

File RegistrationRequest.java

 

Coverage histogram

../../../../img/srcFileCovDistChart7.png
24% of files have more coverage

Code metrics

0
16
11
1
85
68
11
0.69
1.45
11
1

Classes

Class Line # Actions
RegistrationRequest 18 16 11
0.629629663%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    package io.sunshower.service.signup;
2   
3    import io.sunshower.common.crypto.Hashes;
4    import io.sunshower.common.crypto.Multihash;
5    import io.sunshower.model.core.Schemata;
6    import io.sunshower.model.core.auth.User;
7    import io.sunshower.persistence.core.DistributableEntity;
8    import java.util.Calendar;
9    import java.util.Date;
10    import javax.persistence.*;
11    import javax.xml.bind.annotation.XmlAttribute;
12    import javax.xml.bind.annotation.XmlElement;
13    import javax.xml.bind.annotation.XmlRootElement;
14   
15    @Entity
16    @XmlRootElement(name = "request")
17    @Table(name = "REGISTRATION_REQUEST", schema = Schemata.SUNSHOWER)
 
18    public class RegistrationRequest extends DistributableEntity {
19   
20    @XmlElement
21    @Column(name = "request_id")
22    private String requestId;
23   
24    @OneToOne(cascade = CascadeType.PERSIST)
25    @XmlElement
26    @JoinColumn(name = "USER_ID")
27    private User user;
28   
29    @XmlAttribute
30    @Temporal(TemporalType.DATE)
31    private Date requested;
32   
33    @XmlAttribute
34    @Temporal(TemporalType.DATE)
35    private Date expires;
36   
 
37  2 toggle public RegistrationRequest() {}
38   
 
39  1 toggle public RegistrationRequest(User user) {
40  1 this.user = user;
41  1 this.setDefaults();
42    }
43   
 
44  1 toggle public void setRequestId(String requestId) {
45  1 this.requestId = requestId;
46    }
47   
 
48  1 toggle public User getUser() {
49  1 return user;
50    }
51   
 
52  0 toggle public void setUser(User user) {
53  0 this.user = user;
54    }
55   
 
56  0 toggle public Date getRequested() {
57  0 return requested;
58    }
59   
 
60  0 toggle public void setRequested(Date requested) {
61  0 this.requested = requested;
62    }
63   
 
64  0 toggle public Date getExpires() {
65  0 return expires;
66    }
67   
 
68  0 toggle public void setExpires(Date expires) {
69  0 this.expires = expires;
70    }
71   
 
72  1 toggle public String getRequestId() {
73  1 return requestId;
74    }
75   
 
76  4 toggle @Override
77    protected void setDefaults() {
78  4 this.requested = new Date();
79  4 final Calendar calendar = Calendar.getInstance();
80  4 calendar.setTime(requested);
81  4 calendar.add(Calendar.DATE, 1);
82  4 this.expires = calendar.getTime();
83  4 this.requestId = Hashes.create(Multihash.Type.SHA_2_512).hash(user, requested, expires);
84    }
85    }