From 184756cd798fa9c5120b3d25c068e1f90767eaf0 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 15 Jul 2013 08:33:56 +0200 Subject: SONAR-4419 Roles page: improve search engine to add ability to search by project key --- .../src/main/java/org/sonar/core/resource/ResourceDao.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sonar-core') diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java index e18f0e4bfb1..9c9b4bd71f3 100644 --- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java +++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java @@ -19,6 +19,8 @@ */ package org.sonar.core.resource; +import com.google.common.base.Function; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.apache.ibatis.session.SqlSession; import org.sonar.api.component.Component; @@ -199,7 +201,7 @@ public class ResourceDao { } } - public ComponentDto toComponent(ResourceDto resourceDto){ + public static ComponentDto toComponent(ResourceDto resourceDto){ return new ComponentDto() .setKey(resourceDto.getKey()) .setLongName(resourceDto.getLongName()) @@ -207,6 +209,15 @@ public class ResourceDao { .setQualifier(resourceDto.getQualifier()); } + public static List toComponents(List resourceDto){ + return newArrayList(Iterables.transform(resourceDto, new Function() { + @Override + public ComponentDto apply(ResourceDto resourceDto) { + return toComponent(resourceDto); + } + })); + } + public void insertUsingExistingSession(ResourceDto resourceDto, SqlSession session) { ResourceMapper resourceMapper = session.getMapper(ResourceMapper.class); resourceMapper.insert(resourceDto); -- cgit v1.2.3