aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-17 19:20:13 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-17 20:46:57 +0200
commitc0e82d3ac6b1ceae1053b7139f608d86e90faf32 (patch)
tree313245ea5b7959abf920fab1f72e56a083cc53e1 /sonar-core/src/main
parent183b104dadd5b350d4d00a1ef2336094755e5f4f (diff)
downloadsonarqube-c0e82d3ac6b1ceae1053b7139f608d86e90faf32.tar.gz
sonarqube-c0e82d3ac6b1ceae1053b7139f608d86e90faf32.zip
Remove ability to get users from batch
+ drop Hibernate model "User"
Diffstat (limited to 'sonar-core/src/main')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/DeprecatedUserFinder.java (renamed from sonar-core/src/main/java/org/sonar/core/user/HibernateUserFinder.java)26
-rw-r--r--sonar-core/src/main/resources/META-INF/persistence.xml1
2 files changed, 16 insertions, 11 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/user/HibernateUserFinder.java b/sonar-core/src/main/java/org/sonar/core/user/DeprecatedUserFinder.java
index 4cc42aacccc..7a180bb7d54 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/HibernateUserFinder.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/DeprecatedUserFinder.java
@@ -19,32 +19,38 @@
*/
package org.sonar.core.user;
-import org.sonar.api.database.DatabaseSession;
+import javax.annotation.Nullable;
import org.sonar.api.database.model.User;
import org.sonar.api.security.UserFinder;
-import org.sonar.jpa.session.DatabaseSessionFactory;
/**
* @since 2.10
*/
-public class HibernateUserFinder implements UserFinder {
+public class DeprecatedUserFinder implements UserFinder {
- private DatabaseSessionFactory sessionFactory;
+ private final UserDao userDao;
- public HibernateUserFinder(DatabaseSessionFactory sessionFactory) {
- this.sessionFactory = sessionFactory;
+ public DeprecatedUserFinder(UserDao userDao) {
+ this.userDao = userDao;
}
@Override
public User findById(int id) {
- DatabaseSession session = sessionFactory.getSession();
- return session.getSingleResult(User.class, "id", id);
+ return copy(userDao.getUser(id));
}
@Override
public User findByLogin(String login) {
- DatabaseSession session = sessionFactory.getSession();
- return session.getSingleResult(User.class, "login", login);
+ return copy(userDao.selectActiveUserByLogin(login));
+ }
+
+ private User copy(@Nullable UserDto dto) {
+ if (dto != null) {
+ User user = new User().setEmail(dto.getEmail()).setLogin(dto.getLogin()).setName(dto.getName());
+ user.setId(dto.getId().intValue());
+ return user;
+ }
+ return null;
}
}
diff --git a/sonar-core/src/main/resources/META-INF/persistence.xml b/sonar-core/src/main/resources/META-INF/persistence.xml
index d8b0e5613fd..543cc5e66c4 100644
--- a/sonar-core/src/main/resources/META-INF/persistence.xml
+++ b/sonar-core/src/main/resources/META-INF/persistence.xml
@@ -6,7 +6,6 @@
<persistence-unit name="sonar" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
- <class>org.sonar.api.database.model.User</class>
<class>org.sonar.api.database.model.Snapshot</class>
<class>org.sonar.api.measures.Metric</class>
<class>org.sonar.api.database.model.ResourceModel</class>