diff options
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java | 13 |
1 files changed, 12 insertions, 1 deletions
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<ComponentDto> toComponents(List<ResourceDto> resourceDto){ + return newArrayList(Iterables.transform(resourceDto, new Function<ResourceDto, ComponentDto>() { + @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); |