Revision 49828
Added by Panagiotis Kanakakis over 6 years ago
UserDAO.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.goldoa.service.dao; |
2 | 2 |
|
3 |
import eu.dnetlib.goldoa.domain.AccountAction; |
|
4 |
import eu.dnetlib.goldoa.domain.Role; |
|
5 |
import eu.dnetlib.goldoa.domain.User; |
|
6 |
import eu.dnetlib.goldoa.domain.UserRole; |
|
3 |
import eu.dnetlib.goldoa.domain.*; |
|
7 | 4 |
import org.apache.commons.codec.digest.DigestUtils; |
8 | 5 |
import org.apache.commons.logging.Log; |
9 | 6 |
import org.apache.commons.logging.LogFactory; |
... | ... | |
11 | 8 |
import org.hibernate.criterion.Order; |
12 | 9 |
import org.hibernate.criterion.Restrictions; |
13 | 10 |
import org.hibernate.transform.Transformers; |
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
14 | 12 |
import org.springframework.stereotype.Repository; |
15 | 13 |
|
16 | 14 |
import java.math.BigInteger; |
17 | 15 |
import java.sql.Timestamp; |
18 | 16 |
import java.util.List; |
17 |
import java.util.UUID; |
|
19 | 18 |
|
20 | 19 |
/** |
21 | 20 |
* Created by antleb on 3/13/15. |
22 | 21 |
*/ |
23 | 22 |
@Repository |
24 | 23 |
public class UserDAO extends AbstractDao<String, User> { |
25 |
private Log log = LogFactory.getLog(UserDAO.class);
|
|
24 |
private Log LOGGER = LogFactory.getLog(UserDAO.class);
|
|
26 | 25 |
|
27 | 26 |
/** |
28 | 27 |
* Returns the person with the given id. Objects of different type are placeholders containing only their id. |
... | ... | |
199 | 198 |
// .setCacheRegion("user") |
200 | 199 |
.list(); |
201 | 200 |
} |
201 |
|
|
202 |
public User createInActiveResearcher(String firstname, String lastname, String email, Organization organization) { |
|
203 |
User user = new User(); |
|
204 |
user.setFirstname(firstname); |
|
205 |
user.setLastname(lastname); |
|
206 |
user.setEmail(email); |
|
207 |
user.setPassword(DigestUtils.md5Hex(UUID.randomUUID().toString())); |
|
208 |
|
|
209 |
UserRole personRole = new UserRole(); |
|
210 |
UserRolePK urPk = new UserRolePK(); |
|
211 |
urPk.setUser(user); |
|
212 |
urPk.setRole(new Role("researcher","Researcher")); |
|
213 |
personRole.setPk(urPk); |
|
214 |
|
|
215 |
Affiliation affiliation = new Affiliation(); |
|
216 |
affiliation.setOrganization(organization); |
|
217 |
affiliation.getUsers().add(user); |
|
218 |
user.getAffiliations().add(affiliation); |
|
219 |
|
|
220 |
saveUser(user); |
|
221 |
return user; |
|
222 |
} |
|
202 | 223 |
} |
Also available in: Unified diff
1. Change log4j properties file.
2. Add method to create researcher from bulk import csv
3. Change csv handling on bulk import
4. Modify request unit test.